Make the tearoff functionality model/view, the tearoffmenuitem being the
Fri May 7 00:41:46 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtktearoffmenuitem.h: * gtk/gtktearoffmenuitem.c: Make the tearoff functionality model/view, the tearoffmenuitem being the view and the tearoff_state property of the menu being the model. (#101185, Owen Taylor) * gtk/gtkmenu.c: Add a tearoff_state property.
This commit is contained in:
parent
0a41106ac2
commit
30a4c82a3d
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
Fri May 7 00:41:46 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtktearoffmenuitem.h:
|
||||
* gtk/gtktearoffmenuitem.c: Make the tearoff
|
||||
functionality model/view, the tearoffmenuitem being
|
||||
the view and the tearoff_state property of the menu
|
||||
being the model. (#101185, Owen Taylor)
|
||||
|
||||
* gtk/gtkmenu.c: Add a tearoff_state property.
|
||||
|
||||
Thu May 6 23:52:13 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Merge from 2.4:
|
||||
|
@ -1,3 +1,13 @@
|
||||
Fri May 7 00:41:46 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtktearoffmenuitem.h:
|
||||
* gtk/gtktearoffmenuitem.c: Make the tearoff
|
||||
functionality model/view, the tearoffmenuitem being
|
||||
the view and the tearoff_state property of the menu
|
||||
being the model. (#101185, Owen Taylor)
|
||||
|
||||
* gtk/gtkmenu.c: Add a tearoff_state property.
|
||||
|
||||
Thu May 6 23:52:13 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Merge from 2.4:
|
||||
|
@ -1,3 +1,13 @@
|
||||
Fri May 7 00:41:46 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtktearoffmenuitem.h:
|
||||
* gtk/gtktearoffmenuitem.c: Make the tearoff
|
||||
functionality model/view, the tearoffmenuitem being
|
||||
the view and the tearoff_state property of the menu
|
||||
being the model. (#101185, Owen Taylor)
|
||||
|
||||
* gtk/gtkmenu.c: Add a tearoff_state property.
|
||||
|
||||
Thu May 6 23:52:13 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Merge from 2.4:
|
||||
|
@ -1,3 +1,13 @@
|
||||
Fri May 7 00:41:46 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtktearoffmenuitem.h:
|
||||
* gtk/gtktearoffmenuitem.c: Make the tearoff
|
||||
functionality model/view, the tearoffmenuitem being
|
||||
the view and the tearoff_state property of the menu
|
||||
being the model. (#101185, Owen Taylor)
|
||||
|
||||
* gtk/gtkmenu.c: Add a tearoff_state property.
|
||||
|
||||
Thu May 6 23:52:13 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Merge from 2.4:
|
||||
|
@ -110,6 +110,7 @@ enum {
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_TEAROFF_STATE,
|
||||
PROP_TEAROFF_TITLE
|
||||
};
|
||||
|
||||
@ -519,7 +520,22 @@ gtk_menu_class_init (GtkMenuClass *class)
|
||||
P_("Tearoff Title"),
|
||||
P_("A title that may be displayed by the window manager when this menu is torn-off"),
|
||||
"",
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkMenu:tearoff-state:
|
||||
*
|
||||
* A boolean that indicates whether the menu is torn-off.
|
||||
*
|
||||
* Since: 2.6
|
||||
**/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_TEAROFF_STATE,
|
||||
g_param_spec_boolean ("tearoff-state",
|
||||
P_("Tearoff State"),
|
||||
P_("A boolean that indicates whether the menu is torn-off"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("vertical-padding",
|
||||
@ -700,6 +716,9 @@ gtk_menu_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEAROFF_STATE:
|
||||
gtk_menu_set_tearoff_state (menu, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_TEAROFF_TITLE:
|
||||
gtk_menu_set_title (menu, g_value_get_string (value));
|
||||
break;
|
||||
@ -721,6 +740,9 @@ gtk_menu_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEAROFF_STATE:
|
||||
g_value_set_boolean (value, gtk_menu_get_tearoff_state (menu));
|
||||
break;
|
||||
case PROP_TEAROFF_TITLE:
|
||||
g_value_set_string (value, gtk_menu_get_title (menu));
|
||||
break;
|
||||
@ -1840,6 +1862,8 @@ gtk_menu_set_tearoff_state (GtkMenu *menu,
|
||||
menu->tearoff_scrollbar = NULL;
|
||||
menu->tearoff_adjustment = NULL;
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (menu), "tearoff_state");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,6 @@ gtk_tearoff_menu_item_class_init (GtkTearoffMenuItemClass *klass)
|
||||
static void
|
||||
gtk_tearoff_menu_item_init (GtkTearoffMenuItem *tearoff_menu_item)
|
||||
{
|
||||
tearoff_menu_item->torn_off = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -104,7 +103,7 @@ gtk_tearoff_menu_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
GtkTearoffMenuItem *tearoff;
|
||||
|
||||
|
||||
tearoff = GTK_TEAROFF_MENU_ITEM (widget);
|
||||
|
||||
requisition->width = (GTK_CONTAINER (widget)->border_width +
|
||||
@ -113,7 +112,7 @@ gtk_tearoff_menu_item_size_request (GtkWidget *widget,
|
||||
requisition->height = (GTK_CONTAINER (widget)->border_width +
|
||||
widget->style->ythickness) * 2;
|
||||
|
||||
if (tearoff->torn_off)
|
||||
if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off)
|
||||
{
|
||||
requisition->height += ARROW_SIZE;
|
||||
}
|
||||
@ -166,7 +165,7 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget,
|
||||
else
|
||||
gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
|
||||
|
||||
if (tearoff_item->torn_off)
|
||||
if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off)
|
||||
{
|
||||
gint arrow_x;
|
||||
|
||||
@ -239,36 +238,19 @@ gtk_tearoff_menu_item_expose (GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_tearoff_menu_item_delete_cb (GtkMenuItem *menu_item, GdkEventAny *event)
|
||||
{
|
||||
gtk_tearoff_menu_item_activate (menu_item);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item)
|
||||
{
|
||||
GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (menu_item);
|
||||
|
||||
tearoff_menu_item->torn_off = !tearoff_menu_item->torn_off;
|
||||
gtk_widget_queue_resize (GTK_WIDGET (menu_item));
|
||||
|
||||
if (GTK_IS_MENU (GTK_WIDGET (menu_item)->parent))
|
||||
{
|
||||
GtkMenu *menu = GTK_MENU (GTK_WIDGET (menu_item)->parent);
|
||||
gboolean need_connect;
|
||||
|
||||
need_connect = (tearoff_menu_item->torn_off && !menu->tearoff_window);
|
||||
|
||||
gtk_menu_set_tearoff_state (GTK_MENU (GTK_WIDGET (menu_item)->parent),
|
||||
tearoff_menu_item->torn_off);
|
||||
|
||||
if (need_connect)
|
||||
g_signal_connect_swapped (menu->tearoff_window,
|
||||
"delete_event",
|
||||
G_CALLBACK (gtk_tearoff_menu_item_delete_cb),
|
||||
menu_item);
|
||||
gtk_menu_set_tearoff_state (GTK_MENU (GTK_WIDGET (menu_item)->parent),
|
||||
!menu->torn_off);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (menu_item));
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ struct _GtkTearoffMenuItem
|
||||
{
|
||||
GtkMenuItem menu_item;
|
||||
|
||||
guint torn_off : 1;
|
||||
guint _gtk_reserved : 1;
|
||||
};
|
||||
|
||||
struct _GtkTearoffMenuItemClass
|
||||
|
Loading…
Reference in New Issue
Block a user