[Goodies-commits] r3940 - in xfce4-taskmanager/trunk: . src

Johannes Zellner nebulon at xfce.org
Sun Feb 10 23:48:45 CET 2008


Author: nebulon
Date: 2008-02-10 22:48:45 +0000 (Sun, 10 Feb 2008)
New Revision: 3940

Modified:
   xfce4-taskmanager/trunk/INSTALL
   xfce4-taskmanager/trunk/src/callbacks.c
   xfce4-taskmanager/trunk/src/callbacks.h
   xfce4-taskmanager/trunk/src/functions.c
   xfce4-taskmanager/trunk/src/functions.h
   xfce4-taskmanager/trunk/src/interface.c
   xfce4-taskmanager/trunk/src/interface.h
   xfce4-taskmanager/trunk/src/types.h
   xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.c
   xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.h
Log:
- initial priority setting
- few bugfixes



Modified: xfce4-taskmanager/trunk/INSTALL
===================================================================
--- xfce4-taskmanager/trunk/INSTALL	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/INSTALL	2008-02-10 22:48:45 UTC (rev 3940)
@@ -1,13 +1,19 @@
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
-Foundation, Inc.
+Installation Instructions
+*************************
 
-   This file is free documentation; the Free Software Foundation gives
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
 unlimited permission to copy, distribute and modify it.
 
 Basic Installation
 ==================
 
-   These are generic installation instructions.
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
 
    The `configure' shell script attempts to guess correct values for
 various system-dependent variables used during compilation.  It uses
@@ -20,9 +26,9 @@
 
    It can also use an optional file (typically called `config.cache'
 and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  (Caching is
+the results of its tests to speed up reconfiguring.  Caching is
 disabled by default to prevent problems with accidental use of stale
-cache files.)
+cache files.
 
    If you need to do unusual things to compile the package, please try
 to figure out how `configure' could check whether to do them, and mail
@@ -32,20 +38,17 @@
 may remove or edit it.
 
    The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
 
 The simplest way to compile this package is:
 
   1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.  If you're
-     using `csh' on an old version of System V, you might need to type
-     `sh ./configure' instead to prevent `csh' from trying to execute
-     `configure' itself.
+     `./configure' to configure the package for your system.
 
-     Running `configure' takes awhile.  While running, it prints some
-     messages telling which features it is checking for.
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
 
   2. Type `make' to compile the package.
 
@@ -67,51 +70,49 @@
 Compilers and Options
 =====================
 
-   Some systems require unusual options for compilation or linking that
-the `configure' script does not know about.  Run `./configure --help'
-for details on some of the pertinent environment variables.
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
 
    You can give `configure' initial values for configuration parameters
 by setting variables in the command line or in the environment.  Here
 is an example:
 
-     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
 
    *Note Defining Variables::, for more details.
 
 Compiling For Multiple Architectures
 ====================================
 
-   You can compile the package for more than one kind of computer at the
+You can compile the package for more than one kind of computer at the
 same time, by placing the object files for each architecture in their
-own directory.  To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+own directory.  To do this, you can use GNU `make'.  `cd' to the
 directory where you want the object files and executables to go and run
 the `configure' script.  `configure' automatically checks for the
 source code in the directory that `configure' is in and in `..'.
 
-   If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory.  After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
 
 Installation Names
 ==================
 
-   By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc.  You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
 
    You can specify separate installation prefixes for
 architecture-specific files and architecture-independent files.  If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
 
    In addition, if you use an unusual directory layout you can give
-options like `--bindir=PATH' to specify different values for particular
+options like `--bindir=DIR' to specify different values for particular
 kinds of files.  Run `configure --help' for a list of the directories
 you can set and what kinds of files go in them.
 
@@ -122,7 +123,7 @@
 Optional Features
 =================
 
-   Some packages pay attention to `--enable-FEATURE' options to
+Some packages pay attention to `--enable-FEATURE' options to
 `configure', where FEATURE indicates an optional part of the package.
 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
 is something like `gnu-as' or `x' (for the X Window System).  The
@@ -137,11 +138,11 @@
 Specifying the System Type
 ==========================
 
-   There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on.  Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
 `--build=TYPE' option.  TYPE can either be a short name for the system
 type, such as `sun4', or a canonical name which has the form:
 
@@ -156,7 +157,7 @@
 need to know the machine type.
 
    If you are _building_ compiler tools for cross-compiling, you should
