[gnome-system-monitor] Make the WNCK dependency optional (Bug #704215) https://bugzilla.gnome.org/show_bug.cgi?id=704215



commit 3705931e307e87878f205b905eaa3f5daaffcf09
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Tue Jul 16 23:05:08 2013 +0300

    Make the WNCK dependency optional (Bug #704215)
    https://bugzilla.gnome.org/show_bug.cgi?id=704215

 configure.ac           |   21 ++++-
 src/Makefile.am        |    5 +-
 src/nextmon            |  228 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/prettytable.cpp    |   14 +++-
 src/prettytable.h      |    7 ++-
 src/procman-app.cpp    |    2 -
 src/procman-app.h      |    2 +
 src/procproperties.cpp |    2 +
 src/proctable.cpp      |   30 ++++++-
 9 files changed, 300 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 44e1489..388bc35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,7 +41,25 @@ SYSTEMD_REQUIRED=38
 # systemd v43 used the C++ keyword 'class' as a function parameter. This breaks the build for C++ programs.
 SYSTEMD_EXCLUDED=43
 
-PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-3.0 >= 
$LIBWNCK_REQUIRED gtk+-3.0 >= $GTK_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-3.0 >= 
$GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED 
giomm-2.4 >= $GIOMM_REQUIRED gmodule-2.0)
+PKG_CHECK_MODULES(PROCMAN,
+  glib-2.0 >= $GLIB_REQUIRED
+  libgtop-2.0 >= $LIBGTOP_REQUIRED
+  gtk+-3.0 >= $GTK_REQUIRED
+  gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED
+  gtkmm-3.0 >= $GTKMM_REQUIRED
+  libxml-2.0 >= $LIBXML_REQUIRED
+  librsvg-2.0 >= $RSVG_REQUIRED
+  glibmm-2.4 >= $GLIBMM_REQUIRED
+  giomm-2.4 >= $GIOMM_REQUIRED
+  gmodule-2.0
+)
+
+AC_ARG_ENABLE(wnck, AS_HELP_STRING([--enable-wnck], [enable wnck support]),enable_wnck=yes,enable_wnck=no)
+if test "x$enable_wnck" != "xno"; then
+        PKG_CHECK_MODULES(WNCK, libwnck-3.0 >= $LIBWNCK_REQUIRED)
+        AC_DEFINE(HAVE_WNCK, 1, [Define if libwnck is available])
+fi
+AM_CONDITIONAL(HAVE_WNCK, [test "enable_wnck" = "yes"])
 
 PKG_CHECK_MODULES(SCRIPTS, glib-2.0 >= $GLIB_REQUIRED)
 
@@ -127,4 +145,5 @@ Configuration:
        Maintainer mode:        ${USER_MAINTAINER_MODE}
        Languages:              ${ALL_LINGUAS}
         systemd support:        ${have_systemd}
+        wnck support:        ${enable_wnck}
 "
diff --git a/src/Makefile.am b/src/Makefile.am
index 20abca5..87603b2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,8 @@ INCLUDES = \
        -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
        -DDATADIR=\""$(datadir)"\" \
        @PROCMAN_CFLAGS@ \
-       @SYSTEMD_CFLAGS@
+       @SYSTEMD_CFLAGS@ \
+       @WNCK_CFLAGS@
 
 bin_PROGRAMS = gnome-system-monitor
 
@@ -49,7 +50,7 @@ gnome_system_monitor_SOURCES = \
   $(gnome_system_monitor_c_files) \
   procman.cpp
 
-gnome_system_monitor_LDADD = @PROCMAN_LIBS@ @SYSTEMD_LIBS@
+gnome_system_monitor_LDADD = @PROCMAN_LIBS@ @SYSTEMD_LIBS@ @WNCK_LIBS@
 
 gnome_system_monitor_CPPFLAGS = -DGSM_DATA_DIR=\""$(pkgdatadir)"\" \
                                 -DGSM_LIBEXEC_DIR=\""$(pkglibexecdir)"\"
diff --git a/src/nextmon b/src/nextmon
new file mode 100755
index 0000000..35133eb
--- /dev/null
+++ b/src/nextmon
@@ -0,0 +1,228 @@
+#! /bin/bash
+
+# nextmon - temporary wrapper script for .libs/nextmon
+# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.2ubuntu1
+#
+# The nextmon program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command="(cd /home/evfool/Projects/gnome/gnome-system-monitor/src; { test -z \"\${LIBRARY_PATH+set}\" 
|| unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || 
unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || 
unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" 
|| unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || 
unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; 
PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/evfool/.local/bin;
 export PATH; gcc -Wall -Winline -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wcast-align -std=gnu89 -g -O2 -o \$progdir/\$file nextmon-sysmon.o nextmon-system-monitor.o 
-Wl,--export-dynamic -p
 thread  -lgtop-2.0 -lwnck-3 -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lpangomm-1.4 -lgtk-3 
/usr/lib/x86_64-linux-gnu/libcairomm-1.0.so -lgdk-3 -latk-1.0 -lpangocairo-1.0 
/usr/lib/x86_64-linux-gnu/libcairo-gobject.so -lpango-1.0 -lxml2 -lrsvg-2 -lm -lgdk_pixbuf-2.0 
/usr/lib/x86_64-linux-gnu/libcairo.so -lgiomm-2.4 -lgio-2.0 -lglibmm-2.4 -lgobject-2.0 
/usr/lib/x86_64-linux-gnu/libsigc-2.0.so -lgmodule-2.0 -lglib-2.0 ../uber/.libs/libuber-1.0.so -ldl -pthread 
-Wl,-rpath -Wl,/home/evfool/Projects/gnome/gnome-system-monitor/uber/.libs -Wl,-rpath -Wl,/devel/lib)"
+
+# This environment variable determines our operation mode.
+if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='2.4.2'
+  notinst_deplibs=' ../uber/libuber-1.0.la'
+else
+  # When we are sourced in execute mode, $file and $ECHO are already set.
+  if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+    file="$0"
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+    ECHO="printf %s\\n"
+  fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all begin with the string --lt-
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's ../libtool value, followed by no.
+lt_option_debug=
+func_parse_lt_options ()
+{
+  lt_script_arg0=$0
+  shift
+  for lt_opt
+  do
+    case "$lt_opt" in
+    --lt-debug) lt_option_debug=1 ;;
+    --lt-dump-script)
+        lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
+        test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
+        lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'`
+        cat "$lt_dump_D/$lt_dump_F"
+        exit 0
+      ;;
+    --lt-*)
+        $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
+        exit 1
+      ;;
+    esac
+  done
+
+  # Print the debug banner immediately:
+  if test -n "$lt_option_debug"; then
+    echo "nextmon:nextmon:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1.2ubuntu1" 1>&2
+  fi
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+  lt_dump_args_N=1;
+  for lt_arg
+  do
+    $ECHO "nextmon:nextmon:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
+    lt_dump_args_N=`expr $lt_dump_args_N + 1`
+  done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+
+      if test -n "$lt_option_debug"; then
+        $ECHO "nextmon:nextmon:${LINENO}: newargv[0]: $progdir/$program" 1>&2
+        func_lt_dump_args ${1+"$@"} 1>&2
+      fi
+      exec "$progdir/$program" ${1+"$@"}
+
+      $ECHO "$0: cannot exec $program $*" 1>&2
+      exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from $@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+  case " $* " in
+  *\ --lt-*)
+    for lt_wr_arg
+    do
+      case $lt_wr_arg in
+      --lt-*) ;;
+      *) set x "$@" "$lt_wr_arg"; shift;;
+      esac
+      shift
+    done ;;
+  esac
+  func_exec_program_core ${1+"$@"}
+}
+
+  # Parse options
+  func_parse_lt_options "$0" ${1+"$@"}
+
+  # Find the directory that this script lives in.
+  thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'`
+  test "x$thisdir" = "x$file" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'`
+  while test -n "$file"; do
+    destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'`
+
+    # If there was a directory component, then change thisdir.
+    if test "x$destdir" != "x$file"; then
+      case "$destdir" in
+      [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
+      *) thisdir="$thisdir/$destdir" ;;
+      esac
+    fi
+
+    file=`$ECHO "$file" | /bin/sed 's%^.*/%%'`
+    file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'`
+  done
+
+  # Usually 'no', except on cygwin/mingw when embedded into
+  # the cwrapper.
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
+  if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
+    # special case for '.'
+    if test "$thisdir" = "."; then
+      thisdir=`pwd`
+    fi
+    # remove .libs from thisdir
+    case "$thisdir" in
+    *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;;
+    .libs )   thisdir=. ;;
+    esac
+  fi
+
+  # Try to get the absolute directory name.
+  absdir=`cd "$thisdir" && pwd`
+  test -n "$absdir" && thisdir="$absdir"
+
+  program=lt-'nextmon'
+  progdir="$thisdir/.libs"
+
+  if test ! -f "$progdir/$program" ||
+     { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \
+       test "X$file" != "X$progdir/$program"; }; then
+
+    file="$$-$program"
+
+    if test ! -d "$progdir"; then
+      mkdir "$progdir"
+    else
+      rm -f "$progdir/$file"
+    fi
+
+    # relink executable if necessary
+    if test -n "$relink_command"; then
+      if relink_command_output=`eval $relink_command 2>&1`; then :
+      else
+       printf %s\n "$relink_command_output" >&2
+       rm -f "$progdir/$file"
+       exit 1
+      fi
+    fi
+
+    mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
+    { rm -f "$progdir/$program";
+      mv -f "$progdir/$file" "$progdir/$program"; }
+    rm -f "$progdir/$file"
+  fi
+
+  if test -f "$progdir/$program"; then
+    if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+      # Run the actual program with our arguments.
+      func_exec_program ${1+"$@"}
+    fi
+  else
+    # The program doesn't exist.
+    $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
+    $ECHO "This script is just a wrapper for $program." 1>&2
+    $ECHO "See the libtool documentation for more information." 1>&2
+    exit 1
+  fi
+fi
diff --git a/src/prettytable.cpp b/src/prettytable.cpp
index cb9c76a..c33324c 100644
--- a/src/prettytable.cpp
+++ b/src/prettytable.cpp
@@ -1,6 +1,10 @@
 #include <config.h>
