[gnome-system-monitor/wip/procinforefactor: 2/5] Updating icon in the model is proctable's task



commit 93789a06d17ce0c17d3beb769ed737a4322d0114
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Sat Aug 3 14:37:56 2013 +0200

    Updating icon in the model is proctable's task

 src/procinfo.cpp  |   11 -----------
 src/proctable.cpp |   17 +++++++++++++++++
 2 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/procinfo.cpp b/src/procinfo.cpp
index 9ee0ce3..126c56c 100644
--- a/src/procinfo.cpp
+++ b/src/procinfo.cpp
@@ -30,9 +30,6 @@
 #include "selinux.h"
 #include "util.h"
 
-// FIXME
-#include "proctable.h"
-
 
 ProcInfo::UserMap ProcInfo::users;
 ProcInfo::List ProcInfo::all;
@@ -293,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(ProcmanApp::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 55bd09d..c179d2f 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -249,6 +249,21 @@ cb_timeout (gpointer data)
     return G_SOURCE_CONTINUE;
 }
 
+
+static void
+treemodel_update_icon (ProcmanApp *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)
 {
@@ -260,6 +275,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);
@@ -751,6 +767,7 @@ insert_info_to_tree (ProcInfo *info, ProcmanApp *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]