Merge branch 'master' of ssh://git.xfce.org/git/apps/xfce4-taskmanager

Conflicts:
	src/task-manager-bsd.c
This commit is contained in:
Landry Breuil
2010-05-16 12:56:06 +02:00
8 changed files with 231 additions and 292 deletions

View File

@@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: xfce4-taskmanager 0.4.0-rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-05-10 21:04+0000\n"
"POT-Creation-Date: 2010-05-15 10:07+0000\n"
"PO-Revision-Date: 2008-07-31 01:00+0200\n"
"Last-Translator: Fabian Nowak <timystery@arcor.de>\n"
"Language-Team: German <xfce-i18n@xfce.org>\n"
@@ -41,9 +41,9 @@ msgid "Memory: %.2f%%"
msgstr "Speicher: %.2f%%"
#: ../src/process-statusbar.c:135
#, c-format
#, c-format, fuzzy
msgid "Swap: %.2f%%"
msgstr ""
msgstr "Auslagerungsspeicher: %.2f%%"
#: ../src/process-statusbar.c:142
#, c-format
@@ -110,16 +110,17 @@ msgid "Error sending signal"
msgstr "Signal konnte nicht gesendet werden"
#: ../src/process-tree-view.c:227
#, c-format, fuzzy
#, fuzzy, c-format
msgid "An error was encountered by sending a signal to the PID %d. It is likely you don't have the required privileges."
msgstr "Beim Senden eines Signals an die Anwendung mit der ID %d ist ein Fehler aufgetreten. Möglicherweise haben Sie nicht die notwendigen Rechte."
#: ../src/process-tree-view.c:244
#, fuzzy
msgid "Error setting priority"
msgstr ""
msgstr "Fehler beim Setzen der Priorität"
#: ../src/process-tree-view.c:245
#, c-format, fuzzy
#, fuzzy, c-format
msgid "An error was encountered by setting a priority to the PID %d. It is likely you don't have the required privileges."
msgstr "Beim Senden eines Signals an die Anwendung mit der ID %d ist ein Fehler aufgetreten. Möglicherweise haben Sie nicht die notwendigen Rechte."
@@ -167,8 +168,9 @@ msgid "Priority"
msgstr "Priorität"
#: ../src/process-window.c:197
#, fuzzy
msgid "Execution error"
msgstr ""
msgstr "Ausführungsfehler"
#: ../src/process-window.c:226
#, fuzzy
@@ -184,8 +186,9 @@ msgid "Terminal emulator"
msgstr ""
#: ../src/process-window.c:229
#, fuzzy
msgid "XTerm"
msgstr ""
msgstr "XTerm"
#: ../src/process-window.c:271
msgid "Show all processes"
@@ -208,19 +211,19 @@ msgstr ""
"Paul Seyfert"
#: ../src/task-manager.c:146
#, c-format
#, c-format, fuzzy
msgid "%lu MiB"
msgstr ""
msgstr "%lu MiB"
#: ../src/task-manager.c:153
#, c-format
#, c-format, fuzzy
msgid "%lu KiB"
msgstr ""
msgstr "%lu KiB"
#: ../src/task-manager.c:157
#, c-format
#, c-format, fuzzy
msgid "%lu B"
msgstr ""
msgstr "%lu B"
#. TODO make precision optional
#: ../src/task-manager.c:168

View File

