diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-04-30 00:47:21 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-30 00:47:21 +0800 |
commit | c46158a00cd6572504ded30c8a9d1ec1b468d07f (patch) | |
tree | 29aa716204dcd4db73bc2e4f9d433b9f00b8efa9 /lib/egg/eggtoolbar.c | |
parent | 48b245e9205fc5a9a4745e8e0a3146d32a21f816 (diff) | |
download | gsoc2013-epiphany-c46158a00cd6572504ded30c8a9d1ec1b468d07f.tar gsoc2013-epiphany-c46158a00cd6572504ded30c8a9d1ec1b468d07f.tar.gz gsoc2013-epiphany-c46158a00cd6572504ded30c8a9d1ec1b468d07f.tar.bz2 gsoc2013-epiphany-c46158a00cd6572504ded30c8a9d1ec1b468d07f.tar.lz gsoc2013-epiphany-c46158a00cd6572504ded30c8a9d1ec1b468d07f.tar.xz gsoc2013-epiphany-c46158a00cd6572504ded30c8a9d1ec1b468d07f.tar.zst gsoc2013-epiphany-c46158a00cd6572504ded30c8a9d1ec1b468d07f.zip |
Update
2003-04-29 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/egg/egg-editable-toolbar.c:
* lib/egg/eggtoggletoolbutton.c:
* lib/egg/eggtoolbar.c:
* lib/egg/eggtoolbutton.c:
* lib/egg/eggtoolbutton.h:
Update
Diffstat (limited to 'lib/egg/eggtoolbar.c')
-rw-r--r-- | lib/egg/eggtoolbar.c | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c index d24f5f81b..f109a4988 100644 --- a/lib/egg/eggtoolbar.c +++ b/lib/egg/eggtoolbar.c @@ -36,6 +36,9 @@ #include <gdk/gdkkeysyms.h> #include "eggmarshalers.h" #include <gtk/gtkmain.h> +#include <gtk/gtkstock.h> +#include <gtk/gtklabel.h> +#include <string.h> #define DEFAULT_IPADDING 1 #define DEFAULT_SPACE_SIZE 5 @@ -922,7 +925,7 @@ egg_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) gint i; gboolean need_arrow; gint n_expand_items; - gint border_width; + gint border_width, internal_padding; gint available_size; gint n_items; gint needed_size; @@ -932,9 +935,8 @@ egg_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) widget->allocation = *allocation; space_size = get_space_size (toolbar); - - gtk_widget_style_get (widget, "internal_padding", &border_width, NULL); - border_width += GTK_CONTAINER (toolbar)->border_width; + + border_width = GTK_CONTAINER (toolbar)->border_width; if (GTK_WIDGET_REALIZED (widget)) { @@ -945,6 +947,9 @@ egg_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) allocation->height - border_width * 2); } + gtk_widget_style_get (widget, "internal_padding", &internal_padding, NULL); + border_width += internal_padding; + gtk_widget_get_child_requisition (GTK_WIDGET (priv->arrow_button), &arrow_requisition); @@ -2460,6 +2465,32 @@ egg_toolbar_insert_element (EggToolbar *toolbar, icon, callback, user_data, position, FALSE); } +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 GtkWidget * egg_toolbar_internal_insert_element (EggToolbar *toolbar, EggToolbarChildType type, @@ -2526,12 +2557,23 @@ egg_toolbar_internal_insert_element (EggToolbar *toolbar, { if (text) { - child->label = EGG_TOOL_BUTTON (item)->label; - if (use_stock) - g_object_set (G_OBJECT (item), "stock_id", text, NULL); + { + GtkStockItem stock_item; + gchar *label_text; + + egg_tool_button_set_stock_id (EGG_TOOL_BUTTON (item), text); + + gtk_stock_lookup (text, &stock_item); + label_text = elide_underscores (stock_item.label); + child->label = GTK_WIDGET (gtk_label_new (label_text)); + g_free (label_text); + } else - egg_tool_button_set_label (EGG_TOOL_BUTTON (item), text); + { + child->label = gtk_label_new (text); + } + egg_tool_button_set_label_widget (EGG_TOOL_BUTTON (item), child->label); } if (icon) |