]> www.fi.muni.cz Git - evince.git/commitdiff
new script to keep in sync with toolbareditor in libegg
authorJaap Haitsma <jaap@haitsma.org>
Sun, 1 Jul 2007 14:45:24 +0000 (14:45 +0000)
committerJaap A. Haitsma <jhaitsma@src.gnome.org>
Sun, 1 Jul 2007 14:45:24 +0000 (14:45 +0000)
2007-07-01  Jaap Haitsma  <jaap@haitsma.org>

* cut-n-paste/toolbar-editor/update-toolbareditor-from-libegg:

new script to keep in sync with toolbareditor in libegg

* cut-n-paste/toolbar-editor/*:

Run update-toolbareditor-from-libegg so we are in sync again.
Fixes bug #452850.

svn path=/trunk/; revision=2533

ChangeLog
cut-n-paste/toolbar-editor/egg-editable-toolbar.c
cut-n-paste/toolbar-editor/egg-toolbar-editor.c
cut-n-paste/toolbar-editor/egg-toolbars-model.c
cut-n-paste/toolbar-editor/eggtreemultidnd.c
cut-n-paste/toolbar-editor/update-toolbareditor-from-libegg [new file with mode: 0755]

index d75c200d1ac1ef8688458bba0ecb0a8d814245f7..a2a2010edfb4edf2dbeaefb9737db72b986b81da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-07-01  Jaap Haitsma  <jaap@haitsma.org>
+
+       * cut-n-paste/toolbar-editor/update-toolbareditor-from-libegg: 
+
+       new script to keep in sync with toolbareditor in libegg
+
+       * cut-n-paste/toolbar-editor/*: 
+
+       Run update-toolbareditor-from-libegg so we are in sync again. 
+       Fixes bug #452850.
+       
+
 2007-07-01  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-sidebar-links.c: (job_finished_callback):
index 8698ba6ad942772f6b27f747087647d0fbc34492..2b26b4eaaabba0c3479b8379a5c04e5cb3b6b32d 100644 (file)
 #include <gtk/gtktoolitem.h>
 #include <gtk/gtktoolbutton.h>
 #include <gtk/gtkseparatortoolitem.h>
+#include <gtk/gtkicontheme.h>
 #include <glib/gi18n.h>
 #include <string.h>
 
 static void egg_editable_toolbar_class_init    (EggEditableToolbarClass *klass);
 static void egg_editable_toolbar_init          (EggEditableToolbar *etoolbar);
+static GdkPixbuf * new_separator_pixbuf         (void);
 
 #define MIN_TOOLBAR_HEIGHT 20
 #define EGG_ITEM_NAME      "egg-item-name"
@@ -109,7 +111,7 @@ egg_editable_toolbar_get_type (void)
 
   if (G_UNLIKELY (type == 0))
     {
-      const GTypeInfo our_info = {
+      static const GTypeInfo our_info = {
        sizeof (EggEditableToolbarClass),
        NULL,                   /* base_init */
        NULL,                   /* base_finalize */