@@ -2,12 +2,12 @@
# Copyright (C) 2005 Johannes Zellner.
# This file is distributed under the same license as the xfce4-taskmanager package.
# Nuno Miguel <nunis@netcabo.pt>, 2007.
#
#
msgid ""
msgstr ""
"Project-Id-Version: xfce4-taskmanager 0.4.0-rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-05-10 23:04+0200\n"
"POT-Creation-Date: 2010-05-14 10:07+0000\n"
"PO-Revision-Date: 2008-08-28 12:30+0100\n"
"Last-Translator: Nuno Miguel <nunis@netcabo.pt>\n"
"Language-Team: \n"
@@ -16,40 +16,38 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
#: ../xfce4-taskmanager.desktop.in.h:1 ../src/process-window.c:326
#, fuzzy
msgid "Easy to use task manager"
msgstr "Xfce4-Taskmanager é um gestor de tarefas fácil de usar"
msgstr "Gestor de tarefas fácil de utilizar"
#: ../xfce4-taskmanager.desktop.in.h:2 ../src/process-tree-view.c:215
#: ../src/process-tree-view.c:229 ../src/process-tree-view.c:247
#: ../src/process-window.c:199 ../src/process-window.c:321
#, fuzzy
msgid "Task Manager"
msgstr "Gestor de tarefas Xfce4"
msgstr "Gestor de Tarefas"
#: ../src/process-statusbar.c:121
#, c-format
msgid "CPU: %.2f%%"
msgstr ""
msgstr "CPU: %.2f%%"
#: ../src/process-statusbar.c:128
#, c-format
msgid "Memory: %.2f%%"
msgstr ""
msgstr "Memória: %.2f%%"
#: ../src/process-statusbar.c:135
#, c-format
msgid "Swap: %.2f%%"
msgstr ""
msgstr "Swap: %.2f%%"
#: ../src/process-statusbar.c:142
#, c-format
msgid "Processes: %d"
msgstr ""
msgstr "Processos: %d"
#: ../src/process-tree-view.c:106
msgid "Task"
msgstr ""
msgstr "Tarefa"
#: ../src/process-tree-view.c:116 ../src/process-window.c:276
msgid "PID"
@@ -65,67 +63,58 @@ msgstr "Estado"
#: ../src/process-tree-view.c:141
msgid "VSZ"
msgstr ""
msgstr "VSZ"
#: ../src/process-tree-view.c:149
msgid "RSS"
msgstr "RSS"
#: ../src/process-tree-view.c:157 ../src/process-window.c:281
#, fuzzy
msgid "UID"
msgstr "PID"
msgstr "UID"
#: ../src/process-tree-view.c:165 ../src/process-window.c:282
#, fuzzy
msgid "CPU"
msgstr "CPU%"
msgstr "CPU"
#. TRANSLATORS: “Prio.” is short for Priority, it appears in the tree view header.
#. TRANSLATORS: “Prio.” is short for Priority, it appears in the tree view
#. header.
#: ../src/process-tree-view.c:174
#, fuzzy
msgid "Prio."
msgstr "Prio"
msgstr "Prio."
#: ../src/process-tree-view.c:212
#, fuzzy
msgid "Terminate task"
msgstr "Terminar a tarefa?"
msgstr "Terminar tarefa"
#: ../src/process-tree-view.c:212
#, fuzzy
msgid "Kill task"
msgstr "Matar"
msgstr "Matar tarefa"
#: ../src/process-tree-view.c:214
#, c-format
msgid "Are you sure you want to send a signal to the PID %d?"
msgstr ""
msgstr "Tem a certeza que pretende enviar um sinal ao PID %d?"
#: ../src/process-tree-view.c:225
msgid "Error sending signal"
msgstr ""
msgstr "Erro ao enviar o sinal"
#: ../src/process-tree-view.c:227
#, c-format
msgid ""
"An error was encountered by sending a signal to the PID %d. It is likely you "
"don't have the required privileges."
msgstr ""
msgid "An error was encountered by sending a signal to the PID %d. It is likely you don't have the required privileges."
msgstr "Ocorreu um erro ao enviar o sinal ao PID %d. É possível que não tenha os privilégios necessários."
#: ../src/process-tree-view.c:244
msgid "Error setting priority"
msgstr ""
msgstr "Erro ao definir a prioridade"
#: ../src/process-tree-view.c:245
#, c-format
msgid ""
"An error was encountered by setting a priority to the PID %d. It is likely "
"you don't have the required privileges."
msgstr ""
msgid "An error was encountered by setting a priority to the PID %d. It is likely you don't have the required privileges."
msgstr "Ocorreu um erro ao definir a prioridade para o PID %d. É possível que não tenha os privilégios necessários."
#: ../src/process-tree-view.c:260
#, fuzzy
msgid "Terminate"
msgstr "Terminar"
@@ -143,23 +132,23 @@ msgstr "Matar"
#: ../src/process-tree-view.c:287
msgid "Very low"
msgstr ""
msgstr "Muito baixa"
#: ../src/process-tree-view.c:292
msgid "Low"
msgstr ""
msgstr "Baixa"
#: ../src/process-tree-view.c:297
msgid "Normal"
msgstr ""
msgstr "Normal"
#: ../src/process-tree-view.c:302
msgid "High"
msgstr ""
msgstr "Alta"
#: ../src/process-tree-view.c:307
msgid "Very high"
msgstr ""
msgstr "Muito alta"
#: ../src/process-tree-view.c:312 ../src/process-window.c:283
msgid "Priority"
@@ -167,38 +156,35 @@ msgstr "Prioridade"
#: ../src/process-window.c:197
msgid "Execution error"
msgstr ""
msgstr "Erro de execução"
#: ../src/process-window.c:226
msgid "Run Program..."
msgstr ""
msgstr "Executar Programa..."
#: ../src/process-window.c:227
msgid "Application Finder"
msgstr ""
msgstr "Descobridor de Aplicações"
#: ../src/process-window.c:228
#, fuzzy
msgid "Terminal emulator"
msgstr "Autor Original:"
msgstr "Emulador de terminal"
#: ../src/process-window.c:229
#, fuzzy
msgid "XTerm"
msgstr "Terminar"
msgstr "XTerm"
#: ../src/process-window.c:271
#, fuzzy
msgid "Show all processes"
msgstr "Controle os seus processos"
msgstr "Mostrar todos os processos"
#: ../src/process-window.c:279
msgid "Virtual Bytes"
msgstr ""
msgstr "Bytes Virtuais"
#: ../src/process-window.c:280
msgid "Private Bytes"
msgstr ""
msgstr "Bytes Privados"
#: ../src/process-window.c:329
msgid "translator-credits"
@@ -207,23 +193,23 @@ msgstr "Nuno Miguel"
#: ../src/task-manager.c:146
#, c-format
msgid "%lu MiB"
msgstr ""
msgstr "%lu MB"
#: ../src/task-manager.c:153
#, c-format
msgid "%lu KiB"
msgstr ""
msgstr "%lu KB"
#: ../src/task-manager.c:157
#, c-format
msgid "%lu B"
msgstr ""
msgstr "%lu B"
#. TODO make precision optional
#: ../src/task-manager.c:168
#, fuzzy, c-format
#, c-format
msgid "%.2f%%"
msgstr "%0.0f %%"
msgstr "%.2f%%"
#~ msgid "Control your processes"
#~ msgstr "Controle os seus processos"

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: xfce4-taskmanager 0.4.0-rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-05-11 04:07+0000\n"
"POT-Creation-Date: 2010-05-16 04:07+0000\n"
"PO-Revision-Date: 2009-10-17 23:23+0300\n"
"Last-Translator: Vlad Vasilev <lortwer@gmail.com>\n"
"Language-Team: Russian <ru@li.org>\n"
@@ -23,7 +23,6 @@ msgstr "Простой менеджер процессов"
#: ../xfce4-taskmanager.desktop.in.h:2 ../src/process-tree-view.c:215
#: ../src/process-tree-view.c:229 ../src/process-tree-view.c:247
#: ../src/process-window.c:199 ../src/process-window.c:321
#, fuzzy
msgid "Task Manager"
msgstr "Диспетчер задач Xfce 4"

