Example #1
0
    def __create_model(self):
        model = gtk.ListStore(
            gobject.TYPE_INT,
            gtk.gdk.Pixbuf,
            gobject.TYPE_STRING,
            gtk.gdk.Pixbuf,
            gobject.TYPE_STRING,
            gobject.TYPE_STRING,
            gobject.TYPE_BOOLEAN,
        )

        client = gconf.client_get_default()
        logo = get_icon_with_name("gnome-terminal", 24)

        for id in range(12):
            iter = model.append()
            id = id + 1

            title = _("Command %d") % id
            command = client.get_string("/apps/metacity/keybinding_commands/command_%d" % id)
            key = client.get_string("/apps/metacity/global_keybindings/run_command_%d" % id)

            if not command:
                command = _("None")
            icon = get_icon_with_name(command, 24)
            if key == "disabled":
                key = _("disabled")

            model.set(
                iter,
                COLUMN_ID,
                id,
                COLUMN_LOGO,
                logo,
                COLUMN_TITLE,
                title,
                COLUMN_ICON,
                icon,
                COLUMN_COMMAND,
                command,
                COLUMN_KEY,
                key,
                COLUMN_EDITABLE,
                True,
            )

        return model
Example #2
0
 def update_model(self):
     for title, cate, icon in MIMETYPE:
         pixbuf = get_icon_with_name(icon, 24)
         iter = self.model.append(None)
         self.model.set(iter, 
                 COLUMN_ICON, pixbuf, 
                 COLUMN_TITLE, title, 
                 COLUMN_CATE, cate)
    def create_change_icon_hbox(self):
        hbox = gtk.HBox(False, 10)
        label = gtk.Label(_('Click the button to change the menu logo'))
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, False, False, 0)

        button = gtk.Button()
        button.connect('clicked', self.on_change_icon_clicked)
        image = gtk.image_new_from_pixbuf(get_icon_with_name('start-here', 24))
        button.set_image(image)
        hbox.pack_end(button, False, False, 0)

        return hbox
    def on_change_icon_clicked(self, widget):
        dialog = gtk.FileChooserDialog(_('Choose a new logo image'),
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT,
                                                 gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
        filter = gtk.FileFilter()
        filter.set_name(_("PNG image (*.png)"))
        filter.add_mime_type("image/png")
        dialog.set_current_folder(os.path.expanduser('~'))
        dialog.add_filter(filter)

        dest = os.path.expanduser('~/.icons/%s/places/24/start-here.png' % self.__setting.get_icon_theme())
        revert_button = dialog.action_area.get_children()[-1]
        if not os.path.exists(dest):
            revert_button.set_sensitive(False)

        filename = ''
        response = dialog.run()

        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            dialog.destroy()

            if filename:
                pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                w, h = pixbuf.get_width(), pixbuf.get_height()
                if w != 24 or h != 24:
                    ErrorDialog(_("This image size isn't suitable for the panel.\nIt should be 24x24.")).launch()
                    return
                else:
                    os.system('mkdir -p %s' % os.path.dirname(dest))
                    os.system('cp %s %s' % (filename, dest))

                    image = gtk.image_new_from_file(dest)
                    widget.set_image(image)
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            os.remove(dest)
            image = gtk.image_new_from_pixbuf(get_icon_with_name('start-here', 24))
            widget.set_image(image)
        else:
            dialog.destroy()
            return

        dialog = QuestionDialog(_('Do you want your changes to take effect immediately?'))
        if dialog.run() == gtk.RESPONSE_YES:
            os.system('killall gnome-panel')

        dialog.destroy()
Example #5
0
 def get_xdg_icon(self, userdir):
     return get_icon_with_name(self.XDG_ICONS[userdir])