diff options
author | Perberos <[email protected]> | 2012-04-23 05:37:29 -0300 |
---|---|---|
committer | Perberos <[email protected]> | 2012-04-23 05:37:29 -0300 |
commit | 36f6cbeb068f46ebf165e718005699979acaa36f (patch) | |
tree | 25f573671284f6447f92db54b78e910f4f7953a4 /applets/wncklet | |
parent | 5b2e5096babd9008c9f29836a93302816e15b68f (diff) | |
download | mate-panel-36f6cbeb068f46ebf165e718005699979acaa36f.tar.bz2 mate-panel-36f6cbeb068f46ebf165e718005699979acaa36f.tar.xz |
adding an item for system monitors on the windows list applet
Diffstat (limited to 'applets/wncklet')
-rw-r--r-- | applets/wncklet/window-list-menu.xml | 2 | ||||
-rw-r--r-- | applets/wncklet/window-list.c | 69 |
2 files changed, 71 insertions, 0 deletions
diff --git a/applets/wncklet/window-list-menu.xml b/applets/wncklet/window-list-menu.xml index 008d382d..615ed655 100644 --- a/applets/wncklet/window-list-menu.xml +++ b/applets/wncklet/window-list-menu.xml @@ -1,3 +1,5 @@ +<menuitem name="Tasklist System Monitor Item" action="TasklistSystemMonitor" /> +<separator/> <menuitem name="Tasklist Preferences Item" action="TasklistPreferences" /> <menuitem name="Tasklist Help Item" action="TasklistHelp" /> <menuitem name="Tasklist About Item" action="TasklistAbout" /> diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c index edde537d..a7ed6197 100644 --- a/applets/wncklet/window-list.c +++ b/applets/wncklet/window-list.c @@ -64,6 +64,7 @@ typedef struct { guint listeners [3]; } TasklistData; +static void callSystemMonitor(GtkAction* action, TasklistData* tasklist); static void display_properties_dialog(GtkAction* action, TasklistData* tasklist); static void display_help_dialog(GtkAction* action, TasklistData* tasklist); static void display_about_dialog(GtkAction* action, TasklistData* tasklist); @@ -170,8 +171,23 @@ static void destroy_tasklist(GtkWidget* widget, TasklistData* tasklist) g_free(tasklist); } +/* TODO: this is sad, should be used a function to retrieve applications from + * .desktop or some like that. */ +static const char* listOfSystemMonitors[] = { + "mate-system-monitor", + "gnome-system-monitor", +}; + static const GtkActionEntry tasklist_menu_actions[] = { { + "TasklistSystemMonitor", + "utilities-system-monitor", + N_("_System Monitor"), + NULL, + NULL, + G_CALLBACK(callSystemMonitor) + }, + { "TasklistPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), @@ -525,6 +541,34 @@ gboolean window_list_applet_fill(MatePanelApplet* 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(listOfSystemMonitors); i += 1) + { + programpath = g_find_program_in_path(listOfSystemMonitors[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); @@ -544,6 +588,31 @@ gboolean window_list_applet_fill(MatePanelApplet* applet) return TRUE; } +static void callSystemMonitor(GtkAction* action, TasklistData* tasklist) +{ + char* argv[2] = {NULL, NULL}; + char* programpath; + int i; + + for (i = 0; i < G_N_ELEMENTS(listOfSystemMonitors); i += 1) + { + programpath = g_find_program_in_path(listOfSystemMonitors[i]); + + if (programpath != NULL) + { + g_free(programpath); + + argv[0] = listOfSystemMonitors[i]; + + gdk_spawn_on_screen(gtk_widget_get_screen(tasklist->applet), NULL, argv, NULL, + G_SPAWN_SEARCH_PATH, + NULL, NULL, NULL, NULL); + + return; + } + } +} + static void display_help_dialog(GtkAction* action, TasklistData* tasklist) { |