125
po/tr.po
View File

@@ -4,126 +4,123 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-05-10 23:04+0200\n"
"PO-Revision-Date: \n"
"Last-Translator: Samed Beyribey <ras0ir@eventualis.org>\n"
"Last-Translator: Gökmen Görgen <gkmngrgn@gmail.com>\n"
"Language-Team: Xfce-TR <xfce-tr@googlegroups.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Country: TURKEY\n"
#: ../xfce4-taskmanager.desktop.in.h:1 ../src/process-window.c:326
#, fuzzy
#: ../xfce4-taskmanager.desktop.in.h:1
#: ../src/process-window.c:326
msgid "Easy to use task manager"
msgstr "Xfce4-Taskmanager kullanımı kolay bir görev yöneticisidir"
msgstr "Kullanımı kolay görev yöneticisi"
#: ../xfce4-taskmanager.desktop.in.h:2 ../src/process-tree-view.c:215
#: ../src/process-tree-view.c:229 ../src/process-tree-view.c:247
#: ../src/process-window.c:199 ../src/process-window.c:321
#, fuzzy
#: ../xfce4-taskmanager.desktop.in.h:2
#: ../src/process-tree-view.c:215
#: ../src/process-tree-view.c:229
#: ../src/process-tree-view.c:247
#: ../src/process-window.c:199
#: ../src/process-window.c:321
msgid "Task Manager"
msgstr "Xfce4 Görev Yöneticisi"
msgstr "Görev Yöneticisi"
#: ../src/process-statusbar.c:121
#, c-format
msgid "CPU: %.2f%%"
msgstr ""
msgstr "İşlemci : %.2f%%"
#: ../src/process-statusbar.c:128
#, c-format
msgid "Memory: %.2f%%"
msgstr ""
msgstr "Hafıza : %.2f%%"
#: ../src/process-statusbar.c:135
#, c-format
msgid "Swap: %.2f%%"
msgstr ""
msgstr "Takas : %.2f%%"
#: ../src/process-statusbar.c:142
#, c-format
msgid "Processes: %d"
msgstr ""
msgstr "İşlemler : %d"
#: ../src/process-tree-view.c:106
msgid "Task"
msgstr ""
msgstr "Görev"
#: ../src/process-tree-view.c:116 ../src/process-window.c:276
#: ../src/process-tree-view.c:116
#: ../src/process-window.c:276
msgid "PID"
msgstr "PID"
#: ../src/process-tree-view.c:124 ../src/process-window.c:277
#: ../src/process-tree-view.c:124
#: ../src/process-window.c:277
msgid "PPID"
msgstr "PPID"
#: ../src/process-tree-view.c:132 ../src/process-window.c:278
#: ../src/process-tree-view.c:132
#: ../src/process-window.c:278
msgid "State"
msgstr "Durum"
#: ../src/process-tree-view.c:141
msgid "VSZ"
msgstr ""
msgstr "VSZ"
#: ../src/process-tree-view.c:149
msgid "RSS"
msgstr "RSS"
#: ../src/process-tree-view.c:157 ../src/process-window.c:281
#, fuzzy
#: ../src/process-tree-view.c:157
#: ../src/process-window.c:281
msgid "UID"
msgstr "PID"
msgstr "UID"
#: ../src/process-tree-view.c:165 ../src/process-window.c:282
#, fuzzy
#: ../src/process-tree-view.c:165
#: ../src/process-window.c:282
msgid "CPU"
msgstr "CPU%"
msgstr "CPU"
#. TRANSLATORS: “Prio.” is short for Priority, it appears in the tree view header.
#: ../src/process-tree-view.c:174
#, fuzzy
msgid "Prio."
msgstr "Öncel"
msgstr "Öncelik"
#: ../src/process-tree-view.c:212
#, fuzzy
msgid "Terminate task"
msgstr "revi sonlandırmak istiyor musunuz?"
msgstr "reci sonlandır"
#: ../src/process-tree-view.c:212
#, fuzzy
msgid "Kill task"
msgstr "Sonlandır"
msgstr "Süreci öldür"
#: ../src/process-tree-view.c:214
#, c-format
msgid "Are you sure you want to send a signal to the PID %d?"
msgstr ""
msgstr "PID %d için sinyal göndermek istediğinize emin misiniz?"
#: ../src/process-tree-view.c:225
msgid "Error sending signal"
msgstr ""
msgstr "Sinyal gönderme hatası"
#: ../src/process-tree-view.c:227
#, c-format
msgid ""
"An error was encountered by sending a signal to the PID %d. It is likely you "
"don't have the required privileges."
msgstr ""
msgid "An error was encountered by sending a signal to the PID %d. It is likely you don't have the required privileges."
msgstr "PID %d için sinyal gönderilirken beklenmeyen hata oluştu. Muhtemelen gereken izinlere sahip değilsiniz."
#: ../src/process-tree-view.c:244
msgid "Error setting priority"
msgstr ""
msgstr "Öncelik ayarlama hatası"
#: ../src/process-tree-view.c:245
#, c-format
msgid ""
"An error was encountered by setting a priority to the PID %d. It is likely "
"you don't have the required privileges."
msgstr ""
msgid "An error was encountered by setting a priority to the PID %d. It is likely you don't have the required privileges."
msgstr "PID %d için öncelik atarken beklenmeyen hata oluştu. Muhtemelen gereken izinlere sahip değilsiniz."
#: ../src/process-tree-view.c:260
#, fuzzy
msgid "Terminate"
msgstr "Term"
msgstr "Sonlandır"
#: ../src/process-tree-view.c:267
msgid "Stop"
@@ -139,62 +136,60 @@ msgstr "Sonlandır"
#: ../src/process-tree-view.c:287
msgid "Very low"
msgstr ""
msgstr "Çok düşük"
#: ../src/process-tree-view.c:292
msgid "Low"
msgstr ""
msgstr "Düşük"
#: ../src/process-tree-view.c:297
msgid "Normal"
msgstr ""
msgstr "Normal"
#: ../src/process-tree-view.c:302
msgid "High"
msgstr ""
msgstr "Yüksek"
#: ../src/process-tree-view.c:307
msgid "Very high"
msgstr ""
msgstr "Çok yüksek"
#: ../src/process-tree-view.c:312 ../src/process-window.c:283
#: ../src/process-tree-view.c:312
#: ../src/process-window.c:283
msgid "Priority"
msgstr "Öncelik"
#: ../src/process-window.c:197
msgid "Execution error"
msgstr ""
msgstr "Başlatıcı hatası"
#: ../src/process-window.c:226
msgid "Run Program..."
msgstr ""
msgstr "Program Çalıştır"
#: ../src/process-window.c:227
msgid "Application Finder"
msgstr ""
msgstr "Uygulama Bulucu"
#: ../src/process-window.c:228
#, fuzzy
msgid "Terminal emulator"
msgstr "Geliştirici:"
msgstr "Terminal öykünücüsü"
#: ../src/process-window.c:229
#, fuzzy
msgid "XTerm"
msgstr "Term"
msgstr "XTerm"
#: ../src/process-window.c:271
#, fuzzy
msgid "Show all processes"
msgstr "Süreçlerinizi kontrol edin"
msgstr "Tüm işlemleri göster"
#: ../src/process-window.c:279
msgid "Virtual Bytes"
msgstr ""
msgstr "Sanal Bitler"
#: ../src/process-window.c:280
msgid "Private Bytes"
msgstr ""
msgstr "Özel Bitler"
#: ../src/process-window.c:329
msgid "translator-credits"
@@ -203,23 +198,23 @@ msgstr "Samed Beyribey <ras0ir@eventualis.org>, 2008"
#: ../src/task-manager.c:146
#, c-format
msgid "%lu MiB"
msgstr ""
msgstr "%lu MiB"
#: ../src/task-manager.c:153
#, c-format
msgid "%lu KiB"
msgstr ""
msgstr "%lu KiB"
#: ../src/task-manager.c:157
#, c-format
msgid "%lu B"
msgstr ""
msgstr "%lu B"
#. TODO make precision optional
#: ../src/task-manager.c:168
#, fuzzy, c-format
#, c-format
msgid "%.2f%%"
msgstr "%0.0f %%"
msgstr "%.2f%%"
#~ msgid "Control your processes"
#~ msgstr "Süreçlerinizi kontrol edin"