+
+#ifdef HAVE_WNCK
 #define WNCK_I_KNOW_THIS_IS_UNSTABLE
 #include <libwnck/libwnck.h>
+#endif
+
 #include <dirent.h>
 #include <sys/stat.h>
 #include <stdio.h>
@@ -28,11 +32,13 @@ namespace
 
 PrettyTable::PrettyTable()
 {
+#ifdef HAVE_WNCK
   WnckScreen* screen = wnck_screen_get_default();
   g_signal_connect(G_OBJECT(screen), "application_opened",
                   G_CALLBACK(PrettyTable::on_application_opened), this);
   g_signal_connect(G_OBJECT(screen), "application_closed",
                   G_CALLBACK(PrettyTable::on_application_closed), this);
+#endif
 
   // init GIO apps cache
   std::vector<std::string> dirs = Glib::get_system_data_dirs();
@@ -54,7 +60,7 @@ PrettyTable::~PrettyTable()
 {
 }
 
-
+#ifdef HAVE_WNCK
 void
 PrettyTable::on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data)
 {
@@ -122,6 +128,7 @@ PrettyTable::unregister_application(pid_t pid)
   if (it != this->apps.end())
     this->apps.erase(it);
 }
+#endif // HAVE_WNCK
 
 void PrettyTable::init_gio_app_cache ()
 {
@@ -210,6 +217,7 @@ PrettyTable::get_icon_from_gio(const ProcInfo &info)
   return icon;
 }
 
