Proposed patch to GTK+ 1.3
- From: ERDI Gergo <cactus telnet hu>
- To: gtk-devel-list redhat com
- Subject: Proposed patch to GTK+ 1.3
- Date: Wed, 22 Sep 1999 06:38:09 +0200 (CEST)
Hi,
The attached patch is an implementation of Idea #13 from
http://www.jcinteractive.com/gnome-ui/software/widgets/
basically, layouting the toolbar icon and label horizontally.
Please allow me to commit it to the CVS version of GTK+ 1.3, as AFAIK this
is an "unstable" branch, and thus it's no problem if binary compatibility
breaks because of a new GtkToolbarStyle value.
Bye,
Cactus
--
.--= ULLA! =----------------------------. finger cactus@cactus.rulez.org
\ http://cactus.rulez.org \ for PGP public key
`----------= cactus@cactus.rulez.org =--'
F U CN RD THS U CNT SPL WRTH A DM!
? 1
Index: gtkenums.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkenums.h,v
retrieving revision 1.23
diff -u -r1.23 gtkenums.h
--- gtkenums.h 1999/02/24 07:34:27 1.23
+++ gtkenums.h 1999/09/21 19:36:13
@@ -270,7 +270,8 @@
{
GTK_TOOLBAR_ICONS,
GTK_TOOLBAR_TEXT,
- GTK_TOOLBAR_BOTH
+ GTK_TOOLBAR_BOTH,
+ GTK_TOOLBAR_BOTH_HORIZ
} GtkToolbarStyle;
/* Trough types for GtkRange */
Index: gtktoolbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktoolbar.c,v
retrieving revision 1.35
diff -u -r1.35 gtktoolbar.c
--- gtktoolbar.c 1999/09/17 18:17:20 1.35
+++ gtktoolbar.c 1999/09/21 19:37:07
@@ -30,6 +30,7 @@
#include "gtkradiobutton.h"
#include "gtklabel.h"
#include "gtkvbox.h"
+#include "gtkhbox.h"
#include "gtktoolbar.h"
@@ -819,7 +820,6 @@
gint position)
{
GtkToolbarChild *child;
- GtkWidget *vbox;
g_return_val_if_fail (toolbar != NULL, NULL);
g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), NULL);
@@ -839,6 +839,7 @@
child->type = type;
child->icon = NULL;
child->label = NULL;
+ child->box = NULL;
switch (type)
{
@@ -882,14 +883,17 @@
gtk_signal_connect (GTK_OBJECT (child->widget), "clicked",
callback, user_data);
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (child->widget), vbox);
- gtk_widget_show (vbox);
+ if (toolbar->style == GTK_TOOLBAR_BOTH_HORIZ)
+ child->box = gtk_hbox_new (FALSE, 0);
+ else
+ child->box = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (child->widget), child->box);
+ gtk_widget_show (child->box);
if (text)
{
child->label = gtk_label_new (text);
- gtk_box_pack_end (GTK_BOX (vbox), child->label, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (child->box), child->label, FALSE, FALSE, 0);
if (toolbar->style != GTK_TOOLBAR_ICONS)
gtk_widget_show (child->label);
}
@@ -897,7 +901,7 @@
if (icon)
{
child->icon = GTK_WIDGET (icon);
- gtk_box_pack_end (GTK_BOX (vbox), child->icon, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (child->box), child->icon, FALSE, FALSE, 0);
if (toolbar->style != GTK_TOOLBAR_TEXT)
gtk_widget_show (child->icon);
}
@@ -1084,7 +1088,7 @@
case GTK_TOOLBAR_TEXT:
if (child->icon && GTK_WIDGET_VISIBLE (child->icon))
gtk_widget_hide (child->icon);
-
+
if (child->label && !GTK_WIDGET_VISIBLE (child->label))
gtk_widget_show (child->label);
@@ -1096,7 +1100,84 @@
if (child->label && !GTK_WIDGET_VISIBLE (child->label))
gtk_widget_show (child->label);
-
+
+ if (GTK_IS_HBOX (child->box))
+ {
+ if (child->icon)
+ {
+ gtk_object_ref (GTK_OBJECT (child->icon));
+ gtk_container_remove (GTK_CONTAINER (child->box),
+ child->icon);
+ }
+ if (child->label)
+ {
+ gtk_object_ref (GTK_OBJECT (child->label));
+ gtk_container_remove (GTK_CONTAINER (child->box),
+ child->label);
+ }
+ gtk_container_remove (GTK_CONTAINER (child->widget),
+ child->box);
+
+ child->box = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (child->box);
+
+ if (child->label)
+ {
+ gtk_box_pack_end (GTK_BOX (child->box), child->label, FALSE, FALSE, 0);
+ gtk_object_unref (GTK_OBJECT (child->label));
+ }
+ if (child->icon)
+ {
+ gtk_box_pack_end (GTK_BOX (child->box), child->icon, FALSE, FALSE, 0);
+ gtk_object_unref (GTK_OBJECT (child->icon));
+ }
+ gtk_container_add (GTK_CONTAINER (child->widget),
+ child->box);
+ }
+
+ break;
+
+ case GTK_TOOLBAR_BOTH_HORIZ:
+ if (child->icon && !GTK_WIDGET_VISIBLE (child->icon))
+ gtk_widget_show (child->icon);
+ if (child->label && !GTK_WIDGET_VISIBLE (child->label))
+ gtk_widget_show (child->label);
+
+ if (GTK_IS_VBOX (child->box))
+ {
+ if (child->icon)
+ {
+ gtk_object_ref (GTK_OBJECT (child->icon));
+ gtk_container_remove (GTK_CONTAINER (child->box),
+ child->icon);
+ }
+ if (child->label)
+ {
+ gtk_object_ref (GTK_OBJECT (child->label));
+ gtk_container_remove (GTK_CONTAINER (child->box),
+ child->label);
+ }
+ gtk_container_remove (GTK_CONTAINER (child->widget),
+ child->box);
+
+ child->box = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (child->box);
+
+ if (child->label)
+ {
+ gtk_box_pack_end (GTK_BOX (child->box), child->label, TRUE, TRUE, 0);
+ gtk_object_unref (GTK_OBJECT (child->label));
+ }
+ if (child->icon)
+ {
+ gtk_box_pack_end (GTK_BOX (child->box), child->icon, FALSE, FALSE, 0);
+ gtk_object_unref (GTK_OBJECT (child->icon));
+ }
+ gtk_container_add (GTK_CONTAINER (child->widget),
+ child->box);
+
+ }
+
break;
default:
Index: gtktoolbar.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktoolbar.h,v
retrieving revision 1.18
diff -u -r1.18 gtktoolbar.h
--- gtktoolbar.h 1999/09/17 18:17:20 1.18
+++ gtktoolbar.h 1999/09/21 19:37:09
@@ -71,6 +71,7 @@
GtkWidget *widget;
GtkWidget *icon;
GtkWidget *label;
+ GtkWidget *box;
};
struct _GtkToolbar
Index: testgtk.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/testgtk.c,v
retrieving revision 1.167
diff -u -r1.167 testgtk.c
--- testgtk.c 1999/03/17 23:02:10 1.167
+++ testgtk.c 1999/09/21 19:40:09
@@ -624,6 +624,13 @@
}
static void
+set_toolbar_both_horiz (GtkWidget *widget,
+ gpointer data)
+{
+ gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_BOTH_HORIZ);
+}
+
+static void
set_toolbar_small_space (GtkWidget *widget,
gpointer data)
{
@@ -725,7 +732,13 @@
"Both", "Show toolbar icons and text", "Toolbar/Both",
new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
(GtkSignalFunc) set_toolbar_both, toolbar);
-
+ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+ "Both (horizontal)",
+ "Show toolbar icons and text in a horizontal fashion",
+ "Toolbar/BothHoriz",
+ new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
+ (GtkSignalFunc) set_toolbar_both_horiz, toolbar);
+
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
entry = gtk_entry_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]