View File

@@ -17,6 +17,7 @@
*/
#include <stdlib.h>
#include <err.h>
/* for getpwuid() */
#include <sys/types.h>
#include <pwd.h>
@@ -26,9 +27,6 @@
#include <sys/sysctl.h>
/* for swapctl() */
#include <sys/swap.h>
/* for kill() */
#include <signal.h>
#include <err.h>
/* for strlcpy() */
#include <string.h>
/* for getpagesize() */
@@ -207,55 +205,3 @@ gboolean get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64
return TRUE;
}
gboolean send_signal_to_pid (guint task_id, gint sig)
{
gint ret;
switch (sig)
{
case XTM_SIGNAL_TERMINATE:
sig = SIGTERM;
break;
case XTM_SIGNAL_STOP:
sig = SIGSTOP;
break;
case XTM_SIGNAL_CONTINUE:
sig = SIGCONT;
break;
case XTM_SIGNAL_KILL:
sig = SIGKILL;
break;
default:
return TRUE;
}
ret = kill (task_id, sig);
return (ret == 0) ? TRUE : FALSE;
}
gboolean set_priority_to_pid (guint task_id, gint prio)
{
gint res;
switch (prio)
{
case XTM_PRIORITY_VERY_LOW:
prio = 15;
break;
case XTM_PRIORITY_LOW:
prio = 5;
break;
case XTM_PRIORITY_NORMAL:
prio = 0;
break;
case XTM_PRIORITY_HIGH:
prio = -5;
break;
case XTM_PRIORITY_VERY_HIGH:
prio = -15;
break;
default:
return TRUE;
}
res = setpriority (PRIO_PROCESS, task_id, prio);
return (res == 0) ? TRUE : FALSE;
}

