[Goodies-commits] r2034 - xfce4-taskmanager/trunk/src

Johannes Zellner nebulon at xfce.org
Fri Sep 15 15:25:15 CEST 2006


Author: nebulon
Date: 2006-09-15 13:25:12 +0000 (Fri, 15 Sep 2006)
New Revision: 2034

Modified:
   xfce4-taskmanager/trunk/src/callbacks.c
   xfce4-taskmanager/trunk/src/functions.c
   xfce4-taskmanager/trunk/src/interface.c
   xfce4-taskmanager/trunk/src/interface.h
   xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.c
Log:
* applied patch from Enrico Tr?\195?\182ger, adding tooltips to the cpu/mem usage-bars

Thank You ! :-)



Modified: xfce4-taskmanager/trunk/src/callbacks.c
===================================================================
--- xfce4-taskmanager/trunk/src/callbacks.c	2006-09-13 23:36:30 UTC (rev 2033)
+++ xfce4-taskmanager/trunk/src/callbacks.c	2006-09-15 13:25:12 UTC (rev 2034)
@@ -55,9 +55,11 @@
 {
 	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 = "";

Modified: xfce4-taskmanager/trunk/src/functions.c
===================================================================
--- xfce4-taskmanager/trunk/src/functions.c	2006-09-13 23:36:30 UTC (rev 2033)
+++ xfce4-taskmanager/trunk/src/functions.c	2006-09-15 13:25:12 UTC (rev 2034)
@@ -24,6 +24,9 @@
 {
 	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 @@
 
 	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;

Modified: xfce4-taskmanager/trunk/src/interface.c
===================================================================
--- xfce4-taskmanager/trunk/src/interface.c	2006-09-13 23:36:30 UTC (rev 2033)
+++ xfce4-taskmanager/trunk/src/interface.c	2006-09-15 13:25:12 UTC (rev 2034)
@@ -39,6 +39,9 @@
 	
 	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 @@
 	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 @@
 	xfce_about_info_set_homepage(about_info, "http://goodies.xfce.org");
 	xfce_about_info_add_credit(about_info, "Johannes Zellner", "webmaster at 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);

Modified: xfce4-taskmanager/trunk/src/interface.h
===================================================================
--- xfce4-taskmanager/trunk/src/interface.h	2006-09-13 23:36:30 UTC (rev 2033)
+++ xfce4-taskmanager/trunk/src/interface.h	2006-09-15 13:25:12 UTC (rev 2034)
@@ -45,9 +45,12 @@
 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

Modified: xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.c
===================================================================
--- xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.c	2006-09-13 23:36:30 UTC (rev 2033)
+++ xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.c	2006-09-15 13:25:12 UTC (rev 2034)
@@ -5,6 +5,7 @@
 	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 @@
 			
 			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 @@
 	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)




More information about the Goodies-commits mailing list