summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-06-04 23:15:51 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-06-04 23:15:51 +0000
commit1b3c9214371d89a4872574d700b86cb71d6eee56 (patch)
treecc6c602393a292313c61da2b246b5a6b4de2ff4d /gtk
parent9cc992b6e732fef6edf2153821354a6b1b6a5af6 (diff)
downloadgtk+-1b3c9214371d89a4872574d700b86cb71d6eee56.tar.gz
Handle case where we need to parse the xsetting as if it were an RC file
2001-05-10 Havoc Pennington <hp@redhat.com> * gtk/gtksettings.c (gtk_settings_get_property): Handle case where we need to parse the xsetting as if it were an RC file string. * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial value of palette from settings, not from static variable * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to xsettings translation table * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because hardcoding the toolbar style conflicts with new customizable toolbar style philosophy (gtk_toolbar_class_init): add settings for default toolbar style; these are used unless the app specifically forces a toolbar style * gtk/gtksettings.c (settings_install_property_parser): only return at the start if we warn and parser == NULL * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the palette changed handler so we don't notify dead color selections * gtk/gtkstyle.c (gtk_default_draw_shadow): handle xthickness/ythickness of 0 or 1 properly (gtk_default_draw_resize_grip): clear the background behind the resize grips, and align to bottom right if we square the area to be drawn. * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on statusbar label to 1, so it doesn't make toplevels resize oddly (gtk_statusbar_size_request): add grip size to request (gtk_statusbar_size_allocate): hack so the hbox still works with the grip size in the request * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix bug where showing all on a toplevel makes the toolbar button text appear despite the toolbar mode * gtk/gtkmenubar.c: add internal padding style property * gtk/gtktoolbar.c: Add internal padding style property; add shadow type style property * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget state; and put Container::border_width outside the frame * gtk/gtktextview.c: don't draw focus rectangle if we're in interior focus mode, we just use blinking cursor
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcolorsel.c30
-rw-r--r--gtk/gtkiconfactory.c2
-rw-r--r--gtk/gtkmenubar.c35
-rw-r--r--gtk/gtksettings.c66
-rw-r--r--gtk/gtkstatusbar.c115
-rw-r--r--gtk/gtkstyle.c273
-rw-r--r--gtk/gtktextview.c75
-rw-r--r--gtk/gtktoolbar.c255
-rw-r--r--gtk/gtktoolbar.h15
9 files changed, 697 insertions, 169 deletions
diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c
index f14e2654d9..02f847d7c3 100644
--- a/gtk/gtkcolorsel.c
+++ b/gtk/gtkcolorsel.c
@@ -126,6 +126,9 @@ struct _ColorSelectionPrivate
/* Window for grabbing on */
GtkWidget *dropper_grab_widget;
+
+ /* Connection to settings */
+ guint settings_connection;
};
@@ -1621,6 +1624,7 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
{
GtkObjectClass *object_class;
GObjectClass *gobject_class;
+ gchar *palette;
object_class = GTK_OBJECT_CLASS (klass);
gobject_class = G_OBJECT_CLASS (klass);
@@ -1644,8 +1648,14 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
_("Palette to use in the color selector"),
default_colors,
G_PARAM_READWRITE));
+
+ g_object_get (G_OBJECT (gtk_settings_get_global ()),
+ "gtk-color-palette",
+ &palette,
+ NULL);
- fill_palette_from_string (default_colors);
+ fill_palette_from_string (palette);
+ g_free (palette);
change_palette_hook = default_change_palette_func;
@@ -1813,11 +1823,12 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
/* Set default colors */
update_palette (colorsel);
-
- g_signal_connect_data (G_OBJECT (gtk_settings_get_global ()),
- "notify::gtk-color-palette",
- G_CALLBACK (palette_change_notify_instance),
- colorsel, NULL, FALSE, FALSE);
+
+ priv->settings_connection =
+ g_signal_connect_data (G_OBJECT (gtk_settings_get_global ()),
+ "notify::gtk-color-palette",
+ G_CALLBACK (palette_change_notify_instance),
+ colorsel, NULL, FALSE, FALSE);
/* hide unused stuff */
@@ -1862,6 +1873,13 @@ gtk_color_selection_finalize (GObject *object)
if (cselection->private_data)
{
+ ColorSelectionPrivate *priv;
+
+ priv = cselection->private_data;
+
+ g_signal_handler_disconnect (gtk_settings_get_global (),
+ priv->settings_connection);
+
g_free (cselection->private_data);
cselection->private_data = NULL;
}
diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c
index f4d025a041..697281f753 100644
--- a/gtk/gtkiconfactory.c
+++ b/gtk/gtkiconfactory.c
@@ -313,7 +313,7 @@ gtk_icon_factory_lookup_default (const gchar *stock_id)
if (icon_set)
return icon_set;
-
+
tmp_list = g_slist_next (tmp_list);
}
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index 9616638422..9965fef932 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -37,7 +37,7 @@
#define BORDER_SPACING 0
#define CHILD_SPACING 3
-
+#define DEFAULT_IPADDING 1
static void gtk_menu_bar_class_init (GtkMenuBarClass *klass);
static void gtk_menu_bar_size_request (GtkWidget *widget,
@@ -136,6 +136,16 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
GTK_TYPE_SHADOW_TYPE,
GTK_SHADOW_OUT,
G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("internal_padding",
+ _("Internal padding"),
+ _("Amount of border space between the menubar shadow and the menu items"),
+ 0,
+ G_MAXINT,
+ DEFAULT_IPADDING,
+ G_PARAM_READABLE));
+
}
GtkWidget*
@@ -177,6 +187,7 @@ gtk_menu_bar_size_request (GtkWidget *widget,
GList *children;
gint nchildren;
GtkRequisition child_requisition;
+ gint ipadding;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MENU_BAR (widget));
@@ -184,7 +195,7 @@ gtk_menu_bar_size_request (GtkWidget *widget,
requisition->width = 0;
requisition->height = 0;
-
+
if (GTK_WIDGET_VISIBLE (widget))
{
menu_bar = GTK_MENU_BAR (widget);
@@ -222,11 +233,15 @@ gtk_menu_bar_size_request (GtkWidget *widget,
}
}
+ gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+
requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
widget->style->xthickness +
+ ipadding +
BORDER_SPACING) * 2;
requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
widget->style->ythickness +
+ ipadding +
BORDER_SPACING) * 2;
if (nchildren > 0)
@@ -245,6 +260,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
GtkAllocation child_allocation;
GtkRequisition child_requisition;
guint offset;
+ gint ipadding;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MENU_BAR (widget));
@@ -259,15 +275,19 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
allocation->x, allocation->y,
allocation->width, allocation->height);
+ gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+
if (menu_shell->children)
{
child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
widget->style->xthickness +
+ ipadding +
BORDER_SPACING);
offset = child_allocation.x; /* Window edge to menubar start */
child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
widget->style->ythickness +
+ ipadding +
BORDER_SPACING);
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
@@ -314,13 +334,18 @@ gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area)
if (GTK_WIDGET_DRAWABLE (widget))
{
+ gint border;
+
+ border = GTK_CONTAINER (widget)->border_width;
+
gtk_paint_box (widget->style,
widget->window,
- GTK_STATE_NORMAL,
+ GTK_WIDGET_STATE (widget),
get_shadow_type (GTK_MENU_BAR (widget)),
area, widget, "menubar",
- 0, 0,
- -1,-1);
+ border, border,
+ widget->allocation.width - border * 2,
+ widget->allocation.height - border * 2);
}
}
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index ee5c187dbe..3fe8f49277 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -219,10 +219,58 @@ gtk_settings_get_property (GObject *object,
{
GtkSettings *settings = GTK_SETTINGS (object);
- if (gdk_setting_get (pspec->name, value))
- g_param_value_validate (pspec, value);
+ if (g_value_type_transformable (G_TYPE_INT, G_VALUE_TYPE (value)) ||
+ g_value_type_transformable (G_TYPE_STRING, G_VALUE_TYPE (value)) ||
+ g_value_type_transformable (GDK_TYPE_COLOR, G_VALUE_TYPE (value)))
+ {
+ if (gdk_setting_get (pspec->name, value))
+ g_param_value_validate (pspec, value);
+ else
+ g_value_copy (settings->property_values + property_id - 1, value);
+ }
else
- g_value_copy (settings->property_values + property_id - 1, value);
+ {
+ GValue val = { 0, };
+
+ /* Try to get xsetting as a string and parse it. */
+
+ g_value_init (&val, G_TYPE_STRING);
+
+ if (!gdk_setting_get (pspec->name, &val))
+ {
+ g_value_copy (settings->property_values + property_id - 1, value);
+ }
+ else
+ {
+ GValue tmp_value = { 0, };
+ GValue gstring_value = { 0, };
+ GtkRcPropertyParser parser = g_param_spec_get_qdata (pspec,
+ quark_property_parser);
+
+ g_value_init (&gstring_value, G_TYPE_GSTRING);
+
+ g_value_set_boxed (&gstring_value,
+ g_string_new (g_value_get_string (&val)));
+
+ g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+
+ if (parser && _gtk_settings_parse_convert (parser, &gstring_value,
+ pspec, &tmp_value))
+ {
+ g_value_copy (&tmp_value, value);
+ g_param_value_validate (pspec, value);
+ }
+ else
+ {
+ g_value_copy (settings->property_values + property_id - 1, value);
+ }
+
+ g_value_unset (&gstring_value);
+ g_value_unset (&tmp_value);
+ }
+
+ g_value_unset (&val);
+ }
}
static void
@@ -359,9 +407,11 @@ settings_install_property_parser (GtkSettingsClass *class,
break;
default:
if (!parser)
- g_warning (G_STRLOC ": parser needs to be specified for property \"%s\" of type `%s'",
- pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
- return 0;
+ {
+ g_warning (G_STRLOC ": parser needs to be specified for property \"%s\" of type `%s'",
+ pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
+ return 0;
+ }
}
if (g_object_class_find_property (G_OBJECT_CLASS (class), pspec->name))
{
@@ -617,7 +667,7 @@ gtk_rc_property_parse_enum (const GParamSpec *pspec,
if (scanner->token == G_TOKEN_IDENTIFIER)
{
GEnumClass *class = G_PARAM_SPEC_ENUM (pspec)->enum_class;
-
+
enum_value = g_enum_get_value_by_name (class, scanner->value.v_identifier);
if (!enum_value)
enum_value = g_enum_get_value_by_nick (class, scanner->value.v_identifier);
@@ -820,7 +870,7 @@ void
_gtk_settings_handle_event (GdkEventSetting *event)
{
GtkSettings *settings = gtk_settings_get_global ();
-
+
if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings), event->name))
g_object_notify (G_OBJECT (settings), event->name);
}
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index 1ca1466ffa..a032eb7fad 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -30,6 +30,7 @@
#include "gtksignal.h"
#include "gtkstatusbar.h"
#include "gtkwindow.h"
+#include "gtkintl.h"
typedef struct _GtkStatusbarMsg GtkStatusbarMsg;
@@ -63,6 +64,10 @@ static gboolean gtk_statusbar_button_press (GtkWidget *widget,
GdkEventButton *event);
static gboolean gtk_statusbar_expose_event (GtkWidget *widget,
GdkEventExpose *event);
+static void gtk_statusbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static void gtk_statusbar_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
static void gtk_statusbar_create_window (GtkStatusbar *statusbar);
static void gtk_statusbar_destroy_window (GtkStatusbar *statusbar);
@@ -109,8 +114,6 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
object_class->destroy = gtk_statusbar_destroy;
- widget_class->size_allocate = gtk_statusbar_size_allocate;
-
widget_class->realize = gtk_statusbar_realize;
widget_class->unrealize = gtk_statusbar_unrealize;
widget_class->map = gtk_statusbar_map;
@@ -118,6 +121,9 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
widget_class->button_press_event = gtk_statusbar_button_press;
widget_class->expose_event = gtk_statusbar_expose_event;
+
+ widget_class->size_request = gtk_statusbar_size_request;
+ widget_class->size_allocate = gtk_statusbar_size_allocate;
class->messages_mem_chunk = g_mem_chunk_new ("GtkStatusBar messages mem chunk",
sizeof (GtkStatusbarMsg),
@@ -145,27 +151,42 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
GTK_TYPE_NONE, 2,
GTK_TYPE_UINT,
GTK_TYPE_STRING);
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_enum ("shadow_type",
+ _("Shadow type"),
+ _("Style of bevel around the statusbar text"),
+ GTK_TYPE_SHADOW_TYPE,
+ GTK_SHADOW_IN,
+ G_PARAM_READABLE));
}
static void
gtk_statusbar_init (GtkStatusbar *statusbar)
{
GtkBox *box;
-
+ GtkShadowType shadow_type;
+
box = GTK_BOX (statusbar);
box->spacing = 2;
box->homogeneous = FALSE;
statusbar->has_resize_grip = TRUE;
+
+ gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow_type", &shadow_type, NULL);
statusbar->frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), GTK_SHADOW_IN);
+ gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type);
gtk_box_pack_start (box, statusbar->frame, TRUE, TRUE, 0);
gtk_widget_show (statusbar->frame);
statusbar->label = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (statusbar->label), 0.0, 0.0);
+ /* don't expand the size request for the label; if we
+ * do that then toplevels weirdly resize
+ */
+ gtk_widget_set_usize (statusbar->label, 1, -1);
gtk_container_add (GTK_CONTAINER (statusbar->frame), statusbar->label);
gtk_widget_show (statusbar->label);
@@ -426,25 +447,6 @@ get_grip_rect (GtkStatusbar *statusbar,
}
static void
-gtk_statusbar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkStatusbar *statusbar;
- GdkRectangle rect;
-
- statusbar = GTK_STATUSBAR (widget);
-
- GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-
- get_grip_rect (statusbar, &rect);
-
- if (statusbar->grip_window)
- gdk_window_move_resize (statusbar->grip_window,
- rect.x, rect.y,
- rect.width, rect.height);
-}
-
-static void
gtk_statusbar_create_window (GtkStatusbar *statusbar)
{
GtkWidget *widget;
@@ -583,7 +585,7 @@ gtk_statusbar_expose_event (GtkWidget *widget,
if (statusbar->has_resize_grip)
{
get_grip_rect (statusbar, &rect);
-
+
gtk_paint_resize_grip (widget->style,
widget->window,
GTK_WIDGET_STATE (widget),
@@ -601,3 +603,68 @@ gtk_statusbar_expose_event (GtkWidget *widget,
return FALSE;
}
+
+static void
+gtk_statusbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ GtkStatusbar *statusbar;
+ GtkShadowType shadow_type;
+
+ statusbar = GTK_STATUSBAR (widget);
+
+ gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow_type", &shadow_type, NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type);
+
+ GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
+
+ if (statusbar->has_resize_grip)
+ {
+ GdkRectangle rect;
+
+ /* x, y in the grip rect depend on size allocation, but
+ * w, h do not so this is OK
+ */
+ get_grip_rect (statusbar, &rect);
+
+ requisition->width += rect.width;
+ requisition->height = MAX (requisition->height, rect.height);
+ }
+}
+
+static void
+gtk_statusbar_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkStatusbar *statusbar;
+
+ statusbar = GTK_STATUSBAR (widget);
+
+ if (statusbar->has_resize_grip)
+ {
+ GdkRectangle rect;
+ GtkAllocation hbox_allocation;
+ GtkRequisition saved_req;
+
+ widget->allocation = *allocation; /* get_grip_rect needs this info */
+ get_grip_rect (statusbar, &rect);
+
+ if (statusbar->grip_window)
+ gdk_window_move_resize (statusbar->grip_window,
+ rect.x, rect.y,
+ rect.width, rect.height);
+
+ /* enter the bad hack zone */
+ saved_req = widget->requisition;
+ widget->requisition.width -= rect.width; /* HBox::size_allocate needs this */
+ if (widget->requisition.width < 0)
+ widget->requisition.width = 0;
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+ widget->requisition = saved_req;
+ }
+ else
+ {
+ /* chain up normally */
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+ }
+}
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 6aaf330549..e0c526ecd9 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -2116,103 +2116,188 @@ gtk_default_draw_shadow (GtkStyle *style,
break;
case GTK_SHADOW_IN:
- gdk_draw_line (window, gc1,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, gc1,
- x + width - 1, y, x + width - 1, y + height - 1);
-
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, style->bg_gc[state_type],
- x + width - 2, y + 1, x + width - 2, y + height - 2);
-
- gdk_draw_line (window, style->black_gc,
- x + 1, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, style->black_gc,
- x + 1, y + 1, x + 1, y + height - 2);
-
- gdk_draw_line (window, gc2,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc2,
- x, y, x, y + height - 1);
+ /* Light around right and bottom edge */
+
+ if (style->ythickness > 0)
+ gdk_draw_line (window, gc1,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ if (style->xthickness > 0)
+ gdk_draw_line (window, gc1,
+ x + width - 1, y, x + width - 1, y + height - 1);
+
+ if (style->ythickness > 1)
+ gdk_draw_line (window, style->bg_gc[state_type],
+ x + 1, y + height - 2, x + width - 2, y + height - 2);
+ if (style->xthickness > 1)
+ gdk_draw_line (window, style->bg_gc[state_type],
+ x + width - 2, y + 1, x + width - 2, y + height - 2);
+
+ /* Dark around left and top */
+
+ if (style->ythickness > 1)
+ gdk_draw_line (window, style->black_gc,
+ x + 1, y + 1, x + width - 2, y + 1);
+ if (style->xthickness > 1)
+ gdk_draw_line (window, style->black_gc,
+ x + 1, y + 1, x + 1, y + height - 2);
+
+ if (style->ythickness > 0)
+ gdk_draw_line (window, gc2,
+ x, y, x + width - 1, y);
+ if (style->xthickness > 0)
+ gdk_draw_line (window, gc2,
+ x, y, x, y + height - 1);
break;
case GTK_SHADOW_OUT:
- gdk_draw_line (window, gc1,
- x + 1, y + height - 2, x + width - 2, y + height - 2);
- gdk_draw_line (window, gc1,
- x + width - 2, y + 1, x + width - 2, y + height - 2);
-
- gdk_draw_line (window, gc2,
- x, y, x + width - 1, y);
- gdk_draw_line (window, gc2,
- x, y, x, y + height - 1);
-
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, style->bg_gc[state_type],
- x + 1, y + 1, x + 1, y + height - 2);
+ /* Dark around right and bottom edge */
+
+ if (style->ythickness > 0)
+ {
+ if (style->ythickness > 1)
+ {
+ gdk_draw_line (window, gc1,
+ x + 1, y + height - 2, x + width - 2, y + height - 2);
+ gdk_draw_line (window, style->black_gc,
+ x, y + height - 1, x + width - 1, y + height - 1);
+ }
+ else
+ {
+ gdk_draw_line (window, gc1,
+ x + 1, y + height - 1, x + width - 1, y + height - 1);
+ }
+ }
+
+ if (style->xthickness > 0)
+ {
+ if (style->xthickness > 1)
+ {
+ gdk_draw_line (window, gc1,
+ x + width - 2, y + 1, x + width - 2, y + height - 2);
+
+ gdk_draw_line (window, style->black_gc,
+ x + width - 1, y, x + width - 1, y + height - 1);
+ }
+ else
+ {
+ gdk_draw_line (window, gc1,
+ x + width - 1, y + 1, x + width - 1, y + height - 1);
+ }
+ }
- gdk_draw_line (window, style->black_gc,
- x, y + height - 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, style->black_gc,
- x + width - 1, y, x + width - 1, y + height - 1);
+ /* Light around top and left */
+
+ if (style->ythickness > 0)
+ gdk_draw_line (window, gc2,
+ x, y, x + width - 1, y);
+ if (style->xthickness > 0)
+ gdk_draw_line (window, gc2,
+ x, y, x, y + height - 1);
+
+ if (style->ythickness > 1)
+ gdk_draw_line (window, style->bg_gc[state_type],
+ x + 1, y + 1, x + width - 2, y + 1);
+ if (style->xthickness > 1)
+ gdk_draw_line (window, style->bg_gc[state_type],
+ x + 1, y + 1, x + 1, y + height - 2);
break;
case GTK_SHADOW_ETCHED_IN:
case GTK_SHADOW_ETCHED_OUT:
- thickness_light = 1;
- thickness_dark = 1;
+ if (style->xthickness > 0)
+ {
+ if (style->xthickness > 1)
+ {
+ thickness_light = 1;
+ thickness_dark = 1;
- for (i = 0; i < thickness_dark; i++)
+ for (i = 0; i < thickness_dark; i++)
+ {
+ gdk_draw_line (window, gc1,
+ x + width - i - 1,
+ y + i,
+ x + width - i - 1,
+ y + height - i - 1);
+ gdk_draw_line (window, gc2,
+ x + i,
+ y + i,
+ x + i,
+ y + height - i - 2);
+ }
+
+ for (i = 0; i < thickness_light; i++)
+ {
+ gdk_draw_line (window, gc1,
+ x + thickness_dark + i,
+ y + thickness_dark + i,
+ x + thickness_dark + i,
+ y + height - thickness_dark - i - 1);
+ gdk_draw_line (window, gc2,
+ x + width - thickness_light - i - 1,
+ y + thickness_dark + i,
+ x + width - thickness_light - i - 1,
+ y + height - thickness_light - 1);
+ }
+ }
+ else
+ {
+ gdk_draw_line (window,
+ style->dark_gc[state_type],
+ x, y, x, y + height);
+ gdk_draw_line (window,
+ style->dark_gc[state_type],
+ x + width, y, x + width, y + height);
+ }
+ }
+
+ if (style->ythickness > 0)
{
- gdk_draw_line (window, gc1,
- x + i,
- y + height - i - 1,
- x + width - i - 1,
- y + height - i - 1);
- gdk_draw_line (window, gc1,
- x + width - i - 1,
- y + i,
- x + width - i - 1,
- y + height - i - 1);
+ if (style->ythickness > 1)
+ {
+ thickness_light = 1;
+ thickness_dark = 1;
+
+ for (i = 0; i < thickness_dark; i++)
+ {
+ gdk_draw_line (window, gc1,
+ x + i,
+ y + height - i - 1,
+ x + width - i - 1,
+ y + height - i - 1);
- gdk_draw_line (window, gc2,
- x + i,
- y + i,
- x + width - i - 2,
- y + i);
- gdk_draw_line (window, gc2,
- x + i,
- y + i,
- x + i,
- y + height - i - 2);
- }
+ gdk_draw_line (window, gc2,
+ x + i,
+ y + i,
+ x + width - i - 2,
+ y + i);
+ }
- for (i = 0; i < thickness_light; i++)
- {
- gdk_draw_line (window, gc1,
- x + thickness_dark + i,
- y + thickness_dark + i,
- x + width - thickness_dark - i - 1,
- y + thickness_dark + i);
- gdk_draw_line (window, gc1,
- x + thickness_dark + i,
- y + thickness_dark + i,
- x + thickness_dark + i,
- y + height - thickness_dark - i - 1);
+ for (i = 0; i < thickness_light; i++)
+ {
+ gdk_draw_line (window, gc1,
+ x + thickness_dark + i,
+ y + thickness_dark + i,
+ x + width - thickness_dark - i - 1,
+ y + thickness_dark + i);
- gdk_draw_line (window, gc2,
- x + thickness_dark + i,
- y + height - thickness_light - i - 1,
- x + width - thickness_light - 1,
- y + height - thickness_light - i - 1);
- gdk_draw_line (window, gc2,
- x + width - thickness_light - i - 1,
- y + thickness_dark + i,
- x + width - thickness_light - i - 1,
- y + height - thickness_light - 1);
+ gdk_draw_line (window, gc2,
+ x + thickness_dark + i,
+ y + height - thickness_light - i - 1,
+ x + width - thickness_light - 1,
+ y + height - thickness_light - i - 1);
+ }
+ }
+ else
+ {
+ gdk_draw_line (window,
+ style->dark_gc[state_type],
+ x, y, x + width, y);
+ gdk_draw_line (window,
+ style->dark_gc[state_type],
+ x, y + height, x + width, y + height);
+ }
}
+
break;
}
if (area)
@@ -4157,11 +4242,26 @@ gtk_default_draw_resize_grip (GtkStyle *style,
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
+ gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
}
- /* make it square */
- if (width != height)
- width = height = MIN (width, height);
+ /* make it square, aligning to bottom right */
+ if (width < height)
+ {
+ y += (height - width);
+ height = width;
+ }
+ else if (height < width)
+ {
+ x += (width - height);
+ width = height;
+ }
+
+ /* Clear background */
+ gdk_draw_rectangle (window,
+ style->bg_gc[state_type],
+ TRUE,
+ x, y, width, height);
switch (edge)
{
@@ -4209,6 +4309,7 @@ gtk_default_draw_resize_grip (GtkStyle *style,
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
+ gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
}
}
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 95b3b4b00a..c8299e9ea3 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -76,8 +76,6 @@
*
*/
-#define FOCUS_EDGE_WIDTH 1
-
#define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->text_window)
#define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->text_window)
@@ -2236,7 +2234,7 @@ gtk_text_view_get_property (GObject *object,
case PROP_EDITABLE:
g_value_set_boolean (value, text_view->editable);
break;
-
+
case PROP_WRAP_MODE:
g_value_set_enum (value, text_view->wrap_mode);
break;
@@ -2277,14 +2275,23 @@ gtk_text_view_size_request (GtkWidget *widget,
{
GtkTextView *text_view;
GSList *tmp_list;
-
+ gint focus_edge_width;
+ gboolean interior_focus;
+
text_view = GTK_TEXT_VIEW (widget);
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
+
+ if (interior_focus)
+ focus_edge_width = 0;
+ else
+ focus_edge_width = 1;
+
text_view->text_window->requisition.width = text_view->layout->width;
text_view->text_window->requisition.height = text_view->layout->height;
- requisition->width = text_view->text_window->requisition.width + FOCUS_EDGE_WIDTH * 2;
- requisition->height = text_view->text_window->requisition.height + FOCUS_EDGE_WIDTH * 2;
+ requisition->width = text_view->text_window->requisition.width + focus_edge_width * 2;
+ requisition->height = text_view->text_window->requisition.height + focus_edge_width * 2;
if (text_view->left_window)
requisition->width += text_view->left_window->requisition.width;
@@ -2430,7 +2437,9 @@ gtk_text_view_size_allocate (GtkWidget *widget,
GdkRectangle right_rect;
GdkRectangle top_rect;
GdkRectangle bottom_rect;
-
+ gint focus_edge_width;
+ gboolean interior_focus;
+
text_view = GTK_TEXT_VIEW (widget);
DV(g_print(G_STRLOC"\n"));
@@ -2448,7 +2457,14 @@ gtk_text_view_size_allocate (GtkWidget *widget,
* windows get at least a 1x1 allocation.
*/
- width = allocation->width - FOCUS_EDGE_WIDTH * 2;
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
+
+ if (interior_focus)
+ focus_edge_width = 0;
+ else
+ focus_edge_width = 1;
+
+ width = allocation->width - focus_edge_width * 2;
if (text_view->left_window)
left_rect.width = text_view->left_window->requisition.width;
@@ -2470,7 +2486,7 @@ gtk_text_view_size_allocate (GtkWidget *widget,
bottom_rect.width = text_rect.width;
- height = allocation->height - FOCUS_EDGE_WIDTH * 2;
+ height = allocation->height - focus_edge_width * 2;
if (text_view->top_window)
top_rect.height = text_view->top_window->requisition.height;
@@ -2492,8 +2508,8 @@ gtk_text_view_size_allocate (GtkWidget *widget,
right_rect.height = text_rect.height;
/* Origins */
- left_rect.x = FOCUS_EDGE_WIDTH;
- top_rect.y = FOCUS_EDGE_WIDTH;
+ left_rect.x = focus_edge_width;
+ top_rect.y = focus_edge_width;
text_rect.x = left_rect.x + left_rect.width;
text_rect.y = top_rect.y + top_rect.height;
@@ -3465,10 +3481,15 @@ gtk_text_view_expose_event (GtkWidget *widget, GdkEventExpose *event)
static void
gtk_text_view_draw_focus (GtkWidget *widget)
{
+ gboolean interior_focus;
+
+ /* We clear the focus if we are in interior focus mode. */
+ gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
+
if (GTK_WIDGET_DRAWABLE (widget))
{
- if (GTK_WIDGET_HAS_FOCUS (widget))
- {
+ if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
+ {
gtk_paint_focus (widget->style, widget->window,
NULL, widget, "textview",
0, 0,
@@ -5537,16 +5558,26 @@ buffer_to_widget (GtkTextView *text_view,
gint *window_x,
gint *window_y)
{
+ gint focus_edge_width;
+ gboolean interior_focus;
+
+ gtk_widget_style_get (GTK_WIDGET (text_view), "interior_focus", &interior_focus, NULL);
+
+ if (interior_focus)
+ focus_edge_width = 0;
+ else
+ focus_edge_width = 1;
+
if (window_x)
{
- *window_x = buffer_x - text_view->xoffset + FOCUS_EDGE_WIDTH;
+ *window_x = buffer_x - text_view->xoffset + focus_edge_width;
if (text_view->left_window)
*window_x += text_view->left_window->allocation.width;
}
if (window_y)
{
- *window_y = buffer_y - text_view->yoffset + FOCUS_EDGE_WIDTH;
+ *window_y = buffer_y - text_view->yoffset + focus_edge_width;
if (text_view->top_window)
*window_y += text_view->top_window->allocation.height;
}
@@ -5674,16 +5705,26 @@ widget_to_buffer (GtkTextView *text_view,
gint *buffer_x,
gint *buffer_y)
{
+ gint focus_edge_width;
+ gboolean interior_focus;
+
+ gtk_widget_style_get (GTK_WIDGET (text_view), "interior_focus", &interior_focus, NULL);
+
+ if (interior_focus)
+ focus_edge_width = 0;
+ else
+ focus_edge_width = 1;
+
if (buffer_x)
{
- *buffer_x = widget_x - FOCUS_EDGE_WIDTH + text_view->xoffset;
+ *buffer_x = widget_x - focus_edge_width + text_view->xoffset;
if (text_view->left_window)
*buffer_x -= text_view->left_window->allocation.width;
}
if (buffer_y)
{
- *buffer_y = widget_y - FOCUS_EDGE_WIDTH + text_view->yoffset;
+ *buffer_y = widget_y - focus_edge_width + text_view->yoffset;
if (text_view->top_window)
*buffer_y -= text_view->top_window->allocation.height;
}
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index ed8fb0b3b4..1008c0f0c0 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -35,11 +35,13 @@
#include "gtkstock.h"
#include "gtkiconfactory.h"
#include "gtkimage.h"
+#include "gtksettings.h"
#include "gtkintl.h"
+#define DEFAULT_IPADDING 0
#define DEFAULT_SPACE_SIZE 5
-#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_EMPTY
+#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
@@ -69,6 +71,7 @@ struct _GtkToolbarChildSpace
static void gtk_toolbar_class_init (GtkToolbarClass *class);
static void gtk_toolbar_init (GtkToolbar *toolbar);
+static void gtk_toolbar_finalize (GObject *object);
static void gtk_toolbar_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -88,6 +91,7 @@ static void gtk_toolbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_toolbar_style_set (GtkWidget *widget,
GtkStyle *prev_style);
+static void gtk_toolbar_show_all (GtkWidget *widget);
static void gtk_toolbar_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_toolbar_remove (GtkContainer *container,
@@ -174,6 +178,8 @@ gtk_toolbar_class_init (GtkToolbarClass *class)
container_class = (GtkContainerClass *) class;
parent_class = gtk_type_class (gtk_container_get_type ());
+
+ gobject_class->finalize = gtk_toolbar_finalize;
object_class->destroy = gtk_toolbar_destroy;
gobject_class->set_property = gtk_toolbar_set_property;
@@ -185,6 +191,7 @@ gtk_toolbar_class_init (GtkToolbarClass *class)
widget_class->size_request = gtk_toolbar_size_request;
widget_class->size_allocate = gtk_toolbar_size_allocate;
widget_class->style_set = gtk_toolbar_style_set;
+ widget_class->show_all = gtk_toolbar_show_all;
container_class->add = gtk_toolbar_add;
container_class->remove = gtk_toolbar_remove;
@@ -238,6 +245,16 @@ gtk_toolbar_class_init (GtkToolbarClass *class)
G_MAXINT,
DEFAULT_SPACE_SIZE,
G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("internal_padding",
+ _("Internal padding"),
+ _("Amount of border space between the toolbar shadow and the buttons"),
+ 0,
+ G_MAXINT,
+ DEFAULT_IPADDING,
+ G_PARAM_READABLE));
+
gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("space_style",
_("Space style"),
@@ -252,8 +269,66 @@ gtk_toolbar_class_init (GtkToolbarClass *class)
_("Button relief"),
_("Type of bevel around toolbar buttons"),
GTK_TYPE_RELIEF_STYLE,
- GTK_RELIEF_NORMAL,
+ GTK_RELIEF_NONE,
G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_enum ("shadow_type",
+ _("Shadow type"),
+ _("Style of bevel around the toolbar"),
+ GTK_TYPE_SHADOW_TYPE,
+ GTK_SHADOW_OUT,
+ G_PARAM_READABLE));
+
+ gtk_settings_install_property (gtk_settings_get_global (),
+ g_param_spec_enum ("gtk-toolbar-style",
+ _("Toolbar style"),
+ _("Whether default toolbars have text only, text and icons, icons only, etc."),
+ GTK_TYPE_TOOLBAR_STYLE,
+ GTK_TOOLBAR_BOTH,
+ G_PARAM_READWRITE));
+
+ gtk_settings_install_property (gtk_settings_get_global (),
+ g_param_spec_enum ("gtk-toolbar-icon-size",
+ _("Toolbar icon size"),
+ _("Size of icons in default toolbars"),
+ GTK_TYPE_ICON_SIZE,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ G_PARAM_READWRITE));
+}
+
+static void
+style_change_notify (GObject *object,
+ GParamSpec *pspec,
+ gpointer data)
+{
+ GtkToolbar *toolbar;
+
+ toolbar = GTK_TOOLBAR (data);
+
+ if (!toolbar->style_set)
+ {
+ /* pretend it was set, then unset, thus reverting to new default */
+ toolbar->style_set = TRUE;
+ gtk_toolbar_unset_style (toolbar);
+ }
+}
+
+static void
+icon_size_change_notify (GObject *object,
+ GParamSpec *pspec,
+ gpointer data)
+{
+ GtkToolbar *toolbar;
+
+ toolbar = GTK_TOOLBAR (data);
+
+ if (!toolbar->icon_size_set)
+ {
+ /* pretend it was set, then unset, thus reverting to new default */
+ toolbar->icon_size_set = TRUE;
+ gtk_toolbar_unset_icon_size (toolbar);
+ }
}
static void
@@ -265,11 +340,46 @@ gtk_toolbar_init (GtkToolbar *toolbar)
toolbar->num_children = 0;
toolbar->children = NULL;
toolbar->orientation = GTK_ORIENTATION_HORIZONTAL;
- toolbar->style = GTK_TOOLBAR_ICONS;
toolbar->icon_size = DEFAULT_ICON_SIZE;
toolbar->tooltips = gtk_tooltips_new ();
toolbar->button_maxw = 0;
toolbar->button_maxh = 0;
+
+ toolbar->style_set = FALSE;
+ toolbar->icon_size_set = FALSE;
+ g_object_get (gtk_settings_get_global (),
+ "gtk-toolbar-icon-size",
+ &toolbar->icon_size,
+ "gtk-toolbar-style",
+ &toolbar->style,
+ NULL);
+
+ toolbar->style_set_connection =
+ g_signal_connect_data (G_OBJECT (gtk_settings_get_global ()),
+ "notify::gtk-toolbar-style",
+ G_CALLBACK (style_change_notify),
+ toolbar, NULL, FALSE, FALSE);
+
+ toolbar->icon_size_connection =
+ g_signal_connect_data (G_OBJECT (gtk_settings_get_global ()),
+ "notify::gtk-toolbar-icon-size",
+ G_CALLBACK (icon_size_change_notify),
+ toolbar, NULL, FALSE, FALSE);
+}
+
+static void
+gtk_toolbar_finalize (GObject *object)
+{
+ GtkToolbar *toolbar;
+
+ toolbar = GTK_TOOLBAR (object);
+
+ g_signal_handler_disconnect (G_OBJECT (gtk_settings_get_global ()),
+ toolbar->style_set_connection);
+ g_signal_handler_disconnect (G_OBJECT (gtk_settings_get_global ()),
+ toolbar->icon_size_connection);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
@@ -314,16 +424,12 @@ gtk_toolbar_get_property (GObject *object,
}
GtkWidget*
-gtk_toolbar_new (GtkOrientation orientation,
- GtkToolbarStyle style)
+gtk_toolbar_new (void)
{
GtkToolbar *toolbar;
toolbar = gtk_type_new (gtk_toolbar_get_type ());
- toolbar->orientation = orientation;
- toolbar->style = style;
-
return GTK_WIDGET (toolbar);
}
@@ -462,15 +568,32 @@ gtk_toolbar_expose (GtkWidget *widget,
GtkToolbar *toolbar;
GList *children;
GtkToolbarChild *child;
+ gint border_width;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TOOLBAR (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
+ border_width = GTK_CONTAINER (widget)->border_width;
+
if (GTK_WIDGET_DRAWABLE (widget))
{
+ GtkShadowType shadow_type;
+
toolbar = GTK_TOOLBAR (widget);
+ gtk_widget_style_get (widget, "shadow_type", &shadow_type, NULL);
+
+ gtk_paint_box (widget->style,
+ widget->window,
+ GTK_WIDGET_STATE (widget),
+ shadow_type,
+ &event->area, widget, "toolbar",
+ widget->allocation.x + border_width,
+ widget->allocation.y + border_width,
+ widget->allocation.width - border_width,
+ widget->allocation.height - border_width);
+
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
@@ -502,6 +625,7 @@ gtk_toolbar_size_request (GtkWidget *widget,
gint widget_maxw, widget_maxh;
GtkRequisition child_requisition;
gint space_size;
+ gint ipadding;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (widget));
@@ -579,6 +703,12 @@ gtk_toolbar_size_request (GtkWidget *widget,
requisition->height += nbuttons * button_maxh;
}
+ /* Extra spacing */
+ gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+
+ requisition->width += 2 * (widget->style->xthickness + ipadding);
+ requisition->height += 2 * (widget->style->ythickness + ipadding);
+
toolbar->button_maxw = button_maxw;
toolbar->button_maxh = button_maxh;
}
@@ -593,22 +723,29 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
GtkToolbarChildSpace *child_space;
GtkAllocation alloc;
GtkRequisition child_requisition;
- gint border_width;
+ gint x_border_width, y_border_width;
gint space_size;
-
+ gint ipadding;
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (widget));
g_return_if_fail (allocation != NULL);
toolbar = GTK_TOOLBAR (widget);
widget->allocation = *allocation;
+
+ x_border_width = GTK_CONTAINER (toolbar)->border_width;
+ y_border_width = GTK_CONTAINER (toolbar)->border_width;
- border_width = GTK_CONTAINER (toolbar)->border_width;
-
+ gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+
+ x_border_width += 2 * (widget->style->xthickness + ipadding);
+ y_border_width += 2 * (widget->style->ythickness + ipadding);
+
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- alloc.x = allocation->x + border_width;
+ alloc.x = allocation->x + x_border_width;
else
- alloc.y = allocation->y + border_width;
+ alloc.y = allocation->y + y_border_width;
space_size = get_space_size (toolbar);
@@ -698,6 +835,26 @@ gtk_toolbar_style_set (GtkWidget *widget,
}
static void
+child_show_all (GtkWidget *widget)
+{
+ /* Don't show our own children, since that would
+ * show labels we may intend to hide in icons-only mode
+ */
+ if (!g_object_get_data (G_OBJECT (widget),
+ "gtk-toolbar-is-child"))
+ gtk_widget_show_all (widget);
+}
+
+static void
+gtk_toolbar_show_all (GtkWidget *widget)
+{
+ gtk_container_foreach (GTK_CONTAINER (widget),
+ (GtkCallback) child_show_all,
+ NULL);
+ gtk_widget_show (widget);
+}
+
+static void
gtk_toolbar_add (GtkContainer *container,
GtkWidget *widget)
{
@@ -844,7 +1001,8 @@ gtk_toolbar_insert_item (GtkToolbar *toolbar,
*
* 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.
+ * added. The size you set will override user preferences for the default
+ * icon size.
**/
void
gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
@@ -858,6 +1016,8 @@ gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
g_return_if_fail (toolbar != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
+ toolbar->icon_size_set = TRUE;
+
if (toolbar->icon_size == icon_size)
return;
@@ -886,6 +1046,31 @@ gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
}
/**
+ * gtk_toolbar_unset_icon_size:
+ * @toolbar: a #GtkToolbar
+ *
+ * Unsets toolbar icon size set with gtk_toolbar_set_icon_size(), so that
+ * user preferences will be used to determine the icon size.
+ **/
+void
+gtk_toolbar_unset_icon_size (GtkToolbar *toolbar)
+{
+ GtkIconSize size;
+
+ if (toolbar->icon_size_set)
+ {
+ g_object_get (gtk_settings_get_global (),
+ "gtk-toolbar-icon-size",
+ &size, NULL);
+
+ if (size != toolbar->icon_size)
+ gtk_toolbar_set_icon_size (toolbar, size);
+
+ toolbar->icon_size_set = FALSE;
+ }
+}
+
+/**
* gtk_toolbar_insert_stock:
* @toolbar: A #GtkToolbar
* @stock_id: The id of the stock item you want to insert
@@ -1178,6 +1363,13 @@ gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
gtk_widget_show (child->icon);
}
+ if (type != GTK_TOOLBAR_CHILD_WIDGET)
+ {
+ /* Mark child as ours */
+ g_object_set_data (G_OBJECT (child->widget),
+ "gtk-toolbar-is-child",
+ GINT_TO_POINTER (TRUE));
+ }
gtk_widget_show (child->widget);
break;
@@ -1217,7 +1409,6 @@ void
gtk_toolbar_set_orientation (GtkToolbar *toolbar,
GtkOrientation orientation)
{
- g_return_if_fail (toolbar != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
gtk_signal_emit (GTK_OBJECT (toolbar), toolbar_signals[ORIENTATION_CHANGED], orientation);
@@ -1227,12 +1418,40 @@ void
gtk_toolbar_set_style (GtkToolbar *toolbar,
GtkToolbarStyle style)
{
- g_return_if_fail (toolbar != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
+ toolbar->style_set = TRUE;
gtk_signal_emit (GTK_OBJECT (toolbar), toolbar_signals[STYLE_CHANGED], style);
}
+/**
+ * gtk_toolbar_unset_style:
+ * @toolbar: a #GtkToolbar
+ *
+ * Unsets a toolbar style set with gtk_toolbar_set_style(), so that
+ * user preferences will be used to determine the toolbar style.
+ **/
+void
+gtk_toolbar_unset_style (GtkToolbar *toolbar)
+{
+ GtkToolbarStyle style;
+
+ g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
+
+ if (toolbar->style_set)
+ {
+ g_object_get (gtk_settings_get_global (),
+ "gtk-toolbar-style",
+ &style,
+ NULL);
+
+ if (style != toolbar->style)
+ gtk_signal_emit (GTK_OBJECT (toolbar), toolbar_signals[STYLE_CHANGED], style);
+
+ toolbar->style_set = FALSE;
+ }
+}
+
void
gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
gboolean enable)
@@ -1290,7 +1509,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));
diff --git a/gtk/gtktoolbar.h b/gtk/gtktoolbar.h
index 19ed1b90c4..79d3d79dbc 100644
--- a/gtk/gtktoolbar.h
+++ b/gtk/gtktoolbar.h
@@ -91,6 +91,12 @@ struct _GtkToolbar
gint button_maxw;
gint button_maxh;
+
+ guint style_set_connection;
+ guint icon_size_connection;
+
+ guint style_set : 1;
+ guint icon_size_set : 1;
};
struct _GtkToolbarClass
@@ -105,8 +111,7 @@ struct _GtkToolbarClass
GtkType gtk_toolbar_get_type (void) G_GNUC_CONST;
-GtkWidget* gtk_toolbar_new (GtkOrientation orientation,
- GtkToolbarStyle style);
+GtkWidget* gtk_toolbar_new (void);
/* Simple button items */
GtkWidget* gtk_toolbar_append_item (GtkToolbar *toolbar,
@@ -133,8 +138,6 @@ GtkWidget* gtk_toolbar_insert_item (GtkToolbar *toolbar,
gint position);
/* Stock Items */
-void gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
- GtkIconSize icon_size);
GtkWidget* gtk_toolbar_insert_stock (GtkToolbar *toolbar,
const gchar *stock_id,
const char *tooltip_text,
@@ -203,8 +206,12 @@ void gtk_toolbar_set_orientation (GtkToolbar *toolbar,
GtkOrientation orientation);
void gtk_toolbar_set_style (GtkToolbar *toolbar,
GtkToolbarStyle style);
+void gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
+ GtkIconSize icon_size);
void gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
gboolean enable);
+void gtk_toolbar_unset_style (GtkToolbar *toolbar);
+void gtk_toolbar_unset_icon_size (GtkToolbar *toolbar);
#ifdef __cplusplus
}