diff options
author | Liming An <limingx.l.an@intel.com> | 2012-03-23 23:32:17 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-28 16:49:18 +0100 |
commit | b99680f349e0dfa0332acbe6f0ebd80c2c9b71bc (patch) | |
tree | e2515e950dd29e46dbbdfa9b6c487360b8959ec8 /bitbake/lib | |
parent | 673a8f44c55c503a6f4e68c2586685641ca7d74e (diff) | |
download | poky-b99680f349e0dfa0332acbe6f0ebd80c2c9b71bc.tar.gz |
Hob: fixed visually differentiate warnings and errors icon in building log
fixed the bug of 'error' and 'warning' icon is not constaintly with hob ui design
[YOCTO #2097]
(From Poky rev: 5b4f379b5341222e2678043f078b3d33c0556a86)
(Bitbake rev: 3807a95cd48a01486b3ecd5360a59ddfc3a3b6d6)
Signed-off-by: Liming An <limingx.l.an@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobwidget.py | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py index e2247622fa..22898fb273 100644 --- a/bitbake/lib/bb/ui/crumbs/hobwidget.py +++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py | |||
@@ -58,6 +58,8 @@ class hic: | |||
58 | ICON_INDI_ADD_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/add.png')) | 58 | ICON_INDI_ADD_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/add.png')) |
59 | ICON_INDI_ADD_HOVER_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/add-hover.png')) | 59 | ICON_INDI_ADD_HOVER_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/add-hover.png')) |
60 | ICON_INDI_REFRESH_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/refresh.png')) | 60 | ICON_INDI_REFRESH_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/refresh.png')) |
61 | ICON_INDI_ALERT_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/alert.png')) | ||
62 | ICON_INDI_TICK_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/tick.png')) | ||
61 | 63 | ||
62 | class hcc: | 64 | class hcc: |
63 | 65 | ||
@@ -795,6 +797,44 @@ class HobWarpCellRendererText(gtk.CellRendererText): | |||
795 | 797 | ||
796 | gobject.type_register(HobWarpCellRendererText) | 798 | gobject.type_register(HobWarpCellRendererText) |
797 | 799 | ||
800 | class HobIconChecker(hic): | ||
801 | def set_hob_icon_to_stock_icon(self, file_path, stock_id=""): | ||
802 | try: | ||
803 | pixbuf = gtk.gdk.pixbuf_new_from_file(file_path) | ||
804 | except Exception, e: | ||
805 | return None | ||
806 | |||
807 | if stock_id and (gtk.icon_factory_lookup_default(stock_id) == None): | ||
808 | icon_factory = gtk.IconFactory() | ||
809 | icon_factory.add_default() | ||
810 | icon_factory.add(stock_id, gtk.IconSet(pixbuf)) | ||
811 | gtk.stock_add([(stock_id, '_label', 0, 0, '')]) | ||
812 | |||
813 | return icon_factory.lookup(stock_id) | ||
814 | |||
815 | return None | ||
816 | |||
817 | """ | ||
818 | For make hob icon consistently by request, and avoid icon view diff by system or gtk version, we use some 'hob icon' to replace the 'gtk icon'. | ||
819 | this function check the stock_id and make hob_id to replaced the gtk_id then return it or "" | ||
820 | """ | ||
821 | def check_stock_icon(self, stock_name=""): | ||
822 | HOB_CHECK_STOCK_NAME = { | ||
823 | ('hic-dialog-info', 'gtk-dialog-info', 'dialog-info') : self.ICON_INFO_DISPLAY_FILE, | ||
824 | ('hic-ok', 'gtk-ok', 'ok') : self.ICON_INDI_TICK_FILE, | ||
825 | ('hic-dialog-error', 'gtk-dialog-error', 'dialog-error') : self.ICON_INDI_ERROR_FILE, | ||
826 | ('hic-dialog-warning', 'gtk-dialog-warning', 'dialog-warning') : self.ICON_INDI_ALERT_FILE, | ||
827 | } | ||
828 | valid_stock_id = stock_name | ||
829 | if stock_name: | ||
830 | for names, path in HOB_CHECK_STOCK_NAME.iteritems(): | ||
831 | if stock_name in names: | ||
832 | valid_stock_id = names[0] | ||
833 | if not gtk.icon_factory_lookup_default(valid_stock_id): | ||
834 | self.set_hob_icon_to_stock_icon(path, valid_stock_id) | ||
835 | |||
836 | return valid_stock_id | ||
837 | |||
798 | class RefreshRuningController(gobject.GObject): | 838 | class RefreshRuningController(gobject.GObject): |
799 | def __init__(self, widget=None, iter=None): | 839 | def __init__(self, widget=None, iter=None): |
800 | gobject.GObject.__init__(self) | 840 | gobject.GObject.__init__(self) |
@@ -885,23 +925,8 @@ class HobCellRendererPixbuf(gtk.CellRendererPixbuf): | |||
885 | gtk.CellRendererPixbuf.__init__(self) | 925 | gtk.CellRendererPixbuf.__init__(self) |
886 | self.control = RefreshRuningController() | 926 | self.control = RefreshRuningController() |
887 | # create default refrensh stock icon | 927 | # create default refrensh stock icon |
888 | self.set_hob_icon_to_stock_icon(hic.ICON_INDI_REFRESH_FILE, "task-refresh") | 928 | self.checker = HobIconChecker() |
889 | 929 | self.checker.set_hob_icon_to_stock_icon(hic.ICON_INDI_REFRESH_FILE, "task-refresh") | |
890 | def set_hob_icon_to_stock_icon(self, file_path, stock_id=""): | ||
891 | try: | ||
892 | pixbuf = gtk.gdk.pixbuf_new_from_file(file_path) | ||
893 | except Exception, e: | ||
894 | return None | ||
895 | |||
896 | if pixbuf and stock_id and (gtk.icon_factory_lookup_default(stock_id) == None): | ||
897 | icon_factory = gtk.IconFactory() | ||
898 | icon_factory.add_default() | ||
899 | icon_factory.add(stock_id, gtk.IconSet(pixbuf)) | ||
900 | gtk.stock_add([(stock_id, '_label', 0, 0, '')]) | ||
901 | |||
902 | return icon_factory.lookup(stock_id) | ||
903 | |||
904 | return None | ||
905 | 930 | ||
906 | def get_pixbuf_from_stock_icon(self, widget, stock_id="", size=gtk.ICON_SIZE_DIALOG): | 931 | def get_pixbuf_from_stock_icon(self, widget, stock_id="", size=gtk.ICON_SIZE_DIALOG): |
907 | if widget and stock_id and gtk.icon_factory_lookup_default(stock_id): | 932 | if widget and stock_id and gtk.icon_factory_lookup_default(stock_id): |
@@ -909,9 +934,11 @@ class HobCellRendererPixbuf(gtk.CellRendererPixbuf): | |||
909 | 934 | ||
910 | return None | 935 | return None |
911 | 936 | ||
912 | def set_icon_name_to_id(self, name): | 937 | def set_icon_name_to_id(self, new_name): |
913 | if name and type(name) == str: | 938 | if new_name and type(new_name) == str: |
914 | if name.startswith("gtk") or name == "task-refresh": | 939 | # check the name is need to transfer to hob icon or not |
940 | name = self.checker.check_stock_icon(new_name) | ||
941 | if name.startswith("hic") or name.startswith("gtk") or name == "task-refresh": | ||
915 | stock_id = name | 942 | stock_id = name |
916 | else: | 943 | else: |
917 | stock_id = 'gtk-' + name | 944 | stock_id = 'gtk-' + name |