~ubuntu-branches/ubuntu/gutsy/avscan/gutsy

« back to all changes in this revision

Viewing changes to avscan/hview.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2007-08-12 14:22:25 UTC
  • mfrom: (1.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070812142225-2whp6690lilo2wg8
Tags: 3.2.1-openssl-2
Correctly handle DEB_BUILD_OPTIONS=nostrip (Closes: #436496).

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
); 
111
111
void HViewUpdate(hview_struct *hv);
112
112
void HViewDraw(hview_struct *hv);
113
 
void HViewQueueDraw(hview_struct *hv);  
114
 
void HViewSetBusy(hview_struct *hv, gboolean is_busy);
 
113
void HViewQueueDraw(hview_struct *hv);
115
114
void HViewSetStatusMessage(
116
 
        hview_struct *hv, const gchar *mesg,
117
 
        gboolean allow_gtk_iteration
 
115
        hview_struct *hv, const gchar *msg,
 
116
        const gboolean allow_gtk_iteration
118
117
);
 
118
void HViewSetBusy(hview_struct *hv, const gboolean is_busy);
119
119
void HViewMap(hview_struct *hv);
120
120
void HViewUnmap(hview_struct *hv);
121
121
void HViewDelete(hview_struct *hv);
1152
1152
        GtkAdjustment *adj;
1153
1153
        GdkWindow *window;
1154
1154
        GtkWidget *w, *parent2, *parent3, *parent4, *parent5;
1155
 
        hview_struct *hv = HVIEW(
1156
 
            g_malloc0(sizeof(hview_struct))
1157
 
        );
 
1155
        hview_struct *hv = HVIEW(g_malloc0(sizeof(hview_struct)));
1158
1156
        if(hv == NULL)
1159
1157
            return(NULL);
1160
1158
 
1178
1176
        hv->edit_mode_changed_cb = NULL;
1179
1177
        hv->edit_mode_changed_data = NULL;
1180
1178
 
1181
 
        /* Load cursors */
 
1179
        /* Load the cursors */
1182
1180
        hv->busy_cur = gdk_cursor_new(GDK_WATCH);
1183
1181
        hv->text_cur = gdk_cursor_new(GDK_XTERM);
1184
1182
        hv->translate_cur = gdk_cursor_new(GDK_FLEUR);
1185
1183
 
1186
 
        /* Load fonts */
 
1184
        /* Load the fonts */
1187
1185
        hv->font = NULL;
1188
1186
        hv->cell_width = 1;
1189
1187
        hv->cell_height = 1;
1192
1190
        hv->hex_x = 0;
1193
1191
        hv->ascii_x = 0;
1194
1192
 
 
1193
        hv->freeze_count++;
 
1194
 
1195
1195
        /* Toplevel GtkVBox */
1196
1196
        hv->toplevel = w = gtk_vbox_new(FALSE, 0);
1197
1197
        if(GTK_IS_BOX(parent))
1578
1578
            accel_mods = 0;
1579
1579
            func_cb = HViewUnselectAllCB;
1580
1580
            DO_ADD_MENU_ITEM_LABEL  
1581
 
            hv->unselect_all_mi = w;    
 
1581
            hv->unselect_all_mi = w;
1582
1582
 
1583
1583
            DO_ADD_MENU_SEP   
1584
1584
            hv->edit_mode_msep = w;
1650
1650
        HViewUpdate(hv);
1651
1651
        HViewSetStatusMessage(hv, NULL, FALSE);
1652
1652
 
 
1653
 
 
1654
        hv->freeze_count--;
 
1655
 
1653
1656
        return(hv);
1654
1657
}
1655
1658
 
1676
1679
            GTK_WINDOW(w), "hexview", PROG_NAME
1677
1680
        );
1678
1681
#endif
1679
 
        gtk_widget_realize(w);                                           
 
1682
        gtk_widget_realize(w);
1680
1683
        window = w->window;
1681
1684
        if(window != NULL)
