From 29f3f00619cc95cf5e4aae54394014f50aaec716 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Sun, 9 Jul 2006 09:22:39 +0000 Subject: [PATCH] - now the linux-parts are running very save - updated the website in the "about"-dialog (Old svn revision: 1477) --- po/Makefile.in | 2 +- src/functions.c | 24 +++++++++++------------- src/interface.c | 10 +++++++++- src/linux.c | 32 +++++++++++++++++++------------- src/types.h | 3 +++ 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/po/Makefile.in b/po/Makefile.in index 27da035..1a305fc 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -32,7 +32,7 @@ localedir = $(libdir)/locale gnulocaledir = $(datadir)/locale gettextsrcdir = $(datadir)/glib-2.0/gettext/po subdir = po -install_sh = /home/the_hippie/xfce4-taskmanager/trunk/install-sh +install_sh = /home/the_hippie/Projekte/xfce4-taskmanager/trunk/install-sh mkdir_p = mkdir -p -- . mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/src/functions.c b/src/functions.c index d737647..281036b 100644 --- a/src/functions.c +++ b/src/functions.c @@ -28,13 +28,6 @@ gboolean refresh_task_list(void) /* gets the new task list */ new_task_list = (GArray*) get_task_list(); - /* markes all new_tasks to "not checked" */ - for(i = 0; i < new_task_list->len; i++) - { - struct task *new_tmp = &g_array_index(new_task_list, struct task, i); - new_tmp->checked = FALSE; - } - /* check if task is new and marks the task that its checked*/ for(i = 0; i < task_array->len; i++) { @@ -53,7 +46,7 @@ gboolean refresh_task_list(void) strcpy(tmp->state, new_tmp->state); tmp->size = new_tmp->size; tmp->rss = new_tmp->rss; - + refresh_list_item(i); } tmp->checked = TRUE; @@ -72,7 +65,7 @@ gboolean refresh_task_list(void) struct task *tmp = &g_array_index(task_array, struct task, i); - if(tmp->checked == FALSE) + if(!tmp->checked) { remove_list_item((gint)tmp->pid); g_array_remove_index(task_array, i); @@ -91,10 +84,10 @@ gboolean refresh_task_list(void) if(!new_tmp->checked) { - struct task new_task = *new_tmp; + struct task *new_task = new_tmp; - g_array_append_val(task_array, new_task); - if((show_user_tasks && new_task.uid == own_uid) || (show_root_tasks && new_task.uid == 0) || (show_other_tasks && new_task.uid != own_uid && new_task.uid != 0)) + g_array_append_val(task_array, *new_task); + if((show_user_tasks && new_task->uid == own_uid) || (show_root_tasks && new_task->uid == 0) || (show_other_tasks && new_task->uid != own_uid && new_task->uid != 0)) add_new_list_item(tasks); tasks++; } @@ -123,7 +116,9 @@ void load_config(void) win_width = xfce_rc_read_int_entry(rc_file, "win_width", 500); win_height = xfce_rc_read_int_entry(rc_file, "win_height", 400); - + + custom_signal_1 = xfce_rc_read_entry(rc_file, "custom_signal_1", ""); + custom_signal_0 = xfce_rc_read_entry(rc_file, "custom_signal_0", "Hello"); xfce_rc_close(rc_file); } @@ -143,6 +138,9 @@ void save_config(void) xfce_rc_write_int_entry(rc_file, "win_width", win_width); xfce_rc_write_int_entry(rc_file, "win_height", win_height); + + xfce_rc_write_entry(rc_file, "custom_signal_0", custom_signal_0); + xfce_rc_write_entry(rc_file, "custom_signal_1", custom_signal_1); xfce_rc_flush(rc_file); diff --git a/src/interface.c b/src/interface.c index 4b69471..5e1f319 100644 --- a/src/interface.c +++ b/src/interface.c @@ -170,6 +170,14 @@ GtkWidget* create_taskpopup (void) gtk_container_add (GTK_CONTAINER (taskpopup), menu_item); g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_task_menu), "KILL"); + if(strcmp(custom_signal_0, "") != 0) + { + menu_item = gtk_menu_item_new_with_label (custom_signal_0); + 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), "OO"); + } + return taskpopup; } @@ -227,7 +235,7 @@ void show_about_dialog(void) 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://developer.berlios.de/projects/xfce-goodies/"); + 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); diff --git a/src/linux.c b/src/linux.c index 15778d2..dd519cb 100644 --- a/src/linux.c +++ b/src/linux.c @@ -17,13 +17,16 @@ struct task get_task_details(gint pid) stat(filename, &status); - memset(&task, 0, sizeof(task)); + memset(&task, 0, sizeof(struct task)); + + task.pid = -1; + task.checked = FALSE; if((task_file = fopen(filename,"r")) != NULL) { - while(fgets(buffer_status, sizeof buffer_status, task_file) != NULL) + while(fgets(buffer_status, sizeof(buffer_status), task_file) != NULL) { - sscanf(buffer_status, "%i (%255s %c %i %i %i %i %i %255s %255s %255s %255s %255s %255s %255s %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", + sscanf(buffer_status, "%i (%s %c %i %i %i %i %i %s %s %s %s %s %s %s %i %i %i %i %i %i %i %i %i %s %s %s %i %s %s %s %s %s %s %s %s %s %s %i %s %s", &task.pid, // processid &task.name, // processname &task.state, // processstate @@ -75,36 +78,37 @@ struct task get_task_details(gint pid) &dummy ); } - task.uid = status.st_uid; passwdp = getpwuid(task.uid); if(passwdp != NULL && passwdp->pw_name != NULL) g_strlcpy(task.uname, passwdp->pw_name, sizeof task.uname); } + if(task_file != NULL) fclose(task_file); if((cmdline_file = fopen(cmdline_filename,"r")) != NULL) { - *dummy = NULL; - fscanf(cmdline_file, "%s", &dummy); - if(*dummy != NULL) + gchar dummy[255]; + strcpy(&dummy, ""); + fscanf(cmdline_file, "%255s", &dummy); + if(strcmp(dummy, "") != 0) { if(g_strrstr(dummy,"/") != NULL) g_strlcpy(task.name, g_strrstr(dummy,"/")+1, 255); else g_strlcpy(task.name, dummy, 255); - - /* workaround for cmd-line entries with leading "-" */ + + // 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'; @@ -118,13 +122,15 @@ GArray *get_task_list() 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"); return NULL; } + gint count = 0; + while((dir_entry = readdir(dir)) != NULL) { if(atoi(dir_entry->d_name) != 0) @@ -133,10 +139,10 @@ GArray *get_task_list() if(task.pid != -1) g_array_append_val(task_list, task); } + count++; } closedir(dir); - return task_list; } diff --git a/src/types.h b/src/types.h index d463d2d..35eba42 100644 --- a/src/types.h +++ b/src/types.h @@ -55,4 +55,7 @@ gboolean full_view; guint win_width; guint win_height; +const gchar *custom_signal_0; +const gchar *custom_signal_1; + #endif