*** empty log message ***

(Old svn revision: 527)
This commit is contained in:
Johannes Zellner
2005-01-31 08:37:38 +00:00
parent 52f6c6d5ac
commit 12f8223970
11 changed files with 555 additions and 865 deletions

View File

@@ -1 +0,0 @@
SUBDIRS = src

View File

@@ -1,538 +0,0 @@
# Makefile.in generated by automake 1.9.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \
ChangeLog INSTALL NEWS depcomp install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPS_CFLAGS = @DEPS_CFLAGS@
DEPS_LIBS = @DEPS_LIBS@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EXEEXT = @EXEEXT@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
datadir = @datadir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = src
all: all-recursive
.SUFFIXES:
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
cd $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(mkdir_p) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \
check-am clean clean-generic clean-recursive ctags \
ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-shar \
dist-tarZ dist-zip distcheck distclean distclean-generic \
distclean-recursive distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
maintainer-clean-recursive mostlyclean mostlyclean-generic \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -1,6 +1,6 @@
bin_PROGRAMS = xfce4-taskmanager
xfce4_taskmanager_SOURCES = xfce4-taskmanager.c
xfce4_taskmanager_SOURCES = main.c types.h gui.c gui.h functions.c functions.h
INCLUDES = $(DEPS_CFLAGS)

138
src/functions.c Normal file
View File

@@ -0,0 +1,138 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2004 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.
*/
#include "functions.h"
task_count = 0;
/* function to kill the current task */
void send_signal_to_task(gchar *task_id, gchar *signal)
{
if(task_id != "" && signal != NULL)
{
gchar command[64] = "kill -";
g_strlcat(command,signal, 64);
g_strlcat(command," ", 64);
g_strlcat(command,task_id, 64);
if(system(command) != 0)
xfce_err("Couldn't %s the task with ID %s", signal, task_id);
}
}
void refresh_task_list()
{
/* markes all tasks to "not checked" */
gint i;
for(i = 0; i < task_count; i++)
all_tasks[i].checked = FALSE;
/* load the current taskdetails */
DIR *dir;
struct dirent *dir_entry;
if((dir = opendir("/proc")) == NULL)
printf("Error: couldn't load the directory\n");
while((dir_entry = readdir(dir)) != NULL)
{
if(atoi(dir_entry->d_name) != 0)
{
FILE *task_file;
gchar task_file_name[256] = "/proc/";
g_strlcat(task_file_name,dir_entry->d_name, 256);
g_strlcat(task_file_name,"/status", 256);
gchar buffer[256];
gint line_count = 0;
struct task task;
struct passwd *passwdp;
if((task_file = fopen(task_file_name,"r")) != NULL)
{
while(fgets(buffer, 256, task_file) != NULL)
{
if(line_count == 0)
strcpy(task.name,g_strstrip(g_strsplit(buffer, ":", 2)[1]));
else if(line_count == 3)
strcpy(task.pid,g_strstrip(g_strsplit(buffer, ":", 2)[1]));
else if(line_count == 5)
strcpy(task.ppid,g_strstrip(g_strsplit(buffer, ":", 2)[1]));
else if(line_count == 7)
{
passwdp = getpwuid(atoi(g_strsplit(g_strstrip(g_strsplit(buffer, ":", 2)[1]), "\t", 2)[0]));
strcpy(task.uid, passwdp->pw_name);
}
line_count++;
}
line_count = 0;
fclose(task_file);
/* check if task is new and marks the task that its checked*/
gboolean new_task = TRUE;
for(i = 0; i < task_count; i++)
{
if(strcmp(all_tasks[i].pid,task.pid) == 0)
{
all_tasks[i].checked = TRUE;
new_task = FALSE;
}
}
if(new_task)
{
task.checked = TRUE;
all_tasks[task_count] = task;
task_count++;
add_new_list_item(task);
}
}
}
}
closedir(dir);
/* removing all tasks which are not marked */
i = 0;
while(i < task_count)
{
if(!all_tasks[i].checked)
{
remove_list_item(all_tasks[i]);
remove_task_from_array(i);
}
i++;
}
}
void remove_task_from_array(gint count)
{
gint i;
for(i = count; i < task_count; i++)
{
all_tasks[i] = all_tasks[i+1];
}
task_count--;
}

