Re: visibility problems
- From: Matthias Clasen <maclas gmx de>
- To: gtk-devel-list gnome org
- Subject: Re: visibility problems
- Date: 20 Sep 2003 01:15:31 +0200
Am Fre, 2003-09-19 um 23.50 schrieb Owen Taylor:
> > There are only 6 show_all implementations in gtk+ currently, so we can
> > certainly update all those. Or are you concerned about third-party
> > widgets ?
>
> It was a concern, though not a big one ... if you have a use case for
> GtkToolbar as well, then gtk_widget_set_no_show_all() sounds good.
>
Here is an implementation. While doing this I noticed that we have a
custom show_all implementation for GtkColorSelection, but no matching
hide_all. Should I add
static void
gtk_color_selection_hide_all (GtkWidget *widget)
{
gtk_widget_hide (widget);
}
?
Matthias
Index: gtkaction.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkaction.c,v
retrieving revision 1.10
diff -u -p -r1.10 gtkaction.c
--- gtkaction.c 18 Sep 2003 19:04:42 -0000 1.10
+++ gtkaction.c 19 Sep 2003 23:08:03 -0000
@@ -568,6 +568,7 @@ connect_proxy (GtkAction *action,
gtk_widget_show (proxy);
else
gtk_widget_hide (proxy);
+ gtk_widget_set_no_show_all (proxy, TRUE);
if (GTK_IS_MENU_ITEM (proxy))
{
Index: gtkuimanager.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkuimanager.c,v
retrieving revision 1.23
diff -u -p -r1.23 gtkuimanager.c
--- gtkuimanager.c 17 Sep 2003 23:58:25 -0000 1.23
+++ gtkuimanager.c 19 Sep 2003 23:08:05 -0000
@@ -1826,6 +1826,7 @@ update_node (GtkUIManager *self,
info->proxy = gtk_action_create_menu_item (action);
menu = gtk_menu_new ();
tearoff = gtk_tearoff_menu_item_new ();
+ gtk_widget_set_no_show_all (tearoff, TRUE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy), menu);
gtk_menu_shell_insert (GTK_MENU_SHELL (menushell), info->proxy, pos);
@@ -2036,6 +2037,7 @@ update_node (GtkUIManager *self,
GtkToolItem *item = gtk_separator_tool_item_new ();
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
info->proxy = GTK_WIDGET (item);
+ gtk_widget_set_no_show_all (info->proxy, TRUE);
g_object_set_data (G_OBJECT (info->proxy),
"gtk-separator-mode",
GINT_TO_POINTER (SEPARATOR_MODE_SMART));
@@ -2057,6 +2059,7 @@ update_node (GtkUIManager *self,
if (find_menu_position (node, &menushell, &pos))
{
info->proxy = gtk_separator_menu_item_new ();
+ gtk_widget_set_no_show_all (info->proxy, TRUE);
g_object_set_data (G_OBJECT (info->proxy),
"gtk-separator-mode",
GINT_TO_POINTER (SEPARATOR_MODE_SMART));
Index: gtkwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.358
diff -u -p -r1.358 gtkwidget.c
--- gtkwidget.c 7 Aug 2003 21:03:18 -0000 1.358
+++ gtkwidget.c 19 Sep 2003 23:08:07 -0000
@@ -138,7 +138,8 @@ enum {
PROP_COMPOSITE_CHILD,
PROP_STYLE,
PROP_EVENTS,
- PROP_EXTENSION_EVENTS
+ PROP_EXTENSION_EVENTS,
+ PROP_NO_SHOW_ALL
};
typedef struct _GtkStateData GtkStateData;
@@ -521,6 +522,13 @@ gtk_widget_class_init (GtkWidgetClass *k
GDK_TYPE_EXTENSION_MODE,
GDK_EXTENSION_EVENTS_NONE,
G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_NO_SHOW_ALL,
+ g_param_spec_boolean ("no_show_all",
+ _("No show all"),
+ _("Whether gtk_widget_show_all() should not affect this widget"),
+ FALSE,
+ G_PARAM_READWRITE));
widget_signals[SHOW] =
g_signal_new ("show",
G_TYPE_FROM_CLASS (gobject_class),
@@ -1453,6 +1461,9 @@ gtk_widget_set_property (GObject
case PROP_EXTENSION_EVENTS:
gtk_widget_set_extension_events (widget, g_value_get_enum (value));
break;
+ case PROP_NO_SHOW_ALL:
+ gtk_widget_set_no_show_all (widget, g_value_get_boolean (value));
+ break;
default:
break;
}
@@ -1544,6 +1555,9 @@ gtk_widget_get_property (GObject
else
g_value_set_enum (value, (GdkExtensionMode) *modep);
break;
+ case PROP_NO_SHOW_ALL:
+ g_value_set_boolean (value, gtk_widget_get_no_show_all (widget));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2052,6 +2066,9 @@ gtk_widget_show_all (GtkWidget *widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
+ if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)
+ return;
+
class = GTK_WIDGET_GET_CLASS (widget);
if (class->show_all)
@@ -2071,6 +2088,9 @@ gtk_widget_hide_all (GtkWidget *widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
+ if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)
+ return;
+
class = GTK_WIDGET_GET_CLASS (widget);
if (class->hide_all)
@@ -7209,4 +7229,56 @@ gtk_widget_get_clipboard (GtkWidget *wid
return gtk_clipboard_get_for_display (gtk_widget_get_display (widget),
selection);
+}
+
+/**
+ * gtk_widget_get_no_show_all:
+ * @widget: a #GtkWidget
+ *
+ * Returns the current value of the "no_show_all" property, which determines
+ * whether calls to gtk_widget_show_all() and gtk_widget_hide_all()
+ * will affect this widget.
+ *
+ * Return value: the current value of the "no_show_all" property.
+ *
+ * Since: 2.4
+ **/
+gboolean
+gtk_widget_get_no_show_all (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0;
+}
+
+/**
+ * gtk_widget_set_no_show_all:
+ * @widget: a #GtkWidget
+ * @no_show_all: the new value for the "no_show_all" property
+ *
+ * Sets the "no_show_all" property, which determines whether calls to
+ * gtk_widget_show_all() and gtk_widget_hide_all() will affect this widget.
+ *
+ * This is mostly for use in constructing widget hierarchies with externally
+ * controlled visibility, see #GtkUIManager.
+ *
+ * Since: 2.4
+ **/
+void
+gtk_widget_set_no_show_all (GtkWidget *widget,
+ gboolean no_show_all)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ no_show_all = (no_show_all != FALSE);
+
+ if (no_show_all == ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0))
+ return;
+
+ if (no_show_all)
+ GTK_WIDGET_SET_FLAGS (widget, GTK_NO_SHOW_ALL);
+ else
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_SHOW_ALL);
+
+ g_object_notify (G_OBJECT (widget), "no_show_all");
}
Index: gtkwidget.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.h,v
retrieving revision 1.144
diff -u -p -r1.144 gtkwidget.h
--- gtkwidget.h 11 Aug 2003 15:18:27 -0000 1.144
+++ gtkwidget.h 19 Sep 2003 23:08:08 -0000
@@ -76,7 +76,8 @@ typedef enum
*/
GTK_RECEIVES_DEFAULT = 1 << 20,
- GTK_DOUBLE_BUFFERED = 1 << 21
+ GTK_DOUBLE_BUFFERED = 1 << 21,
+ GTK_NO_SHOW_ALL = 1 << 22
} GtkWidgetFlags;
/* Kinds of widget-specific help */
@@ -449,6 +450,9 @@ void gtk_widget_show_now
void gtk_widget_hide (GtkWidget *widget);
void gtk_widget_show_all (GtkWidget *widget);
void gtk_widget_hide_all (GtkWidget *widget);
+void gtk_widget_set_no_show_all (GtkWidget *widget,
+ gboolean no_show_all);
+gboolean gtk_widget_get_no_show_all (GtkWidget *widget);
void gtk_widget_map (GtkWidget *widget);
void gtk_widget_unmap (GtkWidget *widget);
void gtk_widget_realize (GtkWidget *widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]