-use the `--target=TYPE' option to select the type of system they will
+use the option `--target=TYPE' to select the type of system they will
 produce code for.
 
    If you want to _use_ a cross compiler, that generates code for a
@@ -167,9 +168,9 @@
 Sharing Defaults
 ================
 
-   If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
 `configure' looks for `PREFIX/share/config.site' if it exists, then
 `PREFIX/etc/config.site' if it exists.  Or, you can set the
 `CONFIG_SITE' environment variable to the location of the site script.
@@ -178,7 +179,7 @@
 Defining Variables
 ==================
 
-   Variables not defined in a site shell script can be set in the
+Variables not defined in a site shell script can be set in the
 environment passed to `configure'.  However, some packages may run
 configure again during the build, and the customized values of these
 variables may be lost.  In order to avoid this problem, you should set
@@ -186,14 +187,18 @@
 
      ./configure CC=/usr/local2/bin/gcc
 
-will cause the specified gcc to be used as the C compiler (unless it is
+causes the specified `gcc' to be used as the C compiler (unless it is
 overridden in the site shell script).
 
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
 `configure' Invocation
 ======================
 
-   `configure' recognizes the following options to control how it
-operates.
+`configure' recognizes the following options to control how it operates.
 
 `--help'
 `-h'

Modified: xfce4-taskmanager/trunk/src/callbacks.c
===================================================================
--- xfce4-taskmanager/trunk/src/callbacks.c	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/callbacks.c	2008-02-10 22:48:45 UTC (rev 3940)
@@ -22,7 +22,7 @@
 
 void on_button1_button_press_event(GtkButton *button, GdkEventButton *event)
 {
-	GdkEventButton *mouseevent = (GdkEventButton *)event; 
+	GdkEventButton *mouseevent = (GdkEventButton *)event;
 	if(mainmenu == NULL)
 		mainmenu = create_mainmenu ();
 	gtk_menu_popup(GTK_MENU(mainmenu), NULL, NULL, NULL, NULL, mouseevent->button, mouseevent->time);
@@ -35,10 +35,10 @@
 }
 
 gboolean on_treeview1_button_press_event(GtkButton *button, GdkEventButton *event)
-{	
+{
 	if(event->button == 3)
 	{
-		GdkEventButton *mouseevent = (GdkEventButton *)event; 
+		GdkEventButton *mouseevent = (GdkEventButton *)event;
 		if(taskpopup == NULL)
 			taskpopup = create_taskpopup ();
 		gtk_menu_popup(GTK_MENU(taskpopup), NULL, NULL, NULL, NULL, mouseevent->button, mouseevent->time);
@@ -46,6 +46,7 @@
 	return FALSE;
 }
 
+
 void on_info1_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
 	show_about_dialog();
@@ -55,27 +56,75 @@
 {
 	if(signal != NULL)
 	{
-		gchar *s;
+		gint task_action = SIGNAL_NO;
 
-		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))
+		switch(signal[0])
 		{
+			case 'K':
+				if(xfce_confirm(_("Really kill the task?"), GTK_STOCK_YES, NULL))
+					task_action = SIGNAL_KILL;
+				break;
+			case 'T':
+				if(xfce_confirm(_("Really terminate the task?"), GTK_STOCK_YES, NULL))
+					task_action = SIGNAL_TERM;
+				break;
+			case 'S':
+				task_action = SIGNAL_STOP;
+				break;
+			case 'C':
+				task_action = SIGNAL_CONT;
+				break;
+			default:
+				return;
+		}
+		
+		if(task_action != SIGNAL_NO)
+		{
 			gchar *task_id = "";
 			GtkTreeModel *model;
 			GtkTreeIter iter;
-
+			
 			if(gtk_tree_selection_get_selected(selection, &model, &iter))
 			{
 				gtk_tree_model_get(model, &iter, 1, &task_id, -1);
-				send_signal_to_task(task_id, signal);
+				send_signal_to_task(atoi(task_id), task_action);
 				refresh_task_list();
 			}
 		}
+// 		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 = "";
+// 			GtkTreeModel *model;
+// 			GtkTreeIter iter;
+// 
+// 			if(gtk_tree_selection_get_selected(selection, &model, &iter))
+// 			{
+// 				gtk_tree_model_get(model, &iter, 1, &task_id, -1);
+// 				send_signal_to_task(atoi(task_id), signal);
+// 				refresh_task_list();
+// 			}
+// 		}
 	}
 }
 
+void handle_prio_menu(GtkWidget *widget, gchar *prio)
+{
+	gchar *task_id = "";
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+
+	if(gtk_tree_selection_get_selected(selection, &model, &iter))
+	{
+		gtk_tree_model_get(model, &iter, 1, &task_id, -1);
+
+		set_priority_to_task(atoi(task_id), atoi(prio));
+		refresh_task_list();
+	}
+}
+
 void on_show_tasks_toggled (GtkMenuItem *menuitem, gint uid)
 {
 	if(uid == own_uid)
@@ -84,7 +133,7 @@
 		show_root_tasks = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
 	else
 		show_other_tasks = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
-	
+
 	change_task_view();
 }
 
@@ -98,6 +147,6 @@
 {
 	save_config();
 	free(config_file);
-	
+
 	gtk_main_quit();
 }

Modified: xfce4-taskmanager/trunk/src/callbacks.h
===================================================================
--- xfce4-taskmanager/trunk/src/callbacks.h	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/callbacks.h	2008-02-10 22:48:45 UTC (rev 3940)
@@ -28,13 +28,17 @@
 #include <gtk/gtk.h>
 
 #include "functions.h"
-#include "interface.h"                       
+#include "interface.h"
 
+
+#include "xfce-taskmanager-linux.h"
+
 void on_button1_button_press_event(GtkButton *button, GdkEventButton *event);
 void on_button3_toggled_event(GtkButton *button, GdkEventButton *event);
 gboolean on_treeview1_button_press_event(GtkButton *button, GdkEventButton *event);
 void on_info1_activate (GtkMenuItem *menuitem,  gpointer user_data);
 void handle_task_menu(GtkWidget *widget, gchar *signal);
+void handle_prio_menu(GtkWidget *widget, gchar *prio);
 void on_show_tasks_toggled (GtkMenuItem *menuitem, gint uid);
 void on_show_cached_as_free_toggled (GtkMenuItem *menuitem, gint uid);
 

Modified: xfce4-taskmanager/trunk/src/functions.c
===================================================================
--- xfce4-taskmanager/trunk/src/functions.c	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/functions.c	2008-02-10 22:48:45 UTC (rev 3940)
@@ -18,7 +18,6 @@
  */
 
 #include "functions.h"
-#include "xfce-taskmanager-linux.h"
 
 static system_status *sys_stat =NULL;
 
@@ -52,17 +51,25 @@
 			if(new_tmp->pid == tmp->pid)
 			{
 				tmp->old_time = tmp->time;
-				
+
 				tmp->time = new_tmp->time;
-				
+
 				tmp->time_percentage = (gdouble)(tmp->time - tmp->old_time) * (gdouble)(1000.0 / (REFRESH_INTERVAL*num_cpus));
-				if((gint)tmp->ppid != (gint)new_tmp->ppid || strcmp(tmp->state,new_tmp->state) || (unsigned int)tmp->size != (unsigned int)new_tmp->size || (unsigned int)tmp->rss != (unsigned int)new_tmp->rss || (unsigned int)tmp->time != (unsigned int)tmp->old_time)
+				if(
+				    (gint)tmp->ppid != (gint)new_tmp->ppid ||
+				    strcmp(tmp->state,new_tmp->state) ||
+				    (unsigned int)tmp->size != (unsigned int)new_tmp->size ||
+				    (unsigned int)tmp->rss != (unsigned int)new_tmp->rss ||
+				    (unsigned int)tmp->time != (unsigned int)tmp->old_time ||
+				    tmp->prio != new_tmp->prio
+				 )
 				{
 					tmp->ppid = new_tmp->ppid;
 					strcpy(tmp->state, new_tmp->state);
 					tmp->size = new_tmp->size;
 					tmp->rss = new_tmp->rss;
-					
+					tmp->prio = new_tmp->prio;
+
 					refresh_list_item(i);
 				}
 				tmp->checked = TRUE;
@@ -110,29 +117,29 @@
 	}
 
 	g_array_free(new_task_list, TRUE);
-	
+
 	/* update the CPU and memory progress bars */
 	if (sys_stat == NULL)
 		sys_stat = g_new (system_status, 1);
 	get_system_status (sys_stat);
-	
+
 	memory_used = sys_stat->mem_total - sys_stat->mem_free;
 	if ( show_cached_as_free )
 	{
 		memory_used-=sys_stat->mem_cached;
 	}
-	mem_tooltip = g_strdup_printf (_("%d kB of %d kB used"), memory_used, sys_stat->mem_total);
+	mem_tooltip = g_strdup_printf (_("%d kB of %d kB used"), memory_used / 1024, sys_stat->mem_total / 1024);
 	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),  (gdouble)memory_used / sys_stat->mem_total);
-	
+
 	cpu_usage = get_cpu_usage (sys_stat);
 	cpu_tooltip = g_strdup_printf (_("%0.0f %%"), cpu_usage * 100.0);
 	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);
-	
+
 	return TRUE;
 }
 
@@ -192,7 +199,7 @@
 
 	win_width = xfce_rc_read_int_entry(rc_file, "win_width", 500);
 	win_height = xfce_rc_read_int_entry(rc_file, "win_height", 400);
-	
+
 	xfce_rc_close(rc_file);
 }
 

Modified: xfce4-taskmanager/trunk/src/functions.h
===================================================================
--- xfce4-taskmanager/trunk/src/functions.h	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/functions.h	2008-02-10 22:48:45 UTC (rev 3940)
@@ -36,7 +36,7 @@
 #include "types.h"
 #include "interface.h"
 
-#ifdef LINUX
+#ifdef __LINUX__
 #include "xfce-taskmanager-linux.h"
 #endif
 
@@ -46,7 +46,6 @@
 
 gboolean refresh_task_list(void);
 gdouble get_cpu_usage(system_status *sys_stat);
-void send_signal_to_task(gchar *task_id, gchar *signal);
 
 /* Configurationfile support */
 void load_config(void);

Modified: xfce4-taskmanager/trunk/src/interface.c
===================================================================
--- xfce4-taskmanager/trunk/src/interface.c	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/interface.c	2008-02-10 22:48:45 UTC (rev 3940)
@@ -35,12 +35,12 @@
 	GtkWidget *button1;
 	GtkWidget *button2;
 	GtkWidget *button3;
-	
+
 	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);
@@ -53,7 +53,7 @@
 	system_info_box = gtk_hbox_new (FALSE, 10);
 	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"));
@@ -61,7 +61,7 @@
 	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"));
@@ -81,26 +81,26 @@
 	gtk_container_add (GTK_CONTAINER (scrolledwindow1), treeview);
 
 	create_list_store();
-	
+
 	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
 
 	gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(list_store));
-	
+
 	gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(list_store), 1, GTK_SORT_ASCENDING);
 
 	bbox1 = gtk_hbutton_box_new();
 	gtk_box_pack_start(GTK_BOX(vbox1), bbox1, FALSE, TRUE, 0);
 	gtk_widget_show (bbox1);
-  
+
 	button2 = gtk_button_new_from_stock ("gtk-preferences");
 	gtk_widget_show (button2);
 	gtk_box_pack_start (GTK_BOX (bbox1), button2, FALSE, FALSE, 0);
-	
+
 	button3 = gtk_toggle_button_new_with_label (_("more details"));
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button3), full_view);
 	gtk_widget_show (button3);
 	gtk_box_pack_start (GTK_BOX (bbox1), button3, FALSE, FALSE, 0);
-	
+
 	button1 = gtk_button_new_from_stock ("gtk-quit");
 	gtk_widget_show (button1);
 	gtk_box_pack_start (GTK_BOX (bbox1), button1, FALSE, FALSE, 0);
@@ -110,7 +110,7 @@
 	g_signal_connect ((gpointer) button1, "clicked",  G_CALLBACK (on_quit),  NULL);
 	g_signal_connect ((gpointer) button2, "button_release_event",  G_CALLBACK (on_button1_button_press_event),  NULL);
 	g_signal_connect ((gpointer) button3, "toggled",  G_CALLBACK (on_button3_toggled_event),  NULL);
-	
+
 	return window;
 }
 
@@ -118,8 +118,9 @@
 {
 	GtkCellRenderer *cell_renderer;
 
-	list_store = gtk_tree_store_new(8, G_TYPE_STRING, G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
-	
+	/* my change 8->9 */
+	list_store = gtk_tree_store_new(9, G_TYPE_STRING, G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
+
 	cell_renderer = gtk_cell_renderer_text_new();
 
 	column = gtk_tree_view_column_new_with_attributes(_("Command"), cell_renderer, "text", 0, NULL);
@@ -127,49 +128,57 @@
 	gtk_tree_view_column_set_sort_column_id(column, 0);
 	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 0, compare_string_list_item, (void *)0, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-	
+
 	column = gtk_tree_view_column_new_with_attributes(_("PID"), cell_renderer, "text", 1, NULL);
 	gtk_tree_view_column_set_resizable(column, TRUE);
 	gtk_tree_view_column_set_sort_column_id(column, 1);
 	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 1, compare_int_list_item, (void *)1, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-	
+
 	column = gtk_tree_view_column_new_with_attributes(_("PPID"), cell_renderer, "text", 2, NULL);
 	gtk_tree_view_column_set_resizable(column, TRUE);
 	gtk_tree_view_column_set_sort_column_id(column, 2);
 	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 2, compare_string_list_item, (void *)2, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-	
+
 	column = gtk_tree_view_column_new_with_attributes(_("State"), cell_renderer, "text", 3, NULL);
 	gtk_tree_view_column_set_resizable(column, TRUE);
 	gtk_tree_view_column_set_sort_column_id(column, 3);
 	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 3, compare_int_list_item, (void *)3, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-	
+
 	column = gtk_tree_view_column_new_with_attributes(_("VM-Size"), cell_renderer, "text", 4, NULL);
 	gtk_tree_view_column_set_resizable(column, TRUE);
 	gtk_tree_view_column_set_sort_column_id(column, 4);
 	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 4, compare_int_list_item, (void *)4, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-		
+
 	column = gtk_tree_view_column_new_with_attributes(_("RSS"), cell_renderer, "text", 5, NULL);
 	gtk_tree_view_column_set_resizable(column, TRUE);
 	gtk_tree_view_column_set_sort_column_id(column, 5);
 	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 5, compare_int_list_item, (void *)5, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-		
+
 	column = gtk_tree_view_column_new_with_attributes(_("User"), cell_renderer, "text", 6, NULL);
 	gtk_tree_view_column_set_resizable(column, TRUE);
 	gtk_tree_view_column_set_sort_column_id(column, 6);
 	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 6, compare_string_list_item, (void *)6, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-	
+
 	column = gtk_tree_view_column_new_with_attributes(_("CPU%"), cell_renderer, "text", 7, NULL);
 	gtk_tree_view_column_set_resizable(column, TRUE);
 	gtk_tree_view_column_set_sort_column_id(column, 7);
 	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 7, compare_int_list_item, (void *)7, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-	
+
+	/* my change */
+	column = gtk_tree_view_column_new_with_attributes(_("Prio"), cell_renderer, "text", 8, NULL);
+	gtk_tree_view_column_set_resizable(column, TRUE);
+	gtk_tree_view_column_set_sort_column_id(column, 8);
+	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list_store), 8, compare_int_list_item, (void *)8, NULL);
+	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+	/* /my change */
+
 	change_list_store_view();
 }
 
@@ -199,10 +208,48 @@
 	gtk_widget_show (menu_item);
 	gtk_container_add (GTK_CONTAINER (taskpopup), menu_item);
 	g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_task_menu), "KILL");
-	
+
+	menu_item = gtk_menu_item_new_with_mnemonic ( _("Priority") );
+	gtk_menu_item_set_submenu((gpointer) menu_item, create_prio_submenu());
+	gtk_widget_show (menu_item);
+	gtk_container_add (GTK_CONTAINER (taskpopup), menu_item);
+
 	return taskpopup;
 }
 
+GtkWidget *create_prio_submenu(void)
+{
+	GtkWidget *prio_submenu = gtk_menu_new ();
+	GtkWidget *menu_item;
+
+	menu_item = gtk_menu_item_new_with_mnemonic (_("  -10"));
+	gtk_widget_show (menu_item);
+	gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
+	g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "-10");
+	
+	menu_item = gtk_menu_item_new_with_mnemonic (_("  -5"));
+	gtk_widget_show (menu_item);
+	gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
+	g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "-5");
+
+	menu_item = gtk_menu_item_new_with_mnemonic (_("    0"));
+	gtk_widget_show (menu_item);
+	gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
+	g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "0");
+
+	menu_item = gtk_menu_item_new_with_mnemonic (_("   5"));
+	gtk_widget_show (menu_item);
+	gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
+	g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "5");
+
+	menu_item = gtk_menu_item_new_with_mnemonic (_("   10"));
+	gtk_widget_show (menu_item);
+	gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
+	g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "10");
+	
+	return prio_submenu;
+}
+
 GtkWidget* create_mainmenu (void)
 {
 	GtkWidget *mainmenu;
@@ -262,16 +309,16 @@
 {
 	GtkWidget *about_dialog;
 	XfceAboutInfo *about_info;
-	
+
 	about_info = xfce_about_info_new("xfce4-taskmanager", VERSION, "Xfce4-Taskmanager is a easy to use Taskmanager.",XFCE_COPYRIGHT_TEXT("2005", "Johannes Zellner"), XFCE_LICENSE_GPL);
 	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_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);
-	
+
 	xfce_about_info_free(about_info);
 }
 
@@ -287,16 +334,17 @@
 	if(iter != NULL)
 	{
 		struct task *task = &g_array_index(task_array, struct task, i);
-		
+
 		gchar *pid = g_strdup_printf("%i", task->pid);
 		gchar *ppid = g_strdup_printf("%i", task->ppid);
 		gchar *state = g_strdup_printf("%s", task->state);
-		gchar *size = g_strdup_printf("%i kB", task->size);
-		gchar *rss = g_strdup_printf("%i kB", task->rss);
+		gchar *size = g_strdup_printf("%i kB", task->size/1024);
+		gchar *rss = g_strdup_printf("%i kB", task->rss/1024);
 		gchar *name = g_strdup_printf("%s", task->name);
 		gchar *uname = g_strdup_printf("%s", task->uname);
 		gchar *time = g_strdup_printf("%0d%%", (guint)task->time_percentage);
-		
+		gchar *prio = g_strdup_printf("%i", task->prio);	/* my change */
+
 		gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_NAME, name, -1);
 		gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_PID, pid, -1);
 		gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_PPID, ppid, -1);
@@ -305,7 +353,8 @@
 		gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_RSS, rss, -1);
 		gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_UNAME, uname, -1);
 		gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_TIME, time, -1);
-		
+		gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_PRIO, prio, -1);	/* my change */
+
 		g_free(pid);
 		g_free(ppid);
 		g_free(state);
@@ -314,32 +363,16 @@
 		g_free(name);
 		g_free(uname);
 		g_free(time);
+		g_free(prio);	/* my change */
 	}
 }
 
-
-
-void send_signal_to_task(gchar *task_id, gchar *signal)
-{
-	if(task_id != "" && signal != NULL)
-	{
-		gchar command[64] = "kill -";
-		g_strlcat(command,signal, sizeof command);
-		g_strlcat(command," ", sizeof command);
-		g_strlcat(command,task_id, sizeof command);
-		
-		if(system(command) != 0)
-			xfce_err("Couldn't %s the task with ID %s", signal, task_id);
-	}
-}
-
-
 void add_new_list_item(gint i)
 {
 		GtkTreeIter iter;
 
 		gtk_tree_store_append(GTK_TREE_STORE(list_store), &iter, NULL);
-		
+
 		fill_list_item(i, &iter);
 }
 
@@ -348,7 +381,7 @@
 	GtkTreeIter iter;
 	gboolean valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter);
 	struct task task = g_array_index(task_array, struct task, i);
-		
+
 	while(valid)
 	{
 		gchar *str_data = "";
@@ -370,7 +403,7 @@
 {
 	GtkTreeIter iter;
 	gboolean valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter);
-	
+
 	while(valid)
 	{
 		gchar *str_data = "";
@@ -389,10 +422,10 @@
 }
 
 gint compare_int_list_item(GtkTreeModel *model, GtkTreeIter *iter1, GtkTreeIter *iter2, gpointer column)
-{	
+{
 	gchar *s1 = "";
 	gchar *s2 = "";
-        
+
 	gint ret = 0;
 
 	gtk_tree_model_get(model, iter1, column, &s1, -1);
@@ -400,43 +433,43 @@
 
 	gint i1 = 0;
 	gint i2 = 0;
-	
+
 	if(s1 != NULL)
 		i1 = atoi(s1);
-		
+
 	if(s2 != NULL)
 		i2 = atoi(s2);
-		
-	ret = i1 - i2;
-	
+
+	ret = i2 - i1;
+
 	if(s1 != NULL)
 		g_free(s1);
 	if(s2 != NULL)
 		g_free(s2);
-	
+
 	return ret;
 }
 
 gint compare_string_list_item(GtkTreeModel *model, GtkTreeIter *iter1, GtkTreeIter *iter2, gpointer column)
-{	
+{
 	gchar *s1 = "";
 	gchar *s2 = "";
-        
+
 	gint ret = 0;
 
 	gtk_tree_model_get(model, iter1, GPOINTER_TO_INT(column), &s1, -1);
 	gtk_tree_model_get(model, iter2, GPOINTER_TO_INT(column), &s2, -1);
 
 	if(s1 != NULL && s2 != NULL)
-		ret = strcmp(s1, s2);
+		ret = strcmp(s2, s1);
 	else
 		ret = 0;
-	
+
 	if(s1 != NULL)
 		g_free(s1);
 	if(s2 != NULL)
 		g_free(s2);
-	
+
 	return ret;
 }
 
@@ -445,15 +478,15 @@
 {
 	gtk_tree_store_clear(GTK_TREE_STORE(list_store));
 	gint i = 0;
-	
+
 	for(i = 0; i < tasks; i++)
 	{
 		struct task task = g_array_index(task_array, struct task, i);
-		
+
 		if((task.uid == own_uid && show_user_tasks) || (task.uid == 0 && show_root_tasks) || (task.uid != own_uid && task.uid != 0 && show_other_tasks))
 			add_new_list_item(i);
 	}
-	
+
 	refresh_task_list();
 }
 

Modified: xfce4-taskmanager/trunk/src/interface.h
===================================================================
--- xfce4-taskmanager/trunk/src/interface.h	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/interface.h	2008-02-10 22:48:45 UTC (rev 3940)
@@ -46,6 +46,7 @@
 GtkWidget *mainmenu;
 GtkTooltips *tooltips;
 GtkWidget *taskpopup;
+GtkWidget *priopopup;
 GtkWidget *cpu_usage_progress_bar;
 GtkWidget *mem_usage_progress_bar;
 GtkWidget *cpu_usage_progress_bar_box;
@@ -59,6 +60,7 @@
 #define COLUMN_RSS	5
 #define COLUMN_UNAME	6
 #define COLUMN_TIME	7
+#define COLUMN_PRIO 	8
 
 GtkTreeViewColumn *column;
 
@@ -68,6 +70,7 @@
 GtkWidget* create_main_window (void);
 GtkWidget* create_taskpopup (void);
 GtkWidget* create_mainmenu (void);
+GtkWidget *create_prio_submenu(void);
 
 void show_about_dialog(void);
 

Modified: xfce4-taskmanager/trunk/src/types.h
===================================================================
--- xfce4-taskmanager/trunk/src/types.h	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/types.h	2008-02-10 22:48:45 UTC (rev 3940)
@@ -38,6 +38,7 @@
 	gint time;
 	gint old_time;
 	gdouble time_percentage;
+	gint prio;	/* my change */
 };
 
 typedef struct

Modified: xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.c
===================================================================
--- xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.c	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.c	2008-02-10 22:48:45 UTC (rev 3940)
@@ -36,7 +36,7 @@
 	sprintf(cmdline_filename, "/proc/%i/cmdline", pid);
 
 	stat(filename, &status);
-	
+
 	task.pid = -1;
 	task.checked = FALSE;
 
@@ -46,7 +46,7 @@
 		{
 			gint utime = 0;
 			gint stime = 0;
-			
+
 			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
@@ -69,7 +69,7 @@
 						&idummy,	// cutime " waited for children in user
 						&idummy,	// cstime " kernel mode
 						&idummy,	// priority (nice value + fifteen)
-						&idummy,	// nice range from 19 to -19
+						&task.prio,	// nice range from 19 to -19	/* my change */
 						&idummy,	// hardcoded 0
 
 						&idummy,	// itrealvalue time in jiffies to next SIGALRM send to this process
@@ -108,8 +108,8 @@
 		if(passwdp != NULL && passwdp->pw_name != NULL)
 			g_strlcpy(task.uname, passwdp->pw_name, sizeof task.uname);
 	}
-	
 
+
 	if(task_file != NULL)
 		fclose(task_file);
 
@@ -124,16 +124,16 @@
 				g_strlcpy(task.name, g_strrstr(dummy,"/")+1, 255);
 			else
 				g_strlcpy(task.name, dummy, 255);
-				
+
 			// workaround for cmd-line entries with leading "-"
 			if(g_str_has_prefix(task.name, "-"))
 				sscanf(task.name, "-%255s", task.name);
 		}
 	}
-	
+
 	if(cmdline_file != NULL)
 		fclose(cmdline_file);
-	
+
 	if(g_str_has_suffix(task.name, ")"))
 		*g_strrstr(task.name, ")") = '\0';
 
@@ -147,7 +147,7 @@
 	GArray *task_list;
 
 	task_list = g_array_new (FALSE, FALSE, sizeof (struct task));
-	
+
 	if((dir = opendir("/proc/")) == NULL)
 	{
 		fprintf(stderr, "Error: couldn't load the /proc directory\n");
@@ -155,7 +155,7 @@
 	}
 
 	gint count = 0;
-	
+
 	while((dir_entry = readdir(dir)) != NULL)
 	{
 		if(atoi(dir_entry->d_name) != 0)
@@ -200,9 +200,9 @@
 		return FALSE;
 	}
 
-	
+
 	file = fopen (file_name, "r");
-	
+
 	if (file)
 	{
 		if ( fgets (buffer, 100, file) != NULL )
@@ -228,19 +228,19 @@
 	FILE *file;
 	gchar *file_name;
 	gchar *buffer;
-	
+
 	buffer = g_new (gchar, 100);
-	
+
 	file_name = g_strdup ("/proc/meminfo");
-	
+
 	if (!g_file_test (file_name, G_FILE_TEST_EXISTS))
 	{
 		g_free(file_name);
 		return FALSE;
 	}
-	
+
 	file = fopen (file_name, "r");
-	
+
 	if (file)
 	{
 		while (fgets (buffer, 100, file) != NULL)
@@ -253,24 +253,24 @@
 	}
 	g_free (buffer);
 	g_free (file_name);
-	
+
 	buffer = g_new (gchar, 100);
-	
+
 	file_name = g_strdup ("/proc/cpuinfo");
-	
+
 	if (!g_file_test (file_name, G_FILE_TEST_EXISTS))
 	{
 		g_free(file_name);
 		return FALSE;
 	}
-	
+
 	file = fopen (file_name, "r");
-	
+
 	sys_stat->cpu_count = -1;
 
 	if (file)
 	{
-		
+
 		while (fgets (buffer, 100, file) != NULL)
 		{
 			sscanf (buffer, "processor : %i", &sys_stat->cpu_count);
@@ -280,6 +280,33 @@
 	}
 	g_free (buffer);
 	g_free (file_name);
-	
+
 	return TRUE;
 }
+
+void send_signal_to_task(gint task_id, gint signal)
+{
+	if(task_id > 0 && signal != 0)
+	{
+		gint ret = 0;
+		
+		ret = kill(task_id, signal);
+
+		if(ret != 0)
+			xfce_err(_("Couldn't send signal to the task with ID %d"), signal, task_id);
+	}
+}
+
+
+void set_priority_to_task(gint task_id, gint prio)
+{
+	if(task_id > 0)
+	{
+		gchar command[128] = "";
+		g_sprintf(command, "renice %d %d > /dev/null", prio, task_id);
+		
+		if(system(command) != 0)
+			xfce_err(_("Couldn't set priority %d to the task with ID %d"), prio, task_id);
+	}
+}
+

Modified: xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.h
===================================================================
--- xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.h	2008-02-08 16:53:36 UTC (rev 3939)
+++ xfce4-taskmanager/trunk/src/xfce-taskmanager-linux.h	2008-02-10 22:48:45 UTC (rev 3940)
@@ -17,22 +17,32 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#ifndef LINUX_H
-#define LINUX_H
+#ifndef XFCE4_TASKMANAGER_LINUX_H
+#define XFCE4_TASKMANAGER_LINUX_H
 
 #include <glib.h>
+#include <libxfcegui4/libxfcegui4.h>
 #include <dirent.h>
 #include <pwd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdlib.h>
 #include <string.h>
+#include <signal.h>
 
 #include "types.h"
 
+#define SIGNAL_NO	0
+#define SIGNAL_KILL	SIGKILL
+#define SIGNAL_TERM	SIGINT
+#define SIGNAL_CONT	SIGCONT
+#define SIGNAL_STOP	SIGSTOP
+
 struct task get_task_details(gint pid);
 GArray *get_task_list(void); 
 gboolean get_system_status(system_status *sys_stat);
 gboolean get_cpu_usage_from_proc(system_status *sys_stat);
+void send_signal_to_task(gint task_id, gint signal);
+void set_priority_to_task(gint task_id, gint prio);
 
 #endif




More information about the Goodies-commits mailing list