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

gEDA-cvs: branch: master updated (1.1.2.20070818-186-gbc7e666)



The branch, master has been updated
       via  bc7e666d6e8c1620e9e3ab8d124d7d0ade5198ed (commit)
      from  7589460bcbd8ba7683645b9b5aecd5e0b14ad6d2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gattrib/src/x_window.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)


=================
 Commit Messages
=================

commit bc7e666d6e8c1620e9e3ab8d124d7d0ade5198ed
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Dec 24 03:15:51 2007 +0000

    gattrib: Set default window icon to "gattrib" from the icon theme.
    
    When a "gattrib" icon is found in the icon theme, this will be used as the
    default application icon. For GTK versions < 2.6, some default sizes have
    been picked at which to look for icons. GTK >= 2.6 will find the best icon
    by name.

:100644 100644 a710619... 3853f7f... M	gattrib/src/x_window.c

=========
 Changes
=========

commit bc7e666d6e8c1620e9e3ab8d124d7d0ade5198ed
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Dec 24 03:15:51 2007 +0000

    gattrib: Set default window icon to "gattrib" from the icon theme.
    
    When a "gattrib" icon is found in the icon theme, this will be used as the
    default application icon. For GTK versions < 2.6, some default sizes have
    been picked at which to look for icons. GTK >= 2.6 will find the best icon
    by name.

diff --git a/gattrib/src/x_window.c b/gattrib/src/x_window.c
index a710619..3853f7f 100644
--- a/gattrib/src/x_window.c
+++ b/gattrib/src/x_window.c
@@ -54,9 +54,18 @@
 #include <dmalloc.h>
 #endif
 
+/*------------------------------------------------------------------
+ * Gattrib specific defines
+ *------------------------------------------------------------------*/
+#define GATTRIB_THEME_ICON_NAME "gattrib"
+#define GATTRIB_ICON_SIZES 16, 22, 48
+
 static void
 x_window_create_menu(GtkWindow *window, GtkWidget **menubar);
 
+static void
+x_window_set_default_icon( void );
+
 /*! \brief This function initializes the toplevel gtksheet stuff. 
  *
  *  It basically just initializes the following widgets:
@@ -77,6 +86,9 @@ x_window_init()
   GtkWidget *menu_bar;
   GtkWidget *main_vbox;
 
+  /* Set default icon */
+  x_window_set_default_icon();
+
   /*  window is a global declared in globals.h.  */
   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);  
 
@@ -377,3 +389,45 @@ x_window_add_items()
   gtk_widget_show_all( GTK_WIDGET(window) );
 }
 
+
+/*! \brief Setup default icon for GTK windows
+ *
+ *  \par Function Description
+ *  Sets the default window icon by name, to be found in the current icon
+ *  theme. The name used is #defined above as GATTRIB_THEME_ICON_NAME.
+ *
+ *  For GTK versions < 2.6, we have to load the icons explicitly, and pass
+ *  them to GTK. As we don't know what size is appropriate, a #define above,
+ *  GATTRIB_ICON_SIZES is used to list (comma separated) the sizes we have
+ *  icons for. Icons loaded at all of these sizes are passed to GTK.
+ */
+static void
+x_window_set_default_icon( void )
+{
+#if GTK_CHECK_VERSION (2,6,0)
+  gtk_window_set_default_icon_name( GATTRIB_THEME_ICON_NAME );
+#else
+  GtkIconTheme *icon_theme;
+  GdkPixbuf *icon;
+  GList *icon_list = NULL;
+  int icon_size[] = { GATTRIB_ICON_SIZES };
+  int i;
+
+  for ( i = 0; i < sizeof( icon_size ) / sizeof( *icon_size ); i++ ) {
+    icon_theme = gtk_icon_theme_get_default();
+    icon = gtk_icon_theme_load_icon( icon_theme,
+                                     GATTRIB_THEME_ICON_NAME,
+                                     icon_size[i],
+                                     0,   /* flags */
+                                     NULL /* **error */ );
+    if (icon != NULL)
+      icon_list = g_list_append( icon_list, icon );
+  }
+
+  gtk_window_set_default_icon_list( icon_list );
+
+  g_list_foreach( icon_list, (GFunc) g_object_unref, NULL );
+  g_list_free( icon_list );
+#endif
+}
+




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs