Prepare build-env for first beta

This commit is contained in:
Mike Massonnet
2010-05-10 21:36:34 +02:00
parent a21b1bfca8
commit 8dd82ed6a8
14 changed files with 59 additions and 1860 deletions

View File

@@ -1,8 +1,4 @@
#!/bin/sh
#
# Copyright (c) 2002-2007
# The Xfce development team. All rights reserved.
#
(type xdt-autogen) >/dev/null 2>&1 || {
cat >&2 <<EOF
@@ -14,15 +10,18 @@ EOF
exit 1
}
# substitute revision and linguas
linguas=`ls po/*.po 2>/dev/null | awk 'BEGIN {FS="[./]"; ORS=" "} {print $2}'`
if test -d .git; then
revision=`git log --pretty=format:%h -n 1`
echo 'dnl *** This file is automatically generated from configure.ac.in ***' > configure.ac
echo 'dnl *** DO NOT EDIT! ***' >> configure.ac
echo >> configure.ac
linguas=$(ls po/*.po 2>/dev/null | awk 'BEGIN {FS="[./]"; ORS=" "} {print $2}')
if [ -d .git ]; then
revision=$(git log --pretty=format:%h -n 1)
else
revision="UNKNOWN"
revision=UNKNOWN
fi
sed -e "s/@LINGUAS@/${linguas}/g" \
-e "s/@REVISION@/${revision}/g" \
< "configure.in.in" > "configure.in"
< configure.ac.in >> configure.ac
exec xdt-autogen $@

View File

@@ -2,13 +2,14 @@ dnl
dnl xfce4-taskmanager - A small taskmanager based on the Xfce 4 libraries.
dnl
dnl 2005-2007 Johannes Zellner <webmaster@nebulon.de>
dnl 2010 Mike Massonnet <mmassonnet@xfce.org>
dnl ***************************
dnl *** Version information ***
dnl ***************************
m4_define([taskmanager_version_major], [0])
m4_define([taskmanager_version_minor], [5])
m4_define([taskmanager_version_micro], [0])
m4_define([taskmanager_version_micro], [90])
m4_define([taskmanager_version_build], [@REVISION@])
m4_define([taskmanager_version_tag], [git])
m4_define([taskmanager_version], [taskmanager_version_major().taskmanager_version_minor().taskmanager_version_micro()ifelse(taskmanager_version_tag(), [git], [taskmanager_version_tag()-taskmanager_version_build()], [taskmanager_version_tag()])])
@@ -30,14 +31,7 @@ dnl ***************************
AM_INIT_AUTOMAKE([1.8 dist-bzip2])
AM_CONFIG_HEADER([config.h])
AM_MAINTAINER_MODE()
AM_SILENT_RULES([yes])
dnl *******************************
dnl *** Check for UNIX variants ***
dnl *******************************
AC_AIX()
AC_ISC_POSIX()
AC_MINIX()
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl ********************************
dnl *** Check for basic programs ***
@@ -57,10 +51,8 @@ AC_C_CONST()
dnl **********************************
dnl *** Check for standard headers ***
dnl **********************************.
dnl **********************************
AC_HEADER_STDC()
AC_CHECK_HEADERS([dirent.h pwd.h sys/types.h sys/stat.h sys/param.h \
stdio.h stdlib.h string.h unistd.h stdlib.h signal.h])
dnl ******************************
dnl *** Check for i18n support ***
@@ -75,29 +67,39 @@ XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.12.0])
dnl ***********************************
dnl ******* Check for OS family *******
dnl ***********************************
AC_MSG_CHECKING([for operating system family])
case "$target_os" in
dragonfly*|freebsd*|netbsd*|openbsd*|darwin*)
ac_taskmanager_os_family="bsd"
;;
solaris*)
ac_taskmanager_os_family="solaris"
AC_CHECK_LIB([kstat], [kstat_open])
;;
*)
ac_taskmanager_os_family="linux"
;;
esac
AC_MSG_RESULT([$ac_taskmanager_os_family])
AM_CONDITIONAL([OS_BSD_FAMILY], [test x"$ac_taskmanager_os_family" = x"bsd"])
AM_CONDITIONAL([OS_SOLARIS], [test x"$ac_taskmanager_os_family" = x"solaris"])
AM_CONDITIONAL([OS_LINUX], [test x"$ac_taskmanager_os_family" = x"linux"])
dragonfly*|freebsd*|netbsd*|openbsd*|darwin*)
ac_os_implementation="bsd"
;;
solaris*)
ac_os_implementation="solaris"
AC_CHECK_LIB([kstat], [kstat_open])
;;
linux*)
ac_os_implementation="linux"
AC_CHECK_HEADERS([pwd.h signal.h stdio.h string.h sys/resource.h \
sys/stat.h sys/types.h unistd.h])
;;
*)
AC_MSG_CHECKING([for OS implementation])
AC_MSG_ERROR([no OS implementation for $target_os is available])
;;
esac
AC_MSG_CHECKING([for OS implementation])
AC_MSG_RESULT([$ac_os_implementation])
AM_CONDITIONAL([OS_BSD], [test x"$ac_os_implementation" = x"bsd"])
AM_CONDITIONAL([OS_SOLARIS], [test x"$ac_os_implementation" = x"solaris"])
AM_CONDITIONAL([OS_LINUX], [test x"$ac_os_implementation" = x"linux"])
dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
BM_DEBUG_SUPPORT()
XDT_FEATURE_DEBUG()
dnl ***************
dnl *** Outputs ***
dnl ***************
AC_OUTPUT([
Makefile
src/Makefile
@@ -110,7 +112,7 @@ dnl ***************************
echo
echo "Build Configuration:"
echo
echo "* Target OS: $ac_taskmanager_os_family"
echo "* Target OS: $target_os ($ac_os_implementation)"
echo "* Debug Support: $enable_debug"
echo

View File

@@ -1,7 +1,7 @@
xfce4-taskmanager.desktop.in
src/callbacks.c
src/functions.c
src/interface.c
src/taskmanager-bsd.c
src/taskmanager-linux.c
src/process-statusbar.c
src/process-tree-view.c
src/process-window.c
src/process-window.ui
src/task-manager.c
src/main.c

View File

@@ -1 +1,3 @@
src/menu-positions.c
src/taskmanager-bsd.c
src/task-manager-linux.c
src/taskmanager-solaris.c

View File

@@ -1,144 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-07-26 17:54-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../xfce4-taskmanager.desktop.in.h:1
msgid "Control your processes"
msgstr ""
#: ../xfce4-taskmanager.desktop.in.h:2
msgid "Process manager"
msgstr ""
#: ../xfce4-taskmanager.desktop.in.h:3 ../src/interface.c:46
msgid "Xfce4 Taskmanager"
msgstr ""
#: ../src/callbacks.c:72
msgid "Really kill the task?"
msgstr ""
#: ../src/callbacks.c:76
msgid "Really terminate the task?"
msgstr ""
#: ../src/functions.c:134
#, c-format
msgid "%d MB of %d MB used"
msgstr ""
#: ../src/functions.c:139
#, c-format
msgid "%0.0f %%"
msgstr ""
#: ../src/interface.c:61
msgid "Cpu usage"
msgstr ""
#: ../src/interface.c:69
msgid "Memory usage"
msgstr ""
#: ../src/interface.c:136
msgid "Command"
msgstr ""
#: ../src/interface.c:143 ../src/interface.c:347
msgid "PID"
msgstr ""
#: ../src/interface.c:149 ../src/interface.c:348
msgid "PPID"
msgstr ""
#: ../src/interface.c:155 ../src/interface.c:349
msgid "State"
msgstr ""
#: ../src/interface.c:161 ../src/interface.c:350
msgid "VM-Size"
msgstr ""
#: ../src/interface.c:167 ../src/interface.c:351
msgid "RSS"
msgstr ""
#: ../src/interface.c:173 ../src/interface.c:352
msgid "User"
msgstr ""
#: ../src/interface.c:179 ../src/interface.c:353
msgid "CPU%"
msgstr ""
#. my change
#: ../src/interface.c:186
msgid "Prio"
msgstr ""
#: ../src/interface.c:203
msgid "Stop"
msgstr ""
#: ../src/interface.c:208
msgid "Continue"
msgstr ""
#: ../src/interface.c:213
msgid "Term"
msgstr ""
#: ../src/interface.c:218
msgid "Kill"
msgstr ""
#: ../src/interface.c:223 ../src/interface.c:354
msgid "Priority"
msgstr ""
#: ../src/interface.c:293
msgid "Show user tasks"
msgstr ""
#: ../src/interface.c:298
msgid "Show root tasks"
msgstr ""
#: ../src/interface.c:303
msgid "Show other tasks"
msgstr ""
#: ../src/interface.c:308
msgid "Show memory used by cache as free"
msgstr ""
#: ../src/interface.c:375
msgid "Original Author:"
msgstr ""
#: ../src/interface.c:377
msgid "Contributors:"
msgstr ""
#: ../src/interface.c:387
msgid "Xfce4-Taskmanager is an easy to use taskmanager"
msgstr ""
#: ../src/interface.c:395
msgid "translator-credits"
msgstr ""

View File

@@ -20,10 +20,19 @@ xfce4_taskmanager_SOURCES = \
process-tree-view.c process-tree-view.h \
process-statusbar.c process-statusbar.h \
task-manager.c task-manager.h \
task-manager-linux.c \
settings.c settings.h \
$(NULL)
if OS_BSD
xfce4_taskmanager_SOURCES += task-manager-bsd.c
endif
if OS_SOLARIS
xfce4_taskmanager_SOURCES += task-manager-solaris.c
endif
if OS_LINUX
xfce4_taskmanager_SOURCES += task-manager-linux.c
endif
if MAINTAINER_MODE
BUILT_SOURCES = process-window_ui.h
process-window_ui.h: process-window.ui

View File

@@ -1,160 +0,0 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2006 Johannes Zellner <webmaster@nebulon.de>
* 2008 Mike Massonnet <mmassonnet@xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "callbacks.h"
#include "menu-positions.h"
void on_preferences(GtkButton *button)
{
if(mainmenu == NULL)
mainmenu = create_mainmenu();
gtk_menu_popup(GTK_MENU(mainmenu), NULL, NULL, (GtkMenuPositionFunc)position_menu_cover_widget, button, 0, gtk_get_current_event_time());
}
void on_information(GtkButton *button)
{
if(infomenu == NULL)
infomenu = create_infomenu();
gtk_menu_popup(GTK_MENU(infomenu), NULL, NULL, (GtkMenuPositionFunc)position_menu_cover_widget, button, 0, gtk_get_current_event_time());
}
void on_show_info_toggled(GtkCheckMenuItem *menuitem, gint column_id)
{
show_col[column_id] = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
change_list_store_view();
}
gboolean on_treeview1_button_press_event(GtkButton *button, GdkEventButton *event)
{
if(event->button == 3)
{
GdkEventButton *mouseevent = (GdkEventButton *)event;
if(taskpopup == NULL)
taskpopup = create_taskpopup ();
gtk_menu_popup(GTK_MENU(taskpopup), NULL, NULL, NULL, NULL, mouseevent->button, mouseevent->time);
}
return FALSE;
}
void on_info1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
show_about_dialog();
}
void handle_task_menu(GtkWidget *widget, gchar *signal)
{
if(signal != NULL)
{
gint task_action = SIGNAL_NO;
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(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)
show_user_tasks = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
else if(uid == 0)
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();
}
void on_show_cached_as_free_toggled (GtkMenuItem *menuitem, gint uid)
{
show_cached_as_free = !show_cached_as_free;
change_task_view();
}
void on_quit(void)
{
save_config();
free(config_file);
gtk_main_quit();
}

View File

@@ -1,59 +0,0 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2006 Johannes Zellner <webmaster@nebulon.de>
* 2008 Mike Massonnet <mmassonnet@xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __CALLBACKS_H_
#define __CALLBACKS_H_
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "functions.h"
#include "interface.h"
#include "taskmanager.h"
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#define SIGNAL_NO 0
#define SIGNAL_KILL SIGKILL
#define SIGNAL_TERM SIGINT
#define SIGNAL_CONT SIGCONT
#define SIGNAL_STOP SIGSTOP
#else
/* FIXME */
#endif
void on_preferences(GtkButton *button);
void on_information(GtkButton *button);
void on_show_info_toggled(GtkCheckMenuItem *menuitem, gint uid);
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);
void on_quit(void);
#endif

