[nautilus-actions] Implement is_candidate_for_show_if_running() function
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Implement is_candidate_for_show_if_running() function
- Date: Fri, 30 Jul 2010 02:09:19 +0000 (UTC)
commit 112ee32d5e5013c165ea5f0bb24779f994c7d07e
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jul 30 03:31:34 2010 +0200
Implement is_candidate_for_show_if_running() function
ChangeLog | 7 +++++++
TODO | 6 ++----
configure.ac | 2 ++
src/core/na-icontext.c | 27 ++++++++++++++++++++++++---
4 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7bf6f4b..fc619ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-07-30 Pierre Wieser <pwieser trychlos org>
+
+ * configure.ac: Add a dependancy on libgtop.
+
+ * src/core/na-icontext.c (is_candidate_for_show_if_running):
+ Implement the function.
+
2010-07-29 Pierre Wieser <pwieser trychlos org>
* src/io-desktop/nadp-formats.c:
diff --git a/TODO b/TODO
index 74191af..6190d12 100644
--- a/TODO
+++ b/TODO
@@ -486,10 +486,6 @@ Parameter Description
- 2010-06-17: ui.enhancement: implement shortcut button in NactIPropertiesTab page
-- 2010-06-20: TODO: is_candidate_for_show_in: get current environment
-
-- 2010-06-20: TODO: is_candidate_for_show_if_running: get current list of processes
-
- 2010-06-21: it appears that na_ipivot_consumer_notify_of_items_changed() may be called more
than once in the plugin when more than one item is saved in NACT : this should be only once.
@@ -509,3 +505,5 @@ Parameter Description
- 2010-07-30: TODO: is_candidate_for_folders
- 2010-07-30: TODO: is_candidate_for_capabilities
+
+- 2010-06-20: TODO: is_candidate_for_show_in: get current environment
diff --git a/configure.ac b/configure.ac
index 86a012f..5368a13 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,6 +129,7 @@ NAUTILUS_EXTENSION=2.8.0
GCONF_REQUIRED=2.8.0
LIBXML_REQUIRED=2.6.0
GOBJECT_REQUIRED=2.4.0
+LIBGTOP_REQUIRED=2.23.1
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "${PKG_CONFIG}" = "no"; then
@@ -142,6 +143,7 @@ PKG_CHECK_MODULES([NAUTILUS_ACTIONS], \
gconf-2.0 >= ${GCONF_REQUIRED} \
libxml-2.0 >= ${LIBXML_REQUIRED} \
libnautilus-extension >= ${NAUTILUS_EXTENSION} \
+ libgtop-2.0 >= ${LIBGTOP_REQUIRED} \
sm >= 1.0.0 \
uuid \
unique-1.0 \
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index d5ed04b..64d5a7f 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -34,6 +34,10 @@
#include <dbus/dbus-glib.h>
#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <glibtop/proclist.h>
+#include <glibtop/procstate.h>
#include <libnautilus-extension/nautilus-file-info.h>
@@ -575,12 +579,29 @@ is_candidate_for_show_if_running( const NAIContext *object, guint target, GList
{
static const gchar *thisfn = "na_icontext_is_candidate_for_show_if_running";
gboolean ok = TRUE;
+ gchar *searched;
+ glibtop_proclist proclist;
+ glibtop_proc_state procstate;
+ pid_t *pid_list;
+ guint i;
gchar *running = na_object_get_show_if_running( object );
if( running && strlen( running )){
- /* TODO: how to get the list of running processes ?
- * or how to known if a given process is currently running
- */
+ ok = FALSE;
+ searched = g_path_get_basename( running );
+ pid_list = glibtop_get_proclist( &proclist, GLIBTOP_KERN_PROC_ALL, 0 );
+
+ for( i=0 ; i<proclist.number && !ok ; ++i ){
+ glibtop_get_proc_state( &procstate, pid_list[i] );
+ /*g_debug( "%s: i=%d, cmd=%s", thisfn, i, procstate.cmd );*/
+ if( strcmp( procstate.cmd, searched ) == 0 ){
+ g_debug( "%s: i=%d, cmd=%s", thisfn, i, procstate.cmd );
+ ok = TRUE;
+ }
+ }
+
+ g_free( pid_list );
+ g_free( searched );
}
if( !ok ){
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]