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:
Havoc Pennington 2003-10-30 21:11:11 +00:00 committed by Havoc Pennington
parent 18b38ac526
commit 830a52ee25
2 changed files with 61 additions and 54 deletions

View File

@ -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

View File

@ -232,6 +232,9 @@ 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;
@ -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); meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES,
i + 1,
&key, &mods);
screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window); name = get_workspace_name_with_accel (display, xroot, i);
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen)); if (ops & META_MENU_OP_UNSTICK)
label = g_strdup_printf (_("Only on %s"), name);
else
label = g_strdup_printf(_("Move to %s"), name);
mi = menu_item_new (label, FALSE, key, mods);
i = 0; g_free (name);
while (i < n_workspaces) g_free (label);
{
char *label, *name;
MenuData *md;
unsigned int key;
MetaVirtualModifier mods;
meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES, if (!(ops & META_MENU_OP_UNSTICK) &&
i + 1, (active_workspace == i ||
&key, &mods); insensitive & META_MENU_OP_WORKSPACES))
gtk_widget_set_sensitive (mi, FALSE);
else if (insensitive & META_MENU_OP_WORKSPACES)
gtk_widget_set_sensitive (mi, FALSE);
md = g_new (MenuData, 1);
name = get_workspace_name_with_accel (display, xroot, i); md->menu = menu;
if (ops & META_MENU_OP_UNSTICK) md->op = META_MENU_OP_WORKSPACES;
label = g_strdup_printf (_("Only on %s"), name);
else
label = g_strdup_printf(_("Move to %s"), name);
mi = menu_item_new (label, FALSE, key, mods);
g_free (name); g_object_set_data (G_OBJECT (mi),
g_free (label); "workspace",
GINT_TO_POINTER (i));
if (!(ops & META_MENU_OP_UNSTICK) && gtk_signal_connect_full (GTK_OBJECT (mi),
(active_workspace == i || "activate",
insensitive & META_MENU_OP_WORKSPACES)) GTK_SIGNAL_FUNC (activate_cb),
gtk_widget_set_sensitive (mi, FALSE); NULL,
else if (insensitive & META_MENU_OP_WORKSPACES) md,
gtk_widget_set_sensitive (mi, FALSE); g_free, FALSE, FALSE);
md = g_new (MenuData, 1);
md->menu = menu; gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu),
md->op = META_MENU_OP_WORKSPACES; mi);
g_object_set_data (G_OBJECT (mi), gtk_widget_show (mi);
"workspace",
GINT_TO_POINTER (i));
gtk_signal_connect_full (GTK_OBJECT (mi), ++i;
"activate",
GTK_SIGNAL_FUNC (activate_cb),
NULL,
md,
g_free, FALSE, FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu),
mi);
gtk_widget_show (mi);
++i;
}
} }
} }
else else