GtkWidget* ggt_winlist_new (GGTraybar *app) { GtkWidget *winlist = wnck_tasklist_new (); g_assert (app); wnck_tasklist_set_grouping (WNCK_TASKLIST (winlist), WNCK_TASKLIST_AUTO_GROUP); wnck_tasklist_set_include_all_workspaces (WNCK_TASKLIST (winlist), FALSE); wnck_tasklist_set_switch_workspace_on_unminimize (WNCK_TASKLIST (winlist), FALSE); return winlist; }
static void tasklist_update(TasklistData* tasklist) { if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL) { gtk_widget_set_size_request(GTK_WIDGET(tasklist->tasklist), -1, tasklist->size); } else { gtk_widget_set_size_request(GTK_WIDGET(tasklist->tasklist), tasklist->size, -1); } wnck_tasklist_set_grouping(WNCK_TASKLIST(tasklist->tasklist), tasklist->grouping); wnck_tasklist_set_include_all_workspaces(WNCK_TASKLIST(tasklist->tasklist), tasklist->include_all_workspaces); wnck_tasklist_set_switch_workspace_on_unminimize(WNCK_TASKLIST(tasklist->tasklist), tasklist->move_unminimized_windows); }
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, TasklistData* tasklist) #endif { switch (type) { case PANEL_NO_BACKGROUND: #if !GTK_CHECK_VERSION (3, 0 ,0) wnck_tasklist_set_button_relief(WNCK_TASKLIST(tasklist->tasklist), GTK_RELIEF_NORMAL); break; #endif case PANEL_COLOR_BACKGROUND: case PANEL_PIXMAP_BACKGROUND: wnck_tasklist_set_button_relief(WNCK_TASKLIST(tasklist->tasklist), GTK_RELIEF_NONE); break; } }
static void applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient orient, TasklistData* tasklist) { GtkOrientation new_orient; switch (orient) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: new_orient = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: new_orient = GTK_ORIENTATION_HORIZONTAL; break; } if (new_orient == tasklist->orientation) return; tasklist->orientation = new_orient; #if WNCK_CHECK_VERSION (3, 4, 6) wnck_tasklist_set_orientation (WNCK_TASKLIST (tasklist->tasklist), new_orient); #endif tasklist_update(tasklist); }
static void applet_change_background (PanelApplet *applet, cairo_pattern_t *pattern, TasklistData *tasklist) { wnck_tasklist_set_button_relief (WNCK_TASKLIST (tasklist->tasklist), pattern != NULL ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL); }
static void applet_size_request(GtkWidget* widget, GtkRequisition* requisition, TasklistData* tasklist) #endif { int len; const int* size_hints; #if GTK_CHECK_VERSION (3, 0, 0) size_hints = wnck_tasklist_get_size_hint_list (WNCK_TASKLIST (tasklist->tasklist), &len); #else GtkRequisition child_req; WnckTasklist* wncktl = WNCK_TASKLIST(tasklist->tasklist); gtk_widget_get_child_requisition(tasklist->applet, &child_req); size_hints = wnck_tasklist_get_size_hint_list(wncktl, &len); #endif g_assert(len % 2 == 0); mate_panel_applet_set_size_hints(MATE_PANEL_APPLET(tasklist->applet), size_hints, len, 0); }
static void applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation, TasklistData *tasklist) { int len; const int* size_hints; size_hints = wnck_tasklist_get_size_hint_list (WNCK_TASKLIST (tasklist->tasklist), &len); g_assert(len % 2 == 0); mate_panel_applet_set_size_hints(MATE_PANEL_APPLET(tasklist->applet), size_hints, len, 0); }
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t* pattern, TasklistData* tasklist) { switch (type) { case PANEL_NO_BACKGROUND: case PANEL_COLOR_BACKGROUND: case PANEL_PIXMAP_BACKGROUND: wnck_tasklist_set_button_relief(WNCK_TASKLIST(tasklist->tasklist), GTK_RELIEF_NONE); break; } }
static void applet_realized (PanelApplet *applet, TasklistData *tasklist) { WnckScreen *screen; screen = wncklet_get_screen (GTK_WIDGET (applet)); wnck_tasklist_set_screen (WNCK_TASKLIST (tasklist->tasklist), screen); tasklist->icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (tasklist->applet)); }
static void applet_size_request (GtkWidget *widget, GtkRequisition *requisition, TasklistData *tasklist) { int len; const int *size_hints; GtkRequisition child_req; int i; int maximum_size; int *new_size_hints; int new_len = 0; WnckTasklist *wncktl = WNCK_TASKLIST (tasklist->tasklist); gint minimum_size = 0; if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL) minimum_size = wnck_tasklist_get_minimum_width (wncktl); else minimum_size = wnck_tasklist_get_minimum_height (wncktl); gtk_widget_get_child_requisition (tasklist->applet, &child_req); size_hints = wnck_tasklist_get_size_hint_list (wncktl, &len); new_size_hints = g_new0 (int, len); /* size_hints is an array of (max, min) int pairs * where min(i) > max (i+1) * convert it to clipped values */ maximum_size = tasklist->maximum_size - minimum_size; g_assert (maximum_size >= 0); for (i = 0; i < len; i += 2) { if (size_hints[i + 1] <= maximum_size) { /* this one should be stored */ if (size_hints[i] > maximum_size) new_size_hints[new_len] = maximum_size; else new_size_hints[new_len] = size_hints[i]; new_size_hints[new_len + 1] = size_hints[i + 1]; new_len += 2; } } panel_applet_set_size_hints (PANEL_APPLET (tasklist->applet), new_size_hints, new_len, child_req.width - 1); g_free (new_size_hints); }
static void applet_size_request (GtkWidget *widget, GtkRequisition *requisition, TasklistData *tasklist) { int len; const int *size_hints; GtkRequisition child_req; WnckTasklist *wncktl = WNCK_TASKLIST (tasklist->tasklist); gtk_widget_get_child_requisition (tasklist->applet, &child_req); size_hints = wnck_tasklist_get_size_hint_list (wncktl, &len); g_assert (len % 2 == 0); panel_applet_set_size_hints (PANEL_APPLET (tasklist->applet), size_hints, len, 0); }
static void applet_change_orient (PanelApplet *applet, PanelAppletOrient orient, TasklistData *tasklist) { GtkOrientation new_orient; WnckTasklist *wncktl = WNCK_TASKLIST (tasklist->tasklist); gint minimum_size = 0; switch (orient) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: new_orient = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: new_orient = GTK_ORIENTATION_HORIZONTAL; break; } if (new_orient == tasklist->orientation) return; tasklist->orientation = new_orient; /* we need to unset minimum size on the wnck tasklist */ if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL) { /* unset the minimum height and reset minimum width */ minimum_size = wnck_tasklist_get_minimum_height (wncktl); wnck_tasklist_set_minimum_height (wncktl, -1); wnck_tasklist_set_minimum_width (wncktl, minimum_size); } else { /* unset the minimum width and reset minimum height */ minimum_size = wnck_tasklist_get_minimum_width (wncktl); wnck_tasklist_set_minimum_width (wncktl, -1); wnck_tasklist_set_minimum_height (wncktl, minimum_size); } tasklist_update (tasklist); }
/* GConf callback for changes in minimum_size */ static void minimum_size_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, TasklistData *tasklist) { WnckTasklist *wncktl = WNCK_TASKLIST (tasklist->tasklist); gint value; GtkSpinButton *button; if (!tasklist->minimum_size_spin) return; button = GTK_SPIN_BUTTON (tasklist->minimum_size_spin); if (!entry->value || entry->value->type != GCONF_VALUE_INT) return; value = gconf_value_get_int (entry->value); gtk_spin_button_set_value (button, value); if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL) wnck_tasklist_set_minimum_width (wncktl, value); else wnck_tasklist_set_minimum_height (wncktl, value); }
gboolean window_list_applet_fill(MatePanelApplet* applet) { TasklistData* tasklist; GtkActionGroup* action_group; gchar* ui_path; tasklist = g_new0(TasklistData, 1); tasklist->applet = GTK_WIDGET(applet); mate_panel_applet_set_flags(MATE_PANEL_APPLET(tasklist->applet), MATE_PANEL_APPLET_EXPAND_MAJOR | MATE_PANEL_APPLET_EXPAND_MINOR | MATE_PANEL_APPLET_HAS_HANDLE); setup_gsettings(tasklist); tasklist->include_all_workspaces = g_settings_get_boolean (tasklist->settings, "display-all-workspaces"); tasklist->grouping = g_settings_get_enum (tasklist->settings, "group-windows"); tasklist->move_unminimized_windows = g_settings_get_boolean (tasklist->settings, "move-unminimized-windows"); tasklist->size = mate_panel_applet_get_size(applet); switch (mate_panel_applet_get_orient(applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: tasklist->orientation = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: tasklist->orientation = GTK_ORIENTATION_HORIZONTAL; break; } #ifdef WNCK_CHECK_VERSION #if WNCK_CHECK_VERSION (3, 0, 0) tasklist->tasklist = wnck_tasklist_new(); #else tasklist->tasklist = wnck_tasklist_new(NULL); #endif #else tasklist->tasklist = wnck_tasklist_new(NULL); #endif #ifdef WNCK_CHECK_VERSION #if WNCK_CHECK_VERSION (3, 4, 6) wnck_tasklist_set_orientation (WNCK_TASKLIST (tasklist->tasklist), tasklist->orientation); wnck_tasklist_set_middle_click_close (WNCK_TASKLIST (tasklist->tasklist), TRUE); #endif #endif wnck_tasklist_set_icon_loader(WNCK_TASKLIST(tasklist->tasklist), icon_loader_func, tasklist, NULL); g_signal_connect(G_OBJECT(tasklist->tasklist), "destroy", G_CALLBACK(destroy_tasklist), tasklist); #if GTK_CHECK_VERSION (3, 0, 0) g_signal_connect(G_OBJECT(tasklist->applet), "size_allocate", G_CALLBACK(applet_size_allocate), tasklist); #else g_signal_connect(G_OBJECT(tasklist->applet), "size_request", G_CALLBACK(applet_size_request), tasklist); #endif tasklist_update(tasklist); gtk_widget_show(tasklist->tasklist); gtk_container_add(GTK_CONTAINER(tasklist->applet), tasklist->tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "realize", G_CALLBACK(applet_realized), tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "change_orient", G_CALLBACK(applet_change_orient), tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "change_size", G_CALLBACK(applet_change_pixel_size), tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "change_background", G_CALLBACK(applet_change_background), tasklist); mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(tasklist->applet), GTK_WIDGET(tasklist->applet)); action_group = gtk_action_group_new("Tasklist Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, tasklist_menu_actions, G_N_ELEMENTS(tasklist_menu_actions), tasklist); /* disable the item of system monitor, if not exists. * example, mate-system-monitor, o gnome-system-monitor */ char* programpath; int i; for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1) { programpath = g_find_program_in_path(system_monitors[i]); if (programpath != NULL) { g_free(programpath); /* we give up */ goto _system_monitor_found; } /* search another */ } /* system monitor not found */ gtk_action_set_visible(gtk_action_group_get_action(action_group, "TasklistSystemMonitor"), FALSE); _system_monitor_found:; /* end of system monitor item */ ui_path = g_build_filename(WNCK_MENU_UI_DIR, "window-list-menu.xml", NULL); mate_panel_applet_setup_menu_from_file(MATE_PANEL_APPLET(tasklist->applet), ui_path, action_group); g_free(ui_path); if (mate_panel_applet_get_locked_down(MATE_PANEL_APPLET(tasklist->applet))) { GtkAction* action; action = gtk_action_group_get_action(action_group, "TasklistPreferences"); gtk_action_set_visible(action, FALSE); } g_object_unref(action_group); gtk_widget_show(tasklist->applet); return TRUE; }
gboolean window_list_applet_fill (PanelApplet *applet) { TasklistData *tasklist; GtkActionGroup *action_group; GtkAction *action; gchar *ui_path; tasklist = g_new0 (TasklistData, 1); tasklist->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (tasklist->applet), PANEL_APPLET_EXPAND_MAJOR | PANEL_APPLET_EXPAND_MINOR | PANEL_APPLET_HAS_HANDLE); panel_applet_add_preferences (applet, "/schemas/apps/window_list_applet/prefs", NULL); setup_gconf (tasklist); tasklist->include_all_workspaces = g_settings_get_boolean (tasklist->settings, "display-all-workspaces"); tasklist->grouping = g_settings_get_enum (tasklist->settings, "group-windows"); tasklist->move_unminimized_windows = g_settings_get_boolean (tasklist->settings, "move-unminimized-windows"); tasklist->size = panel_applet_get_size (applet); switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: tasklist->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: tasklist->orientation = GTK_ORIENTATION_HORIZONTAL; break; } tasklist->tasklist = wnck_tasklist_new (); wnck_tasklist_set_icon_loader (WNCK_TASKLIST (tasklist->tasklist), icon_loader_func, tasklist, NULL); g_signal_connect (G_OBJECT (tasklist->tasklist), "destroy", G_CALLBACK (destroy_tasklist), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "size_allocate", G_CALLBACK (applet_size_allocate), tasklist); tasklist_update (tasklist); gtk_widget_show (tasklist->tasklist); gtk_container_add (GTK_CONTAINER (tasklist->applet), tasklist->tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "realize", G_CALLBACK (applet_realized), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_orient", G_CALLBACK (applet_change_orient), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_size", G_CALLBACK (applet_change_pixel_size), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_background", G_CALLBACK (applet_change_background), tasklist); panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet), GTK_WIDGET (tasklist->applet)); action_group = gtk_action_group_new ("Tasklist Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, tasklist_menu_actions, G_N_ELEMENTS (tasklist_menu_actions), tasklist); ui_path = g_build_filename (WNCK_MENU_UI_DIR, "window-list-menu.xml", NULL); panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet), ui_path, action_group); g_free (ui_path); action = gtk_action_group_get_action (action_group, "TasklistPreferences"); g_object_bind_property (tasklist->applet, "locked-down", action, "visible", G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE); g_object_unref (action_group); gtk_widget_show (tasklist->applet); return TRUE; }
gboolean window_list_applet_fill (PanelApplet *applet) { TasklistData *tasklist; GError *error; GConfValue *value; gint sizepref; tasklist = g_new0 (TasklistData, 1); tasklist->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (tasklist->applet), PANEL_APPLET_EXPAND_MAJOR | PANEL_APPLET_EXPAND_MINOR | PANEL_APPLET_HAS_HANDLE); panel_applet_add_preferences (applet, "/schemas/apps/window_list_applet/prefs", NULL); setup_gconf (tasklist); error = NULL; tasklist->include_all_workspaces = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error); if (error) { g_error_free (error); tasklist->include_all_workspaces = FALSE; /* Default value */ } error = NULL; tasklist->grouping = -1; value = panel_applet_gconf_get_value (applet, "group_windows", &error); if (error) { g_error_free (error); } else if (value) { tasklist->grouping = get_grouping_type (value); gconf_value_free (value); } if (tasklist->grouping < 0) tasklist->grouping = WNCK_TASKLIST_AUTO_GROUP; /* Default value */ error = NULL; tasklist->move_unminimized_windows = panel_applet_gconf_get_bool (applet, "move_unminimized_windows", &error); if (error) { g_error_free (error); tasklist->move_unminimized_windows = TRUE; /* Default value */ } tasklist->size = panel_applet_get_size (applet); switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: tasklist->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: tasklist->orientation = GTK_ORIENTATION_HORIZONTAL; break; } tasklist->screen = wncklet_get_screen (tasklist->applet); /* because the tasklist doesn't respond to signals at the moment */ wnck_screen_force_update (tasklist->screen); tasklist->tasklist = wnck_tasklist_new (tasklist->screen); wnck_tasklist_set_icon_loader (WNCK_TASKLIST (tasklist->tasklist), icon_loader_func, tasklist, NULL); /* get size preferences */ error = NULL; sizepref = panel_applet_gconf_get_int (applet, "minimum_size", &error); if (error) { sizepref = 50; /* Default value */ g_error_free (error); } if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL) wnck_tasklist_set_minimum_width (WNCK_TASKLIST (tasklist->tasklist), sizepref); else wnck_tasklist_set_minimum_height (WNCK_TASKLIST (tasklist->tasklist), sizepref); error = NULL; sizepref = panel_applet_gconf_get_int (applet, "maximum_size", &error); if (error) { sizepref = 4096; /* Default value */ g_error_free (error); } tasklist->maximum_size = sizepref; g_signal_connect (G_OBJECT (tasklist->tasklist), "destroy", G_CALLBACK (destroy_tasklist), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "size_request", G_CALLBACK (applet_size_request), tasklist); tasklist_update (tasklist); gtk_widget_show (tasklist->tasklist); gtk_container_add (GTK_CONTAINER (tasklist->applet), tasklist->tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "realize", G_CALLBACK (applet_realized), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_orient", G_CALLBACK (applet_change_orient), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_size", G_CALLBACK (applet_change_pixel_size), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_background", G_CALLBACK (applet_change_background), tasklist); panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet), GTK_WIDGET (tasklist->applet)); panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet), NULL, "GNOME_WindowListApplet.xml", NULL, tasklist_menu_verbs, tasklist); if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) { BonoboUIComponent *popup_component; popup_component = panel_applet_get_popup_component (PANEL_APPLET (tasklist->applet)); bonobo_ui_component_set_prop (popup_component, "/commands/TasklistPreferences", "hidden", "1", NULL); } gtk_widget_show (tasklist->applet); return TRUE; }