diff -r -u ../xfce4-panel-svn/plugins/launcher/launcher-dialog.c ./plugins/launcher/launcher-dialog.c --- ../xfce4-panel-svn/plugins/launcher/launcher-dialog.c 2005-12-18 16:27:27.000000000 +0100 +++ ./plugins/launcher/launcher-dialog.c 2005-12-18 16:28:59.000000000 +0100 @@ -68,6 +68,9 @@ GtkWidget *exec; GtkWidget *exec_browse; + GtkWidget *exec_workspace; + GtkWidget *workspace_menu; + GtkWidget *workspace_label; GtkWidget *exec_terminal; GtkWidget *exec_startup; } @@ -288,7 +291,7 @@ } static void -position_icon_menu (GtkMenu * menu, int *x, int *y, gboolean * push_in, +position_popup_menu (GtkMenu * menu, int *x, int *y, gboolean * push_in, GtkWidget *b) { GtkRequisition req; @@ -329,7 +332,7 @@ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb))) { gtk_menu_popup (GTK_MENU (ld->icon_category), NULL, NULL, - (GtkMenuPositionFunc) position_icon_menu, tb, + (GtkMenuPositionFunc) position_popup_menu, tb, 0, gtk_get_current_event_time ()); } } @@ -595,11 +598,170 @@ gtk_box_pack_start (GTK_BOX (hbox), ld->icon_label, TRUE, TRUE, 0); } +static void +workspace_set_label (LauncherDialog *ld, gint n) +{ + gchar label[2048]; + + if (!n) + n = 0; + + if (n > 0) + { + NetkScreen *netk_screen; + NetkWorkspace *ws; + const gchar *ws_name; + + netk_screen = netk_screen_get_default (); + ws = netk_screen_get_workspace (netk_screen, n-1); + ws_name = netk_workspace_get_name (ws); + + if (ws_name) + g_snprintf(label, 2048, "%s %d (%s)", _("Workspace"), n, ws_name); + else + g_snprintf(label, 2048, "%s %d", _("Workspace"), n); + + + } + else + { + g_snprintf(label, 2048, "%s", _("Active Workspace")); + + ld->entry->workspace = 0; + } + + gtk_label_set_text (GTK_LABEL (ld->workspace_label), label); +} + +static void +workspace_menu_activated (GtkWidget *mi, LauncherDialog *ld) +{ + int n = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (mi), "workspace")); + + if (n > 0) + ld->entry->workspace = n; + else + ld->entry->workspace = 0; + + workspace_set_label (ld, n); +} + +static void +workspace_menu_deactivated (GtkWidget *menu, LauncherDialog *ld) +{ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->exec_workspace), FALSE); +} + +static void +popup_workspace_menu (GtkWidget *tb, LauncherDialog *ld) +{ + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb))) + { + gtk_menu_popup (GTK_MENU (ld->workspace_menu), NULL, NULL, + (GtkMenuPositionFunc) position_popup_menu, tb, + 0, gtk_get_current_event_time ()); + } +} + + +static GtkWidget * +create_workspace_menu (LauncherDialog *ld) +{ + GtkWidget *menu, *mi; + + NetkScreen *netk_screen; + NetkWorkspace *ws; + gint nworkspaces, i; + const gchar *ws_name; + gchar mi_label[2048]; + + netk_screen = netk_screen_get_default (); + nworkspaces = netk_screen_get_workspace_count (netk_screen); + + menu = gtk_menu_new (); + + g_signal_connect (menu, "deactivate", + G_CALLBACK (workspace_menu_deactivated), ld); + + mi = gtk_image_menu_item_new_with_label (_("Active Workspace")); + gtk_widget_show (mi); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + + g_object_set_data (G_OBJECT (mi), "workspace", GINT_TO_POINTER (0)); + + g_signal_connect (mi, "activate", + G_CALLBACK (workspace_menu_activated), ld); + + mi = gtk_separator_menu_item_new (); + gtk_widget_show (mi); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + + for (i = 0; i < nworkspaces; i++) + { + ws = netk_screen_get_workspace (netk_screen, i); + ws_name = netk_workspace_get_name (ws); + + if (ws_name) + g_snprintf(mi_label, 2048, "%s %d (%s)", _("Workspace"), i+1, ws_name); + else + g_snprintf(mi_label, 2048, "%s %d", _("Workspace"), i+1); + + mi = gtk_image_menu_item_new_with_label (mi_label); + gtk_widget_show (mi); + gtk_menu_shell_append(GTK_MENU_SHELL (menu), mi); + + g_object_set_data (G_OBJECT (mi), "workspace", GINT_TO_POINTER (i+1)); + + g_signal_connect (mi, "activate", + G_CALLBACK (workspace_menu_activated), ld); + + } + + return menu; +} + /* exec widgets */ static void add_entry_exec_options (LauncherDialog *ld, GtkBox *box, GtkSizeGroup *sg) { - GtkWidget *hbox, *label, *button, *img; + GtkWidget *hbox, *label, *button, *img, *combobox, *hbox2, *arrow, *separator; + + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_widget_show (hbox); + gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + + label = gtk_label_new (_("Workspace")); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + + gtk_size_group_add_widget (sg, label); + + combobox = ld->exec_workspace = gtk_toggle_button_new (); + gtk_widget_show (combobox); + gtk_box_pack_start (GTK_BOX (hbox), combobox, TRUE, TRUE, 0); + + hbox2 = gtk_hbox_new (FALSE, 2); + gtk_widget_show (hbox2); + gtk_container_add (GTK_CONTAINER (combobox), hbox2); + + label = ld->workspace_label = gtk_label_new (_("Active Workspace")); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (hbox2), label, TRUE, TRUE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + + separator = gtk_vseparator_new (); + gtk_widget_show (separator); + gtk_box_pack_start (GTK_BOX (hbox2), separator, FALSE, TRUE, 0); + + arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_IN); + gtk_widget_show (arrow); + gtk_box_pack_start (GTK_BOX (hbox2), arrow, FALSE, TRUE, 0); + + ld->workspace_menu = create_workspace_menu (ld); + + g_signal_connect (ld->exec_workspace, "toggled", + G_CALLBACK (popup_workspace_menu), ld); hbox = gtk_hbox_new (FALSE, BORDER); gtk_widget_show (hbox); @@ -684,6 +846,8 @@ value = ld->entry->exec ? ld->entry->exec : ""; gtk_entry_set_text (GTK_ENTRY (ld->exec), value); + + workspace_set_label (ld, ld->entry->workspace); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->exec_terminal), ld->entry->terminal); @@ -1348,6 +1512,7 @@ e->name = e->comment = e->exec = NULL; e->terminal = e->startup = FALSE; + e->workspace = 0; e->icon.icon.name = NULL; e->icon.type = LAUNCHER_ICON_TYPE_NONE; @@ -1497,6 +1662,9 @@ gtk_entry_set_text (GTK_ENTRY (ld->icon_file), e->icon.icon.name); gtk_entry_set_text (GTK_ENTRY (ld->exec), e->exec); + + workspace_set_label (ld, e->workspace); + gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (ld->exec_terminal), e->terminal); gtk_toggle_button_set_active ( diff -r -u ../xfce4-panel-svn/plugins/launcher/launcher.c ./plugins/launcher/launcher.c --- ../xfce4-panel-svn/plugins/launcher/launcher.c 2005-12-18 16:27:27.000000000 +0100 +++ ./plugins/launcher/launcher.c 2005-12-18 16:28:59.000000000 +0100 @@ -294,7 +294,7 @@ g_free (e); } - + static void launcher_entry_exec (GdkScreen *screen, LauncherEntry *entry) { @@ -303,8 +303,16 @@ if (!entry->exec || !strlen (entry->exec)) return; - xfce_exec_on_screen (screen, entry->real_exec, entry->terminal, + if (entry->workspace > 0) + { + xfce_exec_on_workspace (screen, entry->real_exec, entry->terminal, + entry->startup, (entry->workspace-1), &error); + } + else + { + xfce_exec_on_screen (screen, entry->real_exec, entry->terminal, entry->startup, &error); + } if (error) { @@ -819,6 +827,8 @@ if (!(entry->real_exec = xfce_expand_variables (entry->exec, NULL))) entry->real_exec = g_strdup (entry->exec); } + + entry->workspace = xfce_rc_read_int_entry (rc, "Workspace", 0); entry->terminal = xfce_rc_read_bool_entry (rc, "Terminal", FALSE); @@ -890,6 +900,8 @@ if (entry->exec) xfce_rc_write_entry (rc, "Exec", entry->exec); + + xfce_rc_write_int_entry (rc, "Workspace", entry->workspace); xfce_rc_write_bool_entry (rc, "Terminal", entry->terminal); diff -r -u ../xfce4-panel-svn/plugins/launcher/launcher.h ./plugins/launcher/launcher.h --- ../xfce4-panel-svn/plugins/launcher/launcher.h 2005-12-18 16:27:27.000000000 +0100 +++ ./plugins/launcher/launcher.h 2005-12-18 16:28:59.000000000 +0100 @@ -57,6 +57,7 @@ char *name; char *comment; char *exec; + int workspace; char *real_exec; LauncherIcon icon;