View File

@@ -1,275 +0,0 @@
/* $Id$
*
* Copyright (c) 2006 Johannes Zellner <webmaster@nebulon.de>
* 2008 Mike Massonnet <mmassonnet@xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "functions.h"
static system_status *sys_stat =NULL;
gboolean refresh_task_list(void)
{
gint i, j;
GArray *new_task_list;
gchar *cpu_tooltip, *mem_tooltip;
gdouble cpu_usage;
guint num_cpus;
guint memory_used;
if (sys_stat!=NULL)
num_cpus = sys_stat->cpu_count;
else
num_cpus = 1;
/* gets the new task list */
new_task_list = (GArray*) get_task_list();
/* check if task is new and marks the task that its checked*/
for(i = 0; i < task_array->len; i++)
{
struct task *tmp = &g_array_index(task_array, struct task, i);
tmp->checked = FALSE;
for(j = 0; j < new_task_list->len; j++)
{
struct task *new_tmp = &g_array_index(new_task_list, struct task, j);
if(new_tmp->pid == tmp->pid)
{
/* FIXME */
#ifdef __linux
tmp->old_time = tmp->time;
tmp->time = new_tmp->time;
tmp->old_time_percentage = tmp->time_percentage;
tmp->time_percentage = (gdouble)(tmp->time - tmp->old_time) * (1.0/num_cpus);
#endif
#ifdef __sun
tmp->old_time = tmp->time;
tmp->time = new_tmp->time;
tmp->old_time_percentage = tmp->time_percentage;
tmp->time_percentage = (gdouble)(tmp->time - tmp->old_time) / (100.0*num_cpus);
#endif
if(
tmp->ppid != new_tmp->ppid ||
strcmp(tmp->state,new_tmp->state) ||
tmp->vsize != new_tmp->vsize ||
tmp->rss != new_tmp->rss ||
#ifdef __linux || __sun
tmp->time_percentage != tmp->old_time_percentage ||
#endif
tmp->prio != new_tmp->prio
)
{
tmp->ppid = new_tmp->ppid;
strcpy(tmp->state, new_tmp->state);
tmp->vsize = new_tmp->vsize;
tmp->rss = new_tmp->rss;
tmp->prio = new_tmp->prio;
refresh_list_item(i);
}
tmp->checked = TRUE;
new_tmp->checked = TRUE;
break;
}
else
tmp->checked = FALSE;
}
}
/* check for unchecked old-tasks for deleting */
i = 0;
while( i < task_array->len)
{
struct task *tmp = &g_array_index(task_array, struct task, i);
if(!tmp->checked)
{
remove_list_item((gint)tmp->pid);
g_array_remove_index(task_array, i);
tasks--;
}
else
i++;
}
/* check for unchecked new tasks for inserting */
for(i = 0; i < new_task_list->len; i++)
{
struct task *new_tmp = &g_array_index(new_task_list, struct task, i);
if(!new_tmp->checked)
{
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))
add_new_list_item(tasks);
tasks++;
}
}
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;
memory_used-=sys_stat->mem_buffers;
}
mem_tooltip = g_strdup_printf (_("%d MB of %d MB used"), memory_used/1024, sys_stat->mem_total/1024);
#if !GTK_CHECK_VERSION (2, 12, 0)
gtk_tooltips_set_tip (tooltips, mem_usage_progress_bar_box, mem_tooltip, NULL);
#else
gtk_widget_set_tooltip_text (mem_usage_progress_bar_box, mem_tooltip);
#endif
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);
#if !GTK_CHECK_VERSION (2, 12, 0)
gtk_tooltips_set_tip (tooltips, cpu_usage_progress_bar_box, cpu_tooltip, NULL);
#else
gtk_widget_set_tooltip_text (cpu_usage_progress_bar_box, cpu_tooltip);
#endif
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (cpu_usage_progress_bar), cpu_usage);
g_free (mem_tooltip);
g_free (cpu_tooltip);
return TRUE;
}
gdouble get_cpu_usage(system_status *sys_stat)
{
gdouble cpu_usage = 0.0;
guint current_jiffies;
guint current_used;
guint delta_jiffies;
if ( get_cpu_usage_from_proc( sys_stat ) == FALSE )
{
gint i = 0;
for(i = 0; i < task_array->len; i++)
{
struct task *tmp = &g_array_index(task_array, struct task, i);
cpu_usage += tmp->time_percentage;
}
cpu_usage = cpu_usage / (sys_stat->cpu_count * 100.0);
} else {
if ( sys_stat->cpu_old_jiffies > 0 ) {
current_used =
sys_stat->cpu_user +
sys_stat->cpu_nice +
sys_stat->cpu_system;
current_jiffies =
current_used +
sys_stat->cpu_idle;
delta_jiffies =
current_jiffies - (gdouble)sys_stat->cpu_old_jiffies;
cpu_usage = (gdouble)( current_used - sys_stat->cpu_old_used ) /
(gdouble)delta_jiffies ;
}
}
return cpu_usage;
}
/*
* configurationfile support
*/
void load_config(void)
{
XfceRc *rc_file = xfce_rc_simple_open(config_file, FALSE);
xfce_rc_set_group (rc_file, "General");
show_user_tasks = xfce_rc_read_bool_entry(rc_file, "show_user_tasks", TRUE);
show_root_tasks = xfce_rc_read_bool_entry(rc_file, "show_root_tasks", FALSE);
show_other_tasks = xfce_rc_read_bool_entry(rc_file, "show_other_tasks", FALSE);
show_cached_as_free = xfce_rc_read_bool_entry(rc_file, "show_cached_as_free", TRUE);
sort_column = xfce_rc_read_int_entry(rc_file, "sort_column", COLUMN_PID);
sort_type = xfce_rc_read_int_entry(rc_file, "sort_type", GTK_SORT_ASCENDING);
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_set_group (rc_file, "Information");
show_col[COLUMN_PID] = xfce_rc_read_bool_entry(rc_file, "show_col_pid", TRUE);
show_col[COLUMN_PPID] = xfce_rc_read_bool_entry(rc_file, "show_col_ppid", FALSE);
show_col[COLUMN_STATE] = xfce_rc_read_bool_entry(rc_file, "show_col_state", FALSE);
show_col[COLUMN_MEM] = xfce_rc_read_bool_entry(rc_file, "show_col_mem", FALSE);
show_col[COLUMN_RSS] = xfce_rc_read_bool_entry(rc_file, "show_col_rss", TRUE);
show_col[COLUMN_UNAME] = xfce_rc_read_bool_entry(rc_file, "show_col_uname", FALSE);
show_col[COLUMN_TIME] = xfce_rc_read_bool_entry(rc_file, "show_col_time", TRUE);
show_col[COLUMN_PRIO] = xfce_rc_read_bool_entry(rc_file, "show_col_prio", TRUE);
xfce_rc_close(rc_file);
}
void save_config(void)
{
XfceRc *rc_file = xfce_rc_simple_open(config_file, FALSE);
xfce_rc_set_group (rc_file, "General");
xfce_rc_write_bool_entry(rc_file, "show_user_tasks", show_user_tasks);
xfce_rc_write_bool_entry(rc_file, "show_root_tasks", show_root_tasks);
xfce_rc_write_bool_entry(rc_file, "show_other_tasks", show_other_tasks);
xfce_rc_write_bool_entry(rc_file, "show_cached_as_free", show_cached_as_free);
gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(list_store), &sort_column, &sort_type);
xfce_rc_write_int_entry(rc_file, "sort_column", sort_column);
xfce_rc_write_int_entry(rc_file, "sort_type", sort_type);
gtk_window_get_size(GTK_WINDOW (main_window), (gint *) &win_width, (gint *) &win_height);
xfce_rc_write_int_entry(rc_file, "win_width", win_width);
xfce_rc_write_int_entry(rc_file, "win_height", win_height);
xfce_rc_set_group (rc_file, "Information");
xfce_rc_write_bool_entry(rc_file, "show_col_pid", show_col[COLUMN_PID]);
xfce_rc_write_bool_entry(rc_file, "show_col_ppid", show_col[COLUMN_PPID]);
xfce_rc_write_bool_entry(rc_file, "show_col_state", show_col[COLUMN_STATE]);
xfce_rc_write_bool_entry(rc_file, "show_col_mem", show_col[COLUMN_MEM]);
xfce_rc_write_bool_entry(rc_file, "show_col_rss", show_col[COLUMN_RSS]);
xfce_rc_write_bool_entry(rc_file, "show_col_uname", show_col[COLUMN_UNAME]);
xfce_rc_write_bool_entry(rc_file, "show_col_time", show_col[COLUMN_TIME]);
xfce_rc_write_bool_entry(rc_file, "show_col_prio", show_col[COLUMN_PRIO]);
xfce_rc_flush(rc_file);
xfce_rc_close(rc_file);
}

View File

@@ -1,49 +0,0 @@
/* $Id$
*
* Copyright (c) 2006 Johannes Zellner, <webmaster@nebulon.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include <gtk/gtk.h>
#include <glib.h>
#include <dirent.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxfce4util/libxfce4util.h>
#include "types.h"
#include "interface.h"
#include "taskmanager.h"
gboolean refresh_task_list(void);
gdouble get_cpu_usage(system_status *sys_stat);
/* Configurationfile support */
void load_config(void);
void save_config(void);
#endif

View File

@@ -1,634 +0,0 @@
/* $Id$
*
* Copyright (c) 2006 Johannes Zellner <webmaster@nebulon.de>
* 2008 Mike Massonnet <mmassonnet@xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "interface.h"
GtkWidget* create_main_window (void)
{
GtkWidget *window;
GtkWidget *vbox1, *vbox2;
GtkWidget *bbox1;
GtkWidget *scrolledwindow1;
GtkWidget *button_preferences;
GtkWidget *button_information;
GtkWidget *button_quit;
GtkWidget *system_info_box;
#if !GTK_CHECK_VERSION (2, 12, 0)
tooltips = gtk_tooltips_new();
gtk_tooltips_enable(tooltips);
#endif
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), _("Xfce4 Taskmanager"));
gtk_window_set_icon_name (GTK_WINDOW (window), "utilities-system-monitor");
gtk_window_set_default_size (GTK_WINDOW (window), win_width, win_height);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (window), vbox1);
vbox2 = gtk_vbox_new (FALSE, BORDER);
gtk_widget_show (vbox2);
gtk_container_add (GTK_CONTAINER (vbox1), vbox2);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), BORDER);
system_info_box = gtk_hbox_new (FALSE, BORDER/2);
gtk_widget_show (system_info_box);
gtk_box_pack_start (GTK_BOX (vbox2), 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_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_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);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow1, TRUE, TRUE, 0);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);
treeview = gtk_tree_view_new ();
gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE);
gtk_widget_show (treeview);
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), sort_column, sort_type);
bbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox2), bbox1, FALSE, TRUE, 0);
gtk_widget_show (bbox1);
button_preferences = gtk_button_new_from_stock ("gtk-preferences");
gtk_button_set_focus_on_click (GTK_BUTTON (button_preferences), FALSE);
gtk_widget_show (button_preferences);
gtk_box_pack_start (GTK_BOX (bbox1), button_preferences, FALSE, FALSE, 0);
button_information = gtk_button_new_from_stock ("gtk-info");
gtk_button_set_focus_on_click (GTK_BUTTON (button_information), FALSE);
gtk_widget_show (button_information);
gtk_box_pack_start (GTK_BOX (bbox1), button_information, FALSE, FALSE, 0);
button_quit = gtk_button_new_from_stock ("gtk-quit");
gtk_widget_show (button_quit);
gtk_box_pack_start (GTK_BOX (bbox1), button_quit, FALSE, FALSE, 0);
#if 0
statusbar = gtk_statusbar_new ();
gtk_widget_show (statusbar);
gtk_box_pack_start (GTK_BOX (vbox1), statusbar, FALSE, FALSE, 0);
#endif
g_signal_connect_swapped (treeview, "button-press-event", G_CALLBACK(on_treeview1_button_press_event), NULL);
g_signal_connect (button_preferences, "clicked", G_CALLBACK (on_preferences), NULL);
g_signal_connect (button_information, "clicked", G_CALLBACK (on_information), NULL);
g_signal_connect (button_quit, "clicked", G_CALLBACK (on_quit), NULL);
g_signal_connect (window, "delete-event", G_CALLBACK (on_quit), NULL);
return window;
}
void create_list_store(void)
{
GtkCellRenderer *cell_renderer;
GtkCellRenderer *cell_renderer_right_align;
GtkCellRenderer *cell_renderer_command;
/* 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();
cell_renderer_right_align = gtk_cell_renderer_text_new();
g_object_set(G_OBJECT(cell_renderer_right_align), "xalign", 1.0, NULL);
cell_renderer_command = gtk_cell_renderer_text_new();
g_object_set(G_OBJECT(cell_renderer_command), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
column = gtk_tree_view_column_new_with_attributes(_("Command"), cell_renderer_command, "text", 0, NULL);
gtk_tree_view_column_set_expand(column, TRUE);
gtk_tree_view_column_set_resizable(column, TRUE);
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_right_align, "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_right_align, "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_right_align, "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_right_align, "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_right_align, "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_right_align, "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();
}
GtkWidget* create_taskpopup (void)
{
GtkWidget *taskpopup;
GtkWidget *menu_item;
taskpopup = gtk_menu_new ();
menu_item = gtk_menu_item_new_with_mnemonic (_("Stop"));
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), "STOP");
menu_item = gtk_menu_item_new_with_mnemonic (_("Continue"));
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), "CONT");
menu_item = gtk_menu_item_new_with_mnemonic (_("Term"));
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), "TERM");
menu_item = gtk_menu_item_new_with_mnemonic (_("Kill"));
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;
#ifdef __sun
menu_item = gtk_menu_item_new_with_label ("0");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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), "0");
menu_item = gtk_menu_item_new_with_label ("-5");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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_label ("-10");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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), "-10");
menu_item = gtk_menu_item_new_with_label ("-15");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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), "-15");
menu_item = gtk_menu_item_new_with_label ("-20");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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), "-20");
#else
menu_item = gtk_menu_item_new_with_label ("-10");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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), "-10");
menu_item = gtk_menu_item_new_with_label ("-5");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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_label ("0");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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), "0");
menu_item = gtk_menu_item_new_with_label ("5");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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_label ("10");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.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), "10");
#endif
return prio_submenu;
}
GtkWidget* create_mainmenu (void)
{
GtkWidget *mainmenu;
GtkWidget *info1;
GtkWidget *trennlinie1;
GtkWidget *show_user_tasks1;
GtkWidget *show_root_tasks1;
GtkWidget *show_other_tasks1;
GtkWidget *show_cached_as_free1;
GtkAccelGroup *accel_group;
accel_group = gtk_accel_group_new ();
mainmenu = gtk_menu_new ();
info1 = gtk_image_menu_item_new_from_stock ("gtk-about", accel_group);
gtk_widget_show (info1);
gtk_menu_shell_append(GTK_MENU_SHELL(mainmenu), info1);
trennlinie1 = gtk_separator_menu_item_new ();
gtk_widget_show (trennlinie1);
gtk_menu_shell_append(GTK_MENU_SHELL(mainmenu), trennlinie1);
gtk_widget_set_sensitive (trennlinie1, FALSE);
show_user_tasks1 = gtk_check_menu_item_new_with_mnemonic (_("Show user tasks"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(show_user_tasks1), show_user_tasks);
gtk_widget_show (show_user_tasks1);
gtk_menu_shell_append(GTK_MENU_SHELL(mainmenu), show_user_tasks1);
show_root_tasks1 = gtk_check_menu_item_new_with_mnemonic (_("Show root tasks"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(show_root_tasks1), show_root_tasks);
gtk_widget_show (show_root_tasks1);
gtk_menu_shell_append(GTK_MENU_SHELL(mainmenu), show_root_tasks1);
show_other_tasks1 = gtk_check_menu_item_new_with_mnemonic (_("Show other tasks"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(show_other_tasks1), show_other_tasks);
gtk_widget_show (show_other_tasks1);
gtk_menu_shell_append(GTK_MENU_SHELL(mainmenu), show_other_tasks1);
show_cached_as_free1 = gtk_check_menu_item_new_with_mnemonic (_("Show memory used by cache as free"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(show_cached_as_free1), show_cached_as_free);
gtk_widget_show (show_cached_as_free1);
gtk_menu_shell_append(GTK_MENU_SHELL(mainmenu), show_cached_as_free1);
g_signal_connect ((gpointer) info1, "activate", G_CALLBACK (on_info1_activate), NULL);
g_signal_connect ((gpointer) show_user_tasks1, "toggled", G_CALLBACK (on_show_tasks_toggled), GINT_TO_POINTER(own_uid));
g_signal_connect ((gpointer) show_root_tasks1, "toggled", G_CALLBACK (on_show_tasks_toggled), GINT_TO_POINTER(0));
g_signal_connect ((gpointer) show_other_tasks1, "toggled", G_CALLBACK (on_show_tasks_toggled), GINT_TO_POINTER(-1));
g_signal_connect ((gpointer) show_cached_as_free1, "toggled", G_CALLBACK (on_show_cached_as_free_toggled), GINT_TO_POINTER(0));
gtk_menu_set_accel_group (GTK_MENU (mainmenu), accel_group);
return mainmenu;
}
GtkWidget* create_infomenu (void)
{
GtkWidget *infomenu;
GtkWidget *title;
GtkWidget *title_image;
GtkWidget *separator;
GtkWidget *col_items[N_COLUMNS] = { 0 };
gint i;
infomenu = gtk_menu_new ();
title = gtk_image_menu_item_new_from_stock("gtk-info", NULL);
title_image = gtk_image_new_from_stock ("gtk-info", GTK_ICON_SIZE_BUTTON);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (title), title_image);
gtk_widget_show(title);
gtk_menu_shell_append(GTK_MENU_SHELL(infomenu), title);
gtk_widget_set_sensitive(title, FALSE);
separator = gtk_separator_menu_item_new();
gtk_widget_show(separator);
gtk_menu_shell_append(GTK_MENU_SHELL(infomenu), separator);
gtk_widget_set_sensitive(separator, FALSE);
col_items[COLUMN_PID] = gtk_check_menu_item_new_with_label (_("PID"));
col_items[COLUMN_PPID] = gtk_check_menu_item_new_with_label (_("PPID"));
col_items[COLUMN_STATE] = gtk_check_menu_item_new_with_label (_("State"));
col_items[COLUMN_MEM] = gtk_check_menu_item_new_with_label (_("VM-Size"));
col_items[COLUMN_RSS] = gtk_check_menu_item_new_with_label (_("RSS"));
col_items[COLUMN_UNAME] = gtk_check_menu_item_new_with_label (_("User"));
col_items[COLUMN_TIME] = gtk_check_menu_item_new_with_label (_("CPU%"));
col_items[COLUMN_PRIO] = gtk_check_menu_item_new_with_label (_("Priority"));
for (i = 0; i < N_COLUMNS; i++)
{
if (GTK_IS_WIDGET (col_items[i]))
{
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (col_items[i]), show_col[i]);
gtk_widget_show(col_items[i]);
gtk_menu_shell_append(GTK_MENU_SHELL(infomenu), col_items[i]);
g_signal_connect (col_items[i], "toggled",
G_CALLBACK (on_show_info_toggled), GINT_TO_POINTER(i));
}
}
return infomenu;
}
void show_about_dialog(void)
{
GtkWidget *about_dialog;
const gchar *authors[] = {
"Johannes Zellner <webmaster@nebulon.de>",
"",
_("Contributors:"),
"Mike Massonnet <mmassonnet@xfce.org>",
NULL };
about_dialog = gtk_about_dialog_new();
gtk_about_dialog_set_version(
GTK_ABOUT_DIALOG(about_dialog),
PACKAGE_VERSION);
gtk_about_dialog_set_comments(
GTK_ABOUT_DIALOG(about_dialog),
_("Xfce4-Taskmanager is an easy to use taskmanager"));
gtk_about_dialog_set_website(
GTK_ABOUT_DIALOG(about_dialog),
"http://goodies.xfce.org/projects/applications/xfce4-taskmanager");
gtk_about_dialog_set_authors(
GTK_ABOUT_DIALOG(about_dialog),
authors);
gtk_about_dialog_set_translator_credits(
GTK_ABOUT_DIALOG(about_dialog),
_("translator-credits"));
gtk_about_dialog_set_license(
GTK_ABOUT_DIALOG(about_dialog),
xfce_get_license_text(XFCE_LICENSE_TEXT_GPL));
gtk_about_dialog_set_copyright(
GTK_ABOUT_DIALOG(about_dialog),
"Copyright \302\251 2005-2008 Johannes Zellner");
gtk_window_set_icon_name(GTK_WINDOW(about_dialog), GTK_STOCK_ABOUT);
gtk_dialog_run(GTK_DIALOG(about_dialog));
gtk_widget_destroy(about_dialog);
}
void change_list_store_view(void)
{
gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), COLUMN_PID), show_col[COLUMN_PID]);
gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), COLUMN_PPID), show_col[COLUMN_PPID]);
gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), COLUMN_STATE), show_col[COLUMN_STATE]);
gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), COLUMN_MEM), show_col[COLUMN_MEM]);
gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), COLUMN_RSS), show_col[COLUMN_RSS]);
gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), COLUMN_UNAME), show_col[COLUMN_UNAME]);
gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), COLUMN_TIME), show_col[COLUMN_TIME]);
gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), COLUMN_PRIO), show_col[COLUMN_PRIO]);
}
void fill_list_item(gint i, GtkTreeIter *iter)
{
struct task *task;
gchar *pid;
gchar *ppid;
gchar *state;
gchar *vsize;
gchar *rss;
gchar *name;
gchar *uname;
gchar *time;
gchar *prio;
if(iter != NULL)
{
task = &g_array_index(task_array, struct task, i);
pid = g_strdup_printf("%i", task->pid);
ppid = g_strdup_printf("%i", task->ppid);
state = g_strdup_printf("%s", task->state);
vsize = g_strdup_printf((task->vsize/1024/1024 > 0) ? "%.0f MB" : "%.2f MB",
(gdouble)(task->vsize)/1024/1024);
rss = g_strdup_printf((task->rss/1024/1024 > 0) ? "%.0f MB" : "%.2f MB",
(gdouble)(task->rss)/1024/1024);
name = g_strdup_printf("%s", task->name);
uname = g_strdup_printf("%s", task->uname);
time = g_strdup_printf("%.0f%%", task->time_percentage);
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);
gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_STATE, state, -1);
gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_MEM, vsize, -1);
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);
g_free(vsize);
g_free(rss);
g_free(name);
g_free(uname);
g_free(time);
g_free(prio); /* my change */
}
}
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);
}
void refresh_list_item(gint i)
{
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 = "";
gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, 1, &str_data, -1);
if(task.pid == atoi(str_data))
{
g_free(str_data);
fill_list_item(i, &iter);
break;
}
g_free(str_data);
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter);
}
}
void remove_list_item(gint pid)
{
GtkTreeIter iter;
gboolean valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter);
while(valid)
{
gchar *str_data = "";
gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, 1, &str_data, -1);
if(pid == atoi(str_data))
{
g_free(str_data);
gtk_tree_store_remove(GTK_TREE_STORE(list_store), &iter);
break;
}
g_free(str_data);
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter);
}
}
gint compare_int_list_item(GtkTreeModel *model, GtkTreeIter *iter1, GtkTreeIter *iter2, gpointer column)
{
gchar *s1 = "";
gchar *s2 = "";
gdouble i1 = 0;
gdouble i2 = 0;
gint ret = 0;
gtk_tree_model_get(model, iter1, column, &s1, -1);
gtk_tree_model_get(model, iter2, column, &s2, -1);
if(s1 != NULL)
i1 = 100 * g_strtod(s1, NULL);
if(s2 != NULL)
i2 = 100 * g_strtod(s2, NULL);
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 = strcasecmp(s2, s1);
else
ret = 0;
if(s1 != NULL)
g_free(s1);
if(s2 != NULL)
g_free(s2);
return ret;
}
/* change the task view (user, root, other) */
void change_task_view(void)
{
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();
}

View File

@@ -1,83 +0,0 @@
/* $Id$
*
* Copyright (c) 2006 Johannes Zellner, <webmaster@nebulon.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef INTERFACE_H
#define INTERFACE_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <libxfcegui4/libxfcegui4.h>
#include "functions.h"
#include "callbacks.h"
#include "types.h"
#define BORDER 8
GtkTreeStore *list_store;
GtkTreeSelection *selection;
GtkWidget *treeview;
GtkWidget *mainmenu;
GtkWidget *infomenu;
#if !GTK_CHECK_VERSION (2, 12, 0)
GtkTooltips *tooltips;
#endif
GtkWidget *taskpopup;
GtkWidget *priopopup;
GtkWidget *cpu_usage_progress_bar;
GtkWidget *mem_usage_progress_bar;
GtkWidget *cpu_usage_progress_bar_box;
GtkWidget *mem_usage_progress_bar_box;
GtkTreeViewColumn *column;
void change_list_store_view(void);
void create_list_store(void);
GtkWidget* create_main_window (void);
GtkWidget* create_taskpopup (void);
GtkWidget* create_mainmenu (void);
GtkWidget* create_infomenu (void);
GtkWidget* create_prio_submenu(void);
void show_about_dialog(void);
void fill_list_item(gint i, GtkTreeIter *iter);
void add_new_list_item(gint i);
gint compare_list_item(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data);
gint compare_int_list_item(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data);
gint compare_string_list_item(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data);
void remove_list_item(gint i);
void refresh_list_item(gint i);
void change_task_view(void);
#endif

View File

@@ -81,7 +81,6 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
gchar *uid_name;
get_owner_uid (&treeview->owner_uid, &uid_name);
g_object_get (treeview->settings, "show-all-processes", &treeview->show_all_processes_cached, NULL);
g_debug ("wtf all processes: %d", treeview->show_all_processes_cached);
}
/* Create tree view model */
@@ -435,7 +434,6 @@ settings_changed (GObject *object, GParamSpec *pspec, XtmProcessTreeView *treevi
else if (!g_strcmp0 (pspec->name, "show-all-processes"))
{
g_object_get (object, pspec->name, &treeview->show_all_processes_cached, NULL);
// TODO show/hide system processes from treeview
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (treeview->model_filter));
}
}