View File

@@ -14,8 +14,6 @@
#include <pwd.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <sys/resource.h>
#include <glib.h>
@@ -72,13 +70,19 @@ get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system)
fgets (buffer, 1024, file);
sscanf (buffer, "cpu\t%u %u %u %u", &user, &user_nice, &system, &idle);
_cpu_count = 0;
while (fgets (buffer, 1024, file) != NULL)
if (_cpu_count == 0)
{
if (buffer[0] != 'c' && buffer[1] != 'p' && buffer[2] != 'u')
break;
_cpu_count += 1;
_cpu_count = 0;
while (fgets (buffer, 1024, file) != NULL)
{
if (buffer[0] != 'c' && buffer[1] != 'p' && buffer[2] != 'u')
break;
_cpu_count += 1;
}
if (_cpu_count == 0)
_cpu_count += 1;
}
fclose (file);
old_jiffies_user = cur_jiffies_user;
@@ -91,8 +95,7 @@ get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system)
*cpu_user = (old_jiffies > 0) ? (cur_jiffies_user - old_jiffies_user) * 100 / (gdouble)(cur_jiffies - old_jiffies) : 0;
*cpu_system = (old_jiffies > 0) ? (cur_jiffies_system - old_jiffies_system) * 100 / (gdouble)(cur_jiffies - old_jiffies) : 0;
*cpu_count = (_cpu_count > 0) ? _cpu_count : 1;
_cpu_count = *cpu_count;
*cpu_count = _cpu_count;
return TRUE;
}
@@ -160,6 +163,9 @@ get_cpu_percent (guint pid, gulong jiffies_user, gfloat *cpu_user, gulong jiffie
g_hash_table_insert (hash_cpu_user, GUINT_TO_POINTER (pid), GUINT_TO_POINTER (jiffies_user));
g_hash_table_insert (hash_cpu_system, GUINT_TO_POINTER (pid), GUINT_TO_POINTER (jiffies_system));
if (jiffies_user < jiffies_user_old || jiffies_system < jiffies_system_old)
return;
if (_cpu_count > 0)
{
*cpu_user = (jiffies_user_old > 0) ? (jiffies_user - jiffies_user_old) / (gfloat)_cpu_count : 0;
@@ -329,58 +335,3 @@ pid_is_sleeping (guint pid)
return (state[0] == 'T') ? TRUE : FALSE;
}
gboolean
send_signal_to_pid (guint pid, gint signal)
{
gint sig;
gint res;
switch (signal)
{
case XTM_SIGNAL_TERMINATE:
sig = SIGTERM;
break;
case XTM_SIGNAL_STOP:
sig = SIGSTOP;
break;
case XTM_SIGNAL_CONTINUE:
sig = SIGCONT;
break;
case XTM_SIGNAL_KILL:
sig = SIGKILL;
break;
default:
return TRUE;
}
res = kill (pid, sig);
return (res == 0) ? TRUE : FALSE;
}
gboolean
set_priority_to_pid (guint pid, gint priority)
{
gint prio;
gint res;
switch (priority)
{
case XTM_PRIORITY_VERY_LOW:
prio = 15;
break;
case XTM_PRIORITY_LOW:
prio = 5;
break;
case XTM_PRIORITY_NORMAL:
prio = 0;
break;
case XTM_PRIORITY_HIGH:
prio = -5;
break;
case XTM_PRIORITY_VERY_HIGH:
prio = -15;
break;
default:
return TRUE;
}
res = setpriority (PRIO_PROCESS, pid, prio);
return (res == 0) ? TRUE : FALSE;
}

View File

@@ -14,6 +14,8 @@
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <signal.h>
#include <sys/resource.h>
#include <glib-object.h>
#include <glib/gi18n.h>
@@ -92,34 +94,6 @@ _xtm_task_manager_set_model (XtmTaskManager *manager, GtkTreeModel *model)
manager->model = model;
}
void
get_owner_uid (guint *owner_uid, gchar **owner_uid_name)
{
uid_t uid;
struct passwd *pw;
gchar *username = NULL;
uid = getuid ();
pw = getpwuid (uid);
username = g_strdup ((pw != NULL) ? pw->pw_name : "nobody");
*owner_uid = (guint) uid;
*owner_uid_name = username;
}
gchar *
get_hostname ()
{
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
#endif
char hostname[HOST_NAME_MAX];
if (gethostname (hostname, HOST_NAME_MAX))
return g_strdup ("(unknown)");
return g_strdup_printf ("%s", hostname);
}
static void
model_add_task (GtkTreeModel *model, Task *task)
{
@@ -372,3 +346,88 @@ xtm_task_manager_update_model (XtmTaskManager *manager)
return;
}
void
get_owner_uid (guint *owner_uid, gchar **owner_uid_name)
{
uid_t uid;
struct passwd *pw;
gchar *username = NULL;
uid = getuid ();
pw = getpwuid (uid);
username = g_strdup ((pw != NULL) ? pw->pw_name : "nobody");
*owner_uid = (guint) uid;
*owner_uid_name = username;
}
gchar *
get_hostname ()
{
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
#endif
char hostname[HOST_NAME_MAX];
if (gethostname (hostname, HOST_NAME_MAX))
return g_strdup ("(unknown)");
return g_strdup_printf ("%s", hostname);
}
gboolean
send_signal_to_pid (guint pid, gint signal)
{
gint sig;
gint res;
switch (signal)
{
case XTM_SIGNAL_TERMINATE:
sig = SIGTERM;
break;
case XTM_SIGNAL_STOP:
sig = SIGSTOP;
break;
case XTM_SIGNAL_CONTINUE:
sig = SIGCONT;
break;
case XTM_SIGNAL_KILL:
sig = SIGKILL;
break;
default:
return TRUE;
}
res = kill (pid, sig);
return (res == 0) ? TRUE : FALSE;
}
gboolean
set_priority_to_pid (guint pid, gint priority)
{
gint prio;
gint res;
switch (priority)
{
case XTM_PRIORITY_VERY_LOW:
prio = 15;
break;
case XTM_PRIORITY_LOW:
prio = 5;
break;
case XTM_PRIORITY_NORMAL:
prio = 0;
break;
case XTM_PRIORITY_HIGH:
prio = -5;
break;
case XTM_PRIORITY_VERY_HIGH:
prio = -15;
break;
default:
return TRUE;
}
res = setpriority (PRIO_PROCESS, pid, prio);
return (res == 0) ? TRUE : FALSE;
}

View File

@@ -63,12 +63,10 @@ enum
* OS specific implementation.
*/
gboolean get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64 *memory_cache, guint64 *memory_buffers, guint64 *swap_total, guint64 *swap_free);
gboolean get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system);
gboolean get_task_list (GArray *task_list);
gboolean pid_is_sleeping (guint pid);
gboolean send_signal_to_pid (guint pid, gint signal);
gboolean set_priority_to_pid (guint pid, gint priority);
gboolean get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64 *memory_cache, guint64 *memory_buffers, guint64 *swap_total, guint64 *swap_free);
gboolean get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system);
gboolean get_task_list (GArray *task_list);
gboolean pid_is_sleeping (guint pid);
/**
* GObject class used to update the graphical widgets.
@@ -95,7 +93,9 @@ void xtm_task_manager_update_model (XtmTaskManager *manager);
* Helper functions.
*/
void get_owner_uid (guint *owner_uid, gchar **owner_uid_name);
gchar * get_hostname ();
void get_owner_uid (guint *owner_uid, gchar **owner_uid_name);
gchar * get_hostname ();
gboolean send_signal_to_pid (guint pid, gint signal);
gboolean set_priority_to_pid (guint pid, gint priority);
#endif /* !TASK_MANAGER_H */