Update memory sizes to 64 bit and fix compilation warnings.
[lxde/lxtask.git] / src / callbacks.c
CommitLineData
580e78c2
HJYP
1/*
2 * xfce4-taskmanager - very simple taskmanger
3 *
4 * Copyright (c) 2006 Johannes Zellner, <webmaster@nebulon.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
24
25#include <glib/gi18n.h>
26
27#include "callbacks.h"
28
be8168d3 29extern guint rID;
30
580e78c2
HJYP
31void on_button3_toggled_event(GtkButton *button, GdkEventButton *event)
32{
33 full_view = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
34 change_list_store_view();
35}
36
37gboolean on_treeview1_button_press_event(GtkButton *button, GdkEventButton *event)
38{
39 if(event->button == 3)
40 {
41 GdkEventButton *mouseevent = (GdkEventButton *)event;
42 if(taskpopup == NULL)
43 taskpopup = create_taskpopup ();
44 gtk_menu_popup(GTK_MENU(taskpopup), NULL, NULL, NULL, NULL, mouseevent->button, mouseevent->time);
45 }
46 return FALSE;
47}
48
580e78c2
HJYP
49void handle_task_menu(GtkWidget *widget, gchar *signal)
50{
51 if(signal != NULL)
52 {
53 gint task_action = SIGNAL_NO;
54
55 switch(signal[0])
56 {
57 case 'K':
58 if(confirm(_("Really kill the task?")))
59 task_action = SIGNAL_KILL;
60 break;
61 case 'T':
62 if(confirm(_("Really terminate the task?")))
63 task_action = SIGNAL_TERM;
64 break;
65 case 'S':
66 task_action = SIGNAL_STOP;
67 break;
68 case 'C':
69 task_action = SIGNAL_CONT;
70 break;
71 default:
72 return;
73 }
74
75 if(task_action != SIGNAL_NO)
76 {
77 gchar *task_id = "";
78 GtkTreeModel *model;
79 GtkTreeIter iter;
80
81 if(gtk_tree_selection_get_selected(selection, &model, &iter))
82 {
a4a3fc0a 83 gtk_tree_model_get(model, &iter, COLUMN_PID, &task_id, -1);
204b61f9 84 if(atoi(task_id)==getpid() && task_action==SIGNAL_STOP)
85 {
86 show_error(_("Can't stop process self"));
87 }
88 else
89 {
90 send_signal_to_task(atoi(task_id), task_action);
91 refresh_task_list();
92 }
580e78c2
HJYP
93 }
94 }
580e78c2
HJYP
95 }
96}
97
98void handle_prio_menu(GtkWidget *widget, gchar *prio)
99{
100 gchar *task_id = "";
101 GtkTreeModel *model;
102 GtkTreeIter iter;
103
104 if(gtk_tree_selection_get_selected(selection, &model, &iter))
105 {
106 gtk_tree_model_get(model, &iter, 1, &task_id, -1);
107
108 set_priority_to_task(atoi(task_id), atoi(prio));
109 refresh_task_list();
110 }
111}
112
4ab5f812 113void on_show_tasks_toggled (GtkMenuItem *menuitem, gpointer data)
580e78c2 114{
4ab5f812
AG
115 gssize uid = (gssize)data;
116
117 if(uid == (gssize)own_uid)
580e78c2
HJYP
118 show_user_tasks = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
119 else if(uid == 0)
120 show_root_tasks = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
5ff47b84 121 else if(uid == -1)
580e78c2 122 show_other_tasks = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
5ff47b84 123 else {
124
125 show_full_path = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
126 change_full_path();
127 return;
128 }
129
580e78c2
HJYP
130 change_task_view();
131}
132
4ab5f812 133void on_show_cached_as_free_toggled (GtkMenuItem *menuitem, gpointer data)
580e78c2
HJYP
134{
135 show_cached_as_free = !show_cached_as_free;
136 change_task_view();
137}
138
139void on_quit(void)
140{
be8168d3 141 g_source_remove(rID);
580e78c2
HJYP
142 save_config();
143 free(config_file);
144
145 gtk_main_quit();
146}