Transparent panel icons



It's been bugging me for a while that the applet icon wasn't
transparent, so here's a fix.  First I just went and made the
background tranparent in the pngs, but I discovered that it didn't
help.  8^)  So here's a patch that rids us of imlib and uses the
GnomePixmap widget, which handles the transparency for us.

I would have just committed these, but it looks like my cvs account
hasn't gone through yet?

Also, while I was transparenting the icon, I made the dark color
black, rather than the dark green it was.  If someone was attached to
that, I can change it back.

-- 
Alan Shutko <ats@acm.org> - In a variety of flavors!
Don't get even -- get odd!
? transicon.diff
Index: applet/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-pilot/applet/ChangeLog,v
retrieving revision 1.4
diff -c -r1.4 ChangeLog
*** applet/ChangeLog	1999/11/01 22:04:34	1.4
--- applet/ChangeLog	1999/11/03 18:59:27
***************
*** 1,3 ****
--- 1,16 ----
+ 1999-11-03  Alan Shutko  <ats@acm.org>
+ 
+ 	* pilot.c (create_pilot_widget): Added space to tooltip.
+ 	(pixmaps): Created array to list icons, indexed by state.
+ 	(all): Got rid of darea and now using a GnomePixmap.
+ 	(pilot_expose): Removed.
+ 	(pilot_draw): Now just gnome_pixmap_load_file, instead of the
+ 	drawing area stuff.
+ 	(create_pilot_widget): Got rid of drawing area and now using a
+ 	GnomePixmap, because imlib loading wasn't giving us transparent
+ 	backgrounds.  Also, GNOME will be shifting to GdkPixBuf later on,
+ 	and GnomePixmap should be portable some time to come.
+ 
  1999-11-02  Eskil Heyn Olsen  <deity@eskil.dk>
  
  	* pilot.c (pilot_clicked_cb): clicking should work now, also
Index: applet/pilot.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/applet/pilot.c,v
retrieving revision 1.29
diff -c -r1.29 pilot.c
*** applet/pilot.c	1999/11/01 22:04:34	1.29
--- applet/pilot.c	1999/11/03 18:59:28
***************
*** 36,48 ****
  
  static pilot_properties properties = { NULL };
  
! typedef enum { initializing,syncing,waiting } state;;
  
  static state curstate;
  static GtkWidget *applet;
! static GtkWidget *darea; 
  static GtkWidget *dialogWindow; 
- static GdkImlibImage *pix[3];
  static GtkWidget *pb;
  /* static GtkWidget *dialog; */
  guint timeout_handler_id;
--- 36,54 ----
  
  static pilot_properties properties = { NULL };
  
! typedef enum { initializing,syncing,waiting, num_states } state;
  
+ char *pixmaps[] = 
+ {
+     "sync_broken.png",
+     "syncing_icon.png",
+     "sync_icon.png",
+ };
+ 
  static state curstate;
  static GtkWidget *applet;
! static GtkWidget *pixmap; 
  static GtkWidget *dialogWindow; 
  static GtkWidget *pb;
  /* static GtkWidget *dialog; */
  guint timeout_handler_id;
***************
*** 57,76 ****
  
  void gpilotd_connect_cb(const gchar *id,const GNOME_Pilot_PilotUser *user) {
    applet_widget_set_tooltip(APPLET_WIDGET(applet),_("Synchronizing..."));
! 
!   if(!GTK_WIDGET_REALIZED(darea)) {
      g_warning("! realized");
      return;
    }
    curstate = syncing;
!   pilot_draw(darea);
  }
  
  void gpilotd_disconnect_cb(const gchar *id) {
    applet_widget_set_tooltip(APPLET_WIDGET(applet),_("Ready to synchronize"));
  
    curstate = waiting;
!   pilot_draw(darea);
  }
  
  void gpilotd_request_completed(const gchar *id,unsigned long handle) {
--- 63,82 ----
  
  void gpilotd_connect_cb(const gchar *id,const GNOME_Pilot_PilotUser *user) {
    applet_widget_set_tooltip(APPLET_WIDGET(applet),_("Synchronizing..."));
!   
!   if(!GTK_WIDGET_REALIZED(pixmap)) {
      g_warning("! realized");
      return;
    }
    curstate = syncing;
!   pilot_draw(pixmap);
  }
  
  void gpilotd_disconnect_cb(const gchar *id) {
    applet_widget_set_tooltip(APPLET_WIDGET(applet),_("Ready to synchronize"));
  
    curstate = waiting;
!   pilot_draw(pixmap);
  }
  
  void gpilotd_request_completed(const gchar *id,unsigned long handle) {
***************
*** 146,196 ****
  }
  /******************************************************************/
  
! pilot_draw(GtkWidget *darea)
  {
!   int curpix;
! 
!   switch(curstate) {
!   case initializing: curpix = 2; break;
!   case syncing: curpix = 1; break;
!   case waiting: curpix = 0; break;
!   default: g_error("curstate == default ?!"); break;
!   }
! 
!   if(!GTK_WIDGET_REALIZED(darea)) {
      g_warning("pilot_draw ! realized");
      return;
    }
-   
-   gdk_draw_pixmap(darea->window,
- 		  darea->style->fg_gc[GTK_WIDGET_STATE(darea)],
- 		  pix[curpix]->pixmap,
- 		  0, 0,
- 		  0, 0,
- 		  pix[curpix]->rgb_width, pix[curpix]->rgb_height);
- }
- 
- pilot_expose(GtkWidget *darea, GdkEventExpose *event)
- {
-   int curpix;
- 
-   switch(curstate) {
-   case initializing: curpix = 2; break;
-   case syncing: curpix = 1; break;
-   case waiting: curpix = 0; break;
-   default: g_error("curstate == default ?!"); break;
-   }
  
!   gdk_draw_pixmap(darea->window,
! 		  darea->style->fg_gc[GTK_WIDGET_STATE(darea)],
! 		  pix[curpix]->pixmap,
! 		  event->area.x, event->area.y,
! 		  event->area.x, event->area.y,
! 		  event->area.width, event->area.height);
!   return FALSE;
  }
  
- 
  /******************************************************************/
  
  static int 
--- 152,168 ----
  }
  /******************************************************************/
  
! pilot_draw(GtkWidget *pixmap)
  {
!   if(!GTK_WIDGET_REALIZED(pixmap)) {
      g_warning("pilot_draw ! realized");
      return;
    }
  
!   gnome_pixmap_load_file(GNOME_PIXMAP(pixmap), pixmaps[curstate]);
!   
  }
  
  /******************************************************************/
  
  static int 
***************
*** 610,663 ****
    GtkWidget *frame;
    GtkWidget *event_box;
    GtkStyle *style;
! 
    static GtkTargetEntry drop_types [] = { 
      { "text/uri-list", 0, TARGET_URI_LIST },
    };
    static gint n_drop_types = sizeof (drop_types) / sizeof(drop_types[0]);
  
-   gtk_widget_push_visual (gdk_imlib_get_visual ());
-   gtk_widget_push_colormap (gdk_imlib_get_colormap ());
    style = gtk_widget_get_style(window);
  
!   applet_widget_set_tooltip(APPLET_WIDGET(applet),_("Trying to connect to"
  						    "the GnomePilot Daemon"));
  
!   pix[0] = gdk_imlib_load_image(gnome_unconditional_pixmap_file("sync_icon.png"));
!   if(pix[0]==NULL) g_error("cannot open sync_icon.png");
!   gdk_imlib_render (pix[0], pix[0]->rgb_width, pix[0]->rgb_height);
!   pix[1] = gdk_imlib_load_image(gnome_unconditional_pixmap_file("syncing_icon.png"));
!   if(pix[1]==NULL) g_error("cannot open syncing_icon.png");
!   gdk_imlib_render (pix[1], pix[1]->rgb_width, pix[1]->rgb_height);
!   pix[2] = gdk_imlib_load_image(gnome_unconditional_pixmap_file("sync_broken.png"));
!   if(pix[2]==NULL) g_error("cannot open sync_broken_icon.png");
!   gdk_imlib_render (pix[2], pix[2]->rgb_width, pix[2]->rgb_height);
! 
!   darea = gtk_drawing_area_new();
!   gtk_drawing_area_size(GTK_DRAWING_AREA(darea),
! 			 pix[0]->rgb_width,
! 			 pix[0]->rgb_height);
    curstate = initializing;
  
!   gtk_widget_set_events(darea, gtk_widget_get_events(darea) |
  			GDK_BUTTON_PRESS_MASK);
!   gtk_signal_connect(GTK_OBJECT(darea), "button-press-event",
  		     GTK_SIGNAL_FUNC(pilot_clicked_cb), NULL);
-   gtk_signal_connect_after(GTK_OBJECT(darea), "realize",
-                            GTK_SIGNAL_FUNC(pilot_draw), NULL);
-   gtk_signal_connect(GTK_OBJECT(darea), "expose-event",
- 		     GTK_SIGNAL_FUNC(pilot_expose), NULL);
-   gtk_widget_show(darea);  
  
-   frame = gtk_frame_new(NULL);
-   gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_NONE);
-   gtk_container_add(GTK_CONTAINER(frame),darea);
  
!   gtk_widget_pop_colormap ();
!   gtk_widget_pop_visual ();
  
!   timeout_handler_id = gtk_timeout_add(1000,timeout,darea);
  
    gtk_signal_connect(GTK_OBJECT(applet),"session-save",
  		     GTK_SIGNAL_FUNC(applet_save_session),
  		     NULL);
--- 582,621 ----
    GtkWidget *frame;
    GtkWidget *event_box;
    GtkStyle *style;
!   int i;
!   
    static GtkTargetEntry drop_types [] = { 
      { "text/uri-list", 0, TARGET_URI_LIST },
    };
    static gint n_drop_types = sizeof (drop_types) / sizeof(drop_types[0]);
  
    style = gtk_widget_get_style(window);
  
!   applet_widget_set_tooltip(APPLET_WIDGET(applet),_("Trying to connect to "
  						    "the GnomePilot Daemon"));
  
! 
    curstate = initializing;
+ 
+   for (i = 0; i < sizeof(pixmaps)/sizeof(pixmaps[0]); i++)
+       pixmaps[i] = gnome_unconditional_pixmap_file(pixmaps[i]);
+   
+   pixmap = gnome_pixmap_new_from_file(pixmaps[curstate]);
  
!   gtk_widget_set_events(pixmap, gtk_widget_get_events(pixmap) |
  			GDK_BUTTON_PRESS_MASK);
!   gtk_signal_connect(GTK_OBJECT(pixmap), "button-press-event",
  		     GTK_SIGNAL_FUNC(pilot_clicked_cb), NULL);
  
  
!   gtk_widget_show(pixmap);  
  
!   frame = gtk_frame_new(NULL);
!   gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_NONE);
!   gtk_container_add(GTK_CONTAINER(frame),pixmap);
  
+   timeout_handler_id = gtk_timeout_add(1000,timeout,pixmap);
+   
    gtk_signal_connect(GTK_OBJECT(applet),"session-save",
  		     GTK_SIGNAL_FUNC(applet_save_session),
  		     NULL);
***************
*** 684,696 ****
  					about_cb,
  					NULL);
    /* Now set the dnd features */
!   gtk_drag_dest_set (GTK_WIDGET (darea),
  		     GTK_DEST_DEFAULT_ALL,
  		     drop_types, n_drop_types,
  		     GDK_ACTION_COPY);
  
  
!   gtk_signal_connect(GTK_OBJECT(darea),
  		     "drag_data_received",
  		     GTK_SIGNAL_FUNC(dnd_drop_internal),
  		     NULL);
--- 642,654 ----
  					about_cb,
  					NULL);
    /* Now set the dnd features */
!   gtk_drag_dest_set (GTK_WIDGET (pixmap),
  		     GTK_DEST_DEFAULT_ALL,
  		     drop_types, n_drop_types,
  		     GDK_ACTION_COPY);
  
  
!   gtk_signal_connect(GTK_OBJECT(pixmap),
  		     "drag_data_received",
  		     GTK_SIGNAL_FUNC(dnd_drop_internal),
  		     NULL);
Index: applet/sync_broken.png
===================================================================
RCS file: /cvs/gnome/gnome-pilot/applet/sync_broken.png,v
retrieving revision 1.2
diff -c -r1.2 sync_broken.png
Binary files /tmp/cvs20978caa and sync_broken.png differ
Index: applet/sync_icon.png
===================================================================
RCS file: /cvs/gnome/gnome-pilot/applet/sync_icon.png,v
retrieving revision 1.3
diff -c -r1.3 sync_icon.png
Binary files /tmp/cvs20978daa and sync_icon.png differ
Index: applet/syncing_icon.png
===================================================================
RCS file: /cvs/gnome/gnome-pilot/applet/syncing_icon.png,v
retrieving revision 1.2
diff -c -r1.2 syncing_icon.png
Binary files /tmp/cvs20978eaa and syncing_icon.png differ

sync_icon.png

syncing_icon.png

sync_broken.png



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]