static void set_active_window (WorkspaceButton* self, WnckWindow * window) { if (PRIV (self)->active == window) { return; } if (PRIV (self)->active) { PRIV (self)->active = NULL; } if (window) { PRIV (self)->active = window; gtk_image_set_from_pixbuf (GTK_IMAGE (PRIV (self)->image), wnck_window_get_mini_icon (PRIV (self)->active)); gtk_widget_show (PRIV (self)->image); gtk_label_set_text (GTK_LABEL (PRIV (self)->label), wnck_window_get_name (PRIV (self)->active)); // FIXME: connect to window state changes } else { gtk_widget_hide (PRIV (self)->image); gtk_image_set_from_pixbuf (GTK_IMAGE (PRIV (self)->image), NULL); gtk_label_set_text (GTK_LABEL (PRIV (self)->label), wnck_workspace_get_name (PRIV (self)->workspace)); } }
static void unselect_cb (GtkItem * item, gpointer user_data) { gtk_menu_item_set_label (GTK_MENU_ITEM (item), wnck_workspace_get_name (user_data)); }
static void set_property (GObject * object, guint prop_id, GValue const* value, GParamSpec * pspec) { switch (prop_id) { case PROP_WORKSPACE: /* FIXME: update to renames */ g_return_if_fail (!PRIV (object)->workspace); g_return_if_fail (g_value_get_object (value)); g_return_if_fail (G_VALUE_HOLDS (value, WNCK_TYPE_WORKSPACE)); PRIV (object)->workspace = g_value_get_object (value); gtk_label_set_text (GTK_LABEL (PRIV (object)->label), wnck_workspace_get_name (PRIV (object)->workspace)); g_signal_connect (wnck_workspace_get_screen (PRIV (object)->workspace), "active-window-changed", G_CALLBACK (active_window_changed), object); g_signal_connect (wnck_workspace_get_screen (PRIV (object)->workspace), "window-closed", G_CALLBACK (window_closed), object); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void select_cb (GtkItem * item, gpointer user_data) { gchar* text = g_strdup_printf (_("%s (rename)"), wnck_workspace_get_name (user_data)); gtk_menu_item_set_label (GTK_MENU_ITEM (item), text); g_free (text); }
static void button_toggled_cb (GtkToggleButton* button) { if (gtk_toggle_button_get_active (button)) { GtkWidget* item = NULL; GList * window; g_return_if_fail (!menu); menu = g_object_ref_sink (gtk_menu_new ()); item = gtk_menu_item_new_with_label (wnck_workspace_get_name (PRIV (button)->workspace)); gtk_widget_set_sensitive (item, FALSE); #if 0 g_signal_connect (item, "select", G_CALLBACK (select_cb), PRIV (button)->workspace); g_signal_connect (item, "deselect", G_CALLBACK (unselect_cb), PRIV (button)->workspace); #endif gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_separator_menu_item_new (); gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); for (window = wnck_screen_get_windows (wnck_workspace_get_screen (PRIV (button)->workspace)); window; window = window->next) { if (!wnck_window_is_on_workspace (window->data, PRIV (button)->workspace) || (wnck_window_get_state (window->data) & WNCK_WINDOW_STATE_SKIP_TASKLIST)) { continue; } item = window_menu_item_new (window->data); gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); } gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (button), NULL); gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (GTK_WIDGET (button))); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, menu_position_func, button, 0, gtk_get_current_event_time ()); g_object_add_weak_pointer (G_OBJECT (menu), (gpointer*)&menu); g_signal_connect (menu, "selection-done", G_CALLBACK (untoggle), button); } }
static void workspace_renamed(WnckWorkspace* space, PagerData* pager) { int i; GtkTreeIter iter; i = wnck_workspace_get_number(space); if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pager->workspaces_store), &iter, NULL, i)) gtk_list_store_set(pager->workspaces_store, &iter, 0, wnck_workspace_get_name(space), -1); }
static void update_workspaces_model (PagerData *pager) { int nr_ws, i; WnckWorkspace *workspace; GtkTreeIter iter; nr_ws = wnck_screen_get_workspace_count (pager->screen); gtk_spin_button_set_value (GTK_SPIN_BUTTON (pager->num_workspaces_spin), nr_ws); gtk_list_store_clear (pager->workspaces_store); for (i = 0; i < nr_ws; i++) { workspace = wnck_screen_get_workspace (pager->screen, i); gtk_list_store_append (pager->workspaces_store, &iter); gtk_list_store_set (pager->workspaces_store, &iter, 0, wnck_workspace_get_name (workspace), -1); } }
static void wnck_selector_workspace_name_changed (WnckWorkspace *workspace, GtkLabel *label) { GtkStyleContext *context; GdkRGBA color; char *name; char *markup; context = gtk_widget_get_style_context (GTK_WIDGET (label)); gtk_style_context_get_color (context, GTK_STATE_FLAG_INSENSITIVE, &color); name = g_markup_escape_text (wnck_workspace_get_name (workspace), -1); markup = g_strdup_printf ("<span size=\"x-small\" style=\"italic\" foreground=\"#%.2x%.2x%.2x\">%s</span>", (int)(color.red * 65535 + 0.5), (int)(color.green * 65535 + 0.5), (int)(color.blue * 65535 + 0.5), name); g_free (name); gtk_label_set_markup (label, markup); g_free (markup); }
static char * get_workspace_name_with_accel (WnckWindow *window, int index) { const char *name; int number; name = wnck_workspace_get_name (wnck_screen_get_workspace (wnck_window_get_screen (window), index)); g_assert (name != NULL); /* * If the name is of the form "Workspace x" where x is an unsigned * integer, insert a '_' before the number if it is less than 10 and * return it */ number = 0; if (sscanf (name, _("Workspace %d"), &number) == 1) { /* Keep this in sync with what is in refill_submenu_viewport() */ char *new_name; /* * Above name is a pointer into the Workspace struct. Here we make * a copy copy so we can have our wicked way with it. */ if (number == 10) new_name = g_strdup_printf (_("Workspace 1_0")); else new_name = g_strdup_printf (_("Workspace %s%d"), number < 10 ? "_" : "", number); return new_name; } else { /* * Otherwise this is just a normal name. Escape any _ characters so that * the user's workspace names do not get mangled. If the number is less * than 10 we provide an accelerator. */ char *new_name; const char *source; char *dest; /* * Assume the worst case, that every character is a _. We also * provide memory for " (_#)" */ new_name = g_malloc0 (strlen (name) * 2 + 6 + 1); /* * Now iterate down the strings, adding '_' to escape as we go */ dest = new_name; source = name; while (*source != '\0') { if (*source == '_') *dest++ = '_'; *dest++ = *source++; } /* People don't start at workstation 0, but workstation 1 */ if (index < 9) { g_snprintf (dest, 6, " (_%d)", index + 1); } else if (index == 9) { g_snprintf (dest, 6, " (_0)"); } return new_name; } }
static void workspace_changed_cb(WnckScreen *screen_cb, gpointer data) { WnckWorkspace *workspace; const char *workspace_name; char *color_shading_type; char *secondary_color; char *primary_color; char *picture_filename; char *picture_options; gint picture_opacity; gboolean draw_background; char key[200]; gchar *urlkey; char set_default = 0; workspace = wnck_screen_get_active_workspace(screen_cb); workspace_name = wnck_workspace_get_name(workspace); remove_monitors(); #define GET_BACKGROUND_VALUE(client, type, entry, workspace) \ sprintf(key, MULTI_BACKGROUND_GCONF_PATH "/%s/" # entry, workspace); \ urlkey = url_encode(key); \ entry = gconf_client_get_ ## type(client, urlkey, NULL); \ g_free(urlkey); \ if (entry == NULL) { \ entry = default_ ## entry; \ set_default = 1; \ } GET_BACKGROUND_VALUE (client, string, color_shading_type, workspace_name); GET_BACKGROUND_VALUE (client, string, secondary_color, workspace_name); GET_BACKGROUND_VALUE (client, string, primary_color, workspace_name); GET_BACKGROUND_VALUE (client, string, picture_options, workspace_name); GET_BACKGROUND_VALUE (client, string, picture_filename, workspace_name); /* opacity */ if (!set_default) { sprintf(key, MULTI_BACKGROUND_GCONF_PATH "/%s/picture_opacity", workspace_name); urlkey = url_encode(key); picture_opacity = gconf_client_get_int(client, urlkey, NULL); g_free(urlkey); } else { picture_opacity = default_picture_opacity; } /* draw_background */ if (!set_default) { sprintf(key, MULTI_BACKGROUND_GCONF_PATH "/%s/draw_background", workspace_name); urlkey = url_encode(key); draw_background = gconf_client_get_bool(client, urlkey, NULL); g_free(urlkey); } else { draw_background = default_draw_background; } #define SET_BACKGROUND_VALUE(client, type, entry, workspace) \ gconf_client_set_ ## type(client, DEFAULT_BACKGROUND_GCONF_PATH "/" # entry, entry, NULL) SET_BACKGROUND_VALUE (client, string, picture_filename, workspace_name); SET_BACKGROUND_VALUE (client, int, picture_opacity, workspace_name); SET_BACKGROUND_VALUE (client, string, picture_options, workspace_name); SET_BACKGROUND_VALUE (client, bool, draw_background, workspace_name); SET_BACKGROUND_VALUE (client, string, color_shading_type, workspace_name); SET_BACKGROUND_VALUE (client, string, primary_color, workspace_name); SET_BACKGROUND_VALUE (client, string, secondary_color, workspace_name); add_monitors(); }