Пример #1
0
 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()
Пример #2
0
def setup_icons():
    """Set up some extra stock icons for better PyGTK compatibility."""
    # create a new stock icon for the 'group' action
    root_img_dir = get_image_dir()
    pixbuf = get_icon()
    gcylc_iconset = gtk.IconSet(pixbuf)
    pixbuf = gtk.gdk.pixbuf_new_from_file(root_img_dir + '/icons/group.png')
    grp_iconset = gtk.IconSet(pixbuf)
    pixbuf = gtk.gdk.pixbuf_new_from_file(root_img_dir + '/icons/ungroup.png')
    ungrp_iconset = gtk.IconSet(pixbuf)
    factory = gtk.IconFactory()
    factory.add('gcylc', gcylc_iconset)
    factory.add('group', grp_iconset)
    factory.add('ungroup', ungrp_iconset)
    factory.add_default()
Пример #3
0
	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)
Пример #4
0
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 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)
Пример #6
0
def readImageFromFile(file, width = None, height = None, dither = None,
                      image = None):
    pixbuf = getPixbuf(file)
    if pixbuf is None:
        log.warning("can't find pixmap %s" %(file,))
        return None

    if (width is not None and height is not None
        and height != pixbuf.get_height()
        and width != pixbuf.get_width()):
        pixbuf = pixbuf.scale_simple(width, height,
                                     gtk.gdk.INTERP_BILINEAR)

    if image is None:
        p = gtk.Image()
    else:
        p = image
    if dither:
        (pixmap, mask) = pixbuf.render_pixmap_and_mask()
        pixmap.draw_pixbuf(gtk.gdk.GC(pixmap), pixbuf, 0, 0, 0, 0,
                           pixbuf.get_width(), pixbuf.get_height(),
                           gtk.gdk.RGB_DITHER_MAX, 0, 0)
        p = gtk.Image()
        p.set_from_pixmap(pixmap, mask)
    else:
        source = gtk.IconSource()
        source.set_pixbuf(pixbuf)
        source.set_size(gtk.ICON_SIZE_DIALOG)
        source.set_size_wildcarded(False)
        iconset = gtk.IconSet()
        iconset.add_source(source)
        p.set_from_icon_set(iconset, gtk.ICON_SIZE_DIALOG)

    return p
Пример #7
0
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
Пример #8
0
 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()
Пример #9
0
 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
Пример #10
0
 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()
Пример #11
0
    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))
Пример #12
0
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'
Пример #13
0
 def register_icon(self, iconname):
     # iconname might be '' when page do not define icon
     if (not iconname
             or iconname in (self._loaded_icons | self._locale_icons)):
         return
     if iconname not in self._name2id:
         self.load_icons(refresh=True)
     icon_ref = (self._name2id[iconname], iconname)
     idx = self._tryton_icons.index(icon_ref)
     to_load = slice(max(0, idx - self.batchnum // 2),
         idx + self.batchnum // 2)
     ids = [e[0] for e in self._tryton_icons[to_load]]
     try:
         icons = rpc.execute('model', 'ir.ui.icon', 'read', ids,
             ['name', 'icon'], rpc.CONTEXT)
     except TrytonServerError:
         icons = []
     for icon in icons:
         # svg file cannot be loaded from data into a pixbuf
         fileno, path = tempfile.mkstemp()
         with os.fdopen(fileno, 'w') as svgfile:
             svgfile.write(icon['icon'])
         try:
             pixbuf = gtk.gdk.pixbuf_new_from_file(path.decode(
                 sys.getfilesystemencoding().encode('utf-8')))
         except glib.GError:
             continue
         finally:
             os.remove(path)
             self._tryton_icons.remove((icon['id'], icon['name']))
             del self._name2id[icon['name']]
             self._loaded_icons.add(icon['name'])
         iconset = gtk.IconSet(pixbuf)
         self.add(icon['name'], iconset)
Пример #14
0
 def register_icon(self, iconname):
     # iconname might be '' when page do not define icon
     if (not iconname
             or iconname in (self._loaded_icons | self._locale_icons)):
         return
     if iconname not in self._name2id:
         self.load_icons(refresh=True)
     try:
         icon_ref = (self._name2id[iconname], iconname)
     except KeyError:
         return
     idx = self._tryton_icons.index(icon_ref)
     to_load = slice(max(0, idx - self.batchnum // 2),
                     idx + self.batchnum // 2)
     ids = [e[0] for e in self._tryton_icons[to_load]]
     try:
         icons = rpc.execute('model', 'ir.ui.icon', 'read', ids,
                             ['name', 'icon'], rpc.CONTEXT)
     except TrytonServerError:
         icons = []
     for icon in icons:
         pixbuf = _data2pixbuf(icon['icon'].encode('utf-8'))
         self._tryton_icons.remove((icon['id'], icon['name']))
         del self._name2id[icon['name']]
         self._loaded_icons.add(icon['name'])
         iconset = gtk.IconSet(pixbuf)
         self.add(icon['name'], iconset)
Пример #15
0
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
Пример #16
0
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()
Пример #17
0
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)
Пример #18
0
def setup_stock_icons():
    """Setup any additional 'stock' icons."""
    new_icon_factory = gtk.IconFactory()
    locator = rose.resource.ResourceLocator(paths=sys.path)
    for png_icon_name in [
            "gnome_add", "gnome_add_errors", "gnome_add_warnings",
            "gnome_package_system", "gnome_package_system_errors",
            "gnome_package_system_warnings"
    ]:
        ifile = png_icon_name + ".png"
        istring = png_icon_name.replace("_", "-")
        path = locator.locate("etc/images/rose-config-edit/" + ifile)
        pixbuf = gtk.gdk.pixbuf_new_from_file(path)
        new_icon_factory.add("rose-gtk-" + istring, gtk.IconSet(pixbuf))
    exp_icon_pixbuf = get_icon()
    new_icon_factory.add("rose-exp-logo", gtk.IconSet(exp_icon_pixbuf))
    new_icon_factory.add_default()
Пример #19
0
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
Пример #20
0
 def add_icons(self, icons):
     for stock_id, filename in icons.items():
         if os.path.isfile(os.path.join(self.datadir, filename)):
             iconset = gtk.IconSet(
                 gtk.gdk.pixbuf_new_from_file(
                     os.path.join(self.datadir, filename)))
             self.add(stock_id, iconset)
         else:
             print >> sys.stderr, "File not found: %s" % filename
Пример #21
0
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()
Пример #22
0
    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")
Пример #23
0
def gtk_ico_image_load(path, icosize=None):
    '''try to return a gtk image from path, if fails, return a broken image'''
    if file_readable(path):
        pixbuf = gtk_pixbuf_load(path)
        iconset = gtk.IconSet(pixbuf)
        return gtk.image_new_from_icon_set(iconset,icosize)
    else:
        return gtk.image_new_from_stock(gtk.STOCK_MISSING_IMAGE,
            gtk.ICON_SIZE_DIALOG)
Пример #24
0
 def create_buttons(self):
     # create juick 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('juick.png')
     pixbuf = gtk.gdk.pixbuf_new_from_file(img_path)
     iconset = gtk.IconSet(pixbuf=pixbuf)
     factory = gtk.IconFactory()
     factory.add('juick', iconset)
     factory.add_default()
     img.set_from_stock('juick', gtk.ICON_SIZE_MENU)
     self.button.set_image(img)
     self.button.set_tooltip_text(_('Juick commands'))
     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_juick_button_clicked)
     self.chat_control.handlers[id_] = self.button
     self.button.show()
     # create juick tag button
     self.tag_button = gtk.Button(label=None, stock=None, use_underline=True)
     self.tag_button.set_property('relief', gtk.RELIEF_NONE)
     self.tag_button.set_property('can-focus', False)
     img = gtk.Image()
     img_path = self.plugin.local_file_path('juick_tag_button.png')
     pixbuf = gtk.gdk.pixbuf_new_from_file(img_path)
     iconset = gtk.IconSet(pixbuf=pixbuf)
     factory.add('juick_tag', iconset)
     factory.add_default()
     img.set_from_stock('juick_tag', gtk.ICON_SIZE_MENU)
     self.tag_button.set_image(img)
     actions_hbox.add_with_properties(self.tag_button, 'position',
         send_button_pos - 1, 'expand', False)
     id_ = self.tag_button.connect('clicked', self.on_juick_tag_button_clicked)
     self.chat_control.handlers[id_] = self.tag_button
     self.tag_button.set_no_show_all(True)
     self.tag_button.set_tooltip_text(_('Juick tags'))
     self.tag_button.set_property('visible', self.plugin.config[
         'SHOW_TAG_BUTTON'])
Пример #25
0
 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()
Пример #26
0
def add_icon (file_name, stock_id, label=None, modifier=0, keyval=0):
    pb = gtk.gdk.pixbuf_new_from_file(file_name)
    iconset = gtk.IconSet(pb)
    icon_factory.add(stock_id,iconset)
    icon_factory.add_default()
    gtk.stock_add([(stock_id,
                    label,
                    modifier,
                    keyval,
                    "")])
Пример #27
0
def icon(factory, icon_name, path):
    # Either the file or fullpath must be supplied, but not both:
    sonataset = gtk.IconSet()
    filename = [path]
    icons = [gtk.IconSource() for i in filename]
    for i, iconsource in enumerate(icons):
        iconsource.set_filename(filename[i])
        sonataset.add_source(iconsource)
    factory.add(icon_name, sonataset)
    factory.add_default()
Пример #28
0
 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()
Пример #29
0
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()
Пример #30
0
 def _register_file_icon(self, name, filename):
     #im = gtk.Image()
     #im.set_from_file(filename)
     #pb = im.get_pixbuf()
     try:
         pb = gtk.gdk.pixbuf_new_from_file_at_size(filename, 32, 32)
         icon_set = gtk.IconSet(pb)
         self._register_icon_set(icon_set, name)
     except:
         #XXX: there is a image loader missing
         #     for *.svg its librsvg + its gtk pixmap loader
         print(filename)