+#ifdef HAVE_WNCK
 Glib::RefPtr<Gdk::Pixbuf>
 PrettyTable::get_icon_from_wnck(const ProcInfo &info)
 {
@@ -222,7 +230,7 @@ PrettyTable::get_icon_from_wnck(const ProcInfo &info)
 
   return icon;
 }
-
+#endif
 
 
 Glib::RefPtr<Gdk::Pixbuf>
@@ -279,7 +287,9 @@ PrettyTable::set_icon(ProcInfo &info)
   if (getters.empty())
     {
       getters.push_back(&PrettyTable::get_icon_from_gio);
+#ifdef HAVE_WNCK
       getters.push_back(&PrettyTable::get_icon_from_wnck);
+#endif
       getters.push_back(&PrettyTable::get_icon_from_theme);
       getters.push_back(&PrettyTable::get_icon_from_default);
       getters.push_back(&PrettyTable::get_icon_from_name);
diff --git a/src/prettytable.h b/src/prettytable.h
index 74efe84..6998a02 100644
--- a/src/prettytable.h
+++ b/src/prettytable.h
@@ -11,10 +11,12 @@
 #include <map>
 #include <string>
 
+#ifdef HAVE_WNCK
 extern "C" {
 #define WNCK_I_KNOW_THIS_IS_UNSTABLE
 #include <libwnck/libwnck.h>
 }
+#endif
 
 #include "iconthemewrapper.h"
 
@@ -34,17 +36,20 @@ public:
 
 private:
 
+#ifdef HAVE_WNCK
     static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);
     static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);
 
     void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
     void unregister_application(pid_t pid);
-
+#endif
 
     Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
     Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
     Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
     Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
     Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
     Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
     Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
diff --git a/src/procman-app.cpp b/src/procman-app.cpp
index 62f009f..00d3e04 100644
--- a/src/procman-app.cpp
+++ b/src/procman-app.cpp
@@ -437,8 +437,6 @@ procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child
             visible = g_settings_get_boolean (pt_settings, key);
             g_free (key);
 
