[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/gtkutil.c
From: |
Jan Djärv |
Subject: |
[Emacs-diffs] Changes to emacs/src/gtkutil.c |
Date: |
Sun, 02 Nov 2003 11:47:32 -0500 |
Index: emacs/src/gtkutil.c
diff -c emacs/src/gtkutil.c:1.34 emacs/src/gtkutil.c:1.35
*** emacs/src/gtkutil.c:1.34 Mon Sep 1 11:45:52 2003
--- emacs/src/gtkutil.c Sun Nov 2 11:47:32 2003
***************
*** 1333,1359 ****
return 0;
}
! GtkWidget *xg_did_tearoff;
/* Callback invoked when a detached menu window is removed. Here we
! delete the popup menu.
WIDGET is the top level window that is removed (the parent of the menu).
! EVENT is the event that triggers the window removal.
! CLIENT_DATA points to the menu that is detached.
!
! Returns TRUE to tell GTK to stop processing this event. */
! static gboolean
! tearoff_remove (widget, event, client_data)
GtkWidget *widget;
- GdkEvent *event;
gpointer client_data;
{
! gtk_widget_destroy (GTK_WIDGET (client_data));
! return TRUE;
}
! /* Callback invoked when a menu is detached. It sets the xg_did_tearoff
! variable.
WIDGET is the GtkTearoffMenuItem.
CLIENT_DATA is not used. */
static void
--- 1333,1361 ----
return 0;
}
! static int xg_detached_menus;
!
! /* Returns non-zero if there are detached menus. */
! int
! xg_have_tear_offs ()
! {
! return xg_detached_menus > 0;
! }
/* Callback invoked when a detached menu window is removed. Here we
! decrease the xg_detached_menus count.
WIDGET is the top level window that is removed (the parent of the menu).
! CLIENT_DATA is not used. */
! static void
! tearoff_remove (widget, client_data)
GtkWidget *widget;
gpointer client_data;
{
! if (xg_detached_menus > 0) --xg_detached_menus;
}
! /* Callback invoked when a menu is detached. It increases the
! xg_detached_menus count.
WIDGET is the GtkTearoffMenuItem.
CLIENT_DATA is not used. */
static void
***************
*** 1362,1392 ****
gpointer client_data;
{
GtkWidget *menu = gtk_widget_get_parent (widget);
! if (! gtk_menu_get_tearoff_state (GTK_MENU (menu)))
! return;
!
! xg_did_tearoff = menu;
}
- /* If a detach of a popup menu is done, this function should be called
- to keep the menu around until the detached window is removed.
- MENU is the top level menu for the popup,
- SUBMENU is the menu that got detached (that is MENU or a
- submenu of MENU), see the xg_did_tearoff variable. */
- void
- xg_keep_popup (menu, submenu)
- GtkWidget *menu;
- GtkWidget *submenu;
- {
- GtkWidget *p;
-
- /* Find the top widget for the detached menu. */
- p = gtk_widget_get_toplevel (submenu);
-
- /* Delay destroying the menu until the detached menu is removed. */
- g_signal_connect (G_OBJECT (p), "unmap_event",
- G_CALLBACK (tearoff_remove), menu);
- }
/* Create a menu item widget, and connect the callbacks.
ITEM decribes the menu item.
--- 1364,1378 ----
gpointer client_data;
{
GtkWidget *menu = gtk_widget_get_parent (widget);
! if (gtk_menu_get_tearoff_state (GTK_MENU (menu)))
! {
! ++xg_detached_menus;
! g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (widget)),
! "destroy",
! G_CALLBACK (tearoff_remove), 0);
! }
}
/* Create a menu item widget, and connect the callbacks.
ITEM decribes the menu item.
***************
*** 1585,1591 ****
highlight_cb,
0,
0,
! 1,
0,
cl_data,
0);
--- 1571,1577 ----
highlight_cb,
0,
0,
! add_tearoff_p,
0,
cl_data,
0);
***************
*** 1626,1631 ****
--- 1612,1620 ----
GCallback highlight_cb;
{
GtkWidget *w = 0;
+ int menu_bar_p = strcmp (type, "menubar") == 0;
+ int pop_up_p = strcmp (type, "popup") == 0;
+
if (strcmp (type, "dialog") == 0)
{
w = create_dialog (val, select_cb, deactivate_cb);
***************
*** 1636,1658 ****
if (w)
gtk_widget_set_name (w, "emacs-dialog");
}
! else if (strcmp (type, "menubar") == 0 || strcmp (type, "popup") == 0)
{
w = create_menus (val->contents,
f,
select_cb,
deactivate_cb,
highlight_cb,
! strcmp (type, "popup") == 0,
! strcmp (type, "menubar") == 0,
! 1,
0,
0,
name);
/* Set the cursor to an arrow for popup menus when they are mapped.
This is done by default for menu bar menus. */
! if (strcmp (type, "popup") == 0)
{
/* Must realize so the GdkWindow inside the widget is created. */
gtk_widget_realize (w);
--- 1625,1647 ----
if (w)
gtk_widget_set_name (w, "emacs-dialog");
}
! else if (menu_bar_p || pop_up_p)
{
w = create_menus (val->contents,
f,
select_cb,
deactivate_cb,
highlight_cb,
! pop_up_p,
! menu_bar_p,
! menu_bar_p,
0,
0,
name);
/* Set the cursor to an arrow for popup menus when they are mapped.
This is done by default for menu bar menus. */
! if (pop_up_p)
{
/* Must realize so the GdkWindow inside the widget is created. */
gtk_widget_realize (w);
***************
*** 1834,1842 ****
--- 1823,1838 ----
is up to date when leaving the minibuffer. */
GtkLabel *wlabel = GTK_LABEL (gtk_bin_get_child (GTK_BIN (witem)));
char *utf8_label = get_utf8_string (val->name);
+ GtkWidget *submenu = gtk_menu_item_get_submenu (witem);
gtk_label_set_text (wlabel, utf8_label);
+ /* If this item has a submenu that has been detached, change
+ the title in the WM decorations also. */
+ if (submenu && gtk_menu_get_tearoff_state (GTK_MENU (submenu)))
+ /* Set the title of the detached window. */
+ gtk_menu_set_title (GTK_MENU (submenu), utf8_label);
+
iter = g_list_next (iter);
val = val->next;
++pos;
***************
*** 2222,2239 ****
cl_data = (xg_menu_cb_data*) g_object_get_data (G_OBJECT (menubar),
XG_FRAME_DATA);
! if (! deep_p)
! {
! widget_value *cur = val->contents;
! xg_update_menubar (menubar, f, &list, list, 0, cur,
! select_cb, highlight_cb, cl_data);
! }
! else
{
widget_value *cur;
/* Update all sub menus.
! We must keep the submenu names (GTK menu item widgets) since the
X Window in the XEvent that activates the menu are those widgets. */
/* Update cl_data, menu_item things in F may have changed. */
--- 2218,2232 ----
cl_data = (xg_menu_cb_data*) g_object_get_data (G_OBJECT (menubar),
XG_FRAME_DATA);
! xg_update_menubar (menubar, f, &list, list, 0, val->contents,
! select_cb, highlight_cb, cl_data);
!
! if (deep_p);
{
widget_value *cur;
/* Update all sub menus.
! We must keep the submenus (GTK menu item widgets) since the
X Window in the XEvent that activates the menu are those widgets. */
/* Update cl_data, menu_item things in F may have changed. */
***************
*** 2269,2275 ****
newly created sub menu under witem. */
if (newsub != sub)
gtk_menu_item_set_submenu (witem, newsub);
-
}
}
--- 2262,2267 ----
***************
*** 3250,3257 ****
{
xg_ignore_gtk_scrollbar = 0;
xg_left_ptr_cursor = 0;
! xg_did_tearoff = 0;
!
xg_menu_cb_list.prev = xg_menu_cb_list.next =
xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0;
--- 3242,3248 ----
{
xg_ignore_gtk_scrollbar = 0;
xg_left_ptr_cursor = 0;
! xg_detached_menus = 0;
xg_menu_cb_list.prev = xg_menu_cb_list.next =
xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0;
- [Emacs-diffs] Changes to emacs/src/gtkutil.c,
Jan Djärv <=