Changeset 425

Show
Ignore:
Timestamp:
10/04/07 21:52:56 (6 years ago)
Author:
bjourne
Message:

For the icon in GtkImageScrollWin, use inlined pixbufs instead of
xpms. Although the data is now much more verbose, the xpms wasted
relocations by needing to be pointers which is supposedly very bad.
See dsohowto.pdf for the full scope.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gtkimageview/src/gtkimagescrollwin.c

    r359 r425  
    4545/***** PRIVATE DATA ******************************************/ 
    4646/*************************************************************/ 
    47 static const char *nav_button_xpm[] = { 
    48     "14 14 2 1", 
    49     "   c None", 
    50     ".  c #000000", 
    51     "      ..      ", 
    52     "     ....     ", 
    53     "    ......    ", 
    54     "      ..      ", 
    55     "  .   ..   .  ", 
    56     " ..   ..   .. ", 
    57     "..............", 
    58     "..............", 
    59     " ..   ..   .. ", 
    60     "  .   ..   .  ", 
    61     "      ..      ", 
    62     "    ......    ", 
    63     "     ....     ", 
    64     "      ..      " 
     47#ifdef __GNUC__ 
     48static const guint8 nav_button[] __attribute__ ((__aligned__ (4))) =  
     49#else 
     50static const guint8 nav_button[] =  
     51#endif 
     52
     53    "" 
     54    /* Pixbuf magic (0x47646b50) */ 
     55    "GdkP" 
     56    /* length: header (24) + pixel_data (784) */ 
     57    "\0\0\3(" 
     58    /* pixdata_type (0x1010002) */ 
     59    "\1\1\0\2" 
     60    /* rowstride (56) */ 
     61    "\0\0\0""8" 
     62    /* width (14) */ 
     63    "\0\0\0\16" 
     64    /* height (14) */ 
     65    "\0\0\0\16" 
     66    /* pixel_data: */ 
     67    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377" 
     68    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     69    "\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0" 
     70    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     71    "\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0" 
     72    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     73    "\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     74    "\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377" 
     75    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377" 
     76    "\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0" 
     77    "\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377" 
     78    "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377" 
     79    "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377" 
     80    "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377" 
     81    "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\377\0\0\0\377" 
     82    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0" 
     83    "\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0\0\0" 
     84    "\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0" 
     85    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377" 
     86    "\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     87    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0" 
     88    "\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     89    "\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0" 
     90    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     91    "\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     92    "\0\0\0\0\0" 
    6593}; 
    6694 
    67 static const char *nav_button_xpm_hc[] = { 
    68     "14 14 2 1", 
    69     "   c None", 
    70     ".  c #3e3e3e", 
    71     "      ..      ", 
    72     "     ....     ", 
    73     "    ......    ", 
    74     "      ..      ", 
    75     "  .   ..   .  ", 
    76     " ..   ..   .. ", 
    77     "..............", 
    78     "..............", 
    79     " ..   ..   .. ", 
    80     "  .   ..   .  ", 
    81     "      ..      ", 
    82     "    ......    ", 
    83     "     ....     ", 
    84     "      ..      " 
     95#ifdef __GNUC__ 
     96static const guint8 nav_button_hc[] __attribute__ ((__aligned__ (4))) =  
     97#else 
     98static const guint8 nav_button_hc[] =  
     99#endif 
     100
     101    "" 
     102    /* Pixbuf magic (0x47646b50) */ 
     103    "GdkP" 
     104    /* length: header (24) + pixel_data (784) */ 
     105    "\0\0\3(" 
     106    /* pixdata_type (0x1010002) */ 
     107    "\1\1\0\2" 
     108    /* rowstride (56) */ 
     109    "\0\0\0""8" 
     110    /* width (14) */ 
     111    "\0\0\0\16" 
     112    /* height (14) */ 
     113    "\0\0\0\16" 
     114    /* pixel_data: */ 
     115    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>>>\377>>>\377\0\0\0" 
     116    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     117    "\0\0\0\0\0\0\0>>>\377>>>\377>>>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     118    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>>>\377>>>\377>>>\377>" 
     119    ">>\377>>>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     120    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>>>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0" 
     121    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>>>\377\0\0\0\0\0\0\0\0\0\0" 
     122    "\0\0>>>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0\0>>>\377\0\0\0\0\0\0\0\0\0\0" 
     123    "\0\0>>>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0\0>>>\377>>>\377\0\0\0\0\0\0" 
     124    "\0\0\0\0\0\0>>>\377>>>\377\0\0\0\0>>>\377>>>\377>>>\377>>>\377>>>\377" 
     125    ">>>\377>>>\377>>>\377>>>\377>>>\377>>>\377>>>\377>>>\377>>>\377>>>\377" 
     126    ">>>\377>>>\377>>>\377>>>\377>>>\377>>>\377>>>\377>>>\377>>>\377>>>\377" 
     127    ">>>\377>>>\377>>>\377\0\0\0\0>>>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0\0>" 
     128    ">>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0\0>>>\377>>>\377\0\0\0\0\0\0\0\0\0" 
     129    "\0\0\0>>>\377\0\0\0\0\0\0\0\0\0\0\0\0>>>\377>>>\377\0\0\0\0\0\0\0\0\0" 
     130    "\0\0\0>>>\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     131    "\0\0\0\0>>>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     132    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>>>\377>>>\377>>>\377>>>\377>>>\377" 
     133    ">>>\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     134    "\0\0\0\0\0>>>\377>>>\377>>>\377>>>\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
     135    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>>>\377>>>" 
     136    "\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 
    85137}; 
    86  
    87138 
    88139G_DEFINE_TYPE(GtkImageScrollWin, gtk_image_scroll_win, GTK_TYPE_TABLE); 
     
    243294 
    244295    // Setup the navigator button. 
    245     window->nav_button = gdk_pixbuf_new_from_xpm_data (nav_button_xpm); 
    246     window->nav_button_hc = gdk_pixbuf_new_from_xpm_data (nav_button_xpm_hc); 
     296    window->nav_button = 
     297        gdk_pixbuf_new_from_inline (-1, nav_button, FALSE, NULL); 
     298    window->nav_button_hc = 
     299        gdk_pixbuf_new_from_inline (-1, nav_button_hc, FALSE, NULL); 
    247300    window->nav_image = gtk_image_new_from_pixbuf (window->nav_button); 
     301     
    248302    window->nav_box = gtk_event_box_new (); 
    249  
    250303    gtk_container_add (GTK_CONTAINER (window->nav_box), window->nav_image); 
    251304    g_signal_connect_swapped (G_OBJECT (window->nav_box),