-            column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree), id);
-            if(!column) continue;
             gtk_tree_view_column_set_visible (column, visible);
             /* ensure column is really visible */
             width = MAX(width, 50);
diff --git a/src/procman-app.h b/src/procman-app.h
index ad9ecc0..f24b30a 100644
--- a/src/procman-app.h
+++ b/src/procman-app.h
@@ -91,8 +91,10 @@ MutableProcInfo()
     gulong memwritable;
     gulong mem;
 
+#ifdef HAVE_WNCK
     // wnck gives an unsigned long
     gulong memxserver;
+#endif
 
     gulong start_time;
     guint64 cpu_time;
diff --git a/src/procproperties.cpp b/src/procproperties.cpp
index ab7058c..caa909c 100644
--- a/src/procproperties.cpp
+++ b/src/procproperties.cpp
@@ -86,7 +86,9 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info)
         { N_("Resident Memory"), format_memsize(info->memres)},
         { N_("Writable Memory"), format_memsize(info->memwritable)},
         { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
         { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
         { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
         { N_("CPU Time"), g_strdup_printf(ngettext("%lld second", "%lld seconds", info->cpu_time/HZ), 
(unsigned long long)info->cpu_time/HZ) },
         { N_("Started"), g_strdup_printf("%s", ctime((const time_t*)(&info->start_time)))},
diff --git a/src/proctable.cpp b/src/proctable.cpp
index f9ac6ac..4409460 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -48,6 +48,11 @@
 #include <systemd/sd-login.h>
 #endif
 
+#ifdef HAVE_WNCK
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+#endif
+
 #include "procman-app.h"
 #include "proctable.h"
 #include "callbacks.h"
@@ -298,6 +303,11 @@ proctable_new (ProcmanApp * const app)
         GtkCellRenderer *cell;
         GtkTreeViewColumn *col;
 
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
         cell = gtk_cell_renderer_text_new();
         col = gtk_tree_view_column_new();
         gtk_tree_view_column_pack_start(col, cell, TRUE);
@@ -307,14 +317,17 @@ proctable_new (ProcmanApp * const app)
         g_signal_connect(G_OBJECT(col), "notify::width", G_CALLBACK(cb_column_resized), settings);
         gtk_tree_view_column_set_reorderable(col, TRUE);
         gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
         // type
         switch (i) {
+#ifdef HAVE_WNCK
             case COL_MEMXSERVER:
                 gtk_tree_view_column_set_cell_data_func(col, cell,
                                                         &procman::size_cell_data_func,
                                                         GUINT_TO_POINTER(i),
                                                         NULL);
                 break;
+#endif
             case COL_VMSIZE:
             case COL_MEMRES:
             case COL_MEMSHARED:
@@ -359,7 +372,9 @@ proctable_new (ProcmanApp * const app)
 
         // sorting
         switch (i) {
+#ifdef HAVE_WNCK
             case COL_MEMXSERVER:
+#endif
             case COL_VMSIZE:
             case COL_MEMRES:
             case COL_MEMSHARED:
@@ -388,7 +403,9 @@ proctable_new (ProcmanApp * const app)
             case COL_MEMRES:
             case COL_MEMWRITABLE:
             case COL_MEMSHARED:
+#ifdef HAVE_WNCK
             case COL_MEMXSERVER:
+#endif
             case COL_CPU:
             case COL_NICE:
             case COL_PID:
@@ -566,24 +583,29 @@ static void
 get_process_memory_info(ProcInfo *info)
 {
     glibtop_proc_mem procmem;
+#ifdef HAVE_WNCK
     WnckResourceUsage xresources;
 
     wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
                                   info->pid,
                                   &xresources);
 
+    info->memxserver = xresources.total_bytes_estimate;
+#endif
+
     glibtop_get_proc_mem(&procmem, info->pid);
 
     info->vmsize    = procmem.vsize;
     info->memres    = procmem.resident;
     info->memshared = procmem.share;
 
-    info->memxserver = xresources.total_bytes_estimate;
-
     get_process_memory_writable(info);
 
     // fake the smart memory column if writable is not available
-    info->mem = info->memxserver + (info->memwritable ? info->memwritable : info->memres);
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
 }
 
 
@@ -602,7 +624,9 @@ update_info_mutable_cols(ProcInfo *info)
     tree_store_update(model, &info->node, COL_MEMRES, info->memres);
     tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
     tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
     tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
     tree_store_update(model, &info->node, COL_CPU, info->pcpu);
     tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
     tree_store_update(model, &info->node, COL_START_TIME, info->start_time);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]