34
src/functions.h Normal file
View File

@@ -0,0 +1,34 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2004 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.
*/
#include <gtk/gtk.h>
#include <dirent.h>
#include <pwd.h>
#include <sys/types.h>
#include "types.h"
struct task all_tasks[512];
gint task_count;
struct task task_list;
void refresh_task_list(void);
void send_signal_to_task(gchar *task_id, gchar *signal);

260
src/gui.c Normal file
View File

@@ -0,0 +1,260 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2004 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.
*/
#include "gui.h"
/* create the GUI */
void create_gui(void)
{
GtkWidget *window, *eventbox, *box, *button, *scrolled_window, *tree_view, *main_popup_menu, *task_popup_menu;
GtkCellRenderer *cell_renderer;
GtkTreeViewColumn *column;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "xfce4-taskmanager");
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_set_size_request(GTK_WIDGET(window), 450, 400);
/* popupmenus */
task_popup_menu = create_task_popup_menu();
main_popup_menu = create_main_popup_menu();
/* eventbox */
eventbox = gtk_event_box_new();
gtk_event_box_set_visible_window(GTK_EVENT_BOX(eventbox), FALSE);
gtk_widget_add_events(GTK_WIDGET(eventbox), "BUTTON_PRESS");
g_signal_connect_swapped(G_OBJECT(eventbox), "button-press-event", G_CALLBACK(handle_mouse_events), G_OBJECT(main_popup_menu));
gtk_container_set_border_width(GTK_CONTAINER(eventbox), 0);
gtk_container_add(GTK_CONTAINER(window), eventbox);
gtk_widget_show(eventbox);
box = gtk_vbox_new(FALSE, 10);
gtk_container_set_border_width(GTK_CONTAINER(box), 10);
gtk_container_add(GTK_CONTAINER(eventbox), box);
gtk_widget_show(box);
/* tasklist */
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(box), scrolled_window, TRUE, TRUE, 0);
gtk_widget_show(scrolled_window);
tree_view = gtk_tree_view_new();
g_signal_connect_swapped(G_OBJECT(tree_view), "button-press-event", G_CALLBACK(handle_mouse_events), G_OBJECT(task_popup_menu));
gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view);
gtk_widget_show(tree_view);
selection = gtk_tree_view_get_selection(tree_view);
list_store = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), list_store);
cell_renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("User", cell_renderer, "text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
column = gtk_tree_view_column_new_with_attributes("PID", cell_renderer, "text", 1, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
column = gtk_tree_view_column_new_with_attributes("PPID", cell_renderer, "text", 2, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
column = gtk_tree_view_column_new_with_attributes("Command", cell_renderer, "text", 3, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
/* load the tasklist */
refresh_task_list();
/* Quit-button */
button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_main_quit), NULL);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, TRUE, 0);
gtk_widget_show(button);
gtk_widget_show(window);
}
/* add new tasks to the list */
gboolean add_new_list_item(struct task task)
{
GtkTreeIter iter;
/* Append new line in the list */
gtk_list_store_append(GTK_LIST_STORE(list_store), &iter);
/* Fill the appended line with data */
gchar *list_value_1 = g_strdup_printf("%s", task.uid);
gtk_list_store_set(GTK_LIST_STORE(list_store), &iter, 0, list_value_1, -1);
g_free(list_value_1);
gchar *list_value_2 = g_strdup_printf("%s", task.pid);
gtk_list_store_set(GTK_LIST_STORE(list_store), &iter, 1, list_value_2, -1);
g_free(list_value_2);
gchar *list_value_3 = g_strdup_printf("%s", task.ppid);
gtk_list_store_set(GTK_LIST_STORE(list_store), &iter, 2, list_value_3, -1);
g_free(list_value_3);
gchar *list_value_4 = g_strdup_printf("%s", task.name);
gtk_list_store_set(GTK_LIST_STORE(list_store), &iter, 3, list_value_4, -1);
g_free(list_value_4);
return(TRUE);
}
void remove_list_item(struct task task)
{
gboolean valid;
GtkTreeIter iter;
valid = gtk_tree_model_get_iter_first(list_store, &iter);
while(valid)
{
gchar *str_data;
gtk_tree_model_get(list_store, &iter, 1, &str_data, -1);
if(strcmp(task.pid,str_data) == 0)
{
gtk_list_store_remove(list_store, &iter);
g_free(str_data);
break;
}
g_free(str_data);
valid = gtk_tree_model_iter_next(list_store, &iter);
}
}
GtkWidget *create_task_popup_menu()
{
GtkWidget *menu, *menuitem;
menu = gtk_menu_new();
menuitem = gtk_menu_item_new_with_label("Stop");
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(handle_task_menu), "STOP");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new_with_label("Continue");
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(handle_task_menu), "CONT");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new_with_label("Term");
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(handle_task_menu), "TERM");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new_with_label("Kill");
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(handle_task_menu), "KILL");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show(menuitem);
return(menu);
}
GtkWidget *create_main_popup_menu()
{
GtkWidget *menu, *menuitem;
menu = gtk_menu_new();
menuitem = gtk_menu_item_new_with_label("About");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_main_quit), NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show(menuitem);
return(menu);
}
gboolean handle_mouse_events(GtkWidget *widget, GdkEventButton *event)
{
if(event->button == 3)
{
GdkEventButton *mouseevent = (GdkEventButton *)event;
gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL, mouseevent->button, mouseevent->time);
return FALSE;
}
return(FALSE);
}
void handle_task_menu(GtkWidget *widget, gchar *signal)
{
if(signal != NULL)
{
if(strcmp(signal, "TERM") == 0)
{
if(xfce_confirm("Really TERM the Task?", 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(task_id, signal);
//refresh_task_list();
}
}
}
else if(strcmp(signal, "KILL") == 0)
{
if(xfce_confirm("Really KILL the Task?", 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(task_id, signal);
//refresh_task_list();
}
}
}
else
{
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);
}
}
}
}