@@ -461,6 +463,7 @@ configure_item_cursor (GtkToolItem *item,
       if (priv->edit_mode > 0)
         {
           GdkCursor *cursor;
+          GdkPixbuf *pixbuf = NULL;
           
           cursor = gdk_cursor_new (GDK_HAND2);
           gdk_window_set_cursor (widget->window, cursor);
@@ -468,6 +471,64 @@ configure_item_cursor (GtkToolItem *item,
 
           gtk_drag_source_set (widget, GDK_BUTTON1_MASK, dest_drag_types,
                                G_N_ELEMENTS (dest_drag_types), GDK_ACTION_MOVE);
+          if (GTK_IS_SEPARATOR_TOOL_ITEM (item))
+            {
+              pixbuf = new_separator_pixbuf ();
+            }
+          else
+            {
+              char *icon_name=NULL;
+              char *stock_id=NULL;
+              GtkAction *action;
+              char *name;
+
+              name = g_object_get_data (G_OBJECT (widget), EGG_ITEM_NAME);
+              action = name ? find_action (etoolbar, name) : NULL;
+
+              if (action)
+                {
+                   g_object_get (action,
+                                 "icon-name", &icon_name,
+                                 "stock-id", &stock_id,
+                                 NULL);
+                }
+              if (icon_name)
+                {
+                  GdkScreen *screen;
+                  GtkIconTheme *icon_theme;
+                  GtkSettings *settings;
+                  gint width, height;
+
+                  screen = gtk_widget_get_screen (widget);
+                  icon_theme = gtk_icon_theme_get_for_screen (screen);
+                  settings = gtk_settings_get_for_screen (screen);
+
+                  if (!gtk_icon_size_lookup_for_settings (settings,
+                                                          GTK_ICON_SIZE_LARGE_TOOLBAR,
+                                                          &width, &height))
+                    {
+                      width = height = 24;
+                    }
+
+                  pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
+                                                     MIN (width, height), 0, NULL);
+                }
+              else if (stock_id)
+                {               
+                  pixbuf = gtk_widget_render_icon (widget, stock_id,
+                                                  GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
+                }
+              g_free (icon_name);
+              g_free (stock_id);
+            }
+
+          if (G_UNLIKELY (!pixbuf))
+            {
+              return;
+            }
+          gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
+          g_object_unref (pixbuf);
+
         }
       else
         {
index ba5973cb8ef2fab21fca04dcbc61f78080fdf304..fdf6e3f0fc86c1cfffa88e66cf8074aecdb517e6 100644 (file)
@@ -78,7 +78,7 @@ egg_toolbar_editor_get_type (void)
 
   if (G_UNLIKELY (type == 0))
     {
-      const GTypeInfo our_info = {
+      static const GTypeInfo our_info = {
        sizeof (EggToolbarEditorClass),
        NULL,                   /* base_init */
        NULL,                   /* base_finalize */
@@ -362,12 +362,43 @@ event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
     {
       gchar *stock_id;
       GdkPixbuf *pixbuf;
+
       gtk_image_get_stock (icon, &stock_id, NULL);
       pixbuf = gtk_widget_render_icon (widget, stock_id,
                                       GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
       gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
       g_object_unref (pixbuf);
     }
+  else if (type == GTK_IMAGE_ICON_NAME)
+    {
+      const gchar *icon_name;
+      GdkScreen *screen;
+      GtkIconTheme *icon_theme;
+      GtkSettings *settings;
+      gint width, height;
+      GdkPixbuf *pixbuf;
+
+      gtk_image_get_icon_name (icon, &icon_name, NULL);
+      screen = gtk_widget_get_screen (widget);
+      icon_theme = gtk_icon_theme_get_for_screen (screen);
+      settings = gtk_settings_get_for_screen (screen);
+
+      if (!gtk_icon_size_lookup_for_settings (settings,
+                                              GTK_ICON_SIZE_LARGE_TOOLBAR,
+                                             &width, &height))
+        {
+         width = height = 24;
+       }
+
+      pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
+                                         MIN (width, height), 0, NULL);
+      if (G_UNLIKELY (!pixbuf))
+        return;
+
+      gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
+      g_object_unref (pixbuf);
+
+    }
   else if (type == GTK_IMAGE_PIXBUF)
     {
       GdkPixbuf *pixbuf = gtk_image_get_pixbuf (icon);
@@ -427,8 +458,7 @@ editor_create_item_from_name (EggToolbarEditor *editor,
 {
   GtkWidget *item;
   const char *item_name;
-  const char *stock_id;
-  const char *short_label;
+  char *short_label;
   const char *collate_key;
   
   if (strcmp (name, "_separator") == 0)
@@ -437,36 +467,42 @@ editor_create_item_from_name (EggToolbarEditor *editor,
       
       icon = _egg_editable_toolbar_new_separator_image ();
       short_label = _("Separator");
-      item_name = strdup (name);
+      item_name = g_strdup (name);
       collate_key = g_utf8_collate_key (short_label, -1);
       item = editor_create_item (editor, GTK_IMAGE (icon), 
                                  short_label, drag_action);
     }
   else
     {
-      GValue value = { 0, };
       GtkAction *action;
       GtkWidget *icon;
+      char *stock_id, *icon_name = NULL;
       
       action = find_action (editor, name);
       g_return_val_if_fail (action != NULL, NULL);
 
-      g_value_init (&value, G_TYPE_STRING);
-      g_object_get_property (G_OBJECT (action), "stock_id", &value);
-      stock_id = g_value_get_string (&value);
-      icon = gtk_image_new_from_stock (stock_id ? stock_id : GTK_STOCK_DND,
-                                       GTK_ICON_SIZE_LARGE_TOOLBAR);
-      g_value_unset (&value);
-      
-      g_value_init (&value, G_TYPE_STRING);
-      g_object_get_property (G_OBJECT (action), "short_label", &value);
-      short_label = g_value_get_string (&value);
+      g_object_get (action,
+                    "icon-name", &icon_name,
+                    "stock-id", &stock_id,
+                   "short-label", &short_label,
+                   NULL);
+
+      /* This is a workaround to catch named icons. */
+      if (icon_name)
+        icon = gtk_image_new_from_icon_name (icon_name,
+                                            GTK_ICON_SIZE_LARGE_TOOLBAR);
+      else
+        icon = gtk_image_new_from_stock (stock_id ? stock_id : GTK_STOCK_DND,
+                                         GTK_ICON_SIZE_LARGE_TOOLBAR);
 
-      item_name = strdup (name);
+      item_name = g_strdup (name);
       collate_key = g_utf8_collate_key (short_label, -1);
       item = editor_create_item (editor, GTK_IMAGE (icon),
                                  short_label, drag_action);
-      g_value_unset (&value);
+
+      g_free (short_label);
+      g_free (stock_id);
+      g_free (icon_name);
     }
   
   g_object_set_data_full (G_OBJECT (item), "egg-collate-key",
@@ -602,7 +638,7 @@ setup_editor (EggToolbarEditor *editor)
   editor->priv->scrolled_window = scrolled_window;
   gtk_widget_show (scrolled_window);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
-                                 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
   gtk_box_pack_start (GTK_BOX (editor), scrolled_window, TRUE, TRUE, 0);
 }
 
index 2cd58ac6985d0e18c15c02d9dda15a8069579936..f0a5b0fa0fb5ebe9ddf1ca00ef272d175ce0c345 100644 (file)
@@ -75,7 +75,7 @@ egg_toolbars_model_get_type (void)
 
   if (G_UNLIKELY (type == 0))
     {
-      const GTypeInfo our_info = {
+      static const GTypeInfo our_info = {
        sizeof (EggToolbarsModelClass),
        NULL,                   /* base_init */
        NULL,                   /* base_finalize */
index 4850c68603be55b1e2b1ba00cf275ca9d6d368bb..3a7da919c082fb034a3eb3ba2b5e71d4cc708c1c 100644 (file)
@@ -59,7 +59,7 @@ egg_tree_multi_drag_source_get_type (void)
 
   if (!our_type)
     {
-      const GTypeInfo our_info =
+      static const GTypeInfo our_info =
       {
         sizeof (EggTreeMultiDragSourceIface), /* class_size */
        NULL,           /* base_init */
diff --git a/cut-n-paste/toolbar-editor/update-toolbareditor-from-libegg b/cut-n-paste/toolbar-editor/update-toolbareditor-from-libegg
new file mode 100755 (executable)
index 0000000..fe56a2f
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Get latest toolbar editor from libegg
+# Developers using the toolbar editor in their projects can use this script to
+# fetch the latest toolbar editor from libegg
+echo "Obtaining latest version of toolbar editor from libegg"
+
+FILES="egg-editable-toolbar.c \
+       egg-toolbars-model.c \
+       egg-toolbar-editor.c \
+       eggtreemultidnd.c \
+       egg-editable-toolbar.h \
+       egg-toolbars-model.h \
+       egg-toolbar-editor.h \
+       eggtreemultidnd.h \
+       eggmarshalers.list" 
+
+for FILE in $FILES 
+do
+  svn export http://svn.gnome.org/svn/libegg/trunk/libegg/toolbareditor/$FILE
+done
+