def __init_stock_id(self): # # generate a new stock id # # TODO: do we have to create the stock id every time? self.__stock_id = str(uuid1()) # see http://article.gmane.org/gmane.comp.gnome.gtk%2B.python/5119 # TODO: what is this strange construct for? stock_items = ( ((self.__stock_id, "", 0, 0, "")), ) gtk.stock_add(stock_items) factory = gtk.IconFactory() factory.add_default() # TODO: use IconSource, the Pixbuf is just fallback pixbuf = gdk.pixbuf_new_from_file(self.icon.path) icon_set = gtk.IconSet(pixbuf) factory.add(self.__stock_id, icon_set)
def setFactoryIcons(self,progProvider): goDownPath = progProvider.getIconPath('go-down.svg') goUpPath = progProvider.getIconPath('go-up.svg') refreshPath = progProvider.getIconPath('view-refresh.svg') recordPath = progProvider.getIconPath('multimedia.svg') savePath = progProvider.getIconPath('save.svg') exitPath = progProvider.getIconPath('exit.svg') seriesPath = progProvider.getIconPath('filter_list.png') asList= progProvider.getIconPath('open_folder.png') icoPaths = [goDownPath,goUpPath,refreshPath,recordPath,savePath,exitPath,seriesPath,asList] icoKeys = ["goDown","goUp","refresh","record","save","exit","filtericon","autoSelectList"] for key in icoKeys: items = [(key, '_GTK!', 0, 0, '')] gtk.stock_add(items) # Register our stock items # Add our custom icon factory to the list of defaults factory = gtk.IconFactory() factory.add_default() try: for index,path in enumerate(icoPaths): pixbuf = gtk.gdk.pixbuf_new_from_file(path) # @UndefinedVariable #pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path,64,64) # Register icon to accompany stock item icon_set = gtk.IconSet(pixbuf) key = icoKeys[index] factory.add(key, icon_set) except gobject.GError as error: print(('failed to load GTK logo for toolbar',error))
def setupStockItems(): ''' Setup stock images ''' widget = gtk.DrawingArea() factory = gtk.IconFactory() r = manager.ResourceManager() buf = gtk.gdk.pixbuf_new_from_file( r["resources"]["images"][gtkconstants.STOCK_SEND_IM_FILE] ) icon = gtk.IconSet(buf) factory.add( gtkconstants.STOCK_SEND_IM, icon ) factory.add( gtkconstants.STOCK_COPY_URL, gtk.IconSet(widget.render_icon(gtk.STOCK_COPY, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_COPY_EMAIL, gtk.IconSet(widget.render_icon(gtk.STOCK_COPY, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_OPEN_URL, gtk.IconSet(widget.render_icon(gtk.STOCK_JUMP_TO, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_OFFLINE_MESSAGE, gtk.IconSet(widget.render_icon(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_DEFINE, gtk.IconSet(widget.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_SEND_MOVE, gtk.IconSet(widget.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_RESET_DEFAULT, gtk.IconSet(widget.render_icon(gtk.STOCK_UNDO, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_PASS, gtk.IconSet(widget.render_icon(gtk.STOCK_NO, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_TRADE_LETTERS, gtk.IconSet(widget.render_icon(gtk.STOCK_UNDO, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_SHUFFLE, gtk.IconSet(widget.render_icon(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_REGISTER, gtk.IconSet(widget.render_icon(gtk.STOCK_ADD, gtk.ICON_SIZE_MENU)) ) factory.add( gtkconstants.STOCK_ADD_HOSTNAME, gtk.IconSet(widget.render_icon(gtk.STOCK_COPY, gtk.ICON_SIZE_MENU)) ) factory.add_default() widget.destroy() widget = None
def activate(self, shell): self.shell = shell self.db = shell.props.db self.library = self.shell.props.library_source self.player = shell.props.shell_player data = dict() ui_manager = shell.get_ui_manager() icon_file_name = self.find_file("echo_logo_64a.png") iconsource = gtk.IconSource() iconsource.set_filename(icon_file_name) iconset = gtk.IconSet() iconset.add_source(iconsource) iconfactory = gtk.IconFactory() iconfactory.add("genius_icon", iconset) iconfactory.add_default() data['action_group'] = gtk.ActionGroup('GeniusPluginActions') action = gtk.Action('MakeGeniusPlaylist', _('Echo Nest Recommender Playlist'), _("Make an Echo Nest Recommender playlist"), "genius_icon") action.connect('activate', self.make_playlist, shell) data['action_group'].add_action(action) ui_manager.insert_action_group(data['action_group'], 0) data['ui_id'] = ui_manager.add_ui_from_string(ui_toolbar_button) ui_manager.ensure_update() shell.set_data('GeniusPluginInfo', data)
def register_stock_icons(): try: import pygtk # pygtk.require('2.0') import gtk except: return items = [ ('jdh-hide', '_Hide', 0, 0, None), ('jdh-auto', '_Auto', 0, 0, None), ] # We're too lazy to make our own icons, so we use regular stock icons. aliases = [ ('jdh-hide', gtk.STOCK_CANCEL), ('jdh-auto', gtk.STOCK_EXECUTE), ] gtk.stock_add(items) factory = gtk.IconFactory() factory.add_default() for new_stock, alias in aliases: icon_set = gtk.icon_factory_lookup_default(alias) factory.add(new_stock, icon_set)
def set_stock_icons(st_req, st_path): import pkg_resources as pr icon_names = pr.resource_listdir(st_req, st_path) stock_ids = set(gtk.stock_list_ids()) iconfactory = gtk.IconFactory() theme = gtk.icon_theme_get_default() listed = theme.list_icons() for icon in icon_names: if icon.startswith('.'): continue iconname = icon.split('.', 1)[0] if iconname not in listed: iconres = '/'.join(['data', 'icons', icon]) iconpath = pr.resource_filename(st_req, iconres) try: pixbuf = gtk.gdk.pixbuf_new_from_file(iconpath) iconset = gtk.IconSet(pixbuf) iconfactory.add(iconname, iconset) gtk.icon_theme_add_builtin_icon(iconname, 128, pixbuf) except gobject.GError: # icon could not be loaded pass iconfactory.add_default() return theme, iconfactory
def create_buttons(self): # create /me button actions_hbox = self.chat_control.xml.get_object('actions_hbox') self.button = gtk.Button(label=None, stock=None, use_underline=True) self.button.set_property('relief', gtk.RELIEF_NONE) self.button.set_property('can-focus', False) img = gtk.Image() img_path = self.plugin.local_file_path('gui_for_me.png') pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) iconset = gtk.IconSet(pixbuf=pixbuf) factory = gtk.IconFactory() factory.add('gui_for_me', iconset) factory.add_default() img.set_from_stock('gui_for_me', gtk.ICON_SIZE_MENU) self.button.set_image(img) self.button.set_tooltip_text(_('Insert /me to conversation input box,' ' at cursor position')) send_button = self.chat_control.xml.get_object('send_button') send_button_pos = actions_hbox.child_get_property(send_button, 'position') actions_hbox.add_with_properties(self.button, 'position', send_button_pos - 1, 'expand', False) id_ = self.button.connect('clicked', self.on_me_button_clicked) self.chat_control.handlers[id_] = self.button self.button.show()
def create_stock_icons(): """ Creates the pitivi-only stock icons """ gtk.stock_add([ ('pitivi-render', _('Render'), 0, 0, 'pitivi'), ('pitivi-split', _('Split'), 0, 0, 'pitivi'), ('pitivi-keyframe', _('Keyframe'), 0, 0, 'pitivi'), ('pitivi-unlink', _('Unlink'), 0, 0, 'pitivi'), # Translators: This is an action, the title of a button ('pitivi-link', _('Link'), 0, 0, 'pitivi'), ('pitivi-ungroup', _('Ungroup'), 0, 0, 'pitivi'), # Translators: This is an action, the title of a button ('pitivi-group', _('Group'), 0, 0, 'pitivi'), ]) pixmaps = { "pitivi-render" : "pitivi-render-24.png", "pitivi-split" : "pitivi-split-24.svg", "pitivi-keyframe" : "pitivi-keyframe-24.svg", "pitivi-unlink" : "pitivi-unlink-24.svg", "pitivi-link" : "pitivi-relink-24.svg", "pitivi-ungroup" : "pitivi-ungroup-24.svg", "pitivi-group" : "pitivi-group-24.svg", } factory = gtk.IconFactory() pmdir = get_pixmap_dir() for stockid, path in pixmaps.iteritems(): pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(pmdir, path)) iconset = gtk.IconSet(pixbuf) factory.add(stockid, iconset) factory.add_default()
def load_icons(): items = [STOCK_ROTATE_LEFT, STOCK_ROTATE_RIGHT, STOCK_MOVE_TO_ORIGIN, STOCK_HOR_MIRROR, STOCK_VERT_MIRROR, STOCK_MULTIPLY] path = '' + os.path.join(config.resource_dir, 'icons') iconfactory = gtk.IconFactory() for item in items: gtk.stock_add([(item, '', 0, 0, ''), ]) pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(path, item + '.png')) source = gtk.IconSource() source.set_pixbuf(pixbuf) source.set_size_wildcarded(True) iconset = gtk.IconSet() iconset.add_source(source) iconfactory.add(item, iconset) #Creating aliased icons items = [(STOCK_CUTTING, _('_Cutting'), 0, 0, None), (STOCK_DONT_SAVE, _("_Don't save"), 0, 0, None), ] aliases = [(STOCK_CUTTING, gtk.STOCK_PRINT), (STOCK_DONT_SAVE, gtk.STOCK_NO), ] gtk.stock_add(items) for item, alias in aliases: iconset = gtk.icon_factory_lookup_default(alias) iconfactory.add(item, iconset) iconfactory.add_default()
def __init__(self, data): self.data = data self.data.gtk = gtk self.data.builder = gtk.Builder() factory = gtk.IconFactory() factory.add_default() builder = self.data.builder builder.add_from_file("../res/gui.glade") self.window = builder.get_object("window1") self.window.connect("delete_event", self.delete_event) self.setCellRenderers() #self.pb_blue = gtk.gdk.pixbuf_new_from_file("../pixbuf1.png") #self.pb_green = gtk.gdk.pixbuf_new_from_file("../pixbuf2.png") #self.pb_red = gtk.gdk.pixbuf_new_from_file("../pixbuf3.png") self.data.status = builder.get_object("gui_status") self.viewer = ocad_viewer.ocad_viewer(self.data, gtk, self.window) self.viewer.isLayerVisible = self.isLayerVisible self.initImageViewer() self.viewer.viewer = self.view #every second check if status is empty gobject.timeout_add_seconds(1, self.check_status, False) self.clean_status = True
def register_stock_icons(): ''' This function registers our custom toolbar icons, so they can be themed. ''' items = [('demo-gtk-logo', '_GTK!', 0, 0, '')] # Register our stock items gtk.stock_add(items) # Add our custom icon factory to the list of defaults factory = gtk.IconFactory() factory.add_default() import os img_dir = os.path.join(os.path.dirname(__file__), 'images') img_path = os.path.join(img_dir, 'gtk-logo-rgb.gif') try: pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) # Register icon to accompany stock item # The gtk-logo-rgb icon has a white background, make it transparent # the call is wrapped to (gboolean, guchar, guchar, guchar) transparent = pixbuf.add_alpha(True, chr(255), chr(255), chr(255)) icon_set = gtk.IconSet(transparent) factory.add('demo-gtk-logo', icon_set) except gobject.GError, error: print 'failed to load GTK logo for toolbar'
def create_stock_items(self): # FIXME: Why don't these stock items work for buttons in win32? # Seem to work fine for images...hmm stock_items = (("mfe-general", "_General", 0, 0, "English"), ("mfe-engine", "_Engine", 0, 0, "English"), ("mfe-about", "_Info", 0, 0, "English"), ("mfe-clear", "", 0, 0, "English"), ("mfe-save", "", 0, 0, "English"), ("mfe-doc", "", 0, 0, "English"), ("mfe-license", "_License", 0, 0, "English"), ("mfe-help", "_Help", 0, 0, "English"), ("mfe-quit", "_Quit", 0, 0, "English"), ("mfe-play", "_Play", 0, 0, "English"), ("mfe-stop", "_Stop", 0, 0, "English")) stock_files = (("mfe-general", mfeconst.genimage), ("mfe-engine", mfeconst.engimage), ("mfe-about", mfeconst.aboutimage), ("mfe-clear", mfeconst.clearimage), ("mfe-save", mfeconst.saveimage), ("mfe-doc", mfeconst.docimage), ("mfe-license", mfeconst.licimage), ("mfe-help", mfeconst.helpimage), ("mfe-quit", mfeconst.quitimage), ("mfe-play", mfeconst.playimage), ("mfe-stop", mfeconst.stopimage)) gtk.stock_add(stock_items) factory = gtk.IconFactory() for item, path in stock_files: pixbuf = gtk.gdk.pixbuf_new_from_file(path) icon_set = gtk.IconSet(pixbuf) factory.add(item, icon_set) factory.add_default()
def register_stock_icons(): ctrlshift = gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK icons = [('odml-logo', '_odML', 0, 0, ''), ('odml-add-Section', 'Add _Section', ctrlshift, ord("S"), ''), ('odml-add-Property', 'Add _Property', ctrlshift, ord("P"), ''), ('odml-add-Value', 'Add _Value', ctrlshift, ord("V"), ''), ] gtk.stock_add(icons) # Add our custom icon factory to the list of defaults factory = gtk.IconFactory() factory.add_default() img_dir = get_image_path() for stock_icon in icons: icon_name = stock_icon[0] img_path = os.path.join(img_dir, "%s.png" % icon_name) try: icon = load_pixbuf(img_path) icon_set = gtk.IconSet(icon) for icon in load_icon_pixbufs(icon_name): src = gtk.IconSource() src.set_pixbuf(icon) icon_set.add_source(src) factory.add(icon_name, icon_set) except gobject.GError, error: print 'failed to load icon', icon_name, error
def add_stock_ids(self): ids = [ ('pyide-next', '_Next', gtk.gdk.CONTROL_MASK, gtk.keysyms.N, 'pyide'), ('pyide-step', '_Step', gtk.gdk.CONTROL_MASK, gtk.keysyms.S, 'pyide'), ('pyide-return', '_Return', gtk.gdk.CONTROL_MASK, gtk.keysyms.R, 'pyide'), ('pyide-continue', '_Continue', gtk.gdk.CONTROL_MASK, gtk.keysyms.C, 'pyide'), ('pyide-break', '_Break', gtk.gdk.CONTROL_MASK, gtk.keysyms.B, 'pyide'), ('pyide-edit', '_Edit', gtk.gdk.CONTROL_MASK, gtk.keysyms.E, 'pyide'), ('pyide-run', 'R_un', gtk.gdk.CONTROL_MASK, gtk.keysyms.U, 'pyide'), ('pyide-quit', '_Quit', gtk.gdk.CONTROL_MASK, gtk.keysyms.Q, 'pyide'), ] gtk.stock_add(ids) names = [ 'next', 'step', 'return', 'continue', 'break', 'edit', 'run', 'quit' ] self.iconfactory = gtk.IconFactory() for name in names: iconset = gtk.IconSet(gtk.gdk.pixbuf_new_from_file(name + '.xpm')) self.iconfactory.add('pyide-' + name, iconset) self.iconfactory.add_default() return
def create_buttons(self): # create whiteboard button actions_hbox = self.chat_control.xml.get_object('actions_hbox') self.button = gtk.ToggleButton(label=None, use_underline=True) self.button.set_property('relief', gtk.RELIEF_NONE) self.button.set_property('can-focus', False) img = gtk.Image() img_path = self.plugin.local_file_path('whiteboard.png') pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) iconset = gtk.IconSet(pixbuf=pixbuf) factory = gtk.IconFactory() factory.add('whiteboard', iconset) img_path = self.plugin.local_file_path('brush_tool.png') pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) iconset = gtk.IconSet(pixbuf=pixbuf) factory.add('brush_tool', iconset) img_path = self.plugin.local_file_path('line_tool.png') pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) iconset = gtk.IconSet(pixbuf=pixbuf) factory.add('line_tool', iconset) img_path = self.plugin.local_file_path('oval_tool.png') pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) iconset = gtk.IconSet(pixbuf=pixbuf) factory.add('oval_tool', iconset) factory.add_default() img.set_from_stock('whiteboard', gtk.ICON_SIZE_MENU) self.button.set_image(img) send_button = self.chat_control.xml.get_object('send_button') send_button_pos = actions_hbox.child_get_property( send_button, 'position') actions_hbox.add_with_properties(self.button, 'position', send_button_pos - 1, 'expand', False) id_ = self.button.connect('toggled', self.on_whiteboard_button_toggled) self.chat_control.handlers[id_] = self.button self.button.show()
def register_stock_icons(): # virtual or conda environments as well as local installs might # not have access to the system stock items so we update the IconTheme search path. print("[Info] Updating IconTheme search paths") icon_theme = gtk.icon_theme_get_default() icon_paths = lookup_resource_paths(os.path.join('share', 'icons')) for ipath in icon_paths: icon_theme.prepend_search_path(ipath) ctrlshift = gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK icons = [ ('odml-logo', '_odML', 0, 0, ''), ('odml_addSection', 'Add _Section', ctrlshift, ord("S"), ''), ('odml_addProperty', 'Add _Property', ctrlshift, ord("P"), ''), ('odml_addValue', 'Add _Value', ctrlshift, ord("V"), ''), ('odml_Dustbin', '_Delete', 0, 0, ''), ('INM6-compare-table', 'Compare_entities', ctrlshift, ord("E"), ''), ('INM6-convert-odml', 'Convert_document', ctrlshift, ord("C"), ''), ('INM6-filter-odml', 'Filter_document', ctrlshift, ord("F"), ''), ('INM6-merge-odml', 'Merge_documents', ctrlshift, ord("M"), '') ] # This method is failing (silently) in registering the stock icons. # Passing a list of Gtk.StockItem also has no effects. # To circumvent this, the *stock* and *label* properties of items # have been separated, wherever necessary. gtk.stock_add(icons) # The icons are being registered by the following steps. # Add our custom icon factory to the list of defaults factory = gtk.IconFactory() factory.add_default() for stock_icon in icons: icon_name = stock_icon[0] try: # Dependent on python environment and installation used, default gtk # and custom icons will be found at different locations. name = "%s.%s" % (icon_name, "png") img_dir = get_img_path(name) if not img_dir: print("[Warning] Icon %s not found in supported paths" % name) continue img_path = os.path.join(img_dir, name) icon = load_pixbuf(img_path) icon_set = gtk.IconSet.new_from_pixbuf(icon) for icon in load_icon_pixbufs(icon_name): src = gtk.IconSource() src.set_pixbuf(icon) icon_set.add_source(src) factory.add(icon_name, icon_set) except gobject.GError as error: print('[Warning] Failed to load icon', icon_name, error)
def base_reg_stock_icons(iconpaths, extraiconsize, items): """ Reusable base to register stock icons in Gramps ..attribute iconpaths: list of main directory of the base icon, and extension, eg: [(os.path.join(const.IMAGE_DIR, 'scalable'), '.svg')] ..attribute extraiconsize: list of dir with extra prepared icon sizes and the gtk size to use them for, eg: [(os.path.join(const.IMAGE_DIR, '22x22'), gtk.ICON_SIZE_LARGE_TOOLBAR)] ..attribute items: list of icons to register, eg: [('gramps-db', _('Family Trees'), gtk.gdk.CONTROL_MASK, 0, '')] """ # Register our stock items gtk.stock_add(items) # Add our custom icon factory to the list of defaults factory = gtk.IconFactory() factory.add_default() for data in items: pixbuf = 0 for (dirname, ext) in iconpaths: icon_file = os.path.expanduser(os.path.join( dirname, data[0] + ext)) if os.path.isfile(icon_file): try: pixbuf = gtk.gdk.pixbuf_new_from_file(icon_file) break except: pass if not pixbuf: icon_file = os.path.join(const.IMAGE_DIR, 'gramps.png') pixbuf = gtk.gdk.pixbuf_new_from_file(icon_file) ## FIXME from gtk 2.17.3/2.15.2 change this to ## FIXME pixbuf = pixbuf.add_alpha(True, 255, 255, 255) pixbuf = pixbuf.add_alpha(True, chr(0xff), chr(0xff), chr(0xff)) icon_set = gtk.IconSet(pixbuf) #add different sized icons, always png type! for size in extraiconsize: pixbuf = 0 icon_file = os.path.expanduser( os.path.join(size[0], data[0] + '.png')) if os.path.isfile(icon_file): try: pixbuf = gtk.gdk.pixbuf_new_from_file(icon_file) except: pass if pixbuf: source = gtk.IconSource() source.set_size_wildcarded(False) source.set_size(size[1]) source.set_pixbuf(pixbuf) icon_set.add_source(source) factory.add(data[0], icon_set)
def init_icons(): factory = gtk.IconFactory() fn = "/usr/share/icons/hicolor/16x16/apps/tomboy.png" #TODO: Generalize pixbuf = gtk.gdk.pixbuf_new_from_file(fn) set = gtk.IconSet(pixbuf) factory.add(_tomboy_stock_icon, set) factory.add_default() _icons_initialized = True
def add_gtk_icon_to_stock(icon_name, label_str_localized): gtk.stock_add([(icon_name, label_str_localized, 0, 0, None)]) iconsource = gtk.IconSource() iconsource.set_icon_name(icon_name) iconset = gtk.IconSet() iconset.add_source(iconsource) icon_factory = gtk.IconFactory() icon_factory.add(icon_name, iconset) icon_factory.add_default()
def activate(self, shell): """ Activation method, initialization phase """ # Store the shell self.shell = shell # Retrieve some gconf values self.autosaveenabled = gconf.client_get_default().get_bool( gconf_keys['autosaveenabled']) self.ratingsenabled = gconf.client_get_default().get_bool( gconf_keys['ratingsenabled']) self.playcountsenabled = gconf.client_get_default().get_bool( gconf_keys['playcountsenabled']) # Create stock id for icons (save,restore, clean) iconfactory = gtk.IconFactory() #stock_ids = gtk.stock_list_ids() for stock_id, file in [('save_rating_playcount', 'save.png'), ('restore_rating_playcount', 'restore.png'), ('clean_alltags', 'clean.png')]: # only load image files when our stock_id is not present #if stock_id not in stock_ids: iconset = gtk.IconSet( gtk.gdk.pixbuf_new_from_file(self.find_file(file))) iconfactory.add(stock_id, iconset) iconfactory.add_default() # Setup gtk.Action (for the right-click menu) (see method definition below) self.setup_gtkactions(shell) # Setup statusbar and progressbar player = shell.get_player() self.statusbar = player.get_property("statusbar") # Is there a better way to get access to it ??? self.progressbar = self.statusbar.get_children()[1] # Store a reference to the db self.db = shell.props.db # If autosave is enabled, each time an entry is changed call the given method if self.autosaveenabled: self.entrychanged_sig_id = self.db.connect('entry-changed', self._on_entry_change) # Variable to store processing stats self.num_saved = 0 self.num_failed = 0 self.num_restored = 0 self.num_already_done = 0 self.num_cleaned = 0 # Index of the current selected item self.iel = 0 # Start time self.t0 = 0 print("Plugin activated")
def _init_icons(self): gtk.window_set_default_icon_from_file(get_image('diglib.svg')) icon_factory = gtk.IconFactory() for stock_id in ('diglib-document-add', 'diglib-document-open', 'diglib-document-copy', 'diglib-document-delete', 'diglib-document-tag', 'diglib-directory-add'): icon_path = get_image('%s.svg' % stock_id) icon_set = gtk.IconSet(gtk.gdk.pixbuf_new_from_file(icon_path)) icon_factory.add(stock_id, icon_set) icon_factory.add_default()
def register_iconsets(self, icon_info): iconfactory = gtk.IconFactory() stock_ids = gtk.stock_list_ids() for stock_id, file in icon_info: ## only load image files when our stock_id is not present if stock_id not in stock_ids: pixbuf = gtk.gdk.pixbuf_new_from_file(file) iconset = gtk.IconSet(pixbuf) iconfactory.add(stock_id, iconset) iconfactory.add_default()
def load_icons(): _icons = (('gimp-flip-horizontal.png', 'comix-flip-horizontal'), ('gimp-flip-vertical.png', 'comix-flip-vertical'), ('gimp-rotate-180.png', 'comix-rotate-180'), ('gimp-rotate-270.png', 'comix-rotate-270'), ('gimp-rotate-90.png', 'comix-rotate-90'), ('gimp-thumbnails.png', 'comix-thumbnails'), ('gimp-transform.png', 'comix-transform'), ('tango-enhance-image.png', 'comix-enhance-image'), ('tango-add-bookmark.png', 'comix-add-bookmark'), ('tango-archive.png', 'comix-archive'), ('tango-image.png', 'comix-image'), ('library.png', 'comix-library'), ('comments.png', 'comix-comments'), ('zoom.png', 'comix-zoom'), ('lens.png', 'comix-lens'), ('double-page.png', 'comix-double-page'), ('manga.png', 'comix-manga'), ('fitbest.png', 'comix-fitbest'), ('fitwidth.png', 'comix-fitwidth'), ('fitheight.png', 'comix-fitheight'), ('fitmanual.png', 'comix-fitmanual')) icon_path = None # Some heuristics to find the path to the icon image files. base = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))) # Try source directory. if os.path.isfile(os.path.join(base, 'images/16x16/comix.png')): icon_path = os.path.join(base, 'images') else: # Try system directories. for prefix in [base, '/usr', '/usr/local', '/usr/X11R6']: if os.path.isfile( os.path.join( prefix, 'share/comix/images/16x16/comix.png')): # Try one icon_path = os.path.join(prefix, 'share/comix/images') break if icon_path is None: return # Load window title icon. pixbuf = gtk.gdk.pixbuf_new_from_file( os.path.join(icon_path, '16x16/comix.png')) gtk.window_set_default_icon(pixbuf) # Load application icons. factory = gtk.IconFactory() for filename, stockid in _icons: try: filename = os.path.join(icon_path, filename) pixbuf = gtk.gdk.pixbuf_new_from_file(filename) iconset = gtk.IconSet(pixbuf) factory.add(stockid, iconset) except Exception: print('! Could not load icon "{}".'.format(filename)) factory.add_default()
def register_stock_icons(): """ Register the stock icons used by the various classes in the module. """ factory = gtk.IconFactory() factory.add_default() for stock_id in [STOCK_ICON, STOCK_SET_STAR, STOCK_UNSET_STAR]: pixbuf = gdk.pixbuf_new_from_file( os.path.join(musicapplet.defs.PKG_DATA_DIR, "%s.png" % stock_id)) icon_set = gtk.IconSet(pixbuf) factory.add(stock_id, icon_set)
def register_icons(): """Adds custom icons to the list of stock IDs.""" icon_info = {'pondus_plot': parameters.plot_button_path} iconfactory = gtk.IconFactory() stock_ids = gtk.stock_list_ids() for stock_id in icon_info: # only load image files when our stock_id is not present if stock_id not in stock_ids: icon_file = icon_info[stock_id] pixbuf = gtk.gdk.pixbuf_new_from_file(icon_file) iconset = gtk.IconSet(pixbuf) iconfactory.add(stock_id, iconset) iconfactory.add_default()
def setup_scheduler_icon(ipath=None): """Setup a 'stock' icon for the scheduler""" new_icon_factory = gtk.IconFactory() locator = rose.resource.ResourceLocator(paths=sys.path) iname = "rose-gtk-scheduler" if ipath is None: new_icon_factory.add( iname, gtk.icon_factory_lookup_default(gtk.STOCK_MISSING_IMAGE)) else: path = locator.locate(ipath) pixbuf = gtk.gdk.pixbuf_new_from_file(path) new_icon_factory.add(iname, gtk.IconSet(pixbuf)) new_icon_factory.add_default()
def load_icons(): _icons = (('gimp-flip-horizontal.png', 'mcomix-flip-horizontal'), ('gimp-flip-vertical.png', 'mcomix-flip-vertical'), ('gimp-rotate-180.png', 'mcomix-rotate-180'), ('gimp-rotate-270.png', 'mcomix-rotate-270'), ('gimp-rotate-90.png', 'mcomix-rotate-90'), ('gimp-thumbnails.png', 'mcomix-thumbnails'), ('gimp-transform.png', 'mcomix-transform'), ('tango-enhance-image.png', 'mcomix-enhance-image'), ('tango-add-bookmark.png', 'mcomix-add-bookmark'), ('tango-archive.png', 'mcomix-archive'), ('tango-image.png', 'mcomix-image'), ('library.png', 'mcomix-library'), ('comments.png', 'mcomix-comments'), ('zoom.png', 'mcomix-zoom'), ('lens.png', 'mcomix-lens'), ('double-page.png', 'mcomix-double-page'), ('manga.png', 'mcomix-manga'), ('fitbest.png', 'mcomix-fitbest'), ('fitwidth.png', 'mcomix-fitwidth'), ('fitheight.png', 'mcomix-fitheight'), ('fitmanual.png', 'mcomix-fitmanual'), ('goto-first-page.png', 'mcomix-goto-first-page'), ('goto-last-page.png', 'mcomix-goto-last-page'), ('next-page.png', 'mcomix-next-page'), ('previous-page.png', 'mcomix-previous-page'), ('next-archive.png', 'mcomix-next-archive'), ('previous-archive.png', 'mcomix-previous-archive'), ('next-directory.png', 'mcomix-next-directory'), ('previous-directory.png', 'mcomix-previous-directory')) # Load window title icons. pixbufs = mcomix_icons() gtk.window_set_default_icon_list(*pixbufs) # Load application icons. factory = gtk.IconFactory() for filename, stockid in _icons: try: icon_data = resource_string('mcomix.images', filename) pixbuf = image_tools.load_pixbuf_data(icon_data) iconset = gtk.IconSet(pixbuf) factory.add(stockid, iconset) except Exception: log.warning(_('! Could not load icon "%s"'), filename) factory.add_default()
def create_stock_button(icons): """ Register stock buttons from custom images. @param icons: A list of tuples containing filename, name and description """ factory = gtk.IconFactory() factory.add_default() for img, name, description in icons: pb = gtk.gdk.pixbuf_new_from_file(os.path.join(const.IMAGEDIR, img)) iconset = gtk.IconSet(pb) factory.add(name, iconset) gtk.stock_add([(name, description, 0, 0, "pigeonplanner")])
def register_iconset(icon_info): iconfactory = gtk.IconFactory() stock_ids = gtk.stock_list_ids() for stock_id, file in icon_info: # only load image files when our stock_id is not present if stock_id not in stock_ids: try: pixbuf = gtk.gdk.pixbuf_new_from_file(icon_path + file) iconset = gtk.IconSet(pixbuf) iconfactory.add(stock_id, iconset) except: pass iconfactory.add_default() return iconfactory
def register_stock_icons(): """ Register the custom stock icons used by the applet. """ factory = gtk.IconFactory() factory.add_default() for stock_id in [PANFLUTE, SET_STAR, UNSET_STAR]: pixbuf = gtk.gdk.pixbuf_new_from_file( os.path.join(panflute.defs.PKG_DATA_DIR, "{0}.svg".format(stock_id))) icon_set = gtk.IconSet(pixbuf) factory.add(stock_id, icon_set)