36
src/gui.h Normal file
View File

@@ -0,0 +1,36 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2004 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.
*/
#include <gtk/gtk.h>
#include <libxfcegui4/libxfcegui4.h>
#include "types.h"
#include "functions.h"
GtkTreeSelection *selection;
GtkListStore *list_store;
void gui_create(void);
gboolean add_new_list_item(struct task task);
void remove_list_item(struct task task);
GtkWidget *create_task_popup_menu(void);
GtkWidget *create_main_popup_menu(void);
gboolean handle_mouse_events(GtkWidget *widget, GdkEventButton *event);
void handle_task_menu(GtkWidget *widget, gchar *signal);

53
src/main.c Normal file
View File

@@ -0,0 +1,53 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2004 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.
*/
#include <gtk/gtk.h>
#include <glib.h>
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include "gui.h"
/* config vars */
#define REFRESH_INTERVAL 1
/* handler for SIGALRM to refresh the list */
void refresh_handler(void)
{
refresh_task_list();
alarm(REFRESH_INTERVAL);
}
/* main */
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
create_gui();
signal(SIGALRM, refresh_handler);
alarm(REFRESH_INTERVAL);
gtk_main();
return 0;
}

33
src/types.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2004 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 __TYPES_H_
#define __TYPES_H_
struct task
{
gchar pid[256];
gchar ppid[256];
gchar uid[256];
gchar name[256];
gboolean checked;
};
#endif

Binary file not shown.

View File

