[gnome-system-monitor] Removed iconthemewrapper



commit a01595208b8ea1f660b73e23310bb1ff8757353a
Author: Robert Roth <robert roth off gmail com>
Date:   Sat Jan 10 04:16:20 2015 +0200

    Removed iconthemewrapper

 src/Makefile.am          |    1 -
 src/disks.cpp            |   70 ++++++++++++++++++++-------------------------
 src/iconthemewrapper.cpp |   57 -------------------------------------
 src/iconthemewrapper.h   |   26 -----------------
 src/prettytable.cpp      |   18 +++++++----
 src/prettytable.h        |    3 --
 6 files changed, 42 insertions(+), 133 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 11fd5d4..e4206e2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,7 +31,6 @@ gnome_system_monitor_cpp_files = \
        gsm_gksu.cpp \
        gsm_pkexec.cpp \
        lsof.cpp \
-       iconthemewrapper.cpp \
        prefsdialog.cpp \
        application.cpp
 
diff --git a/src/disks.cpp b/src/disks.cpp
index 3f3a99d..b0d27ca 100644
--- a/src/disks.cpp
+++ b/src/disks.cpp
@@ -1,8 +1,6 @@
 /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 #include <config.h>
 
-#include <giomm.h>
-#include <giomm/themedicon.h>
 #include <gtk/gtk.h>
 #include <glibtop/mountlist.h>
 #include <glibtop/fsusage.h>
@@ -11,7 +9,6 @@
 #include "disks.h"
 #include "application.h"
 #include "util.h"
-#include "iconthemewrapper.h"
 #include "settings-keys.h"
 #include "treeview.h"
 
@@ -65,49 +62,44 @@ fsusage_stats(const glibtop_fsusage *buf,
     }
 }
 
-
-namespace
+static const char* get_icon_for_path(const char* path)
 {
-    string get_icon_for_path(const std::string& path)
-    {
-        using namespace Glib;
-        using namespace Gio;
-
-        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
-        // all i need an icon name.
-        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
-
-        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
-
-        for (size_t i = 0; i != mounts.size(); ++i) {
-            if (mounts[i]->get_name() != path)
-                continue;
-
-            RefPtr<Icon> icon = mounts[i]->get_icon();
-            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+    GVolumeMonitor *monitor;
+    GList *mounts;
+    uint i;
+    GMount *mount;
+    GIcon *icon;
+    const char* name = "";
+
+    monitor = g_volume_monitor_get ();
+    mounts = g_volume_monitor_get_mounts (monitor);
+
+    for (i = 0; i < g_list_length (mounts); i++) {
+        mount = G_MOUNT (g_list_nth_data(mounts, i));
+        if (strcmp(g_mount_get_name(mount), path))
+            continue;
+
+        icon = g_mount_get_icon (mount);
+
+        if (!icon)
+            continue;
+        name = g_icon_to_string (icon);
+        g_object_unref (icon);
+    }
 
-            if (themed_icon) {
-                char* name = 0;
-                // FIXME: not wrapped yet
-                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
-                return make_string(name);
-            }
-        }
+    g_list_free_full (mounts, g_object_unref);
+    return name;
 
-        return "";
-    }
 }
 
-
-static Glib::RefPtr<Gdk::Pixbuf>
+static GdkPixbuf*
 get_icon_for_device(const char *mountpoint)
 {
-    procman::IconThemeWrapper icon_theme;
-    string icon_name = get_icon_for_path(mountpoint);
-    if (icon_name == "")
+    const char* icon_name = get_icon_for_path(mountpoint);
+    if (!strcmp(icon_name, ""))
         // FIXME: defaults to a safe value
         icon_name = "drive-harddisk"; // get_icon_for_path("/");
-    return icon_theme->load_icon(icon_name, 24, Gtk::ICON_LOOKUP_USE_BUILTIN);
+    return gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), icon_name, 24, 
GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
 }
 
 
@@ -184,7 +176,7 @@ remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n
 static void
 add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
 {
-    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    GdkPixbuf* pixbuf;
     GtkTreeIter iter;
     glibtop_fsusage usage;
     guint64 bused, bfree, bavail, btotal;
@@ -209,7 +201,7 @@ add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
         gtk_list_store_append(list, &iter);
 
     gtk_list_store_set(list, &iter,
-                       DISK_ICON, pixbuf->gobj(),
+                       DISK_ICON, pixbuf,
                        DISK_DEVICE, entry->devname,
                        DISK_DIR, entry->mountdir,
                        DISK_TYPE, entry->type,
diff --git a/src/prettytable.cpp b/src/prettytable.cpp
index f4fe716..cb1f3bb 100644
--- a/src/prettytable.cpp
+++ b/src/prettytable.cpp
@@ -77,7 +77,7 @@ PrettyTable::on_application_opened(WnckScreen* screen, WnckApplication* app, gpo
 
   Glib::RefPtr<Gdk::Pixbuf> icon;
 
-  icon = that->theme->load_icon(icon_name, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN);
+  icon = Glib::wrap(gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), icon_name, APP_ICON_SIZE, 
GTK_ICON_LOOKUP_USE_BUILTIN, NULL));
 
   if (not icon) {
     icon = Glib::wrap(wnck_application_get_icon(app), /* take_copy */ true);
@@ -156,7 +156,7 @@ void PrettyTable::file_monitor_event(Glib::RefPtr<Gio::File>,
 Glib::RefPtr<Gdk::Pixbuf>
 PrettyTable::get_icon_from_theme(const ProcInfo &info)
 {
-  return this->theme->load_icon(info.name, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN | 
Gtk::ICON_LOOKUP_FORCE_SIZE);
+  return Glib::wrap(gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), info.name, APP_ICON_SIZE, 
(GtkIconLookupFlags)(GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_FORCE_SIZE), NULL));
 }
 
 
@@ -189,7 +189,7 @@ PrettyTable::get_icon_from_default(const ProcInfo &info)
     IconCache::iterator it(this->defaults.find(name));
 
     if (it == this->defaults.end()) {
-      pix = this->theme->load_icon(name, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN | 
Gtk::ICON_LOOKUP_FORCE_SIZE);
+      pix = Glib::wrap(gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), name.c_str(), APP_ICON_SIZE, 
(GtkIconLookupFlags)(GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_FORCE_SIZE), NULL));
       if (pix)
        this->defaults[name] = pix;
     } else
@@ -209,12 +209,16 @@ PrettyTable::get_icon_from_gio(const ProcInfo &info)
   if (executable) {
     Glib::RefPtr<Gio::AppInfo> app = this->gio_apps[executable];
     Glib::RefPtr<Gio::Icon> gicon;
+    Gtk::IconInfo info;
 
     if (app)
       gicon = app->get_icon();
 
     if (gicon)
-      icon = this->theme->load_gicon(gicon, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN | 
Gtk::ICON_LOOKUP_FORCE_SIZE);
+      info = Glib::wrap(gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), gicon->gobj(), 
APP_ICON_SIZE, (GtkIconLookupFlags)(GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_FORCE_SIZE)));
+
+    if (info)
+      icon = Glib::wrap(gtk_icon_info_load_icon (info.gobj(), NULL));
   }
 
   g_strfreev(cmdline);
@@ -240,14 +244,14 @@ PrettyTable::get_icon_from_wnck(const ProcInfo &info)
 Glib::RefPtr<Gdk::Pixbuf>
 PrettyTable::get_icon_from_name(const ProcInfo &info)
 {
-  return this->theme->load_icon(info.name, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN | 
Gtk::ICON_LOOKUP_FORCE_SIZE);
+return Glib::wrap(gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), info.name, APP_ICON_SIZE, 
(GtkIconLookupFlags)(GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_FORCE_SIZE), NULL));
 }
 
 
 Glib::RefPtr<Gdk::Pixbuf>
 PrettyTable::get_icon_dummy(const ProcInfo &)
 {
-  return this->theme->load_icon("application-x-executable", APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN);
+    return Glib::wrap(gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "application-x-executable", 
APP_ICON_SIZE, GTK_ICON_LOOKUP_USE_BUILTIN, NULL));
 }
 
 
@@ -273,7 +277,7 @@ Glib::RefPtr<Gdk::Pixbuf>
 PrettyTable::get_icon_for_kernel(const ProcInfo &info)
 {
   if (is_kthread(info))
-    return this->theme->load_icon("applications-system", APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN);
+    return Glib::wrap(gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "applications-system", 
APP_ICON_SIZE, GTK_ICON_LOOKUP_USE_BUILTIN, NULL));
 
   return Glib::RefPtr<Gdk::Pixbuf>();
 }
diff --git a/src/prettytable.h b/src/prettytable.h
index a0eba1b..627ac6f 100644
--- a/src/prettytable.h
+++ b/src/prettytable.h
@@ -19,8 +19,6 @@ extern "C" {
 }
 #endif
 
-#include "iconthemewrapper.h"
-
 class ProcInfo;
 
 using std::string;
@@ -70,7 +68,6 @@ private:
     IconCache defaults;
     DesktopDirMonitors monitors;
     AppCache gio_apps;
-    procman::IconThemeWrapper theme;
 };
 
 


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