summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog75
-rw-r--r--ChangeLog.pre-2-1075
-rw-r--r--ChangeLog.pre-2-475
-rw-r--r--ChangeLog.pre-2-675
-rw-r--r--ChangeLog.pre-2-875
-rw-r--r--gtk/gtk.h18
-rw-r--r--gtk/gtkexpander.c4
-rw-r--r--gtk/gtktoolbar.c98
-rw-r--r--gtk/gtktoolbar.h3
-rw-r--r--gtk/gtktoolbutton.c118
-rw-r--r--gtk/gtktoolbutton.h7
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/testtoolbar.c583
13 files changed, 999 insertions, 213 deletions
diff --git a/ChangeLog b/ChangeLog
index 66b1e61e61..2c02311468 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+Wed Jul 2 15:42:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtk.h: Add new toolbar headers
+
+ * tests/testtoolbar.c: new file
+
+ * tests/Makefile.am (noinst_PROGRAMS): Add testtoolbar.c
+
+ * gtk/gtkexpander.c (gtk_expander_class_init): Make it compile
+
+Tue Jul 1 22:49:25 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.c:
+ (gtk_toolbar_remove_tool_item): Fix bug where list is changed
+ inside a for loop (pointed out by Morten Welinder).
+ (gtk_toolbar_focus_home_or_end): Minor formatting change
+
+ Comments from Owen:
+
+ * gtk/gtktoolbutton.c: remove copy of elide_underscores(). Use
+ gtk_toolbar_elide_underscores instead.
+
+ * gtk/gtktoolbar.c: rename signal from focus_ends to
+ focus_home_or_end.
+ (_gtk_toolbar_elide_underscores): export this as an internal
+ function.
+ (gtk_toolbar_move_focus): add comment explaining difference to
+ gtk_toolbar_focus();
+ (gtk_toolbar_list_children_in_focus_order): Make TAB_FORWARD and
+ TAB_BACKWARD focus the right widgets in RTL mode
+
+ * gtk/gtktoolbutton.c (gtk_tool_button_new): Change to take
+ "label" and "icon" parameters
+
+ * gtk/gtktoolbutton.[ch]: remove icon_set property.
+
2003-07-01 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (gtk_spin_button_set_digits): Improve docs. (116364, Morten Welinder)
@@ -64,20 +100,35 @@
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
- * gtkradiotoolbutton.c
- * gtkradiotoolbutton.h
- * gtktoggletoolbutton.c
- * gtktoggletoolbutton.h
- * gtktoolbutton.c
- * gtktoolbutton.h
- * gtktoolitem.c
- * gtktoolitem.h
- * gtktoolbar.c
- * gtktoolbar.h
- * gtkseparatortoolitem.c
- * gtkseparatortoolitem.h
+ * gtkradiotoolbutton.c: new file
+ * gtkradiotoolbutton.h: "
+ * gtktoggletoolbutton.c: "
+ * gtktoggletoolbutton.h: "
+ * gtktoolbutton.c: "
+ * gtktoolbutton.h: "
+ * gtktoolitem.c: "
+ * gtktoolitem.h: "
+ * gtktoolbar.c: many changes
+ * gtktoolbar.h: many changes
+ * gtkseparatortoolitem.c: new file
+ * gtkseparatortoolitem.h "
New toolbar.
+
+ - Items on a toolbar are now separate widgets, instances of a
+ subclass of GtkToolItem.
+
+ - Items there aren't room for on the toolbar are unmapped, and an
+ overflow menu with a proxy menu item is added instead.
+
+ - The toolbar is keyboard navigatable. Press TAB to focus the
+ first item, then use arrow keys and Ctrl TAB to move around the
+ toolbar. TAB moves focus out of the toolbar.
+
+ - Bascially all of the old toolbar API is deprecated in favor of
+ new API in gtktoolbar.h, gtktoolitem.h, gtktoolbutton.h
+
+ - The toolbar is backwards compatible with the old toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 66b1e61e61..2c02311468 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,39 @@
+Wed Jul 2 15:42:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtk.h: Add new toolbar headers
+
+ * tests/testtoolbar.c: new file
+
+ * tests/Makefile.am (noinst_PROGRAMS): Add testtoolbar.c
+
+ * gtk/gtkexpander.c (gtk_expander_class_init): Make it compile
+
+Tue Jul 1 22:49:25 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.c:
+ (gtk_toolbar_remove_tool_item): Fix bug where list is changed
+ inside a for loop (pointed out by Morten Welinder).
+ (gtk_toolbar_focus_home_or_end): Minor formatting change
+
+ Comments from Owen:
+
+ * gtk/gtktoolbutton.c: remove copy of elide_underscores(). Use
+ gtk_toolbar_elide_underscores instead.
+
+ * gtk/gtktoolbar.c: rename signal from focus_ends to
+ focus_home_or_end.
+ (_gtk_toolbar_elide_underscores): export this as an internal
+ function.
+ (gtk_toolbar_move_focus): add comment explaining difference to
+ gtk_toolbar_focus();
+ (gtk_toolbar_list_children_in_focus_order): Make TAB_FORWARD and
+ TAB_BACKWARD focus the right widgets in RTL mode
+
+ * gtk/gtktoolbutton.c (gtk_tool_button_new): Change to take
+ "label" and "icon" parameters
+
+ * gtk/gtktoolbutton.[ch]: remove icon_set property.
+
2003-07-01 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (gtk_spin_button_set_digits): Improve docs. (116364, Morten Welinder)
@@ -64,20 +100,35 @@
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
- * gtkradiotoolbutton.c
- * gtkradiotoolbutton.h
- * gtktoggletoolbutton.c
- * gtktoggletoolbutton.h
- * gtktoolbutton.c
- * gtktoolbutton.h
- * gtktoolitem.c
- * gtktoolitem.h
- * gtktoolbar.c
- * gtktoolbar.h
- * gtkseparatortoolitem.c
- * gtkseparatortoolitem.h
+ * gtkradiotoolbutton.c: new file
+ * gtkradiotoolbutton.h: "
+ * gtktoggletoolbutton.c: "
+ * gtktoggletoolbutton.h: "
+ * gtktoolbutton.c: "
+ * gtktoolbutton.h: "
+ * gtktoolitem.c: "
+ * gtktoolitem.h: "
+ * gtktoolbar.c: many changes
+ * gtktoolbar.h: many changes
+ * gtkseparatortoolitem.c: new file
+ * gtkseparatortoolitem.h "
New toolbar.
+
+ - Items on a toolbar are now separate widgets, instances of a
+ subclass of GtkToolItem.
+
+ - Items there aren't room for on the toolbar are unmapped, and an
+ overflow menu with a proxy menu item is added instead.
+
+ - The toolbar is keyboard navigatable. Press TAB to focus the
+ first item, then use arrow keys and Ctrl TAB to move around the
+ toolbar. TAB moves focus out of the toolbar.
+
+ - Bascially all of the old toolbar API is deprecated in favor of
+ new API in gtktoolbar.h, gtktoolitem.h, gtktoolbutton.h
+
+ - The toolbar is backwards compatible with the old toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 66b1e61e61..2c02311468 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,39 @@
+Wed Jul 2 15:42:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtk.h: Add new toolbar headers
+
+ * tests/testtoolbar.c: new file
+
+ * tests/Makefile.am (noinst_PROGRAMS): Add testtoolbar.c
+
+ * gtk/gtkexpander.c (gtk_expander_class_init): Make it compile
+
+Tue Jul 1 22:49:25 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.c:
+ (gtk_toolbar_remove_tool_item): Fix bug where list is changed
+ inside a for loop (pointed out by Morten Welinder).
+ (gtk_toolbar_focus_home_or_end): Minor formatting change
+
+ Comments from Owen:
+
+ * gtk/gtktoolbutton.c: remove copy of elide_underscores(). Use
+ gtk_toolbar_elide_underscores instead.
+
+ * gtk/gtktoolbar.c: rename signal from focus_ends to
+ focus_home_or_end.
+ (_gtk_toolbar_elide_underscores): export this as an internal
+ function.
+ (gtk_toolbar_move_focus): add comment explaining difference to
+ gtk_toolbar_focus();
+ (gtk_toolbar_list_children_in_focus_order): Make TAB_FORWARD and
+ TAB_BACKWARD focus the right widgets in RTL mode
+
+ * gtk/gtktoolbutton.c (gtk_tool_button_new): Change to take
+ "label" and "icon" parameters
+
+ * gtk/gtktoolbutton.[ch]: remove icon_set property.
+
2003-07-01 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (gtk_spin_button_set_digits): Improve docs. (116364, Morten Welinder)
@@ -64,20 +100,35 @@
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
- * gtkradiotoolbutton.c
- * gtkradiotoolbutton.h
- * gtktoggletoolbutton.c
- * gtktoggletoolbutton.h
- * gtktoolbutton.c
- * gtktoolbutton.h
- * gtktoolitem.c
- * gtktoolitem.h
- * gtktoolbar.c
- * gtktoolbar.h
- * gtkseparatortoolitem.c
- * gtkseparatortoolitem.h
+ * gtkradiotoolbutton.c: new file
+ * gtkradiotoolbutton.h: "
+ * gtktoggletoolbutton.c: "
+ * gtktoggletoolbutton.h: "
+ * gtktoolbutton.c: "
+ * gtktoolbutton.h: "
+ * gtktoolitem.c: "
+ * gtktoolitem.h: "
+ * gtktoolbar.c: many changes
+ * gtktoolbar.h: many changes
+ * gtkseparatortoolitem.c: new file
+ * gtkseparatortoolitem.h "
New toolbar.
+
+ - Items on a toolbar are now separate widgets, instances of a
+ subclass of GtkToolItem.
+
+ - Items there aren't room for on the toolbar are unmapped, and an
+ overflow menu with a proxy menu item is added instead.
+
+ - The toolbar is keyboard navigatable. Press TAB to focus the
+ first item, then use arrow keys and Ctrl TAB to move around the
+ toolbar. TAB moves focus out of the toolbar.
+
+ - Bascially all of the old toolbar API is deprecated in favor of
+ new API in gtktoolbar.h, gtktoolitem.h, gtktoolbutton.h
+
+ - The toolbar is backwards compatible with the old toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 66b1e61e61..2c02311468 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,39 @@
+Wed Jul 2 15:42:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtk.h: Add new toolbar headers
+
+ * tests/testtoolbar.c: new file
+
+ * tests/Makefile.am (noinst_PROGRAMS): Add testtoolbar.c
+
+ * gtk/gtkexpander.c (gtk_expander_class_init): Make it compile
+
+Tue Jul 1 22:49:25 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.c:
+ (gtk_toolbar_remove_tool_item): Fix bug where list is changed
+ inside a for loop (pointed out by Morten Welinder).
+ (gtk_toolbar_focus_home_or_end): Minor formatting change
+
+ Comments from Owen:
+
+ * gtk/gtktoolbutton.c: remove copy of elide_underscores(). Use
+ gtk_toolbar_elide_underscores instead.
+
+ * gtk/gtktoolbar.c: rename signal from focus_ends to
+ focus_home_or_end.
+ (_gtk_toolbar_elide_underscores): export this as an internal
+ function.
+ (gtk_toolbar_move_focus): add comment explaining difference to
+ gtk_toolbar_focus();
+ (gtk_toolbar_list_children_in_focus_order): Make TAB_FORWARD and
+ TAB_BACKWARD focus the right widgets in RTL mode
+
+ * gtk/gtktoolbutton.c (gtk_tool_button_new): Change to take
+ "label" and "icon" parameters
+
+ * gtk/gtktoolbutton.[ch]: remove icon_set property.
+
2003-07-01 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (gtk_spin_button_set_digits): Improve docs. (116364, Morten Welinder)
@@ -64,20 +100,35 @@
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
- * gtkradiotoolbutton.c
- * gtkradiotoolbutton.h
- * gtktoggletoolbutton.c
- * gtktoggletoolbutton.h
- * gtktoolbutton.c
- * gtktoolbutton.h
- * gtktoolitem.c
- * gtktoolitem.h
- * gtktoolbar.c
- * gtktoolbar.h
- * gtkseparatortoolitem.c
- * gtkseparatortoolitem.h
+ * gtkradiotoolbutton.c: new file
+ * gtkradiotoolbutton.h: "
+ * gtktoggletoolbutton.c: "
+ * gtktoggletoolbutton.h: "
+ * gtktoolbutton.c: "
+ * gtktoolbutton.h: "
+ * gtktoolitem.c: "
+ * gtktoolitem.h: "
+ * gtktoolbar.c: many changes
+ * gtktoolbar.h: many changes
+ * gtkseparatortoolitem.c: new file
+ * gtkseparatortoolitem.h "
New toolbar.
+
+ - Items on a toolbar are now separate widgets, instances of a
+ subclass of GtkToolItem.
+
+ - Items there aren't room for on the toolbar are unmapped, and an
+ overflow menu with a proxy menu item is added instead.
+
+ - The toolbar is keyboard navigatable. Press TAB to focus the
+ first item, then use arrow keys and Ctrl TAB to move around the
+ toolbar. TAB moves focus out of the toolbar.
+
+ - Bascially all of the old toolbar API is deprecated in favor of
+ new API in gtktoolbar.h, gtktoolitem.h, gtktoolbutton.h
+
+ - The toolbar is backwards compatible with the old toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 66b1e61e61..2c02311468 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,39 @@
+Wed Jul 2 15:42:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtk.h: Add new toolbar headers
+
+ * tests/testtoolbar.c: new file
+
+ * tests/Makefile.am (noinst_PROGRAMS): Add testtoolbar.c
+
+ * gtk/gtkexpander.c (gtk_expander_class_init): Make it compile
+
+Tue Jul 1 22:49:25 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+
+ * gtk/gtktoolbar.c:
+ (gtk_toolbar_remove_tool_item): Fix bug where list is changed
+ inside a for loop (pointed out by Morten Welinder).
+ (gtk_toolbar_focus_home_or_end): Minor formatting change
+
+ Comments from Owen:
+
+ * gtk/gtktoolbutton.c: remove copy of elide_underscores(). Use
+ gtk_toolbar_elide_underscores instead.
+
+ * gtk/gtktoolbar.c: rename signal from focus_ends to
+ focus_home_or_end.
+ (_gtk_toolbar_elide_underscores): export this as an internal
+ function.
+ (gtk_toolbar_move_focus): add comment explaining difference to
+ gtk_toolbar_focus();
+ (gtk_toolbar_list_children_in_focus_order): Make TAB_FORWARD and
+ TAB_BACKWARD focus the right widgets in RTL mode
+
+ * gtk/gtktoolbutton.c (gtk_tool_button_new): Change to take
+ "label" and "icon" parameters
+
+ * gtk/gtktoolbutton.[ch]: remove icon_set property.
+
2003-07-01 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (gtk_spin_button_set_digits): Improve docs. (116364, Morten Welinder)
@@ -64,20 +100,35 @@
Mon Jun 30 01:20:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
- * gtkradiotoolbutton.c
- * gtkradiotoolbutton.h
- * gtktoggletoolbutton.c
- * gtktoggletoolbutton.h
- * gtktoolbutton.c
- * gtktoolbutton.h
- * gtktoolitem.c
- * gtktoolitem.h
- * gtktoolbar.c
- * gtktoolbar.h
- * gtkseparatortoolitem.c
- * gtkseparatortoolitem.h
+ * gtkradiotoolbutton.c: new file
+ * gtkradiotoolbutton.h: "
+ * gtktoggletoolbutton.c: "
+ * gtktoggletoolbutton.h: "
+ * gtktoolbutton.c: "
+ * gtktoolbutton.h: "
+ * gtktoolitem.c: "
+ * gtktoolitem.h: "
+ * gtktoolbar.c: many changes
+ * gtktoolbar.h: many changes
+ * gtkseparatortoolitem.c: new file
+ * gtkseparatortoolitem.h "
New toolbar.
+
+ - Items on a toolbar are now separate widgets, instances of a
+ subclass of GtkToolItem.
+
+ - Items there aren't room for on the toolbar are unmapped, and an
+ overflow menu with a proxy menu item is added instead.
+
+ - The toolbar is keyboard navigatable. Press TAB to focus the
+ first item, then use arrow keys and Ctrl TAB to move around the
+ toolbar. TAB moves focus out of the toolbar.
+
+ - Bascially all of the old toolbar API is deprecated in favor of
+ new API in gtktoolbar.h, gtktoolitem.h, gtktoolbutton.h
+
+ - The toolbar is backwards compatible with the old toolbar.
2003-06-29 Matthias Clasen <maclas@gmx.de>
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 3bafe27bc9..2c7ffe5d72 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -35,18 +35,18 @@
#include <gtk/gtkaccessible.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkalignment.h>
-#include <gtk/gtkaspectframe.h>
#include <gtk/gtkarrow.h>
+#include <gtk/gtkaspectframe.h>
+#include <gtk/gtkbbox.h>
#include <gtk/gtkbin.h>
#include <gtk/gtkbindings.h>
#include <gtk/gtkbox.h>
-#include <gtk/gtkbbox.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkcalendar.h>
#include <gtk/gtkcellrenderer.h>
+#include <gtk/gtkcellrendererpixbuf.h>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkcellrenderertoggle.h>
-#include <gtk/gtkcellrendererpixbuf.h>
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkclipboard.h>
@@ -74,8 +74,8 @@
#include <gtk/gtkgamma.h>
#include <gtk/gtkgc.h>
#include <gtk/gtkhandlebox.h>
-#include <gtk/gtkhbox.h>
#include <gtk/gtkhbbox.h>
+#include <gtk/gtkhbox.h>
#include <gtk/gtkhpaned.h>
#include <gtk/gtkhruler.h>
#include <gtk/gtkhscale.h>
@@ -115,6 +115,7 @@
#include <gtk/gtkprogressbar.h>
#include <gtk/gtkradiobutton.h>
#include <gtk/gtkradiomenuitem.h>
+#include <gtk/gtkradiotoolbutton.h>
#include <gtk/gtkrange.h>
#include <gtk/gtkrc.h>
#include <gtk/gtkruler.h>
@@ -124,14 +125,15 @@
#include <gtk/gtkselection.h>
#include <gtk/gtkseparator.h>
#include <gtk/gtkseparatormenuitem.h>
+#include <gtk/gtkseparatortoolitem.h>
#include <gtk/gtksettings.h>
#include <gtk/gtksignal.h>
#include <gtk/gtksizegroup.h>
#include <gtk/gtksocket.h>
#include <gtk/gtkspinbutton.h>
+#include <gtk/gtkstatusbar.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkstyle.h>
-#include <gtk/gtkstatusbar.h>
#include <gtk/gtktable.h>
#include <gtk/gtktearoffmenuitem.h>
#include <gtk/gtktext.h>
@@ -139,7 +141,11 @@
#include <gtk/gtktextview.h>
#include <gtk/gtktipsquery.h>
#include <gtk/gtktogglebutton.h>
+#include <gtk/gtktoggletoolbutton.h>
#include <gtk/gtktoolbar.h>
+#include <gtk/gtktoolbar.h>
+#include <gtk/gtktoolbutton.h>
+#include <gtk/gtktoolitem.h>
#include <gtk/gtktooltips.h>
#include <gtk/gtktree.h>
#include <gtk/gtktreednd.h>
@@ -151,8 +157,8 @@
#include <gtk/gtktreeview.h>
#include <gtk/gtktreeviewcolumn.h>
#include <gtk/gtktypeutils.h>
-#include <gtk/gtkvbox.h>
#include <gtk/gtkvbbox.h>
+#include <gtk/gtkvbox.h>
#include <gtk/gtkversion.h>
#include <gtk/gtkviewport.h>
#include <gtk/gtkvpaned.h>
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index 06948807f2..cef9dc6427 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -246,9 +246,7 @@ gtk_expander_class_init (GtkExpanderClass *klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkExpanderClass, activate),
NULL, NULL,
- _gtk_marsha /**
-
-l_VOID__VOID,
+ _gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 8b4096ed1b..7ec12c706d 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -78,7 +78,7 @@ enum {
STYLE_CHANGED,
POPUP_CONTEXT_MENU,
MOVE_FOCUS,
- FOCUS_ENDS,
+ FOCUS_HOME_OR_END,
LAST_SIGNAL
};
@@ -147,10 +147,10 @@ static void gtk_toolbar_real_orientation_changed (GtkToolbar *toolbar,
static void gtk_toolbar_real_style_changed (GtkToolbar *toolbar,
GtkToolbarStyle style);
-static gboolean gtk_toolbar_move_focus (GtkToolbar *toolbar,
- GtkDirectionType dir);
-static gboolean gtk_toolbar_focus_ends (GtkToolbar *toolbar,
- gboolean home);
+static gboolean gtk_toolbar_move_focus (GtkToolbar *toolbar,
+ GtkDirectionType dir);
+static gboolean gtk_toolbar_focus_home_or_end (GtkToolbar *toolbar,
+ gboolean focus_home);
static gboolean gtk_toolbar_button_press (GtkWidget *toolbar,
GdkEventButton *event);
@@ -343,11 +343,11 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
_gtk_marshal_BOOLEAN__ENUM,
G_TYPE_BOOLEAN, 1,
GTK_TYPE_DIRECTION_TYPE);
- toolbar_signals[FOCUS_ENDS] =
- _gtk_binding_signal_new ("focus_ends",
+ toolbar_signals[FOCUS_HOME_OR_END] =
+ _gtk_binding_signal_new ("focus_home_or_end",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_CALLBACK (gtk_toolbar_focus_ends),
+ G_CALLBACK (gtk_toolbar_focus_home_or_end),
NULL, NULL,
_gtk_marshal_BOOLEAN__BOOLEAN,
G_TYPE_BOOLEAN, 1,
@@ -468,20 +468,20 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
add_arrow_bindings (binding_set, GDK_Down, GTK_DIR_DOWN);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0,
- "focus_ends", 1,
+ "focus_home_or_end", 1,
G_TYPE_BOOLEAN, TRUE);
gtk_binding_entry_add_signal (binding_set, GDK_Home, 0,
- "focus_ends", 1,
+ "focus_home_or_end", 1,
G_TYPE_BOOLEAN, TRUE);
gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0,
- "focus_ends", 1,
+ "focus_home_or_end", 1,
G_TYPE_BOOLEAN, FALSE);
gtk_binding_entry_add_signal (binding_set, GDK_End, 0,
- "focus_ends", 1,
+ "focus_home_or_end", 1,
G_TYPE_BOOLEAN, FALSE);
- add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_RIGHT);
- add_ctrl_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_LEFT);
+ add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
+ add_ctrl_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
g_type_class_add_private (gobject_class, sizeof (GtkToolbarPrivate));
}
@@ -1271,7 +1271,10 @@ gtk_toolbar_list_children_in_focus_order (GtkToolbar *toolbar,
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
GList *result = NULL;
GList *list;
+ gboolean rtl;
+ /* generate list of children in reverse logical order */
+
for (list = priv->items; list != NULL; list = list->next)
{
GtkToolItem *item = list->data;
@@ -1288,32 +1291,41 @@ gtk_toolbar_list_children_in_focus_order (GtkToolbar *toolbar,
}
result = g_list_prepend (result, priv->arrow_button);
-
- if (dir == GTK_DIR_RIGHT || dir == GTK_DIR_DOWN || dir == GTK_DIR_TAB_FORWARD)
- result = g_list_reverse (result);
- if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
- result = g_list_reverse (result);
+ rtl = (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL);
+
+ /* move in logical order when
+ *
+ * - dir is TAB_FORWARD
+ *
+ * - in RTL mode and moving left or up
+ *
+ * - in LTR mode and moving right or down
+ */
+ if (dir == GTK_DIR_TAB_FORWARD ||
+ (rtl && (dir == GTK_DIR_UP || dir == GTK_DIR_LEFT)) ||
+ (!rtl && (dir == GTK_DIR_DOWN || dir == GTK_DIR_RIGHT)))
+ {
+ result = g_list_reverse (result);
+ }
return result;
}
static gboolean
-gtk_toolbar_focus_ends (GtkToolbar *toolbar,
- gboolean home)
+gtk_toolbar_focus_home_or_end (GtkToolbar *toolbar,
+ gboolean focus_home)
{
GList *children, *list;
- GtkDirectionType dir = home? GTK_DIR_RIGHT : GTK_DIR_LEFT;
+ GtkDirectionType dir = focus_home? GTK_DIR_RIGHT : GTK_DIR_LEFT;
children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
{
children = g_list_reverse (children);
- if (dir == GTK_DIR_RIGHT)
- dir = GTK_DIR_LEFT;
- else
- dir = GTK_DIR_RIGHT;
+
+ dir = (dir == GTK_DIR_RIGHT)? GTK_DIR_LEFT : GTK_DIR_RIGHT;
}
for (list = children; list != NULL; list = list->next)
@@ -1332,13 +1344,25 @@ gtk_toolbar_focus_ends (GtkToolbar *toolbar,
return TRUE;
}
+/* Keybinding handler. This function is called when the user presses
+ * Ctrl TAB or an arrow key.
+ */
static gboolean
gtk_toolbar_move_focus (GtkToolbar *toolbar,
GtkDirectionType dir)
{
GList *list;
gboolean try_focus = FALSE;
- GList *children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
+ GList *children;
+ GtkContainer *container = GTK_CONTAINER (toolbar);
+
+ if (container->focus_child &&
+ gtk_widget_child_focus (container->focus_child, dir))
+ {
+ return TRUE;
+ }
+
+ children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
for (list = children; list != NULL; list = list->next)
{
@@ -1356,8 +1380,8 @@ gtk_toolbar_move_focus (GtkToolbar *toolbar,
return TRUE;
}
-/* The focus handler for the toolbar. It called when the user presses TAB or otherwise
- * tries to focus the toolbar.
+/* The focus handler for the toolbar. It called when the user presses
+ * TAB or otherwise tries to focus the toolbar.
*/
static gboolean
gtk_toolbar_focus (GtkWidget *widget,
@@ -2078,9 +2102,11 @@ gtk_toolbar_remove_tool_item (GtkToolbar *toolbar,
g_return_if_fail (GTK_IS_TOOL_ITEM (item));
priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-
- for (tmp = priv->items; tmp != NULL; tmp = tmp->next)
+
+ tmp = priv->items;
+ while (tmp)
{
+ GList *next = tmp->next;
GtkWidget *child = tmp->data;
if (child == GTK_WIDGET (item))
@@ -2098,6 +2124,8 @@ gtk_toolbar_remove_tool_item (GtkToolbar *toolbar,
break;
}
+
+ tmp = next;
}
}
@@ -2588,8 +2616,8 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar,
icon, callback, user_data, position, FALSE);
}
-static gchar *
-elide_underscores (const gchar *original)
+gchar *
+_gtk_toolbar_elide_underscores (const gchar *original)
{
gchar *q, *result;
const gchar *p;
@@ -2660,7 +2688,7 @@ gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
break;
case GTK_TOOLBAR_CHILD_BUTTON:
- item = gtk_tool_button_new ();
+ item = gtk_tool_button_new (NULL, NULL);
child->widget = GTK_TOOL_BUTTON (item)->button;
break;
@@ -2693,7 +2721,7 @@ gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (item), text);
gtk_stock_lookup (text, &stock_item);
- label_text = elide_underscores (stock_item.label);
+ label_text = _gtk_toolbar_elide_underscores (stock_item.label);
child->label = GTK_WIDGET (gtk_label_new (label_text));
g_free (label_text);
}
diff --git a/gtk/gtktoolbar.h b/gtk/gtktoolbar.h
index 87d570383a..49162e3011 100644
--- a/gtk/gtktoolbar.h
+++ b/gtk/gtktoolbar.h
@@ -157,6 +157,9 @@ GtkIconSize gtk_toolbar_get_icon_size (GtkToolbar *toolbar);
gboolean gtk_toolbar_get_tooltips (GtkToolbar *toolbar);
GtkReliefStyle gtk_toolbar_get_relief_style (GtkToolbar *toolbar);
+/* internal function */
+gchar * _gtk_toolbar_elide_underscores (const gchar *original);
+
#ifndef GTK_DISABLE_DEPRECATED
/* Simple button items */
void gtk_toolbar_set_style (GtkToolbar *toolbar,
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c
index a5fa3be88e..6deab67e4c 100644
--- a/gtk/gtktoolbutton.c
+++ b/gtk/gtktoolbutton.c
@@ -30,6 +30,7 @@
#include "gtkstock.h"
#include "gtkvbox.h"
#include "gtkintl.h"
+#include "gtktoolbar.h"
#include <string.h>
@@ -46,7 +47,6 @@ enum {
PROP_USE_UNDERLINE,
PROP_LABEL_WIDGET,
PROP_STOCK_ID,
- PROP_ICON_SET,
PROP_ICON_WIDGET,
};
@@ -158,13 +158,6 @@ gtk_tool_button_class_init (GtkToolButtonClass *klass)
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
- PROP_ICON_SET,
- g_param_spec_boxed ("icon_set",
- _("Icon set"),
- _("Icon set to use to draw the item's icon"),
- GTK_TYPE_ICON_SET,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
PROP_ICON_WIDGET,
g_param_spec_object ("icon_widget",
_("Icon widget"),
@@ -192,7 +185,7 @@ gtk_tool_button_init (GtkToolButton *button,
/* create button */
button->button = g_object_new (klass->button_type, NULL);
- gtk_button_set_focus_on_click (button->button, FALSE);
+ gtk_button_set_focus_on_click (GTK_BUTTON (button->button), FALSE);
g_signal_connect_object (button->button, "clicked",
G_CALLBACK (button_clicked), button, 0);
@@ -250,32 +243,6 @@ gtk_tool_button_size_allocate (GtkWidget *widget,
}
}
-static gchar *
-elide_underscores (const gchar *original)
-{
- gchar *q, *result;
- const gchar *p;
- gboolean last_underscore;
-
- q = result = g_malloc (strlen (original) + 1);
- last_underscore = FALSE;
-
- for (p = original; *p; p++)
- {
- if (!last_underscore && *p == '_')
- last_underscore = TRUE;
- else
- {
- last_underscore = FALSE;
- *q++ = *p;
- }
- }
-
- *q = '\0';
-
- return result;
-}
-
static void
gtk_tool_button_construct_contents (GtkToolItem *tool_item)
{
@@ -345,7 +312,7 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
label_text = "";
if (elide)
- label_text = elide_underscores (label_text);
+ label_text = _gtk_toolbar_elide_underscores (label_text);
else
label_text = g_strdup (label_text);
@@ -360,12 +327,7 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (button));
if (need_icon)
{
- if (button->icon_set)
- {
- icon = gtk_image_new_from_icon_set (button->icon_set, icon_size);
- gtk_widget_show (icon);
- }
- else if (button->icon_widget)
+ if (button->icon_widget)
{
icon = button->icon_widget;
@@ -456,9 +418,6 @@ gtk_tool_button_set_property (GObject *object,
case PROP_STOCK_ID:
gtk_tool_button_set_stock_id (button, g_value_get_string (value));
break;
- case PROP_ICON_SET:
- gtk_tool_button_set_icon_set (button, g_value_get_boxed (value));
- break;
case PROP_ICON_WIDGET:
gtk_tool_button_set_icon_widget (button, g_value_get_object (value));
break;
@@ -489,9 +448,6 @@ gtk_tool_button_get_property (GObject *object,
case PROP_STOCK_ID:
g_value_set_string (value, button->stock_id);
break;
- case PROP_ICON_SET:
- g_value_set_boxed (value, gtk_tool_button_get_icon_set (button));
- break;
case PROP_ICON_WIDGET:
g_value_set_object (value, button->icon_widget);
break;
@@ -536,11 +492,7 @@ gtk_tool_button_create_menu_proxy (GtkToolItem *item)
else
menu_item = gtk_image_menu_item_new_with_label (label);
- if (button->icon_set)
- {
- menu_image = gtk_image_new_from_icon_set (button->icon_set, GTK_ICON_SIZE_MENU);
- }
- else if (button->icon_widget && GTK_IS_IMAGE (button->icon_widget))
+ if (button->icon_widget && GTK_IS_IMAGE (button->icon_widget))
{
GtkImage *image = GTK_IMAGE (button->icon_widget);
GtkImageType storage_type = gtk_image_get_storage_type (image);
@@ -605,12 +557,19 @@ gtk_tool_button_new_from_stock (const gchar *stock_id)
}
GtkToolItem *
-gtk_tool_button_new (void)
+gtk_tool_button_new (const gchar *label,
+ GtkWidget *icon_widget)
{
GtkToolButton *button;
-
+
button = g_object_new (GTK_TYPE_TOOL_BUTTON,
NULL);
+
+ if (label)
+ gtk_tool_button_set_label (button, label);
+
+ if (icon_widget)
+ gtk_tool_button_set_icon_widget (button, icon_widget);
return GTK_TOOL_ITEM (button);
}
@@ -703,8 +662,6 @@ gtk_tool_button_set_icon_widget (GtkToolButton *button,
if (icon != button->icon_widget)
{
- g_object_freeze_notify (G_OBJECT (button));
-
if (button->icon_widget)
g_object_unref (G_OBJECT (button->icon_widget));
@@ -715,19 +672,10 @@ gtk_tool_button_set_icon_widget (GtkToolButton *button,
}
button->icon_widget = icon;
-
- if (button->icon_widget && button->icon_set)
- {
- gtk_icon_set_unref (button->icon_set);
- button->icon_set = NULL;
-
- g_object_notify (G_OBJECT (button), "icon_set");
- }
gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
g_object_notify (G_OBJECT (button), "icon_widget");
- g_object_thaw_notify (G_OBJECT (button));
}
}
@@ -772,41 +720,3 @@ gtk_tool_button_get_icon_widget (GtkToolButton *button)
return button->icon_widget;
}
-
-void
-gtk_tool_button_set_icon_set (GtkToolButton *button,
- GtkIconSet *icon_set)
-{
- g_return_if_fail (GTK_IS_TOOL_BUTTON (button));
-
- if (icon_set != button->icon_set)
- {
- g_object_freeze_notify (G_OBJECT (button));
-
- if (button->icon_set)
- gtk_icon_set_unref (button->icon_set);
-
- button->icon_set = icon_set;
-
- if (button->icon_set && button->icon_widget)
- {
- g_object_unref (button->icon_widget);
- button->icon_widget = NULL;
-
- g_object_notify (G_OBJECT (button->icon_widget), "icon_widget");
- }
-
- gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "icon_set");
- g_object_thaw_notify (G_OBJECT (button));
- }
-}
-
-GtkIconSet *
-gtk_tool_button_get_icon_set (GtkToolButton *button)
-{
- g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);
-
- return button->icon_set;
-}
diff --git a/gtk/gtktoolbutton.h b/gtk/gtktoolbutton.h
index 72456e894e..e2c6efbfe7 100644
--- a/gtk/gtktoolbutton.h
+++ b/gtk/gtktoolbutton.h
@@ -48,7 +48,6 @@ struct _GtkToolButton
gchar *label_text;
GtkWidget *label_widget;
GtkWidget *icon_widget;
- GtkIconSet *icon_set;
guint use_underline : 1;
};
@@ -64,7 +63,8 @@ struct _GtkToolButtonClass
};
GType gtk_tool_button_get_type (void);
-GtkToolItem *gtk_tool_button_new (void);
+GtkToolItem *gtk_tool_button_new (const gchar *label,
+ GtkWidget *icon_widget);
GtkToolItem *gtk_tool_button_new_from_stock (const gchar *stock_id);
void gtk_tool_button_set_label (GtkToolButton *button,
@@ -76,9 +76,6 @@ gboolean gtk_tool_button_get_use_underline (GtkToolButton *button);
void gtk_tool_button_set_stock_id (GtkToolButton *button,
const gchar *stock_id);
G_CONST_RETURN gchar *gtk_tool_button_get_stock_id (GtkToolButton *button);
-void gtk_tool_button_set_icon_set (GtkToolButton *button,
- GtkIconSet *icon_set);
-GtkIconSet * gtk_tool_button_get_icon_set (GtkToolButton *button);
void gtk_tool_button_set_icon_widget (GtkToolButton *button,
GtkWidget *icon);
GtkWidget * gtk_tool_button_get_icon_widget (GtkToolButton *button);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0838ed4b18..3cd09889d8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,6 +40,7 @@ noinst_PROGRAMS = \
$(testsocket_programs) \
testtext \
testtextbuffer \
+ testtoolbar \
testtreeedit \
testtreeview \
testtreefocus \
@@ -89,6 +90,7 @@ testselection_LDADD = $(LDADDS)
testsocket_LDADD = $(LDADDS)
testsocket_child_LDADD = $(LDADDS)
testtextbuffer_LDADD = $(LDADDS)
+testtoolbar_LDADD = $(LDADDS)
testtreeedit_LDADD = $(LDADDS)
testtreeview_LDADD = $(LDADDS)
testtreefocus_LDADD = $(LDADDS)
@@ -118,6 +120,10 @@ testtext_SOURCES = \
prop-editor.c \
testtext.c
+testtoolbar_SOURCES = \
+ testtoolbar.c \
+ prop-editor.c
+
testsocket_SOURCES = \
testsocket.c \
testsocket_common.c
diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c
new file mode 100644
index 0000000000..6ad3b8e848
--- /dev/null
+++ b/tests/testtoolbar.c
@@ -0,0 +1,583 @@
+/* testtoolbar.c
+ *
+ * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
+ * Copyright (C) 2002 James Henstridge <james@daa.com.au>
+ * Copyright (C) 2003 Soeren Sandmann <sandmann@daimi.au.dk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+#include "prop-editor.h"
+
+static void
+reload_clicked (GtkWidget *widget)
+{
+ static GdkAtom atom_rcfiles = GDK_NONE;
+
+ GdkEventClient sev;
+ int i;
+
+ if (!atom_rcfiles)
+ atom_rcfiles = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
+
+ for(i = 0; i < 5; i++)
+ sev.data.l[i] = 0;
+ sev.data_format = 32;
+ sev.message_type = atom_rcfiles;
+ gdk_event_send_clientmessage_toall ((GdkEvent *) &sev);
+}
+
+static void
+change_orientation (GtkWidget *button, GtkWidget *toolbar)
+{
+ GtkWidget *table;
+ GtkOrientation orientation;
+
+ table = gtk_widget_get_parent (toolbar);
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ orientation = GTK_ORIENTATION_VERTICAL;
+ else
+ orientation = GTK_ORIENTATION_HORIZONTAL;
+
+ g_object_ref (toolbar);
+ gtk_container_remove (GTK_CONTAINER (table), toolbar);
+ gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), orientation);
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ gtk_table_attach (GTK_TABLE (table), toolbar,
+ 0,2, 0,1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+ }
+ else
+ {
+ gtk_table_attach (GTK_TABLE (table), toolbar,
+ 0,1, 0,4, GTK_FILL, GTK_FILL|GTK_EXPAND, 0, 0);
+ }
+ g_object_unref (toolbar);
+}
+
+static void
+change_show_arrow (GtkWidget *button, GtkWidget *toolbar)
+{
+ gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar),
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
+}
+
+static void
+set_toolbar_style_toggled (GtkCheckButton *button, GtkToolbar *toolbar)
+{
+ GtkWidget *option_menu;
+ int style;
+
+ option_menu = g_object_get_data (G_OBJECT (button), "option-menu");
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ {
+ style = gtk_option_menu_get_history (GTK_OPTION_MENU (option_menu));
+
+ gtk_toolbar_set_style (toolbar, style);
+ gtk_widget_set_sensitive (option_menu, TRUE);
+ }
+ else
+ {
+ gtk_toolbar_unset_style (toolbar);
+ gtk_widget_set_sensitive (option_menu, FALSE);
+ }
+}
+
+static void
+change_toolbar_style (GtkWidget *option_menu, GtkWidget *toolbar)
+{
+ GtkToolbarStyle style;
+
+ style = gtk_option_menu_get_history (GTK_OPTION_MENU (option_menu));
+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), style);
+}
+
+static void
+set_visible_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
+ GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+ GtkToolItem *tool_item;
+ gboolean visible;
+
+ gtk_tree_model_get (model, iter, 0, &tool_item, -1);
+
+ g_object_get (G_OBJECT (tool_item), "visible", &visible, NULL);
+ g_object_set (G_OBJECT (cell), "active", visible, NULL);
+ g_object_unref (tool_item);
+}
+
+static void
+visibile_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
+ GtkTreeModel *model)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkToolItem *tool_item;
+ gboolean visible;
+
+ path = gtk_tree_path_new_from_string (path_str);
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
+ g_object_get (G_OBJECT (tool_item), "visible", &visible, NULL);
+ g_object_set (G_OBJECT (tool_item), "visible", !visible, NULL);
+ g_object_unref (tool_item);
+
+ gtk_tree_model_row_changed (model, path, &iter);
+ gtk_tree_path_free (path);
+}
+
+static void
+set_expand_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
+ GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+ GtkToolItem *tool_item;
+
+ gtk_tree_model_get (model, iter, 0, &tool_item, -1);
+
+ g_object_set (G_OBJECT (cell), "active", tool_item->expand, NULL);
+ g_object_unref (tool_item);
+}
+
+static void
+expand_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
+ GtkTreeModel *model)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkToolItem *tool_item;
+
+ path = gtk_tree_path_new_from_string (path_str);
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
+ gtk_tool_item_set_expand (tool_item, !tool_item->expand);
+ g_object_unref (tool_item);
+
+ gtk_tree_model_row_changed (model, path, &iter);
+ gtk_tree_path_free (path);
+}
+
+static void
+set_pack_end_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
+ GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+ GtkToolItem *tool_item;
+
+ gtk_tree_model_get (model, iter, 0, &tool_item, -1);
+
+ g_object_set (G_OBJECT (cell), "active", tool_item->pack_end, NULL);
+ g_object_unref (tool_item);
+}
+
+static void
+pack_end_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
+ GtkTreeModel *model)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkToolItem *tool_item;
+
+ path = gtk_tree_path_new_from_string (path_str);
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
+ gtk_tool_item_set_pack_end (tool_item, !tool_item->pack_end);
+ g_object_unref (tool_item);
+
+ gtk_tree_model_row_changed (model, path, &iter);
+ gtk_tree_path_free (path);
+}
+
+static void
+set_homogeneous_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
+ GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+ GtkToolItem *tool_item;
+
+ gtk_tree_model_get (model, iter, 0, &tool_item, -1);
+
+ g_object_set (G_OBJECT (cell), "active", tool_item->homogeneous, NULL);
+ g_object_unref (tool_item);
+}
+
+static void
+homogeneous_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
+ GtkTreeModel *model)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkToolItem *tool_item;
+
+ path = gtk_tree_path_new_from_string (path_str);
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
+ gtk_tool_item_set_homogeneous (tool_item, !tool_item->homogeneous);
+ g_object_unref (tool_item);
+
+ gtk_tree_model_row_changed (model, path, &iter);
+ gtk_tree_path_free (path);
+}
+
+static GtkListStore *
+create_items_list (GtkWidget **tree_view_p)
+{
+ GtkWidget *tree_view;
+ GtkListStore *list_store;
+ GtkCellRenderer *cell;
+
+ list_store = gtk_list_store_new (2, GTK_TYPE_TOOL_ITEM, G_TYPE_STRING);
+
+ tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
+
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, "Tool Item",
+ gtk_cell_renderer_text_new (),
+ "text", 1, NULL);
+
+ cell = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (cell, "toggled", G_CALLBACK (visibile_toggled),
+ list_store);
+ gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view),
+ -1, "Visible",
+ cell,
+ set_visible_func, NULL, NULL);
+
+ cell = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (cell, "toggled", G_CALLBACK (expand_toggled),
+ list_store);
+ gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view),
+ -1, "Expand",
+ cell,
+ set_expand_func, NULL, NULL);
+
+ cell = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (cell, "toggled", G_CALLBACK (pack_end_toggled),
+ list_store);
+ gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view),
+ -1, "Pack End",
+ cell,
+ set_pack_end_func, NULL, NULL);
+
+ cell = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (cell, "toggled", G_CALLBACK (homogeneous_toggled),
+ list_store);
+ gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (tree_view),
+ -1, "Homogeneous",
+ cell,
+ set_homogeneous_func, NULL,NULL);
+
+ g_object_unref (list_store);
+
+ *tree_view_p = tree_view;
+
+ return list_store;
+}
+
+static void
+add_item_to_list (GtkListStore *store, GtkToolItem *item, const gchar *text)
+{
+ GtkTreeIter iter;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ 0, item,
+ 1, text,
+ -1);
+
+}
+
+static void
+bold_toggled (GtkToggleToolButton *button)
+{
+ g_message ("Bold toggled (active=%d)",
+ gtk_toggle_tool_button_get_active (button));
+}
+
+static void
+set_icon_size_toggled (GtkCheckButton *button, GtkToolbar *toolbar)
+{
+ GtkWidget *option_menu;
+ int icon_size;
+
+ option_menu = g_object_get_data (G_OBJECT (button), "option-menu");
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ {
+ icon_size = gtk_option_menu_get_history (GTK_OPTION_MENU (option_menu));
+ icon_size += GTK_ICON_SIZE_SMALL_TOOLBAR;
+
+ gtk_toolbar_set_icon_size (toolbar, icon_size);
+ gtk_widget_set_sensitive (option_menu, TRUE);
+ }
+ else
+ {
+ gtk_toolbar_unset_icon_size (toolbar);
+ gtk_widget_set_sensitive (option_menu, FALSE);
+ }
+}
+
+static void
+icon_size_history_changed (GtkOptionMenu *menu, GtkToolbar *toolbar)
+{
+ int icon_size;
+
+ icon_size = gtk_option_menu_get_history (menu);
+ icon_size += GTK_ICON_SIZE_SMALL_TOOLBAR;
+
+ gtk_toolbar_set_icon_size (toolbar, icon_size);
+}
+
+static gboolean
+toolbar_drag_drop (GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y, guint time, GtkWidget *label)
+{
+ gchar buf[32];
+
+ g_snprintf(buf, sizeof(buf), "%d",
+ gtk_toolbar_get_drop_index (GTK_TOOLBAR (widget), x, y));
+ gtk_label_set_label (GTK_LABEL (label), buf);
+
+ return TRUE;
+}
+
+static GtkTargetEntry target_table[] = {
+ { "application/x-toolbar-item", 0, 0 }
+};
+
+static GtkWidget *
+make_prop_editor (GObject *object)
+{
+ GtkWidget *prop_editor = create_prop_editor (object, 0);
+ gtk_widget_show (prop_editor);
+ return prop_editor;
+}
+
+static void
+rtl_toggled (GtkCheckButton *check)
+{
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
+ gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
+ else
+ gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ GtkWidget *window, *toolbar, *table, *treeview, *scrolled_window;
+ GtkWidget *hbox, *checkbox, *option_menu, *menu;
+ gint i;
+ static const gchar *toolbar_styles[] = { "icons", "text", "both (vertical)",
+ "both (horizontal)" };
+ GtkToolItem *item;
+ GtkListStore *store;
+ GtkWidget *image;
+ GtkWidget *menuitem;
+ GtkWidget *button;
+ GtkWidget *label;
+ GSList *group;
+
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
+
+ table = gtk_table_new (4, 2, FALSE);
+ gtk_container_add (GTK_CONTAINER (window), table);
+
+ toolbar = gtk_toolbar_new ();
+ gtk_table_attach (GTK_TABLE (table), toolbar,
+ 0,2, 0,1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+ gtk_table_attach (GTK_TABLE (table), hbox,
+ 1,2, 1,2, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+
+ checkbox = gtk_check_button_new_with_mnemonic("_Vertical");
+ gtk_box_pack_start (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+ g_signal_connect (checkbox, "toggled",
+ G_CALLBACK (change_orientation), toolbar);
+
+ checkbox = gtk_check_button_new_with_mnemonic("_Show Arrow");
+ gtk_box_pack_start (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+ g_signal_connect (checkbox, "toggled",
+ G_CALLBACK (change_show_arrow), toolbar);
+
+ checkbox = gtk_check_button_new_with_mnemonic("_Set Toolbar Style:");
+ g_signal_connect (checkbox, "toggled", G_CALLBACK (set_toolbar_style_toggled), toolbar);
+ gtk_box_pack_start (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+
+ option_menu = gtk_option_menu_new();
+ gtk_widget_set_sensitive (option_menu, FALSE);
+ g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
+
+ menu = gtk_menu_new();
+ for (i = 0; i < G_N_ELEMENTS (toolbar_styles); i++)
+ {
+ GtkWidget *menuitem;
+
+ menuitem = gtk_menu_item_new_with_label (toolbar_styles[i]);
+ gtk_container_add (GTK_CONTAINER (menu), menuitem);
+ gtk_widget_show (menuitem);
+ }
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
+ gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu),
+ GTK_TOOLBAR (toolbar)->style);
+ gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0);
+ g_signal_connect (option_menu, "changed",
+ G_CALLBACK (change_toolbar_style), toolbar);
+
+ checkbox = gtk_check_button_new_with_mnemonic("_Set Icon Size:");
+ g_signal_connect (checkbox, "toggled", G_CALLBACK (set_icon_size_toggled), toolbar);
+ gtk_box_pack_start (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+
+ option_menu = gtk_option_menu_new();
+ g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
+ gtk_widget_set_sensitive (option_menu, FALSE);
+ menu = gtk_menu_new();
+ menuitem = gtk_menu_item_new_with_label ("small toolbar");
+ g_object_set_data (G_OBJECT (menuitem), "value-id", GINT_TO_POINTER (GTK_ICON_SIZE_SMALL_TOOLBAR));
+ gtk_container_add (GTK_CONTAINER (menu), menuitem);
+ gtk_widget_show (menuitem);
+
+ menuitem = gtk_menu_item_new_with_label ("large toolbar");
+ g_object_set_data (G_OBJECT (menuitem), "value-id", GINT_TO_POINTER (GTK_ICON_SIZE_LARGE_TOOLBAR));
+ gtk_container_add (GTK_CONTAINER (menu), menuitem);
+ gtk_widget_show (menuitem);
+
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
+ gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0);
+ g_signal_connect (option_menu, "changed",
+ G_CALLBACK (icon_size_history_changed), toolbar);
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_table_attach (GTK_TABLE (table), scrolled_window,
+ 1,2, 2,3, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
+
+ store = create_items_list (&treeview);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), treeview);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_NEW);
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), "Custom label");
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), NULL);
+ add_item_to_list (store, item, "New");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_OPEN);
+ add_item_to_list (store, item, "Open");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_separator_tool_item_new ();
+ add_item_to_list (store, item, "-----");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_REFRESH);
+ add_item_to_list (store, item, "Refresh");
+ g_signal_connect (item, "clicked", G_CALLBACK (reload_clicked), NULL);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
+ item = gtk_tool_item_new ();
+ gtk_widget_show (image);
+ gtk_container_add (GTK_CONTAINER (item), image);
+ add_item_to_list (store, item, "(Custom Item)");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
+ add_item_to_list (store, item, "Back");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_separator_tool_item_new ();
+ add_item_to_list (store, item, "-----");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
+ add_item_to_list (store, item, "Forward");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_BOLD);
+ g_signal_connect (item, "toggled", G_CALLBACK (bold_toggled), NULL);
+ add_item_to_list (store, item, "Bold");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_separator_tool_item_new ();
+ add_item_to_list (store, item, "-----");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_radio_tool_button_new_from_stock (NULL, GTK_STOCK_JUSTIFY_LEFT);
+ group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
+ add_item_to_list (store, item, "Left");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_radio_tool_button_new_from_stock (group, GTK_STOCK_JUSTIFY_CENTER); make_prop_editor (G_OBJECT (item));
+
+ group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
+ add_item_to_list (store, item, "Center");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ item = gtk_radio_tool_button_new_from_stock (group, GTK_STOCK_JUSTIFY_RIGHT);
+
+ add_item_to_list (store, item, "Right");
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+ gtk_table_attach (GTK_TABLE (table), hbox,
+ 1,2, 3,4, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+
+ button = gtk_button_new_with_label ("Drag me to the toolbar");
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ label = gtk_label_new ("Drop index:");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ label = gtk_label_new ("");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ checkbox = gtk_check_button_new_with_mnemonic("_Right to left");
+ if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
+ else
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), FALSE);
+ g_signal_connect (checkbox, "toggled", G_CALLBACK (rtl_toggled), NULL);
+
+ gtk_box_pack_end (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+
+ gtk_drag_source_set (button, GDK_BUTTON1_MASK,
+ target_table, G_N_ELEMENTS (target_table),
+ GDK_ACTION_MOVE);
+ gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
+ target_table, G_N_ELEMENTS (target_table),
+ GDK_ACTION_MOVE);
+ g_signal_connect (toolbar, "drag_drop",
+ G_CALLBACK (toolbar_drag_drop), label);
+
+ gtk_widget_show_all (window);
+
+ make_prop_editor (G_OBJECT (toolbar));
+
+ gtk_main ();
+
+ return 0;
+}