@@ -1,325 +0,0 @@
/*
* xfce4-taskmanager - very simple taskmanger
*
* Copyright (c) 2004 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.
*/
#include <gtk/gtk.h>
#include <glib.h>
#include <stdio.h>
#include <libxfcegui4/libxfcegui4.h>
#include <dirent.h>
#include <pwd.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
/* config vars */
#define REFRESH_INTERVAL 3
gchar *current_task_id = "";
GtkListStore *model;
GtkWidget *window;
struct task
{
gchar pid[256];
gchar ppid[256];
gchar uid[256];
gchar name[256];
};
/* called, if the user select a listitem */
static void select_task(GtkTreeSelection *selection)
{
GtkTreeIter iter;
GtkTreeModel *model;
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gtk_tree_model_get (model, &iter, 1, &current_task_id, -1);
}
}
/* appends a new listitem */
static void add_new_list_item(struct task task)
{
GtkTreeIter iter;
struct passwd *passwdp;
/* Append new line in the list */
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
/* Fill the appended line with data */
passwdp = getpwuid(atoi(task.uid));
gchar *list_value_1 = g_strdup_printf("%s", passwdp->pw_name);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, list_value_1, -1);
g_free(list_value_1);
gchar *list_value_2 = g_strdup_printf("%s", task.pid);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1, list_value_2, -1);
g_free(list_value_2);
gchar *list_value_3 = g_strdup_printf("%s", task.ppid);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, 2, list_value_3, -1);
g_free(list_value_3);
gchar *list_value_4 = g_strdup_printf("%s", task.name);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, 3, list_value_4, -1);
g_free(list_value_4);
}
/* reads all taskes from 'ps' and creates the listitems */
static void get_task_list(void)
{
DIR *dir;
struct dirent *dir_entry;
if((dir = opendir("/proc")) == NULL)
printf("Error: couldn't load the directory\n");
while((dir_entry = readdir(dir)) != NULL)
{
if(atoi(dir_entry->d_name) != 0)
{
FILE *task_file;
gchar task_file_name[256] = "/proc/";
g_strlcat(task_file_name,dir_entry->d_name, 256);
g_strlcat(task_file_name,"/status", 256);
gchar buffer[256];
gint line_count = 0;
struct task task;
if((task_file = fopen(task_file_name,"r")) != NULL)
{
while(fgets(buffer, 256, task_file) != NULL)
{
if(line_count == 0)
strcpy(task.name,g_strstrip(g_strsplit(buffer, ":", 2)[1]));
else if(line_count == 3)
strcpy(task.pid,g_strstrip(g_strsplit(buffer, ":", 2)[1]));
else if(line_count == 5)
strcpy(task.ppid,g_strstrip(g_strsplit(buffer, ":", 2)[1]));
else if(line_count == 7)
strcpy(task.uid,g_strsplit(g_strstrip(g_strsplit(buffer, ":", 2)[1]), "\t", 2)[0]);
line_count++;
}
line_count = 0;
fclose(task_file);
add_new_list_item(task);
}
}
}
closedir(dir);
}
/* function to kill the current task */
static void send_signal_to_task(gchar *signal)
{
if(current_task_id != "")
{
gchar command[64] = "kill -";
g_strlcat(command,signal, 64);
g_strlcat(command," ", 64);
g_strlcat(command,current_task_id, 64);
if(system(command) != 0)
xfce_err("Couldn't %s the task with ID %s", signal, current_task_id);
}
}
/* handles all the button events */
static void handle_events(GtkWidget *widget, gchar *widget_action)
{
if(strcmp(widget_action, "task_stop") == 0)
{
send_signal_to_task("STOP");
gtk_list_store_clear(GTK_LIST_STORE(model));
get_task_list();
}
if(strcmp(widget_action, "task_cont") == 0)
{
send_signal_to_task("CONT");
gtk_list_store_clear(GTK_LIST_STORE(model));
get_task_list();
}
if(strcmp(widget_action, "task_term") == 0)
{
if(xfce_confirm("Really TERM the task?", GTK_STOCK_OK, NULL))
{
send_signal_to_task("TERM");
gtk_list_store_clear(GTK_LIST_STORE(model));
get_task_list();
}
}
if(strcmp(widget_action, "task_kill") == 0)
{
if(xfce_confirm("Really KILL the task?", GTK_STOCK_OK, NULL))
{
send_signal_to_task("KILL");
gtk_list_store_clear(GTK_LIST_STORE(model));
get_task_list();
}
}
if(strcmp(widget_action, "button_reload") == 0)
{
gtk_list_store_clear(GTK_LIST_STORE(model));
get_task_list();
}
if(strcmp(widget_action, "button_quit") == 0)
{
gtk_main_quit();
}
}
/* handles all the mouse events */
static gboolean handle_mouse_events(GtkWidget *widget, GdkEventButton *event)
{
printf("hallo");
if(event->button == 3)
{
GdkEventButton *mouseevent = (GdkEventButton *)event;
gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL, mouseevent->button, mouseevent->time);
return FALSE;
}
return FALSE;
}
/* create the GUI */
static void create_gui(void)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "xfce4-taskmanager");
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
gtk_widget_set_size_request (GTK_WIDGET (window), 450, 400);
GtkWidget *button;
GtkWidget *box1;
box1 = gtk_vbox_new(FALSE, 10);
/* list rightclickmenu */
GtkWidget *list_popupmenu;
GtkWidget *popupmenuitem;
list_popupmenu = gtk_menu_new();
popupmenuitem = gtk_menu_item_new_with_label("Stop");
gtk_menu_shell_append(GTK_MENU_SHELL(list_popupmenu), popupmenuitem);
g_signal_connect(G_OBJECT(popupmenuitem), "activate", G_CALLBACK(handle_events), "task_stop");
gtk_widget_show(popupmenuitem);
popupmenuitem = gtk_menu_item_new_with_label("Continue");
gtk_menu_shell_append(GTK_MENU_SHELL(list_popupmenu), popupmenuitem);
g_signal_connect(G_OBJECT(popupmenuitem), "activate", G_CALLBACK(handle_events), "task_cont");
gtk_widget_show(popupmenuitem);
popupmenuitem = gtk_menu_item_new_with_label("Term");
gtk_menu_shell_append(GTK_MENU_SHELL(list_popupmenu), popupmenuitem);
g_signal_connect(G_OBJECT(popupmenuitem), "activate", G_CALLBACK(handle_events), "task_term");
gtk_widget_show(popupmenuitem);
popupmenuitem = gtk_menu_item_new_with_label("Kill");
gtk_menu_shell_append(GTK_MENU_SHELL(list_popupmenu), popupmenuitem);
g_signal_connect(G_OBJECT(popupmenuitem), "activate", G_CALLBACK(handle_events), "task_kill");
gtk_widget_show(popupmenuitem);
/* tasklistgui */
GtkWidget *scrolled_window;
GtkTreeSelection *select;
GtkWidget *tree_view;
GtkTreeIter iter;
GtkCellRenderer *cell;
GtkTreeViewColumn *column;
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
model = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
tree_view = gtk_tree_view_new();
gtk_container_add (GTK_CONTAINER(scrolled_window), tree_view);
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
g_signal_connect_swapped (G_OBJECT(tree_view), "button-press-event", G_CALLBACK(handle_mouse_events), G_OBJECT(list_popupmenu));
gtk_widget_show (tree_view);
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("User", cell, "text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), GTK_TREE_VIEW_COLUMN (column));
column = gtk_tree_view_column_new_with_attributes("PID", cell, "text", 1, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), GTK_TREE_VIEW_COLUMN (column));
column = gtk_tree_view_column_new_with_attributes("PPID", cell, "text", 2, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), GTK_TREE_VIEW_COLUMN (column));
column = gtk_tree_view_column_new_with_attributes("Command", cell, "text", 3, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), GTK_TREE_VIEW_COLUMN (column));
select = gtk_tree_view_get_selection(GTK_TREE_VIEW (tree_view));
gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(select_task), NULL);
/* load the tasklist */
get_task_list();
gtk_box_pack_start(GTK_BOX(box1), scrolled_window, TRUE, TRUE, 0);
gtk_widget_show(scrolled_window);
/* QUIT-Button */
button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK(handle_events), "button_quit");
gtk_box_pack_start(GTK_BOX(box1), button, FALSE, TRUE, 0);
gtk_widget_show(button);
gtk_container_add (GTK_CONTAINER(window), box1);
gtk_widget_show(box1);
gtk_widget_show(window);
}
/* handler for SIGALRM to refresh the list */
void refresh_handler(void)
{
gtk_list_store_clear(GTK_LIST_STORE(model));
get_task_list();
alarm(REFRESH_INTERVAL);
}
/* main */
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
create_gui();
signal(SIGALRM, refresh_handler);
alarm(REFRESH_INTERVAL);
gtk_main();
return 0;
}