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>
* 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;
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->frames = frames;
menu->client_xwindow = client_xwindow;
@ -313,72 +316,70 @@ meta_window_menu_new (MetaFrames *frames,
if (ops & META_MENU_OP_WORKSPACES)
{
GtkWidget *mi;
Display *display;
Window xroot;
GdkScreen *screen;
meta_verbose ("Creating %d-workspace menu current space %d\n",
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;
Display *display;
Window xroot;
GdkScreen *screen;
char *label, *name;
MenuData *md;
unsigned int key;
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);
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
name = get_workspace_name_with_accel (display, xroot, i);
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;
while (i < n_workspaces)
{
char *label, *name;
MenuData *md;
unsigned int key;
MetaVirtualModifier mods;
g_free (name);
g_free (label);
meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES,
i + 1,
&key, &mods);
if (!(ops & META_MENU_OP_UNSTICK) &&
(active_workspace == i ||
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);
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);
md->menu = menu;
md->op = META_MENU_OP_WORKSPACES;
g_free (name);
g_free (label);
g_object_set_data (G_OBJECT (mi),
"workspace",
GINT_TO_POINTER (i));
if (!(ops & META_MENU_OP_UNSTICK) &&
(active_workspace == i ||
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);
gtk_signal_connect_full (GTK_OBJECT (mi),
"activate",
GTK_SIGNAL_FUNC (activate_cb),
NULL,
md,
g_free, FALSE, FALSE);
md->menu = menu;
md->op = META_MENU_OP_WORKSPACES;
gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu),
mi);
g_object_set_data (G_OBJECT (mi),
"workspace",
GINT_TO_POINTER (i));
gtk_widget_show (mi);
gtk_signal_connect_full (GTK_OBJECT (mi),
"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;
}
++i;
}
}
else