1682
1685
        {
1748
1751
void HViewSetViewFont(hview_struct *hv, const gchar *font_name)
1749
1752
{
1750
1753
        if(hv == NULL)   
1751
 
            return;
 
1754
            return;
1752
1755
 
1753
1756
        if(font_name != NULL)
1754
1757
        {
1784
1787
                s[i] = 'X';
1785
1788
            s[len] = '\0';
1786
1789
            gdk_string_bounds(font, s, &b);
1787
 
            g_free(s);
 
1790
            g_free(s);
1788
1791
            column_width[1] = b.width;
1789
1792
            hv->ascii_x = column_width[0] + column_width[1];
1790
1793
 
2003
2006
/*
2004
2007
 *      Updates the Hex View's Status Bar message.
2005
2008
 *
2006
 
 *      If mesg is NULL then the cursor position status message will
 
2009
 *      If msg is NULL then the cursor position status message will
2007
2010
 *      be set.
2008
2011
 */
2009
2012
void HViewSetStatusMessage(
2010
 
        hview_struct *hv, const gchar *mesg,
2011
 
        gboolean allow_gtk_iteration
 
2013
        hview_struct *hv, const gchar *msg,
 
2014
        const gboolean allow_gtk_iteration
2012
2015
)
2013
2016
{
2014
 
        GtkWidget *w = (hv != NULL) ? hv->status_bar_label : NULL;
2015
 
        if(w == NULL)
 
2017
        if(hv == NULL)
2016
2018
            return;
2017
2019
 
2018
 
        if(mesg == NULL)
 
2020
        if(msg == NULL)
2019
2021
        {
2020
2022
            gint i = hv->buf_pos;
2021
 
            gchar *buf;
 
2023
            gchar *msg;
2022
2024
 
2023
2025
            /* Is a value being edited? */
2024
2026
            if((hv->edit_buf_i > 0) && (sizeof(hv->edit_buf) >= 2))
2025
2027
            {
2026
 
                buf = g_strdup_printf(
 
2028
                msg = g_strdup_printf(
2027
2029
"Address: 0x%.8X - Position: %i - Size: %i -\
2028
2030
 Mode: %s - Hex: 0x%c%c%c",
2029
2031
                    i, i,
2039
2041
            else
2040
2042
            {
2041
2043
                if((i >= 0) && (i < hv->buf_len) && (hv->buf != NULL))
2042
 
                    buf = g_strdup_printf(
 
2044
                    msg = g_strdup_printf(
2043
2045
"Address: 0x%.8X - Position: %i - Size: %i -\
2044
2046
 Mode: %s - Hex: 0x%.2X - ASCII: %c",
2045
2047
                        i, i,
2051
2053
                            (gchar)hv->buf[i] : ' '
2052
2054
                    );
2053
2055
                else
2054
 
                    buf = STRDUP("");
 
2056
                    msg = STRDUP("");
2055
2057
            }
2056
 
            gtk_label_set_text(GTK_LABEL(w), buf);
2057
 
            g_free(buf);
 
2058
            gtk_label_set_text(GTK_LABEL(hv->status_bar_label), msg);
 
2059
            g_free(msg);
2058
2060
        }
2059
2061
        else
2060
2062
        {
2061
 
            gtk_label_set_text(GTK_LABEL(w), mesg);
 
2063
            gtk_label_set_text(GTK_LABEL(hv->status_bar_label), msg);
2062
2064
        }
2063
2065
 
2064
2066
        while((gtk_events_pending() > 0) && allow_gtk_iteration)
2068
2070
/*
2069
2071
 *      Marks the Hex View as busy or ready.
2070
2072
 */
2071
 
void HViewSetBusy(hview_struct *hv, gboolean is_busy)
 
2073
void HViewSetBusy(hview_struct *hv, const gboolean is_busy)
2072
2074
{
2073
2075
        GdkCursor *cur;
2074
 
        GtkWidget *w = (hv != NULL) ? hv->toplevel : NULL;
2075
 
        if(w == NULL)
 
2076
        GtkWidget *w;
 
2077
 
 
2078
        if(hv == NULL)
2076
2079
            return;
2077
2080
 
2078
2081
        /* If the toplevel is not a GtkWindow then set only for the
2079
2082
         * view GtkDrawingArea
2080
2083
         */
2081
 
        if(!GTK_IS_WINDOW(hv))
2082
 
        {
 
2084
        if(GTK_IS_WINDOW(hv->toplevel))
 
2085
            w = hv->toplevel;
 
2086
        else
2083
2087
            w = hv->view_da;
2084
 
            if(w == NULL)
2085
 
                return;
2086
 
        }
 
2088
        if(w == NULL)
 
2089
            return;
2087
2090
 
2088
2091
        if(is_busy)
2089
2092
        {
2090
 
            /* Increase busy count */
 
2093
            /* Increase the busy count */
2091
2094
            hv->busy_count++;
2092
2095
 
2093
2096
            /* If already busy then don't change anything */
2098
2101
        }
2099
2102
        else
2100
2103
        {
2101
 
            /* Reduce busy count */
 
2104
            /* Reduce the busy count */
2102
2105
            hv->busy_count--;
2103
2106
            if(hv->busy_count < 0)
2104
2107
                hv->busy_count = 0;
2105
2108
 
2106
 
            /* If still busy do not change anything */
 
2109
            /* If still busy then do not change anything */
2107
2110
            if(hv->busy_count > 0)
2108
2111
                return;
2109
2112
 
2110
 
            cur = NULL;         /* Use default cursor */
 
2113
            cur = NULL;         /* Use the default cursor */
2111
2114
        }
2112
2115
 
2113
 
        /* Update toplevel window's cursor */
2114
2116
        if(w->window != NULL)
2115
2117
        {
2116
2118
            gdk_window_set_cursor(w->window, cur);
2123
2125
 */
2124
2126
void HViewMap(hview_struct *hv)
2125
2127
{
2126
 
        GtkWidget *w = (hv != NULL) ? hv->toplevel : NULL;
2127
 
        if(w == NULL)
 
2128
        GtkWidget *w;
 
2129
 
 
2130
        if(hv == NULL)
2128
2131
            return;
2129
2132
 
 
2133
        w = hv->toplevel;
2130
2134
        if(GTK_IS_WINDOW(w))
2131
2135
            gtk_widget_show_raise(w);
2132
2136
        else
2139
2143
 */
2140
2144
void HViewUnmap(hview_struct *hv)
2141
2145
{
2142
 
        GtkWidget *w = (hv != NULL) ? hv->toplevel : NULL;
2143
 
        if(w == NULL)
 
2146
        if(hv == NULL)
2144
2147
            return;
2145
2148
 
2146
 
        gtk_widget_hide(w);
 
2149
        gtk_widget_hide(hv->toplevel);
2147
2150
        hv->map_state = FALSE;
2148
2151
}
2149
2152
 
2160
2163
        GTK_TIMEOUT_REMOVE(hv->scroll_toid);
2161
2164
        hv->scroll_toid = 0;
2162
2165
 
2163
 
 
2164
2166
        HViewUnmap(hv);
2165
2167
 
 
2168
        hv->freeze_count++;
2166
2169
 
2167
2170
        colormap = hv->colormap;
2168
2171
 
2190
2193
 
2191
2194
        GDK_FONT_UNREF(hv->font);
2192
2195
 
 
2196
        hv->freeze_count--;
 
2197
 
2193
2198
        g_free(hv);
2194
2199
}