mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
patch to avoid creating stick/unstick menu items when only one workspace,
2003-10-30 Havoc Pennington <hp@redhat.com> * src/menu.c (meta_window_menu_new): patch to avoid creating stick/unstick menu items when only one workspace, bug #116563 from Michael Terry
This commit is contained in:
parent
18b38ac526
commit
830a52ee25
@ -1,3 +1,9 @@
|
|||||||
|
2003-10-30 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* src/menu.c (meta_window_menu_new): patch to avoid creating
|
||||||
|
stick/unstick menu items when only one workspace, bug #116563
|
||||||
|
from Michael Terry
|
||||||
|
|
||||||
2003-10-25 Havoc Pennington <hp@redhat.com>
|
2003-10-25 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* src/window.c (meta_window_notify_focus): if a window is focused
|
* src/window.c (meta_window_notify_focus): if a window is focused
|
||||||
|
109
src/menu.c
109
src/menu.c
@ -232,13 +232,16 @@ meta_window_menu_new (MetaFrames *frames,
|
|||||||
int i;
|
int i;
|
||||||
MetaWindowMenu *menu;
|
MetaWindowMenu *menu;
|
||||||
|
|
||||||
|
if (n_workspaces < 2)
|
||||||
|
ops &= ~(META_MENU_OP_STICK | META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES);
|
||||||
|
|
||||||
menu = g_new (MetaWindowMenu, 1);
|
menu = g_new (MetaWindowMenu, 1);
|
||||||
menu->frames = frames;
|
menu->frames = frames;
|
||||||
menu->client_xwindow = client_xwindow;
|
menu->client_xwindow = client_xwindow;
|
||||||
menu->func = func;
|
menu->func = func;
|
||||||
menu->data = data;
|
menu->data = data;
|
||||||
menu->ops = ops;
|
menu->ops = ops;
|
||||||
menu->insensitive = insensitive;
|
menu->insensitive = insensitive;
|
||||||
|
|
||||||
menu->menu = gtk_menu_new ();
|
menu->menu = gtk_menu_new ();
|
||||||
|
|
||||||
@ -313,72 +316,70 @@ meta_window_menu_new (MetaFrames *frames,
|
|||||||
|
|
||||||
if (ops & META_MENU_OP_WORKSPACES)
|
if (ops & META_MENU_OP_WORKSPACES)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
GtkWidget *mi;
|
||||||
|
Display *display;
|
||||||
|
Window xroot;
|
||||||
|
GdkScreen *screen;
|
||||||
|
|
||||||
meta_verbose ("Creating %d-workspace menu current space %d\n",
|
meta_verbose ("Creating %d-workspace menu current space %d\n",
|
||||||
n_workspaces, active_workspace);
|
n_workspaces, active_workspace);
|
||||||
|
|
||||||
if (n_workspaces > 1)
|
display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window);
|
||||||
|
|
||||||
|
screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window);
|
||||||
|
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (i < n_workspaces)
|
||||||
{
|
{
|
||||||
GtkWidget *mi;
|
char *label, *name;
|
||||||
Display *display;
|
MenuData *md;
|
||||||
Window xroot;
|
unsigned int key;
|
||||||
GdkScreen *screen;
|
MetaVirtualModifier mods;
|
||||||
|
|
||||||
display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window);
|
|
||||||
|
|
||||||
screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window);
|
|
||||||
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (i < n_workspaces)
|
|
||||||
{
|
|
||||||
char *label, *name;
|
|
||||||
MenuData *md;
|
|
||||||
unsigned int key;
|
|
||||||
MetaVirtualModifier mods;
|
|
||||||
|
|
||||||
meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES,
|
meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES,
|
||||||
i + 1,
|
i + 1,
|
||||||
&key, &mods);
|
&key, &mods);
|
||||||
|
|
||||||
name = get_workspace_name_with_accel (display, xroot, i);
|
name = get_workspace_name_with_accel (display, xroot, i);
|
||||||
if (ops & META_MENU_OP_UNSTICK)
|
if (ops & META_MENU_OP_UNSTICK)
|
||||||
label = g_strdup_printf (_("Only on %s"), name);
|
label = g_strdup_printf (_("Only on %s"), name);
|
||||||
else
|
else
|
||||||
label = g_strdup_printf(_("Move to %s"), name);
|
label = g_strdup_printf(_("Move to %s"), name);
|
||||||
mi = menu_item_new (label, FALSE, key, mods);
|
mi = menu_item_new (label, FALSE, key, mods);
|
||||||
|
|
||||||
g_free (name);
|
g_free (name);
|
||||||
g_free (label);
|
g_free (label);
|
||||||
|
|
||||||
if (!(ops & META_MENU_OP_UNSTICK) &&
|
if (!(ops & META_MENU_OP_UNSTICK) &&
|
||||||
(active_workspace == i ||
|
(active_workspace == i ||
|
||||||
insensitive & META_MENU_OP_WORKSPACES))
|
insensitive & META_MENU_OP_WORKSPACES))
|
||||||
gtk_widget_set_sensitive (mi, FALSE);
|
gtk_widget_set_sensitive (mi, FALSE);
|
||||||
else if (insensitive & META_MENU_OP_WORKSPACES)
|
else if (insensitive & META_MENU_OP_WORKSPACES)
|
||||||
gtk_widget_set_sensitive (mi, FALSE);
|
gtk_widget_set_sensitive (mi, FALSE);
|
||||||
md = g_new (MenuData, 1);
|
md = g_new (MenuData, 1);
|
||||||
|
|
||||||
md->menu = menu;
|
md->menu = menu;
|
||||||
md->op = META_MENU_OP_WORKSPACES;
|
md->op = META_MENU_OP_WORKSPACES;
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (mi),
|
g_object_set_data (G_OBJECT (mi),
|
||||||
"workspace",
|
"workspace",
|
||||||
GINT_TO_POINTER (i));
|
GINT_TO_POINTER (i));
|
||||||
|
|
||||||
gtk_signal_connect_full (GTK_OBJECT (mi),
|
gtk_signal_connect_full (GTK_OBJECT (mi),
|
||||||
"activate",
|
"activate",
|
||||||
GTK_SIGNAL_FUNC (activate_cb),
|
GTK_SIGNAL_FUNC (activate_cb),
|
||||||
NULL,
|
NULL,
|
||||||
md,
|
md,
|
||||||
g_free, FALSE, FALSE);
|
g_free, FALSE, FALSE);
|
||||||
|
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu),
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu),
|
||||||
mi);
|
mi);
|
||||||
|
|
||||||
gtk_widget_show (mi);
|
gtk_widget_show (mi);
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user