]> Pileus Git - ~andy/gtk/commitdiff
New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock to
authorAlexander Larsson <alexl@redhat.com>
Thu, 15 Mar 2001 09:09:06 +0000 (09:09 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Thu, 15 Mar 2001 09:09:06 +0000 (09:09 +0000)
2001-03-15 Alexander Larsson  <alexl@redhat.com>

* gtk/gtktoolbar.[ch]:
New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock
to add stock items to toolbars.

* gtk/Makefile.am:
Remove ../gdk/gdkim.h from gdk_headers.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/Makefile.am
gtk/gtktoolbar.c
gtk/gtktoolbar.h

index 4a9688a0f77ede6777fa08bf1a0ee85056d15af7..118f1a08ed05cc09a6f438846319db830264b590 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2001-03-15    <alexl@redhat.com>
+
+       * gtk/gtktoolbar.[ch]:
+       New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock
+       to add stock items to toolbars.
+
+       * gtk/Makefile.am:
+       Remove ../gdk/gdkim.h from gdk_headers.
+
 2001-03-15  Sven Neumann  <sven@gimp.org>
 
        * gdk/gdkim.h: removed
index 4a9688a0f77ede6777fa08bf1a0ee85056d15af7..118f1a08ed05cc09a6f438846319db830264b590 100644 (file)
@@ -1,3 +1,12 @@
+2001-03-15    <alexl@redhat.com>
+
+       * gtk/gtktoolbar.[ch]:
+       New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock
+       to add stock items to toolbars.
+
+       * gtk/Makefile.am:
+       Remove ../gdk/gdkim.h from gdk_headers.
+
 2001-03-15  Sven Neumann  <sven@gimp.org>
 
        * gdk/gdkim.h: removed
index 4a9688a0f77ede6777fa08bf1a0ee85056d15af7..118f1a08ed05cc09a6f438846319db830264b590 100644 (file)
@@ -1,3 +1,12 @@
+2001-03-15    <alexl@redhat.com>
+
+       * gtk/gtktoolbar.[ch]:
+       New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock
+       to add stock items to toolbars.
+
+       * gtk/Makefile.am:
+       Remove ../gdk/gdkim.h from gdk_headers.
+
 2001-03-15  Sven Neumann  <sven@gimp.org>
 
        * gdk/gdkim.h: removed
index 4a9688a0f77ede6777fa08bf1a0ee85056d15af7..118f1a08ed05cc09a6f438846319db830264b590 100644 (file)
@@ -1,3 +1,12 @@
+2001-03-15    <alexl@redhat.com>
+
+       * gtk/gtktoolbar.[ch]:
+       New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock
+       to add stock items to toolbars.
+
+       * gtk/Makefile.am:
+       Remove ../gdk/gdkim.h from gdk_headers.
+
 2001-03-15  Sven Neumann  <sven@gimp.org>
 
        * gdk/gdkim.h: removed
index 4a9688a0f77ede6777fa08bf1a0ee85056d15af7..118f1a08ed05cc09a6f438846319db830264b590 100644 (file)
@@ -1,3 +1,12 @@
+2001-03-15    <alexl@redhat.com>
+
+       * gtk/gtktoolbar.[ch]:
+       New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock
+       to add stock items to toolbars.
+
+       * gtk/Makefile.am:
+       Remove ../gdk/gdkim.h from gdk_headers.
+
 2001-03-15  Sven Neumann  <sven@gimp.org>
 
        * gdk/gdkim.h: removed
index 4a9688a0f77ede6777fa08bf1a0ee85056d15af7..118f1a08ed05cc09a6f438846319db830264b590 100644 (file)
@@ -1,3 +1,12 @@
+2001-03-15    <alexl@redhat.com>
+
+       * gtk/gtktoolbar.[ch]:
+       New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock
+       to add stock items to toolbars.
+
+       * gtk/Makefile.am:
+       Remove ../gdk/gdkim.h from gdk_headers.
+
 2001-03-15  Sven Neumann  <sven@gimp.org>
 
        * gdk/gdkim.h: removed
index 4a9688a0f77ede6777fa08bf1a0ee85056d15af7..118f1a08ed05cc09a6f438846319db830264b590 100644 (file)
@@ -1,3 +1,12 @@
+2001-03-15    <alexl@redhat.com>
+
+       * gtk/gtktoolbar.[ch]:
+       New functions gtk_toolbar_set_icon_size and gtk_toolbar_insert_stock
+       to add stock items to toolbars.
+
+       * gtk/Makefile.am:
+       Remove ../gdk/gdkim.h from gdk_headers.
+
 2001-03-15  Sven Neumann  <sven@gimp.org>
 
        * gdk/gdkim.h: removed
index c330298af0a6e35f5ad74a4be4399dc8eb716f4b..e9feac73e4ed4e692f2a49dd4f9baf41dcc66fdd 100644 (file)
@@ -370,7 +370,6 @@ gdk_headers = @STRIP_BEGIN@         \
        ../gdk/gdkevents.h      \
        ../gdk/gdkfont.h        \
        ../gdk/gdkgc.h          \
-       ../gdk/gdkim.h          \
        ../gdk/gdkimage.h       \
        ../gdk/gdkinput.h       \
        ../gdk/gdkpixmap.h      \
index 7b6aeeb39eb3d53d2be37c53ea75b167c76f7bd3..a98402aeb172d8a38f6d4730c8366808b2b903cd 100644 (file)
 #include "gtkvbox.h"
 #include "gtkhbox.h"
 #include "gtktoolbar.h"
+#include "gtkstock.h"
+#include "gtkiconfactory.h"
+#include "gtkimage.h"
 
 
 #define DEFAULT_SPACE_SIZE  5
 #define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_EMPTY
 
+#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
+
 #define SPACE_LINE_DIVISION 10
 #define SPACE_LINE_START    3
 #define SPACE_LINE_END      7
@@ -198,6 +203,7 @@ gtk_toolbar_init (GtkToolbar *toolbar)
   toolbar->relief       = GTK_RELIEF_NORMAL;
   toolbar->space_size   = DEFAULT_SPACE_SIZE;
   toolbar->space_style  = DEFAULT_SPACE_STYLE;
+  toolbar->icon_size    = DEFAULT_ICON_SIZE;
   toolbar->tooltips     = gtk_tooltips_new ();
   toolbar->button_maxw  = 0;
   toolbar->button_maxh  = 0;
@@ -751,6 +757,105 @@ gtk_toolbar_insert_item (GtkToolbar    *toolbar,
                                     position);
 }
 