View File

@@ -1,407 +0,0 @@
/*
* Copyright (c) 2006 Johannes Zellner <webmaster@nebulon.de>
* Copyright (c) 2008 Mike Massonnet <mmassonnet@xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <dirent.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include "taskmanager.h"
static void get_cmdline(gint pid, gchar *cmdline, gint length, gchar *cmdline_full, gint length_full)
{
FILE *file;
char filename[255];
char *p;
char *args = NULL;
int c;
int i = 0, j = 0;
int cmdline_found = 0;
char buffer[4096];
int idummy;
snprintf (filename, 255, "/proc/%i/cmdline", pid);
file = fopen (filename, "r");
if (file == NULL) {
return;
}
/* read byte per byte until EOF */
for (i = 0; (c = fgetc (file)) != EOF; i++) {
if (c == 0) {
c = ' ';
cmdline_found = 1;
if (args == NULL) {
args = cmdline_full + i;
}
}
if (!cmdline_found) {
cmdline[i] = c;
cmdline[i+1] = '\0';
}
cmdline_full[i] = c;
if (i == length_full - 1) {
break;
}
}
if (cmdline_full[i-1] == ' ') {
cmdline_full[i-1] = '\0';
} else {
cmdline_full[i] = '\0';
}
if (args != NULL && args[0] == '\0')
args = NULL;
fclose (file);
/* daemon processes and kernel processes don't have a cmdline */
if (i == 0) {
/* read from /proc/pid/stat and enclose with brakets */
snprintf (filename, 255, "/proc/%i/stat", pid);
file = fopen (filename, "r");
if (file == NULL) {
return;
}
fgets (buffer, sizeof (buffer), file);
fclose (file);
cmdline_full[0] = '[';
sscanf (buffer, "%i (%252s", &idummy, &cmdline_full[1]);
if (NULL != (strrchr (cmdline_full, ')'))) {
*strrchr (cmdline_full, ')') = '\0';
}
i = strlen (cmdline_full);
cmdline_full[i] = ']';
cmdline_full[i+1] = '\0';
strncpy (cmdline, cmdline_full, length);
return;
}
/* get the short version */
p = strchr (cmdline, ':');
if (NULL != p) {
*p = '\0';
} else {
p = strrchr (cmdline, '/');
if (NULL != p) {
for (i = p - cmdline + 1, j = 0; cmdline[i] != '\0'; i++, j++) {
cmdline[j] = cmdline[i];
}
cmdline[j] = '\0';
}
}
if (args != NULL) {
for (i = strlen(cmdline), j = 0; args[j] != '\0' && i < length - 1; i++, j++) {
cmdline[i] = args[j];
}
cmdline[i] = '\0';
}
if (cmdline[0] == '-') {
for (i = 0; cmdline[i] != '\0'; i++) {
cmdline[i] = cmdline[i+1];
}
}
}
static struct task get_task_details(gint pid)
{
FILE *task_file;
FILE *cmdline_file;
gchar dummy[255];
gint idummy;
gchar buffer_status[1024];
struct task task;
struct passwd *passwdp;
struct stat status;
gchar filename[255];
gchar cmdline_filename[255];
static gint pagesize = 0;
gint utime = 0;
gint stime = 0;
sprintf(filename, "/proc/%i/stat", pid);
sprintf(cmdline_filename, "/proc/%i/cmdline", pid);
task.pid = -1;
task.checked = FALSE;
stat(filename, &status);
if (pagesize == 0)
{
pagesize = sysconf(_SC_PAGESIZE);
if (pagesize == 0)
pagesize = 4*1024;
}
if(NULL == (task_file = fopen(filename,"r")))
return task;
fgets(buffer_status, sizeof(buffer_status), task_file);
fclose(task_file);
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
dummy, // processname
task.state, // processstate
&task.ppid, // parentid
&idummy, // processs groupid
&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
&utime, // utime the number of jiffies that this process has scheduled in user mode
&stime, // stime " kernel mode
&idummy, // cutime " waited for children in user
&idummy, // cstime " kernel mode
&idummy, // priority (nice value + fifteen)
&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
&idummy, // starttime jiffies the process startet after system boot
&task.vsize, // vsize in bytes
&task.rss, // rss (number of pages in real memory)
dummy, // rlim limit in bytes for rss
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, // nswap
dummy, // cnswap
dummy, // exit_signal
&idummy, // CPU number last executed on
dummy,
dummy
);
task.old_time = task.time;
task.time = stime + utime;
task.time_percentage = 0;
task.rss *= pagesize;
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));
get_cmdline(pid, task.name, sizeof(task.name), task.fullname, sizeof(task.fullname));
return task;
}
GArray *get_task_list(void)
{
DIR *dir;
struct dirent *dir_entry;
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)
{
struct task task = get_task_details(atoi(dir_entry->d_name));
if(task.pid != -1)
g_array_append_val(task_list, task);
}
count++;
}
closedir(dir);
return task_list;
}
gboolean get_cpu_usage_from_proc(system_status *sys_stat)
{
const gchar *file_name = "/proc/stat";
gchar buffer[100];
gboolean retval = FALSE;
FILE *file;
if ( sys_stat->valid_proc_reading == TRUE ) {
sys_stat->cpu_old_jiffies =
sys_stat->cpu_user +
sys_stat->cpu_nice +
sys_stat->cpu_system+
sys_stat->cpu_idle;
sys_stat->cpu_old_used =
sys_stat->cpu_user +
sys_stat->cpu_nice +
sys_stat->cpu_system;
} else {
sys_stat->cpu_old_jiffies = 0;
}
sys_stat->valid_proc_reading = FALSE;
if (!g_file_test (file_name, G_FILE_TEST_EXISTS))
{
return FALSE;
}
file = fopen (file_name, "r");
if (file)
{
if ( fgets (buffer, 100, file) != NULL )
{
if ( sscanf (buffer, "cpu\t%u %u %u %u",
&sys_stat->cpu_user,
&sys_stat->cpu_nice,
&sys_stat->cpu_system,
&sys_stat->cpu_idle
) == 4 )
{
sys_stat->valid_proc_reading = TRUE;
retval = TRUE;
}
}
fclose( file );
}
return retval;
}
gboolean get_system_status (system_status *sys_stat)
{
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)
{
sscanf (buffer, "MemTotal:\t%u kB", &sys_stat->mem_total);
sscanf (buffer, "MemFree:\t%u kB", &sys_stat->mem_free);
sscanf (buffer, "Cached:\t%u kB", &sys_stat->mem_cached);
sscanf (buffer, "Buffers:\t%u kB", &sys_stat->mem_buffers);
}
fclose (file);
}
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);
}
fclose (file);
sys_stat->cpu_count++;
}
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 %d 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_snprintf(command, 128, "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);
}
}