? birnan Index: applets/wncklet/workspace-switcher.c =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/workspace-switcher.c,v retrieving revision 1.77 diff -u -r1.77 workspace-switcher.c --- applets/wncklet/workspace-switcher.c 7 Aug 2006 23:49:19 -0000 1.77 +++ applets/wncklet/workspace-switcher.c 18 Sep 2006 23:28:00 -0000 @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include "workspace-switcher.h" @@ -48,6 +51,9 @@ /* Properties: */ GtkWidget *properties_dialog; + GtkWidget *notebook; + GtkWidget *viewport_child; + GtkWidget *workspace_child; GtkWidget *display_workspaces_toggle; GtkWidget *all_workspaces_radio; GtkWidget *current_only_radio; @@ -56,6 +62,8 @@ GtkWidget *num_workspaces_spin; GtkWidget *workspaces_tree; GtkWidget *about; + GtkWidget *width_spinbutton; + GtkWidget *height_spinbutton; GtkListStore *workspaces_store; @@ -780,6 +788,37 @@ } static void +spinbutton_changed (GtkWidget *widget, + gpointer data) +{ + GConfClient *client = gconf_client_get_default (); + const char *key = data; + + int value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget)); + + gconf_client_set_int (client, key, value, NULL); +} + +static void +setup_spinbutton (GtkSpinButton *spin, + const char *key, + int minimum) +{ + GConfClient *client = gconf_client_get_default (); + int value; + + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (GTK_WIDGET (spin), FALSE); + + value = gconf_client_get_int (client, key, NULL); + + gtk_spin_button_set_range (spin, minimum, G_MAXINT); + gtk_spin_button_set_value (spin, value); + + g_signal_connect (spin, "value_changed", G_CALLBACK (spinbutton_changed), (gpointer)key); +} + +static void setup_dialog (GladeXML *xml, PagerData *pager) { @@ -910,6 +949,114 @@ pager, pager->applet); } + + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (pager->notebook), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (pager->notebook), FALSE); + + setup_spinbutton (pager->width_spinbutton, "/apps/compiz/general/screen0/options/hsize", 1); + setup_spinbutton (pager->height_spinbutton, "/apps/compiz/general/screen0/options/vsize", 1); +} + +/* get_wm_window() and current_window_manager() are essentially cutted and pasted + * from gnome-wm.c from gnome-control-center. + */ +static Window +get_wm_window (void) +{ + Window *xwindow; + Atom type; + gint format; + gulong nitems; + gulong bytes_after; + Window result; + + XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (), + XInternAtom (GDK_DISPLAY (), "_NET_SUPPORTING_WM_CHECK", False), + 0, G_MAXLONG, False, XA_WINDOW, &type, &format, + &nitems, &bytes_after, (guchar **) &xwindow); + + if (type != XA_WINDOW) + { + return None; + } + + gdk_error_trap_push (); + XSelectInput (GDK_DISPLAY (), *xwindow, StructureNotifyMask | PropertyChangeMask); + XSync (GDK_DISPLAY (), False); + + if (gdk_error_trap_pop ()) + { + XFree (xwindow); + return None; + } + + result = *xwindow; + XFree (xwindow); + + return result; +} + +static char* +get_current_window_manager (void) +{ + Atom utf8_string, atom, type; + int result; + char *retval; + int format; + gulong nitems; + gulong bytes_after; + gchar *val; + Window wm_window = get_wm_window (); + + utf8_string = XInternAtom (GDK_DISPLAY (), "UTF8_STRING", False); + atom = XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False); + + gdk_error_trap_push (); + + result = XGetWindowProperty (GDK_DISPLAY (), + wm_window, + atom, + 0, G_MAXLONG, + False, utf8_string, + &type, &format, &nitems, + &bytes_after, (guchar **)&val); + + if (gdk_error_trap_pop () || result != Success) + return NULL; + + if (type != utf8_string || + format !=8 || + nitems == 0) + { + if (val) + XFree (val); + return NULL; + } + + if (!g_utf8_validate (val, nitems, NULL)) + { + XFree (val); + return NULL; + } + + retval = g_strndup (val, nitems); + + XFree (val); + + return retval; +} + +static gboolean +compiz_is_running (void) +{ + gboolean result; + char *wm = get_current_window_manager (); + + result = wm && strcmp (wm, "compiz") == 0; + + g_free (wm); + + return result; } static void @@ -917,23 +1064,50 @@ PagerData *pager, const gchar *verbname) { - if (pager->properties_dialog == NULL) { - GladeXML *xml; + gboolean using_compiz; + + if (pager->properties_dialog == NULL) { + GladeXML *xml = glade_xml_new (PAGER_GLADEDIR "/workspace-switcher.glade", NULL, NULL); - xml = glade_xml_new (PAGER_GLADEDIR "/workspace-switcher.glade", NULL, NULL); pager->properties_dialog = glade_xml_get_widget (xml, "pager_properties_dialog"); - + pager->notebook = glade_xml_get_widget (xml, "notebook"); + pager->viewport_child = glade_xml_get_widget (xml, "viewport-child"); + pager->workspace_child = glade_xml_get_widget (xml, "workspace-child"); + pager->width_spinbutton = glade_xml_get_widget (xml, "width-spinbutton"); + pager->height_spinbutton = glade_xml_get_widget (xml, "height-spinbutton"); + + g_object_ref (pager->viewport_child); + g_object_ref (pager->workspace_child); + g_object_add_weak_pointer (G_OBJECT (pager->properties_dialog), (gpointer *) &pager->properties_dialog); setup_dialog (xml, pager); - - g_object_unref (G_OBJECT (xml)); + + g_object_unref (G_OBJECT (xml)); } + using_compiz = compiz_is_running(); + + if (using_compiz) { + gtk_widget_hide (pager->workspace_child); + gtk_widget_show (pager->viewport_child); + gtk_window_set_resizable (GTK_WINDOW (pager->properties_dialog), FALSE); + } + else { + gtk_widget_show (pager->workspace_child); + gtk_widget_hide (pager->viewport_child); + gtk_window_set_resizable (GTK_WINDOW (pager->properties_dialog), TRUE); + } + gtk_window_set_icon_name (GTK_WINDOW (pager->properties_dialog), "gnome-panel-workspace-switcher"); gtk_window_set_screen (GTK_WINDOW (pager->properties_dialog), gtk_widget_get_screen (pager->applet)); gtk_window_present (GTK_WINDOW (pager->properties_dialog)); + + if (using_compiz) { + gtk_widget_grab_focus (pager->width_spinbutton); + gtk_editable_select_region (GTK_EDITABLE (pager->width_spinbutton), 0, -1); + } } Index: applets/wncklet/workspace-switcher.glade =================================================================== RCS file: /cvs/gnome/gnome-panel/applets/wncklet/workspace-switcher.glade,v retrieving revision 1.23 diff -u -r1.23 workspace-switcher.glade --- applets/wncklet/workspace-switcher.glade 13 Oct 2003 20:11:52 -0000 1.23 +++ applets/wncklet/workspace-switcher.glade 18 Sep 2006 23:28:00 -0000 @@ -12,6 +12,13 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False False @@ -33,6 +40,7 @@ gtk-help True GTK_RELIEF_NORMAL + True -11 @@ -46,6 +54,7 @@ gtk-close True GTK_RELIEF_NORMAL + True 0 @@ -59,58 +68,45 @@ - - 5 + True - False - 18 + True + True + False + GTK_POS_TOP + False + False - + + 5 True False - 6 - - - - True - <b>Switcher</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - + 18 - + True False - 0 + 6 - + True - + <b>Switcher</b> False - False + True GTK_JUSTIFY_LEFT False False - 0.5 + 0 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -120,21 +116,28 @@ - + True False - 6 + 0 - + True - True - Show _only the current workspace - True - GTK_RELIEF_NORMAL - False - False - True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -144,22 +147,22 @@ - + True False - 12 + 6 - + True True - Show _all workspaces in: + Show _only the current workspace True GTK_RELIEF_NORMAL + True False False True - current_only_radio 0 @@ -169,22 +172,81 @@ - + True False - 6 + 12 - + True True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 1 16 1 10 10 + Show _all workspaces in: + True + GTK_RELIEF_NORMAL + True + False + False + True + current_only_radio + + + 0 + False + False + + + + + + True + False + 6 + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 16 1 10 10 + + + 0 + True + True + + + + + + True + rows + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + num_rows_spin + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + 0 @@ -192,12 +254,114 @@ True + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + False + True + + + + + + True + False + 6 + + + + True + <b>Workspaces</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 6 + + + + True + False + 12 - + True - rows - False + Number of _workspaces: + True False GTK_JUSTIFY_CENTER False @@ -206,7 +370,11 @@ 0.5 0 0 - num_rows_spin + num_workspaces_spin + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -214,6 +382,83 @@ False + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 36 1 10 10 + + + 0 + True + True + + + + + 0 + False + False + + + + + + True + Workspace na_mes: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + workspaces_tree_view + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + 100 + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + Workspace Names + True + False + False + False + True + False + False + False + + 0 @@ -221,6 +466,25 @@ True + + + + True + True + Show workspace _names in switcher + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + 0 @@ -244,22 +508,45 @@ - 0 - False - True + False + True - + + True + label7 + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 6 True False 6 - + True - <b>Workspaces</b> + <b>Desktop Size</b> False True GTK_JUSTIFY_LEFT @@ -269,6 +556,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -278,13 +569,13 @@ - + True False 0 - + True False @@ -296,6 +587,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -305,129 +600,178 @@ - + True False 6 - + True + 2 + 3 False - 12 + 6 + 6 - + True - Number of _workspaces: - True + Width: + False False - GTK_JUSTIFY_CENTER + GTK_JUSTIFY_LEFT False False 0 0.5 0 0 - num_workspaces_spin + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + + + + + + + True + Height: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + - + + True + columns + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + rows + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 2 + 3 + 1 + 2 + fill + + + + + + True True 1 0 - True + False GTK_UPDATE_ALWAYS False False - 1 1 36 1 10 10 + 1 0 100 1 10 10 - 0 - True - True + 1 + 2 + 0 + 1 + fill + - - - 0 - False - False - - - - - - True - Workspace na_mes: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - workspaces_tree_view - - - 0 - False - False - - - - - - 100 - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - + True - Workspace Names True - False - False - False - True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + 1 + 2 + 1 + 2 + fill + + 0 - True - True - - - - - - True - True - Show workspace _names in switcher - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 False False @@ -448,9 +792,31 @@ - 0 - True - True + False + True + + + + + + True + label8 + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab