[d-feet] Bring back the application icons



commit de131ca1621971f52e6b671b005407d132ccb059
Author: Thomas Bechtold <thomasbechtold jpberlin de>
Date:   Mon Jul 15 13:12:25 2013 +0200

    Bring back the application icons

 src/dfeet/bus_watch.py  |   20 ++++++++++++++++++--
 src/dfeet/wnck_utils.py |    5 +++--
 2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/dfeet/bus_watch.py b/src/dfeet/bus_watch.py
index 6d7974f..f3ce182 100644
--- a/src/dfeet/bus_watch.py
+++ b/src/dfeet/bus_watch.py
@@ -5,6 +5,7 @@ from gi.repository import GObject, Gtk, Gio
 
 from dfeet.uiloader import UILoader
 from dfeet.introspection import AddressInfo
+from dfeet.wnck_utils import IconTable
 
 
 class BusNameBox(Gtk.VBox):
@@ -15,16 +16,26 @@ class BusNameBox(Gtk.VBox):
         self.__process_id = 0
         self.__command_line = ''
         self.__activatable = False
+        self.__icon_table = IconTable.get_instance()
+        self.__icon_image = Gtk.Image.new_from_pixbuf(self.__icon_table.default_icon)
+
+        self.__hbox = Gtk.HBox(spacing=5, halign=Gtk.Align.START)
+        self.pack_start(self.__hbox, True, True, 0)
+        #icon
+        self.__hbox.pack_start(self.__icon_image, True, True, 0)
+        #other information
+        self.__vbox_right = Gtk.VBox(spacing=5, expand=True)
+        self.__hbox.pack_start(self.__vbox_right, True, True, 0)
 
         #first element
         self.__label_bus_name = Gtk.Label()
         self.__label_bus_name.set_markup("<b>{0}</b>".format(self.__bus_name))
         self.__label_bus_name.set_halign(Gtk.Align.START)
-        self.pack_start(self.__label_bus_name, True, True, 0)
+        self.__vbox_right.pack_start(self.__label_bus_name, True, True, 0)
         #second element
         self.__label_info = Gtk.Label()
         self.__label_info.set_halign(Gtk.Align.START)
-        self.pack_start(self.__label_info, True, True, 0)
+        self.__vbox_right.pack_start(self.__label_info, True, True, 0)
         #separator for the boxes
         self.pack_end(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL), True, True, 0)
         #update widget information
@@ -41,6 +52,11 @@ class BusNameBox(Gtk.VBox):
             label_info_str += "activatable: no"
         if self.__process_id:
             label_info_str += ", pid: {0}".format(self.__process_id)
+            #get the icon (if available)
+            if self.__process_id in self.__icon_table.app_map.keys():
+                self.__icon_image.set_from_pixbuf(self.__icon_table.app_map[self.__process_id])
+            else:
+                self.__icon_image.set_from_pixbuf(self.__icon_table.default_icon)
         if self.__command_line:
             label_info_str += ", cmd: {0}".format(self.__command_line)
         label_info_str += "</small>"
diff --git a/src/dfeet/wnck_utils.py b/src/dfeet/wnck_utils.py
index b744d45..4fa37a8 100644
--- a/src/dfeet/wnck_utils.py
+++ b/src/dfeet/wnck_utils.py
@@ -1,8 +1,8 @@
+# -*- coding: utf-8 -*-
 # This module facilitates the optional use of libwnck to get application
 # icon information. If the wnck module is not installed we fallback to default
 # behvior
 
-from gi.repository import GObject
 from gi.repository import Gtk
 
 try:
@@ -12,7 +12,7 @@ except:
     has_libwnck = False
 
 
-class IconTable:
+class IconTable(object):
     instance = None
 
     def __init__(self):
@@ -24,6 +24,7 @@ class IconTable:
 
         if has_libwnck:
             screen = Wnck.Screen.get_default()
+            Wnck.Screen.force_update(screen)
             screen.connect('application_opened', self.on_app_open)
             screen.connect('application_closed', self.on_app_close)
 


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