def __init__(self, app): self.app = app self.builder = gtk.Builder() self.builder.add_from_string( pkg_resources.resource_string(__name__, "data/ui/note.glade")) self.builder.connect_signals(self) loader = gtk.gdk.PixbufLoader('png') loader.write( pkg_resources.resource_string(__name__, "resources/icons/icon.png")) loader.close() icons = gtk.IconTheme() app_icon = "tray" try: assert icons.has_icon(app_icon) except AssertionError: app_icon = "/tmp/tray.png" icon = pkg_resources.resource_string(__name__, 'resources/tray/tray.png') f = open(app_icon, "w") f.write(icon) f.close() self.builder.get_object('noteWindow').set_modal(False) self.builder.get_object('noteWindow').set_icon_from_file(app_icon) self.builder.get_object('noteWindow').show() self.builder.get_object('noteWindow').connect( 'destroy', lambda x: gtk.main_quit())
def apply_icon(self, requested_icon): """Set the window icon""" icon_theme = gtk.IconTheme() icon = None if requested_icon: try: self.set_icon_from_file(requested_icon) icon = self.get_icon() except (NameError, gobject.GError): dbg('Unable to load 48px %s icon as file' % (repr(requested_icon))) if requested_icon and icon is None: try: icon = icon_theme.load_icon(requested_icon, 48, 0) except (NameError, gobject.GError): dbg('Unable to load 48px %s icon' % (repr(requested_icon))) if icon is None: try: icon = icon_theme.load_icon(self.wmclass_name, 48, 0) except (NameError, gobject.GError): dbg('Unable to load 48px %s icon' % (self.wmclass_name)) if icon is None: try: icon = icon_theme.load_icon(APP_NAME, 48, 0) except (NameError, gobject.GError): dbg('Unable to load 48px Terminator icon') icon = self.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON) self.set_icon(icon)
def set_theme(self, name): if name is None: self.theme = gtk.icon_theme_get_default() else: self.theme = gtk.IconTheme() self.theme.prepend_search_path(moonbeam_theme_dir) self.theme.set_custom_theme(name)
def __init__(self, app): self._app = app self._app.dew = self icons = gtk.IconTheme() app_icon = "tray" try: assert icons.has_icon(app_icon) except AssertionError: app_icon = "/tmp/tray.png" icon = pkg_resources.resource_string(__name__, 'resources/tray/tray.png') f = open(app_icon, "w") f.write(icon) f.close() if not hasattr(self._app, 'statusIcon'): self._app.statusIcon = appindicator.Indicator( 'Dewdrop', app_icon, appindicator.CATEGORY_APPLICATION_STATUS) self._app.statusIcon.set_status(appindicator.STATUS_ACTIVE) self.init_menu() self.dapi = DAPI() self.dapi.auth(self._app._cfg.get('email'), self._app._cfg.get('passhash')) self.show_hide_drop() gtk.main()
def callback(self, menuitems, menu, terminal): """Add our menu items to the menu""" item = gtk.MenuItem(_('Custom Commands')) menuitems.append(item) submenu = gtk.Menu() item.set_submenu(submenu) menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) menuitem.connect("activate", self.configure) submenu.append(menuitem) menuitem = gtk.SeparatorMenuItem() submenu.append(menuitem) theme = gtk.IconTheme() for command in self.cmd_list: if not command['enabled']: continue exe = command['command'].split(' ')[0] iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN) if iconinfo: image = gtk.Image() image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU) menuitem = gtk.ImageMenuItem(command['name']) menuitem.set_image(image) else: menuitem = gtk.MenuItem(command["name"]) menuitem.connect("activate", self._execute, { 'terminal': terminal, 'command': command['command'] }) submenu.append(menuitem)
def loadIcon(stock_item_id): '''Loads an icon to show it in the GUI. The following directories are searched in order to get the icon, if not found a missing-image.png is returned. * core/data/ui/gui/data/icons/<size>/<stock_item_id> * Operating system theme directory :param stock_item_id: Stock item id string :return: The icon's pixbuf ''' stock_item = getattr(gtk, stock_item_id) local_icon = os.path.join('core', 'ui', 'gui', 'data', 'icons', '16', '%s.png' % stock_item) if os.path.exists(local_icon): im = gtk.Image() im.set_from_file(local_icon) im.show() return im.get_pixbuf() else: icon_theme = gtk.IconTheme() try: icon = icon_theme.load_icon(stock_item, 16, ()) except: # If param id not found use this image icon = loadImage('missing-image.png').get_pixbuf() return icon
def get_icon_theme(name): if isinstance(name, gtk.IconTheme): return name theme = gtk.IconTheme() if not name: settings = gtk.settings_get_default() name = settings.get_property('gtk-icon-theme-name') theme.set_custom_theme(name) return theme
def create_status_icon(self): icon_theme = gtk.IconTheme() icon_theme.append_search_path(ICON_LOCATION) icon = gui_misc.get_icon(icon_theme, NOTIFY_ICON_NAME, 24) status_icon = gtk.status_icon_new_from_pixbuf(icon) status_icon.set_visible(False) status_icon.connect('activate', self.activate_status_icon) status_icon.connect('notify', self.notify_status_icon) return status_icon
def get_system_icon_info(icon_theme="Deepin", icon_name="NULL", size=48): ''' Get system level icon info @param icon_theme: Gtk Icon Theme, for example, Deepin @param icon_name: the name of the icon to lookup, for example, preferences-power @param size: desired icon size, for example, 48 ''' __icon_theme = gtk.IconTheme() __icon_theme.set_custom_theme(icon_theme) return __icon_theme.lookup_icon(icon_name, size, gtk.ICON_LOOKUP_NO_SVG)
def apply_icon(self): """Set the window icon""" icon_theme = gtk.IconTheme() try: icon = icon_theme.load_icon(APP_NAME, 48, 0) except (NameError, gobject.GError): dbg('Unable to load 48px Terminator icon') icon = self.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON) self.set_icon(icon)
def __init__(self, default_width=350, default_height=160, confirm_callback=None, cancel_callback=None): ''' Initialize InputDialog class. @param title: Input dialog title. @param init_text: Initialize input text. @param default_width: Width of dialog, default is 330 pixel. @param default_height: Height of dialog, default is 330 pixel. @param confirm_callback: Callback when user click confirm button, this callback accept one argument that return by user input text. @param cancel_callback: Callback when user click cancel button, this callback not need argument. ''' # Init. DialogBox.__init__(self, _("Autostart app"), default_width, default_height, DIALOG_MASK_SINGLE_PAGE) self.confirm_callback = confirm_callback self.cancel_callback = cancel_callback self.on_click = None self.confirm_button = Button(_("OK")) self.cancel_button = Button(_("Cancel")) self.confirm_button.connect("clicked", lambda w: self.click_confirm_button()) self.cancel_button.connect("clicked", lambda w: self.click_cancel_button()) self.connect( "destroy", self._close_callback ) #self.close_callback is None at this moment, so we use _close_callback # get system pixbuf icon_theme = gtk.IconTheme() icon_theme.set_custom_theme("Deepin") icon_info = None if icon_theme: icon_info = icon_theme.lookup_icon("folder-open", 16, gtk.ICON_LOOKUP_NO_SVG) self.icon_pixbuf = None if icon_info: self.icon_pixbuf = DynamicPixbuf(icon_info.get_filename()) else: self.icon_pixbuf = app_theme.get_pixbuf("navigate/none-small.png") table = self.add_new_box() self.pack(self.body_box, [table]) self.right_button_box.set_buttons( [self.cancel_button, self.confirm_button]) self.connect("show", self.focus_input)
def refresh(self, button): w = gtk.Window() i = gtk.IconTheme() w.set_icon(i.load_icon("gtk-refresh", 48, gtk.ICON_LOOKUP_FORCE_SVG)) v = gtk.VBox() l = gtk.Label("Refreshed") b = gtk.Button(stock="gtk-close") b.connect("clicked", self.win_destroy, w) v.pack_start(l, True, True, 2) v.pack_start(b) w.add(v) w.resize(200, 100) w.show_all()
def create_icon(self, cat, icon_str = None, exe = None): # Creates icons to be shown in results if cat == 'calc': it = gtk.IconTheme() p = os.path.dirname(os.path.abspath(__file__)) + "/icons/calculator.png" pb = gtk.gdk.pixbuf_new_from_file(p) elif cat == 'app': # Some apps need adjusting. for instance, pycrust's .desktop file has this: # Icon=/usr/share/pixmaps/pycrust. This here will not work. we have to split at / # and take the last bit (pycrust). But not all will work this way. Python's is # Icon=/usr/share/pixmaps/python2.6.xpm. Passing python2.6.xpm to load_icon() # will give an error. try: # icon_str has an icon in system's icon theme it = gtk.IconTheme() a = icon_str.split('/')[-1] pb = it.load_icon(a, 32, gtk.ICON_LOOKUP_FORCE_SVG) except: try: # icon_str is a path to an image somewhere pb = gtk.gdk.pixbuf_new_from_file(icon_str) except: try: # Sometimes there is an image im /usr/share/pixmaps with the proram's name pb = it.load_icon(exe, 32, gtk.ICON_LOOKUP_FORCE_SVG) except: # And when there isn't use a generic terminal icon p = os.path.dirname(os.path.abspath(__file__)) + "/icons/terminal.png" pb = gtk.gdk.pixbuf_new_from_file(p) else: #print "Cat: %s" % cat uri = os.path.dirname(os.path.abspath(__file__)) + "/icons/%s.png" % cat #uri = './icons/%s.png' % cat pb = gtk.gdk.pixbuf_new_from_file(uri) img = gtk.Image() img.set_from_pixbuf(pb) return img
def get_icon(self): if self.icon is not None: # Load it from an absolute filename if os.path.exists(self.icon): try: return gtk.gdk.pixbuf_new_from_file_at_size(self.icon, 24, 24) except gobject.GError, ge: pass # Load it from the current icon theme (icon_name, extension) = os.path.splitext(os.path.basename(self.icon)) theme = gtk.IconTheme() if theme.has_icon(icon_name): return theme.load_icon(icon_name, 24, 0)
class LayoutLauncher: """Class implementing the various parts of the preferences editor""" terminator = None config = None registry = None plugins = None keybindings = None window = None builder = None layouttreeview = None layouttreestore = None def __init__(self): self.terminator = Terminator() self.terminator.register_launcher_window(self) self.config = config.Config() self.config.base.reload() self.builder = gtk.Builder() try: # Figure out where our library is on-disk so we can open our UI (head, _tail) = os.path.split(config.__file__) librarypath = os.path.join(head, 'layoutlauncher.glade') gladefile = open(librarypath, 'r') gladedata = gladefile.read() except Exception, ex: print "Failed to find layoutlauncher.glade" print ex return self.builder.add_from_string(gladedata) self.window = self.builder.get_object('layoutlauncherwin') icon_theme = gtk.IconTheme() try: icon = icon_theme.load_icon('terminator-layout', 48, 0) except (NameError, gobject.GError): dbg('Unable to load 48px Terminator preferences icon') icon = self.window.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON) self.window.set_icon(icon) self.builder.connect_signals(self) self.window.connect('destroy', self.on_destroy_event) self.window.show_all() self.layouttreeview = self.builder.get_object('layoutlist') self.layouttreestore = self.builder.get_object('layoutstore') self.update_layouts()
def show(link): if not pynotify.init ("summary-body"): return False icons = gtk.IconTheme() app_icon = "dewdrop" try: assert icons.has_icon(app_icon) except AssertionError: app_icon = "/tmp/dewdrop.png" icon = pkg_resources.resource_string(__name__, 'windows/resources/tray/white.png') f = open(app_icon, "w") f.write(icon) f.close() n = pynotify.Notification ("DewDrop", "Upload Complete: %s" % link, app_icon) n.show()
def update(link): if not pynotify.init("summary-body"): return False icons = gtk.IconTheme() app_icon = "dewdrop" try: assert icons.has_icon(app_icon) except AssertionError: app_icon = "/tmp/dewdrop.png" icon = pkg_resources.resource_string(__name__, 'resources/icons/icon.png') f = open(app_icon, "w") f.write(icon) f.close() n = pynotify.Notification("DewDrop", "Update Available: %s" % link, app_icon) n.show()
def __init__(self): # Our own instance of a HIGSpinnerImages self.spinner_images = HIGSpinnerImages() # These are on Private member in the C implementation self.icon_theme = gtk.IconTheme() self.originals = None self.images = None # We might have access to a "default" animated icon. # For example, if we're on a GNOME desktop, and have the (default) # "gnome-icon-theme" package installed, we might have access # to "gnome-spinner". Check it before using, though if (self.icon_theme.lookup_icon("gnome-spinner", -1, 0)): self.default_animated_icon_name = "gnome-spinner" else: self.default_animated_icon_name = None
def main(): parser = optparse.OptionParser( usage='usage: %prog [options] [saved flow graphs]', version=VERSION_AND_DISCLAIMER_TEMPLATE % gr.version()) options, args = parser.parse_args() try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0)) except: pass platform = Platform( prefs_file=gr.prefs(), version=gr.version(), version_parts=(gr.major_version(), gr.api_version(), gr.minor_version()), install_prefix=gr.prefix() ) ActionHandler(args, platform) gtk.main()
def __load_users_treeview(self): model = self.users_treeview.get_model() treeselection = self.users_treeview.get_selection() for uid, name, user_name in self.dbus_client.list_users(): print "uid: %s, name: %s, user_name: %s" % (uid, name, user_name) if os.name == "posix": face_file = '/home/%s/.face' % name elif os.name == "nt": import glob all_users_path = os.environ["ALLUSERSPROFILE"] face_file = None for p in glob.glob( os.path.join(all_users_path, "*", "Microsoft", "User Account Pictures", "%s.bmp" % name)): face_file = p print face_file break if face_file == None: face_file = "/fake/path" if os.path.exists(face_file): pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( face_file, 50, 50) else: if os.name == "posix": icon_theme = gtk.IconTheme() pixbuf = icon_theme.load_icon('nobody', 50, gtk.ICON_LOOKUP_USE_BUILTIN) elif os.name == "nt": pixbuf = None if len(user_name) > 0: model.append([uid, pixbuf, user_name]) else: model.append([uid, pixbuf, name]) treeselection.set_mode(gtk.SELECTION_SINGLE) self.users_selection_change_cb_id = treeselection.connect( "changed", self.__on_users_treeview_selection_changed)
class control_box(gtk.HBox): gsignal('detach-clicked') gsignal('close-clicked') icon_theme = gtk.IconTheme() icon_theme.set_custom_theme('Humility') load_flags = gtk.ICON_LOOKUP_FORCE_SVG close_pixbuf = icon_theme.load_icon('gtk-close', 14, load_flags) detach_pixbuf = icon_theme.load_icon('gtk-go-up', 12, load_flags) def __init__(self, detach_button=True, close_button=True): gtk.HBox.__init__(self) db = clickable_eventbox(self.get_detach_image()) db.connect('clicked', self.cb_detach_clicked) if detach_button: self.pack_start(db) cb = clickable_eventbox(self.get_close_image()) cb.connect('clicked', self.cb_close_clicked) if close_button: self.pack_start(cb) def cb_close_clicked(self, eventbox): self.emit('close-clicked') def cb_detach_clicked(self, eventbox): self.emit('detach-clicked') def get_close_image(self): close_image = gtk.Image() close_image.set_from_pixbuf(self.close_pixbuf) return close_image def get_detach_image(self): detach_image = gtk.Image() detach_image.set_from_pixbuf(self.detach_pixbuf) return detach_image
def __setup_logo_image(self): icon_name = self.icon_setting.get_value(user='******') log.info('Get icon_name from user: gdm, icon name: %s' % icon_name) path = os.path.expanduser( '~gdm/.icons/%s/apps/64/%s' % (self.icon_theme_setting.get_value(user='******'), self.icon_setting.get_value(user='******'))) EXIST = False FORMAT = '' if proxy.is_exists(path + '.png'): path = path + '.png' EXIST = True FORMAT = '.png' elif proxy.is_exists(path + '.svg'): path = path + '.svg' EXIST = True FORMAT = '.svg' if EXIST: log.info("The icon path is: %s" % path) path = proxy.get_as_tempfile(path, os.getuid()) log.debug('Custom log is exits, the tempfile is %s' % path) if FORMAT == '.svg': pixbuf = gtk.gdk.pixbuf_new_from_file(path) pixbuf = pixbuf.scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR) self.logo_image.set_from_pixbuf(pixbuf) else: self.logo_image.set_from_file(path) else: icontheme = gtk.IconTheme() icontheme.set_custom_theme( self.icon_theme_setting.get_value(user='******')) try: self.logo_image.set_from_pixbuf( icontheme.load_icon(icon_name, 64, 0)) except: pass
def button_cb(self, button): print "Button clicked" fileinfo = gnomevfs.FileInfo() fileinfo.valid_fields |= gnomevfs.FILE_INFO_FIELDS_TYPE fileinfo.type = gnomevfs.FILE_TYPE_DIRECTORY names = self.mime.get_icon_names(self.entry.get_text()) icontheme = gtk.IconTheme() self.model.clear() for i in names: supported = icontheme.has_icon(i) print "Found icon %s. Supported: " % (i, ), supported if supported: pixbuf = icontheme.load_icon(i, 48, gtk.ICON_LOOKUP_USE_BUILTIN) #TODO Set the model self.model.append(( pixbuf, i, ))
def __init__(self, app): self.app = app self.builder = gtk.Builder() self.builder.add_from_string(pkg_resources.resource_string(__name__, "/data/ui/login.glade")) self.builder.connect_signals(self) loader = gtk.gdk.PixbufLoader('png') loader.write(pkg_resources.resource_string(__name__, "/resources/icon/dewdrop-128-black.png")) loader.close() icons = gtk.IconTheme() app_icon = "tray" try: assert icons.has_icon(app_icon) except AssertionError: app_icon = "/tmp/tray.png" icon = pkg_resources.resource_string(__name__, '/resources/tray/white.png') f = open(app_icon, "w") f.write(icon) f.close() self.builder.get_object('loginWindow').set_icon_from_file(app_icon) self.builder.get_object('loginImage').set_from_pixbuf(loader.get_pixbuf()) self.builder.get_object('loginWindow').show() self.builder.get_object('loginWindow').connect('destroy', lambda x: gtk.main_quit())
from apt.progress.base import AcquireProgress, InstallProgress import base64 import mimetypes import socket import fnmatch import gtk import re # Configs log = Logger("APP") applications_dir = "/usr/share/applications" config_dir = "/etc/cri/serve-chroot" remote_test_server = "8.8.8.8" remote_test_port = 53 icon_theme = "Numix" theme = gtk.IconTheme() theme.set_custom_theme(icon_theme) icon_size = 256 default_icon = theme.lookup_icon("exec", icon_size, 0) # Global locked variables app_list = [] cche = cache.Cache() # Global functions def check_internet(): try: log.info("Checking for an internet connection...") socket.setdefaulttimeout(1) socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(
def createTheme(d): theme = gtk.IconTheme() theme.set_custom_theme(d) return theme
def __init__(self, app): self.app = app self.builder = gtk.Builder() self.builder.add_from_string( pkg_resources.resource_string(__name__, "data/ui/settings.glade")) self.builder.connect_signals(self) loader = gtk.gdk.PixbufLoader('png') loader.write( pkg_resources.resource_string(__name__, "resources/icons/icon.png")) loader.close() icons = gtk.IconTheme() app_icon = "tray" try: assert icons.has_icon(app_icon) except AssertionError: app_icon = "/tmp/tray.png" icon = pkg_resources.resource_string(__name__, 'resources/tray/tray.png') f = open(app_icon, "w") f.write(icon) f.close() dropzone = self.app._cfg.get('dropzone') #self.orig_dropzone = dropzone name = "btnHide" if dropzone == "custom": name = "btnCustom" #self.orig_x = self.app._cfg.get('x') #self.orig_x = self.app._cfg.get('y') elif dropzone == "tl": name = "btnTopLeft" elif dropzone == "tm": name = "btnTopMiddle" elif dropzone == "tr": name = "btnTopRight" elif dropzone == "ml": name = "btnMiddleLeft" elif dropzone == "mr": name = "btnMiddleRight" elif dropzone == "bl": name = "btnBottomLeft" elif dropzone == "bm": name = "btnBottomMiddle" elif dropzone == "br": name = "btnBottomRight" self.builder.get_object(name).set_active(True) self.builder.get_object('settingsWindow').set_focus( self.builder.get_object(name)) self.builder.get_object('settingsWindow').set_modal(False) self.builder.get_object('settingsWindow').set_icon_from_file(app_icon) self.builder.get_object('settingsWindow').show() self.builder.get_object('settingsWindow').connect( 'destroy', lambda x: gtk.main_quit())
# -*- coding: utf-8 -*- # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: import gtk import os import shelve import shutil I = gtk.IconTheme() I.set_custom_theme('Rodent') f = open('iconmaker.data', 'r') try: shutil.rmtree('iconbuild') except: pass try: os.remove('icons.dat') except: pass os.mkdir('iconbuild') outfile = shelve.open('icons.dat') for line in f: name, key = [s.strip() for s in line.split(' ')] i = I.load_icon(name, 15, 0) d = i.get_pixels() cs = i.get_colorspace() ha = i.get_has_alpha() bp = i.get_bits_per_sample() w = i.get_width() h = i.get_height() rs = i.get_rowstride()
'kupfer-object-multiple': 'gtk-file', 'kupfer-catalog': 'folder-saved-search', } kupfer_locally_installed_names = set() def _icon_theme_changed(theme): pretty.print_info(__name__, "Icon theme changed, clearing cache") global icon_cache icon_cache = {} _default_theme = gtk.icon_theme_get_default() _default_theme.connect("changed", _icon_theme_changed) _local_theme = gtk.IconTheme() _local_theme.set_search_path([]) def parse_load_icon_list(icon_list_data, get_data_func, plugin_name=None): """ @icon_list_data: A bytestring whose lines identify icons @get_data_func: A function to return the data for a relative filename @plugin_name: plugin id, if applicable """ for line in icon_list_data.splitlines(): # ignore '#'-comments if line.startswith("#") or not line.strip(): continue fields = map(str.strip, line.split('\t')) if len(fields) < 2:
# -*- coding: utf-8 -*- ''' Модуль работы с иконками ''' from __builtin__ import edna_builtin import gtk import gio type_ico_load = gtk.ICON_LOOKUP_USE_BUILTIN get_theme = gtk.icon_theme_get_default() get_theme_gnome = gtk.IconTheme() get_theme_gnome.set_custom_theme('gnome') def icon_load_try(name, size): ''' Безопасная процедура загрузки иконок ''' try: return get_theme.load_icon(name, size, type_ico_load) except glib.GError: return get_theme_gnome.load_icon(name, size, type_ico_load) def create_icons_container(): ''' Создание контейнера с иконками ''' dic_icon = {}