diff --git a/src/callbacks.c b/src/callbacks.c index d6b5381..d2ddb93 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -55,9 +55,11 @@ void handle_task_menu(GtkWidget *widget, gchar *signal) { if(signal != NULL) { - gchar s[32]; + gchar *s; - sprintf(s, "Really %s the Task?", signal); + if (strcmp(signal, "KILL") == 0) s = _("Really kill the task?"); + else s = _("Really terminate the task?"); + if(strcmp(signal, "STOP") == 0 || strcmp(signal, "CONT") == 0 || xfce_confirm(s, GTK_STOCK_YES, NULL)) { gchar *task_id = ""; diff --git a/src/functions.c b/src/functions.c index f935443..1d0ec75 100644 --- a/src/functions.c +++ b/src/functions.c @@ -24,6 +24,9 @@ gboolean refresh_task_list(void) { gint i, j; GArray *new_task_list; + gchar *cpu_tooltip, *mem_tooltip; + gdouble cpu_usage; + system_status *sys_stat; /* gets the new task list */ new_task_list = (GArray*) get_task_list(); @@ -102,10 +105,21 @@ gboolean refresh_task_list(void) g_array_free(new_task_list, TRUE); - system_status *sys_stat = g_new (system_status, 1); + /* update the CPU and memory progress bars */ + sys_stat = g_new (system_status, 1); get_system_status (sys_stat); + + mem_tooltip = g_strdup_printf (_("%d kB of %d kB used"), sys_stat->mem_total - sys_stat->mem_free, sys_stat->mem_total); + gtk_tooltips_set_tip (tooltips, mem_usage_progress_bar_box, mem_tooltip, NULL); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (mem_usage_progress_bar), 1.0 - ( (gdouble) sys_stat->mem_free / sys_stat->mem_total )); - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (cpu_usage_progress_bar), get_cpu_usage(sys_stat)); + + cpu_usage = get_cpu_usage (sys_stat); + cpu_tooltip = g_strdup_printf (_("%0.0f %%"), cpu_usage * 100); + gtk_tooltips_set_tip (tooltips, cpu_usage_progress_bar_box, cpu_tooltip, NULL); + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (cpu_usage_progress_bar), cpu_usage); + + g_free (mem_tooltip); + g_free (cpu_tooltip); g_free (sys_stat); return TRUE; diff --git a/src/interface.c b/src/interface.c index 4ef6ad7..a5df301 100644 --- a/src/interface.c +++ b/src/interface.c @@ -39,6 +39,9 @@ GtkWidget* create_main_window (void) GtkWidget *system_info_box; + tooltips = gtk_tooltips_new(); + gtk_tooltips_enable(tooltips); + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), _("xfce4-taskmanager")); gtk_window_set_default_size (GTK_WINDOW (window), win_width, win_height); @@ -52,15 +55,21 @@ GtkWidget* create_main_window (void) gtk_widget_show (system_info_box); gtk_box_pack_start (GTK_BOX (vbox1), system_info_box, FALSE, TRUE, 0); + cpu_usage_progress_bar_box = gtk_event_box_new (); cpu_usage_progress_bar = gtk_progress_bar_new (); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (cpu_usage_progress_bar), _("cpu usage")); gtk_widget_show (cpu_usage_progress_bar); - gtk_box_pack_start (GTK_BOX (system_info_box), cpu_usage_progress_bar, TRUE, TRUE, 0); + gtk_widget_show (cpu_usage_progress_bar_box); + gtk_container_add (GTK_CONTAINER (cpu_usage_progress_bar_box), cpu_usage_progress_bar); + gtk_box_pack_start (GTK_BOX (system_info_box), cpu_usage_progress_bar_box, TRUE, TRUE, 0); + mem_usage_progress_bar_box = gtk_event_box_new (); mem_usage_progress_bar = gtk_progress_bar_new (); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (mem_usage_progress_bar), _("memory usage")); gtk_widget_show (mem_usage_progress_bar); - gtk_box_pack_start (GTK_BOX (system_info_box), mem_usage_progress_bar, TRUE, TRUE, 0); + gtk_widget_show (mem_usage_progress_bar_box); + gtk_container_add (GTK_CONTAINER (mem_usage_progress_bar_box), mem_usage_progress_bar); + gtk_box_pack_start (GTK_BOX (system_info_box), mem_usage_progress_bar_box, TRUE, TRUE, 0); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow1); @@ -252,7 +261,7 @@ void show_about_dialog(void) xfce_about_info_set_homepage(about_info, "http://goodies.xfce.org"); xfce_about_info_add_credit(about_info, "Johannes Zellner", "webmaster@nebulon.de", "Original Author"); - about_dialog = xfce_about_dialog_new(GTK_WINDOW(main_window), about_info, NULL); + about_dialog = xfce_about_dialog_new_with_values(GTK_WINDOW(main_window), about_info, NULL); g_signal_connect(G_OBJECT(about_dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL); gtk_window_set_title (GTK_WINDOW (about_dialog), _("xfce4-taskmanager")); gtk_widget_show(about_dialog); diff --git a/src/interface.h b/src/interface.h index 28fff04..6899603 100644 --- a/src/interface.h +++ b/src/interface.h @@ -45,9 +45,12 @@ GtkTreeStore *list_store; GtkTreeSelection *selection; GtkWidget *treeview; GtkWidget *mainmenu; +GtkTooltips *tooltips; GtkWidget *taskpopup; GtkWidget *cpu_usage_progress_bar; GtkWidget *mem_usage_progress_bar; +GtkWidget *cpu_usage_progress_bar_box; +GtkWidget *mem_usage_progress_bar_box; #define COLUMN_NAME 0 #define COLUMN_PID 1 diff --git a/src/xfce-taskmanager-linux.c b/src/xfce-taskmanager-linux.c index 39139d5..ff8c452 100755 --- a/src/xfce-taskmanager-linux.c +++ b/src/xfce-taskmanager-linux.c @@ -5,6 +5,7 @@ struct task get_task_details(gint pid) FILE *task_file; FILE *cmdline_file; gchar dummy[255]; + gint idummy; gchar buffer_status[255]; struct task task; struct passwd *passwdp; @@ -29,54 +30,54 @@ struct task get_task_details(gint pid) sscanf(buffer_status, "%i (%255s %1s %i %i %i %i %i %255s %255s %255s %255s %255s %i %i %i %i %i %i %i %i %i %i %i %255s %255s %255s %i %255s %255s %255s %255s %255s %255s %255s %255s %255s %255s %i %255s %255s", &task.pid, // processid - &task.name, // processname - &task.state, // processstate + task.name, // processname + task.state, // processstate &task.ppid, // parentid - &dummy, // processs groupid + &idummy, // processs groupid - &dummy, // session id - &dummy, // tty id - &dummy, // tpgid: The process group ID of the process running on tty of the process - &dummy, // flags - &dummy, // minflt minor faults the process has maid + &idummy, // session id + &idummy, // tty id + &idummy, // tpgid: The process group ID of the process running on tty of the process + dummy, // flags + dummy, // minflt minor faults the process has maid - &dummy, // cminflt - &dummy, // majflt - &dummy, // cmajflt + dummy, // cminflt + dummy, // majflt + dummy, // cmajflt &utime, // utime the number of jiffies that this process has scheduled in user mode &stime, // stime " kernel mode - &dummy, // cutime " waited for children in user - &dummy, // cstime " kernel mode - &dummy, // priority (nice value + fifteen) - &dummy, // nice range from 19 to -19 - &dummy, // hardcoded 0 + &idummy, // cutime " waited for children in user + &idummy, // cstime " kernel mode + &idummy, // priority (nice value + fifteen) + &idummy, // nice range from 19 to -19 + &idummy, // hardcoded 0 - &dummy, // itrealvalue time in jiffies to next SIGALRM send to this process - &dummy, // starttime jiffies the process startet after system boot + &idummy, // itrealvalue time in jiffies to next SIGALRM send to this process + &idummy, // starttime jiffies the process startet after system boot &task.size, // vsize in bytes &task.rss, // rss - &dummy, // rlim limit in bytes for rss + dummy, // rlim limit in bytes for rss - &dummy, // startcode - &dummy, // endcode - &dummy, // startstack - &dummy, // kstkesp value of esp (stack pointer) - &dummy, // kstkeip value of EIP (instruction pointer) + dummy, // startcode + dummy, // endcode + &idummy, // startstack + dummy, // kstkesp value of esp (stack pointer) + dummy, // kstkeip value of EIP (instruction pointer) - &dummy, // signal. bitmap of pending signals - &dummy, // blocked: bitmap of blocked signals - &dummy, // sigignore: bitmap of ignored signals - &dummy, // sigcatch: bitmap of catched signals - &dummy, // wchan + dummy, // signal. bitmap of pending signals + dummy, // blocked: bitmap of blocked signals + dummy, // sigignore: bitmap of ignored signals + dummy, // sigcatch: bitmap of catched signals + dummy, // wchan - &dummy, // nswap - &dummy, // cnswap - &dummy, // exit_signal - &dummy, // CPU number last executed on - &dummy, + dummy, // nswap + dummy, // cnswap + dummy, // exit_signal + &idummy, // CPU number last executed on + dummy, - &dummy + dummy ); task.time = stime + utime; task.old_time = task.time; @@ -96,8 +97,8 @@ struct task get_task_details(gint pid) if((cmdline_file = fopen(cmdline_filename,"r")) != NULL) { gchar dummy[255]; - strcpy(&dummy, ""); - fscanf(cmdline_file, "%255s", &dummy); + strcpy(dummy, ""); + fscanf(cmdline_file, "%255s", dummy); if(strcmp(dummy, "") != 0) { if(g_strrstr(dummy,"/") != NULL)