mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
This is an implementation of Idea #13 from
http://www.jcinteractive.com/gnome-ui/software/widgets/ basically, layouting the toolbar icon and label horizontally.
This commit is contained in:
parent
637a466d5c
commit
b196167dbc
@ -270,7 +270,8 @@ typedef enum
|
||||
{
|
||||
GTK_TOOLBAR_ICONS,
|
||||
GTK_TOOLBAR_TEXT,
|
||||
GTK_TOOLBAR_BOTH
|
||||
GTK_TOOLBAR_BOTH,
|
||||
GTK_TOOLBAR_BOTH_HORIZ
|
||||
} GtkToolbarStyle;
|
||||
|
||||
/* Trough types for GtkRange */
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "gtkradiobutton.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkvbox.h"
|
||||
#include "gtkhbox.h"
|
||||
#include "gtktoolbar.h"
|
||||
|
||||
|
||||
@ -819,7 +820,7 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar,
|
||||
gint position)
|
||||
{
|
||||
GtkToolbarChild *child;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *box;
|
||||
|
||||
g_return_val_if_fail (toolbar != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), NULL);
|
||||
@ -882,14 +883,17 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar,
|
||||
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)
|
||||
box = gtk_hbox_new (FALSE, 0);
|
||||
else
|
||||
box = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (child->widget), box);
|
||||
gtk_widget_show (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 (box), child->label, FALSE, FALSE, 0);
|
||||
if (toolbar->style != GTK_TOOLBAR_ICONS)
|
||||
gtk_widget_show (child->label);
|
||||
}
|
||||
@ -897,7 +901,7 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar,
|
||||
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 (box), child->icon, FALSE, FALSE, 0);
|
||||
if (toolbar->style != GTK_TOOLBAR_TEXT)
|
||||
gtk_widget_show (child->icon);
|
||||
}
|
||||
@ -1055,6 +1059,7 @@ gtk_real_toolbar_style_changed (GtkToolbar *toolbar,
|
||||
{
|
||||
GList *children;
|
||||
GtkToolbarChild *child;
|
||||
GtkWidget* box = NULL;
|
||||
|
||||
g_return_if_fail (toolbar != NULL);
|
||||
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
|
||||
@ -1084,7 +1089,7 @@ gtk_real_toolbar_style_changed (GtkToolbar *toolbar,
|
||||
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);
|
||||
|
||||
@ -1097,6 +1102,86 @@ gtk_real_toolbar_style_changed (GtkToolbar *toolbar,
|
||||
if (child->label && !GTK_WIDGET_VISIBLE (child->label))
|
||||
gtk_widget_show (child->label);
|
||||
|
||||
box = (GtkWidget*)gtk_container_children (GTK_CONTAINER (child->widget))->data;
|
||||
|
||||
if (GTK_IS_HBOX (box))
|
||||
{
|
||||
if (child->icon)
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (child->icon));
|
||||
gtk_container_remove (GTK_CONTAINER (box),
|
||||
child->icon);
|
||||
}
|
||||
if (child->label)
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (child->label));
|
||||
gtk_container_remove (GTK_CONTAINER (box),
|
||||
child->label);
|
||||
}
|
||||
gtk_container_remove (GTK_CONTAINER (child->widget),
|
||||
box);
|
||||
|
||||
box = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (box);
|
||||
|
||||
if (child->label)
|
||||
{
|
||||
gtk_box_pack_end (GTK_BOX (box), child->label, FALSE, FALSE, 0);
|
||||
gtk_object_unref (GTK_OBJECT (child->label));
|
||||
}
|
||||
if (child->icon)
|
||||
{
|
||||
gtk_box_pack_end (GTK_BOX (box), child->icon, FALSE, FALSE, 0);
|
||||
gtk_object_unref (GTK_OBJECT (child->icon));
|
||||
}
|
||||
gtk_container_add (GTK_CONTAINER (child->widget),
|
||||
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);
|
||||
|
||||
box = (GtkWidget*)gtk_container_children (GTK_CONTAINER (child->widget))->data;
|
||||
|
||||
if (GTK_IS_VBOX (box))
|
||||
{
|
||||
if (child->icon)
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (child->icon));
|
||||
gtk_container_remove (GTK_CONTAINER (box),
|
||||
child->icon);
|
||||
}
|
||||
if (child->label)
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (child->label));
|
||||
gtk_container_remove (GTK_CONTAINER (box),
|
||||
child->label);
|
||||
}
|
||||
gtk_container_remove (GTK_CONTAINER (child->widget),
|
||||
box);
|
||||
|
||||
box = gtk_hbox_new (FALSE, 0);
|
||||
gtk_widget_show (box);
|
||||
|
||||
if (child->label)
|
||||
{
|
||||
gtk_box_pack_end (GTK_BOX (box), child->label, TRUE, TRUE, 0);
|
||||
gtk_object_unref (GTK_OBJECT (child->label));
|
||||
}
|
||||
if (child->icon)
|
||||
{
|
||||
gtk_box_pack_end (GTK_BOX (box), child->icon, FALSE, FALSE, 0);
|
||||
gtk_object_unref (GTK_OBJECT (child->icon));
|
||||
}
|
||||
gtk_container_add (GTK_CONTAINER (child->widget), box);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -623,6 +623,13 @@ set_toolbar_both (GtkWidget *widget,
|
||||
gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_BOTH);
|
||||
}
|
||||
|
||||
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 @@ create_toolbar (void)
|
||||
"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 ();
|
||||
|
@ -623,6 +623,13 @@ set_toolbar_both (GtkWidget *widget,
|
||||
gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_BOTH);
|
||||
}
|
||||
|
||||
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 @@ create_toolbar (void)
|
||||
"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 ();
|
||||
|
Loading…
Reference in New Issue
Block a user