+/**
+ * gtk_toolbar_set_icon_size:
+ * @toolbar: A #GtkToolbar
+ * @icon_size: The #GtkIconSize that stock icons in the toolbar shall have.
+ *
+ * This function sets the size of stock icons in the toolbar. You
+ * can call it both before you add the icons and after they've been
+ * added.
+ **/
+void
+gtk_toolbar_set_icon_size (GtkToolbar  *toolbar,
+                          GtkIconSize  icon_size)
+{
+  GList *children;
+  GtkToolbarChild *child;
+  GtkImage *image;
+  gchar *stock_id;
+
+  g_return_if_fail (toolbar != NULL);
+  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
+
+  if (toolbar->icon_size == icon_size)
+    return;
+  
+  toolbar->icon_size = icon_size;
+
+  for (children = toolbar->children; children; children = children->next)
+    {
+      child = children->data;
+      if (child->type == GTK_TOOLBAR_CHILD_BUTTON &&
+         GTK_IS_IMAGE (child->icon))
+       {
+         image = GTK_IMAGE (child->icon);
+         if (gtk_image_get_storage_type (image) == GTK_IMAGE_STOCK)
+           {
+             gtk_image_get_stock (image, &stock_id, NULL);
+             stock_id = g_strdup (stock_id);
+             gtk_image_set_from_stock (image,
+                                       stock_id,
+                                       icon_size);
+             g_free (stock_id);
+           }
+       }
+    }
+  
+  gtk_widget_queue_resize (GTK_WIDGET (toolbar));
+}
+
+/**
+ * gtk_toolbar_insert_stock:
+ * @toolbar: A #GtkToolbar
+ * @stock_id: The id of the stock item you want to insert
+ * @tooltip_text: The text in the tooltip of the toolbar button
+ * @tooltip_private_text: The private text of the tooltip
+ * @callback: The callback called when the toolbar button is clicked.
+ * @user_data: user data passed to callback
+ * @position: The position the button shall be inserted at.
+ *            -1 means at the end.
+ *
+ * Inserts a stock item at the specified position of the toolbar.
+ */
+GtkWidget*
+gtk_toolbar_insert_stock (GtkToolbar      *toolbar,
+                         const gchar     *stock_id,
+                         const char      *tooltip_text,
+                         const char      *tooltip_private_text,
+                         GtkSignalFunc    callback,
+                         gpointer         user_data,
+                         gint             position)
+{
+  GtkStockItem item;
+  GtkWidget *image;
+
+  if (gtk_stock_lookup (stock_id, &item))
+    {
+      image = gtk_image_new_from_stock (stock_id, toolbar->icon_size);
+
+      return gtk_toolbar_insert_item (toolbar,
+                                     item.label,
+                                     tooltip_text,
+                                     tooltip_private_text,
+                                     image,
+                                     callback,
+                                     user_data,
+                                     position);
+    }
+  else
+    return gtk_toolbar_insert_item (toolbar,
+                                   stock_id,
+                                   tooltip_text,
+                                   tooltip_private_text,
+                                   NULL,
+                                   callback,
+                                   user_data,
+                                   position);
+}
+
+
+
 void
 gtk_toolbar_append_space (GtkToolbar *toolbar)
 {
index 76702284d0d74511aaca5ae6c98cd576dccfc72a..a64aa8eaaa64a8f3cce507d88ee0e20ff902712f 100644 (file)
@@ -87,6 +87,7 @@ struct _GtkToolbar
   GtkToolbarStyle  style;
   gint             space_size; /* big optional space between buttons */
   GtkToolbarSpaceStyle space_style;
+  GtkIconSize      icon_size;
 
   GtkTooltips     *tooltips;
 
@@ -134,6 +135,19 @@ GtkWidget* gtk_toolbar_insert_item     (GtkToolbar      *toolbar,
                                        gpointer         user_data,
                                        gint             position);
 
+/* Stock Items */
+void       gtk_toolbar_set_icon_size   (GtkToolbar      *toolbar,
+                                       GtkIconSize      stock_size);
+GtkWidget* gtk_toolbar_insert_stock    (GtkToolbar      *toolbar,
+                                       const gchar     *stock_id,
+                                       const char      *tooltip_text,
+                                       const char      *tooltip_private_text,
+                                       GtkSignalFunc    callback,
+                                       gpointer         user_data,
+                                       gint             position);
+
+
+
 /* Space Items */
 void       gtk_toolbar_append_space    (GtkToolbar      *toolbar);
 void       gtk_toolbar_prepend_space   (GtkToolbar      *toolbar);