[gnome-system-monitor/wip/procinfo2: 4/6] Updating icon in the model is proctable's task



commit bc85e56aae0d0f93da024b4c9ffd513aa23f917c
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Thu May 8 18:37:30 2014 +0200

    Updating icon in the model is proctable's task

 src/procinfo.cpp  |   10 ----------
 src/proctable.cpp |   17 +++++++++++++++++
 2 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/procinfo.cpp b/src/procinfo.cpp
index 1207688..9e41e63 100644
--- a/src/procinfo.cpp
+++ b/src/procinfo.cpp
@@ -30,8 +30,6 @@
 #include "selinux.h"
 #include "util.h"
 
-// FIXME
-#include "proctable.h"
 
 ProcInfo::UserMap ProcInfo::users;
 ProcInfo::List ProcInfo::all;
@@ -292,13 +290,5 @@ void
 ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
 {
     this->pixbuf = icon;
-
-    GtkTreeModel *model;
-    model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (
-            gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(
-            gtk_tree_view_get_model (GTK_TREE_VIEW(GsmApplication::get()->tree))))));
-    gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
-                       COL_PIXBUF, (this->pixbuf ? this->pixbuf->gobj() : NULL),
-                       -1);
 }
 
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 7c877c3..b654293 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -165,6 +165,21 @@ cb_timeout (gpointer data)
     return G_SOURCE_CONTINUE;
 }
 
+
+static void
+treemodel_update_icon (GsmApplication *app, ProcInfo *info)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (
+            gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(
+            gtk_tree_view_get_model (GTK_TREE_VIEW(app->tree))))));
+
+    gtk_tree_store_set(GTK_TREE_STORE(model), &info->node,
+                       COL_PIXBUF, (info->pixbuf ? info->pixbuf->gobj() : NULL),
+                       -1);
+}
+
 static void
 cb_refresh_icons (GtkIconTheme *theme, gpointer data)
 {
@@ -176,6 +191,7 @@ cb_refresh_icons (GtkIconTheme *theme, gpointer data)
 
     for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
         app->pretty_table->set_icon(*(it->second));
+        treemodel_update_icon (app, it->second);
     }
 
     cb_timeout(app);
@@ -661,6 +677,7 @@ insert_info_to_tree (ProcInfo *info, GsmApplication *app, bool forced = false)
                         -1);
 
     app->pretty_table->set_icon(*info);
+    treemodel_update_icon (app, info);
 
     procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
 }


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