def __init__(self, uuid, data, spices, size_groups):
        super(DownloadSpicesRow, self).__init__()

        self.uuid = uuid
        self.data = data
        self.spices = spices
        self.name = data['name']
        self.description = data['description']
        self.score = data['score']
        self.timestamp = data['last_edited']

        self.has_update = False

        self.status_ids = {}

        self.installed = self.spices.get_is_installed(uuid)

        widget = SettingsWidget()
        widget.set_spacing(15)
        self.add(widget)

        icon = spices.get_icon(uuid)
        widget.pack_start(icon, False, False, 0)

        desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        desc_box.set_hexpand(True)
        desc_box.set_halign(Gtk.Align.FILL)
        name_label = Gtk.Label()
        name_markup = GLib.markup_escape_text(self.name)
        name_label.set_markup('<b>{}</b>'.format(name_markup))
        name_label.set_hexpand(True)
        name_label.set_halign(Gtk.Align.START)
        desc_box.pack_start(name_label, False, False, 0)

        description_label = SettingsLabel()
        description_markup = GLib.markup_escape_text(
            sanitize_html(self.description))
        description_label.set_markup(
            '<small>{}</small>'.format(description_markup))
        desc_box.pack_start(description_label, False, False, 0)

        widget.pack_start(desc_box, True, True, 0)

        score_box = Gtk.Box()
        score_image = Gtk.Image.new_from_icon_name('starred-symbolic', 2)
        score_box.pack_start(score_image, False, False, 0)
        score_label = Gtk.Label(self.score)
        score_box.pack_start(score_label, False, False, 5)
        widget.pack_start(score_box, False, False, 0)
        size_groups[0].add_widget(score_box)

        self.status_box = Gtk.Box()
        self.status_box.set_spacing(4)
        widget.pack_start(self.status_box, False, False, 0)
        size_groups[1].add_widget(self.status_box)

        self.button_box = Gtk.Box()
        self.button_box.set_valign(Gtk.Align.CENTER)
        self.button_box.set_baseline_position(Gtk.BaselinePosition.CENTER)
        widget.pack_start(self.button_box, False, False, 0)
        size_groups[2].add_widget(self.button_box)

        if not self.installed:
            download_button = Gtk.Button.new_from_icon_name(
                'go-down-symbolic', 2)
            self.button_box.pack_start(download_button, False, False, 0)
            download_button.connect('clicked', self.download)
            download_button.set_tooltip_text(_("Install"))
        elif self.spices.get_has_update(uuid):
            self.has_update = True
            download_button = Gtk.Button.new_from_icon_name(
                'view-refresh-symbolic', 2)
            self.button_box.pack_start(download_button, False, False, 0)
            download_button.connect('clicked', self.download)
            download_button.set_tooltip_text(_("Update"))

        if self.installed:
            self.add_status('installed', 'object-select-symbolic',
                            _("Installed"))

        self.show_all()
Пример #2
0
    def __init__(self, book: Book):
        self.book: Book = book
        self.ui = cozy.ui.main_view.CozyUI()

        self.ONLINE_TOOLTIP_TEXT = _("Open book overview")
        self.OFFLINE_TOOLTIP_TEXT = _("Currently offline")

        super().__init__()
        self.event_box = Gtk.EventBox()
        self.add_events(Gdk.EventMask.KEY_PRESS_MASK)
        self.box = Gtk.Box()
        self.box.set_orientation(Gtk.Orientation.VERTICAL)
        self.box.set_spacing(7)
        self.box.set_halign(Gtk.Align.CENTER)
        self.box.set_valign(Gtk.Align.START)
        self.box.set_margin_top(10)

        # label contains the book name and is limited to x chars
        title_label = Gtk.Label()
        title = tools.shorten_string(self.book.name, MAX_BOOK_LENGTH)
        title_label.set_text(title)
        title_label.get_style_context().add_class("bold")
        title_label.set_xalign(0.5)
        title_label.set_line_wrap(Pango.WrapMode.WORD_CHAR)
        title_label.props.max_width_chars = 30
        title_label.props.justify = Gtk.Justification.CENTER

        author_label = Gtk.Label.new(
            tools.shorten_string(self.book.author, MAX_BOOK_LENGTH))
        author_label.set_xalign(0.5)
        author_label.set_line_wrap(Pango.WrapMode.WORD_CHAR)
        author_label.props.max_width_chars = 30
        author_label.props.justify = Gtk.Justification.CENTER
        author_label.get_style_context().add_class("dim-label")

        self.art = AlbumElement(self.book,
                                180,
                                self.ui.window.get_scale_factor(),
                                bordered=True,
                                square=False)

        if is_external(self.book.db_object
                       ) and not self.book.offline and not FilesystemMonitor(
                       ).get_book_online(self.book):
            super().set_sensitive(False)
            self.box.set_tooltip_text(self.OFFLINE_TOOLTIP_TEXT)
        else:
            self.box.set_tooltip_text(self.ONLINE_TOOLTIP_TEXT)

        # assemble finished element
        self.box.add(self.art)
        self.box.add(title_label)
        self.box.add(author_label)
        self.event_box.add(self.box)
        self.add(self.event_box)

        self.art.connect("play-pause-clicked", self._on_album_art_press_event)
        self.event_box.connect("button-press-event",
                               self.__on_button_press_event)
        self.connect("key-press-event", self.__on_key_press_event)
        FilesystemMonitor().add_listener(self.__on_storage_changed)
        Settings().add_listener(self.__on_storage_changed)
Пример #3
0
    def create_ui(self, with_nsm):
        self.channels = []
        self.output_channels = []
        self.window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
        self.window.set_icon_name('jack_mixer')
        self.gui_factory = gui.Factory(self.window, self.meter_scales,
                                       self.slider_scales)
        self.gui_factory.connect('midi-behavior-mode-changed',
                                 self.on_midi_behavior_mode_changed)
        self.gui_factory.emit_midi_behavior_mode()

        self.vbox_top = Gtk.VBox()
        self.window.add(self.vbox_top)

        self.menu_accelgroup = Gtk.AccelGroup()
        self.window.add_accel_group(self.menu_accelgroup)

        self.menubar = Gtk.MenuBar()
        self.vbox_top.pack_start(self.menubar, False, True, 0)

        mixer_menu_item = Gtk.MenuItem.new_with_mnemonic("_Mixer")
        self.menubar.append(mixer_menu_item)
        edit_menu_item = Gtk.MenuItem.new_with_mnemonic('_Edit')
        self.menubar.append(edit_menu_item)
        help_menu_item = Gtk.MenuItem.new_with_mnemonic('_Help')
        self.menubar.append(help_menu_item)

        self.width = 420
        self.height = 420
        self.paned_position = 210
        self.window.set_default_size(self.width, self.height)

        self.mixer_menu = Gtk.Menu()
        mixer_menu_item.set_submenu(self.mixer_menu)

        self.mixer_menu.append(
            self.new_menu_item('New _Input Channel', self.on_add_input_channel,
                               "<Control>N"))
        self.mixer_menu.append(
            self.new_menu_item('New Output _Channel',
                               self.on_add_output_channel,
                               "<Shift><Control>N"))

        self.mixer_menu.append(Gtk.SeparatorMenuItem())
        if not with_nsm:
            self.mixer_menu.append(
                self.new_menu_item('_Open...', self.on_open_cb, "<Control>O"))

        self.mixer_menu.append(
            self.new_menu_item('_Save', self.on_save_cb, "<Control>S"))

        if not with_nsm:
            self.mixer_menu.append(
                self.new_menu_item('Save _As...', self.on_save_as_cb,
                                   "<Shift><Control>S"))

        self.mixer_menu.append(Gtk.SeparatorMenuItem())
        if with_nsm:
            self.mixer_menu.append(
                self.new_menu_item('_Hide', self.nsm_hide_cb, "<Control>W"))
        else:
            self.mixer_menu.append(
                self.new_menu_item('_Quit', self.on_quit_cb, "<Control>Q"))

        edit_menu = Gtk.Menu()
        edit_menu_item.set_submenu(edit_menu)

        self.channel_edit_input_menu_item = self.new_menu_item(
            '_Edit Input Channel', enabled=False)
        edit_menu.append(self.channel_edit_input_menu_item)
        self.channel_edit_input_menu = Gtk.Menu()
        self.channel_edit_input_menu_item.set_submenu(
            self.channel_edit_input_menu)

        self.channel_edit_output_menu_item = self.new_menu_item(
            'E_dit Output Channel', enabled=False)
        edit_menu.append(self.channel_edit_output_menu_item)
        self.channel_edit_output_menu = Gtk.Menu()
        self.channel_edit_output_menu_item.set_submenu(
            self.channel_edit_output_menu)

        self.channel_remove_input_menu_item = self.new_menu_item(
            '_Remove Input Channel', enabled=False)
        edit_menu.append(self.channel_remove_input_menu_item)
        self.channel_remove_input_menu = Gtk.Menu()
        self.channel_remove_input_menu_item.set_submenu(
            self.channel_remove_input_menu)

        self.channel_remove_output_menu_item = self.new_menu_item(
            'Re_move Output Channel', enabled=False)
        edit_menu.append(self.channel_remove_output_menu_item)
        self.channel_remove_output_menu = Gtk.Menu()
        self.channel_remove_output_menu_item.set_submenu(
            self.channel_remove_output_menu)

        edit_menu.append(Gtk.SeparatorMenuItem())
        edit_menu.append(
            self.new_menu_item('Shrink Input Channels',
                               self.on_narrow_input_channels_cb,
                               "<Control>minus"))
        edit_menu.append(
            self.new_menu_item('Expand Input Channels',
                               self.on_widen_input_channels_cb,
                               "<Control>plus"))
        edit_menu.append(Gtk.SeparatorMenuItem())

        edit_menu.append(
            self.new_menu_item('_Clear', self.on_channels_clear, "<Control>X"))
        edit_menu.append(Gtk.SeparatorMenuItem())
        edit_menu.append(
            self.new_menu_item('_Preferences', self.on_preferences_cb,
                               "<Control>P"))

        help_menu = Gtk.Menu()
        help_menu_item.set_submenu(help_menu)

        help_menu.append(self.new_menu_item('_About', self.on_about, "F1"))

        self.hbox_top = Gtk.HBox()
        self.vbox_top.pack_start(self.hbox_top, True, True, 0)

        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                        Gtk.PolicyType.AUTOMATIC)

        self.hbox_inputs = Gtk.Box()
        self.hbox_inputs.set_spacing(0)
        self.hbox_inputs.set_border_width(0)
        self.hbox_top.set_spacing(0)
        self.hbox_top.set_border_width(0)
        self.scrolled_window.add(self.hbox_inputs)
        self.hbox_outputs = Gtk.Box()
        self.hbox_outputs.set_spacing(0)
        self.hbox_outputs.set_border_width(0)
        self.scrolled_output = Gtk.ScrolledWindow()
        self.scrolled_output.set_policy(Gtk.PolicyType.AUTOMATIC,
                                        Gtk.PolicyType.AUTOMATIC)
        self.scrolled_output.add(self.hbox_outputs)
        self.paned = Gtk.HPaned()
        self.paned.set_wide_handle(True)
        self.hbox_top.pack_start(self.paned, True, True, 0)
        self.paned.pack1(self.scrolled_window, True, False)
        self.paned.pack2(self.scrolled_output, True, False)
        self.window.connect("destroy", Gtk.main_quit)
        self.window.connect('delete-event', self.on_delete_event)
Пример #4
0
    def __init__(self, parent, start_slot=1, channel_size=3):
        Gtk.Window.__init__(self, title="EMPR Display - Channel Viewer")
        self.parent = parent
        self.set_default_size(200, 200)
        self.set_border_width(10)
        self.start_slot = start_slot
        self.channel_size = channel_size
        self.colour_label = None
        self.colour_area = None

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
        vbox.set_homogeneous(False)

        label = Gtk.Label(label="Channel Data")
        vbox.pack_start(label, False, True, 0)

        scrolledwindow = Gtk.ScrolledWindow()

        liststore = Gtk.ListStore(str, str)
        self.packet_data = liststore
        for i in range(channel_size):
            if i + start_slot < 513:
                liststore.append([str(i + start_slot), "0x00"])
            else:
                liststore.append([str(i + start_slot), "Out of Range"])
        self.update_values()

        treeview = Gtk.TreeView(model=liststore)
        fontdesc = Pango.FontDescription("monospace 10")
        treeview.modify_font(fontdesc)
        renderer_slot = Gtk.CellRendererText()
        column_slot = Gtk.TreeViewColumn("Slot", renderer_slot, text=0)
        treeview.append_column(column_slot)
        renderer_value = Gtk.CellRendererText()
        column_value = Gtk.TreeViewColumn("Value", renderer_value, text=1)
        treeview.append_column(column_value)

        scrolledwindow.add(treeview)
        vbox.pack_start(scrolledwindow, True, True, 0)

        if channel_size == 3 or 9 > channel_size > 6:
            label = Gtk.Label(label="Channel Colour")
            vbox.pack_start(label, False, True, 0)

            area = Gtk.DrawingArea()
            area.set_size_request(24, 24)

            self.colour_area = area
            vbox.pack_start(area, False, True, 0)

            label = Gtk.Label(label="Channel Colour Hex Code")
            vbox.pack_start(label, False, True, 0)

            label = Gtk.Label(label="#ffffff")
            self.colour_label = label
            vbox.pack_start(label, False, True, 0)

            self.update_values()

        self.add(vbox)

        self.show_all()

        self.id = UIChannelDisplay.channel_window_index
        self.connect("destroy", self.on_close)
        UIChannelDisplay.channel_window_index += 1
Пример #5
0
    def __init__(self, **options):
        name = _("Dynamic Workspaces")
        Gtk.ListBox.__init__(self)
        _GSettingsTweak.__init__(self,
                                 name,
                                 "org.gnome.mutter",
                                 "dynamic-workspaces",
                                 loaded=_shell_loaded)

        self.set_selection_mode(Gtk.SelectionMode.NONE)

        # Needs other page elements to get margins too
        # self.props.margin_left = 50
        # self.props.margin_right = 50

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(name, xalign=0)
        lbl.props.xalign = 0.0
        desc = _(
            "Workspaces can be created on demand, and are automatically removed when empty."
        )
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check1 = Gtk.Image.new_from_icon_name("object-select-symbolic",
                                                   Gtk.IconSize.SMALL_TOOLBAR)
        self.check1.set_no_show_all(True)
        self.check1.set_visible(self.settings[self.key_name])

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check1, False, False, 0)

        self.add(row)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(_("Static Workspaces"), xalign=0)
        lbl.props.xalign = 0.0
        desc = _("Number of workspaces is fixed.")
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check2 = Gtk.Image.new_from_icon_name("object-select-symbolic",
                                                   Gtk.IconSize.SMALL_TOOLBAR)
        self.check2.set_no_show_all(True)
        self.check2.set_visible(not self.settings[self.key_name])

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check2, False, False, 0)

        self.add(row)
        self.connect('row-activated', self.on_row_clicked)
Пример #6
0
    def __init__(self, app):
        super().__init__(orientation=Gtk.Orientation.VERTICAL)
        self.app = app

        control_box = Gtk.Box()
        self.pack_start(control_box, False, False, 0)

        link_button = Gtk.Button.new_with_label(_('New Link Task'))
        link_button.connect('clicked', self.on_link_button_clicked)
        control_box.pack_start(link_button, False, False, 0)

        reload_button = Gtk.Button.new_with_label(_('Reload'))
        reload_button.props.margin_left = 40
        reload_button.connect('clicked', self.on_reload_button_clicked)
        control_box.pack_start(reload_button, False, False, 0)

        open_button = Gtk.Button.new_with_label(_('Open Directory'))
        open_button.connect('clicked', self.on_open_button_clicked)
        control_box.pack_start(open_button, False, False, 0)

        clear_button = Gtk.Button.new_with_label(_('Clear'))
        clear_button.set_tooltip_text(_('Clear finished or canceled tasks'))
        clear_button.connect('clicked', self.on_clear_button_clicked)
        control_box.pack_end(clear_button, False, False, 0)

        remove_button = Gtk.Button.new_with_label(_('Remove'))
        remove_button.set_tooltip_text(_('Remove selected tasks'))
        remove_button.connect('clicked', self.on_remove_button_clicked)
        control_box.pack_end(remove_button, False, False, 0)

        cancel_button = Gtk.Button.new_with_label(_('Cancel'))
        cancel_button.set_tooltip_text(_('Cancel selected tasks'))
        cancel_button.connect('clicked', self.on_cancel_button_clicked)
        control_box.pack_end(cancel_button, False, False, 0)

        # show loading process
        self.loading_spin = Gtk.Spinner()
        self.loading_spin.props.margin_right = 5
        control_box.pack_end(self.loading_spin, False, False, 0)

        scrolled_win = Gtk.ScrolledWindow()
        self.pack_start(scrolled_win, True, True, 0)

        # task_id, name, path, source_url, size, finished_size,
        # status, percent, human_size, tooltip
        self.liststore = Gtk.ListStore(str, str, str, str, GObject.TYPE_INT64,
                                       GObject.TYPE_INT64, int, int, str, str)
        self.treeview = Gtk.TreeView(model=self.liststore)
        self.treeview.set_headers_clickable(True)
        self.treeview.set_reorderable(True)
        self.treeview.set_search_column(NAME_COL)
        self.treeview.set_tooltip_column(TOOLTIP_COL)
        self.selection = self.treeview.get_selection()
        scrolled_win.add(self.treeview)

        name_cell = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END,
                                         ellipsize_set=True)
        name_col = Gtk.TreeViewColumn(_('Name'), name_cell, text=NAME_COL)
        name_col.set_expand(True)
        self.treeview.append_column(name_col)
        name_col.set_sort_column_id(NAME_COL)
        self.liststore.set_sort_func(NAME_COL, gutil.tree_model_natsort)

        size_cell = Gtk.CellRendererText()
        size_col = Gtk.TreeViewColumn(_('Size'), size_cell, text=HUMANSIZE_COL)
        self.treeview.append_column(size_col)
        size_col.props.min_width = 145
        size_col.set_sort_column_id(SIZE_COL)

        percent_cell = Gtk.CellRendererProgress()
        percent_col = Gtk.TreeViewColumn(_('Progress'),
                                         percent_cell,
                                         value=PERCENT_COL)
        self.treeview.append_column(percent_col)
        percent_col.props.min_width = 145
        percent_col.set_sort_column_id(PERCENT_COL)
Пример #7
0
    def __init__(self, videodict):

        Gtk.EventBox.__init__(self)

        self.set_border_width(2)

        self.videodict = videodict

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        keys = self.videodict.keys()

        if "previews" in keys:
            imagen = Gtk.Image()
            hbox.pack_start(imagen, False, False, 3)

            if type(self.videodict["previews"]) == list:
                # FIXME: siempre hay 4 previews.
                url = self.videodict["previews"][0][0]
                import time
                archivo = "/dev/shm/preview%d" % time.time()

                try:
                    # FIXME: Porque Falla si no hay Conexión.
                    import urllib
                    fileimage, headers = urllib.urlretrieve(url, archivo)
                    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                        fileimage, 200, 150)
                    imagen.set_from_pixbuf(pixbuf)

                    ### Convertir imagen a string por si se quiere guardar.
                    import base64
                    pixbuf_file = open(fileimage, 'rb')
                    image_string = base64.b64encode(pixbuf_file.read())
                    pixbuf_file.close()
                    self.videodict["previews"] = image_string

                except:
                    print "No hay Conexión a Internet."

                if os.path.exists(archivo):
                    os.remove(archivo)

            else:
                import base64
                loader = GdkPixbuf.PixbufLoader()
                loader.set_size(200, 150)
                image_string = base64.b64decode(self.videodict["previews"])
                loader.write(image_string)
                loader.close()

                pixbuf = loader.get_pixbuf()
                imagen.set_from_pixbuf(pixbuf)

        vbox.pack_start(Gtk.Label("%s: %s" % ("id",
            self.videodict["id"])), True, True, 0)

        vbox.pack_start(Gtk.Label("%s: %s" % ("Título",
            self.videodict["titulo"])), True, True, 0)

        vbox.pack_start(Gtk.Label("%s: %s" % ("Categoría",
            self.videodict["categoria"])), True, True, 0)

        #vbox.pack_start(gtk.Label("%s: %s" % ("Etiquetas",
        #    self.videodict["etiquetas"])), True, True, 0)

        #vbox.pack_start(gtk.Label("%s: %s" % ("Descripción",
        #   self.videodict["descripcion"])), True, True, 0)

        vbox.pack_start(Gtk.Label("%s: %s %s" % ("Duración",
            int(float(self.videodict["duracion"]) / 60.0), "Minutos")),
            True, True, 0)

        #vbox.pack_start(gtk.Label("%s: %s" % ("Reproducción en la Web",
        #   self.videodict["flash player"])), True, True, 0)

        vbox.pack_start(Gtk.Label("%s: %s" % ("url",
            self.videodict["url"])), True, True, 0)

        for label in vbox.get_children():
            label.set_alignment(0.0, 0.5)

        hbox.pack_start(vbox, False, False, 5)
        self.add(hbox)

        self.show_all()

        self.connect("button_press_event", self.__button_press)
Пример #8
0
    def __create_headerbar(self):
        headerbar = Gtk.HeaderBar()
        headerbar.set_show_close_button(True)

        back_button = Gtk.Button.new_from_icon_name("go-previous-symbolic",
                                                    Gtk.IconSize.SMALL_TOOLBAR)
        back_button.set_always_show_image(True)
        back_button.set_tooltip_text(_("Close project"))
        back_button.connect("clicked", self.__close_project_cb)
        back_button.set_margin_right(4 * PADDING)
        headerbar.pack_start(back_button)

        undo_button = Gtk.Button.new_from_icon_name("edit-undo-symbolic",
                                                    Gtk.IconSize.SMALL_TOOLBAR)
        undo_button.set_always_show_image(True)
        undo_button.set_label(_("Undo"))
        undo_button.set_action_name("app.undo")
        undo_button.set_use_underline(True)

        redo_button = Gtk.Button.new_from_icon_name("edit-redo-symbolic",
                                                    Gtk.IconSize.SMALL_TOOLBAR)
        redo_button.set_always_show_image(True)
        redo_button.set_action_name("app.redo")
        redo_button.set_use_underline(True)

        self.save_button = Gtk.Button.new_with_label(_("Save"))
        self.save_button.set_focus_on_click(False)

        self.render_button = Gtk.Button.new_from_icon_name(
            "system-run-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
        self.render_button.set_always_show_image(True)
        self.render_button.set_label(_("Render"))
        self.render_button.set_tooltip_text(
            _("Export your project as a finished movie"))
        self.render_button.set_sensitive(False)  # The only one we have to set.
        self.render_button.connect("clicked", self._renderCb)

        undo_redo_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                spacing=0)
        undo_redo_box.get_style_context().add_class("linked")
        undo_redo_box.pack_start(undo_button,
                                 expand=False,
                                 fill=False,
                                 padding=0)
        undo_redo_box.pack_start(redo_button,
                                 expand=False,
                                 fill=False,
                                 padding=0)
        headerbar.pack_start(undo_redo_box)

        self.builder.add_from_file(
            os.path.join(get_ui_dir(), "mainmenubutton.ui"))

        self.menu_button = self.builder.get_object("menubutton")

        headerbar.pack_end(self.menu_button)
        headerbar.pack_end(self.save_button)
        headerbar.pack_end(self.render_button)
        headerbar.show_all()

        return headerbar
Пример #9
0
 def __init__(self, title, description, button_text, text_array):
     Template.__init__(self, title, description, button_text)
     self.button_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                     spacing=0)
     self.buttons = []
     self.box.pack_start(self.button_container, False, False, 0)
Пример #10
0
    def __init__(self,
                 parent,
                 subtitle,
                 name=None,
                 rolls=None,
                 style_css=None):

        if rolls is None:
            rolls = []
        self.rolls = copy.deepcopy(rolls)
        self.name = name

        Gtk.Dialog.__init__(
            self,
            'Template',
            parent,
            Gtk.DialogFlags.MODAL,
            use_header_bar=True,
        )
        self.set_size_request(600, 900)
        self.add_button('Cancel', Gtk.ResponseType.CANCEL)
        self.add_button('OK', Gtk.ResponseType.OK)

        # Create the header bar.
        header = self.get_header_bar()
        header.set_title('Template')
        header.set_subtitle(subtitle)

        # Create the main grid.
        dlg_grid = Gtk.Grid()
        dlg_grid.set_row_spacing(18)
        dlg_grid.set_column_spacing(12)
        dlg_grid.set_border_width(18)
        self.get_content_area().add(dlg_grid)

        # Create the add roll grid.
        add_grid = Gtk.Grid()
        add_grid.set_row_spacing(8)
        add_grid.set_column_spacing(12)
        dlg_grid.attach(add_grid, 0, 0, 1, 1)

        # Create the template details main label.
        details_lbl = Gtk.Label()
        details_lbl.set_markup(
            '<span size="x-large">Template Details</span>', )
        details_lbl.set_alignment(0, 0.5)
        details_lbl.set_margin_bottom(5)
        add_grid.attach_next_to(
            details_lbl,
            None,
            Gtk.PositionType.RIGHT,
            3,
            1,
        )

        # Create the template name row.
        name_lbl = Gtk.Label('Name')
        name_lbl.set_alignment(1, 0.5)
        add_grid.attach_next_to(
            name_lbl,
            details_lbl,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )
        self.name_ent = Gtk.Entry()
        self.name_ent.set_hexpand(True)
        add_grid.attach_next_to(
            self.name_ent,
            name_lbl,
            Gtk.PositionType.RIGHT,
            2,
            1,
        )

        # Create the add roll main label.
        add_lbl = Gtk.Label()
        add_lbl.set_markup('<span size=\'x-large\'>Add Roll</span>')
        add_lbl.set_alignment(0, 0.5)
        add_lbl.set_margin_top(5)
        add_lbl.set_margin_bottom(5)
        add_grid.attach_next_to(
            add_lbl,
            name_lbl,
            Gtk.PositionType.BOTTOM,
            3,
            1,
        )

        # Create the roll row.
        roll_row_lbl = Gtk.Label('Roll')
        roll_row_lbl.set_alignment(1, 0.5)
        add_grid.attach_next_to(
            roll_row_lbl,
            add_lbl,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )
        roll_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.count_ent = Gtk.Entry()
        self.count_ent.set_width_chars(4)
        self.count_ent.props.xalign = 0.5
        roll_box.pack_start(self.count_ent, False, False, 0)
        self.count_error_popover = Gtk.Popover()
        self.count_error_popover.set_relative_to(self.count_ent)
        d_lbl = Gtk.Label('d')
        roll_box.pack_start(d_lbl, True, True, 0)
        self.die_ent = Gtk.Entry()
        self.die_ent.set_width_chars(4)
        self.die_ent.props.xalign = 0.5
        roll_box.pack_start(self.die_ent, False, False, 0)
        self.die_error_popover = Gtk.Popover()
        self.die_error_popover.set_relative_to(self.die_ent)
        plus_lbl = Gtk.Label('+')
        roll_box.pack_start(plus_lbl, True, True, 0)
        self.mod_ent = Gtk.Entry()
        self.mod_ent.set_width_chars(4)
        self.mod_ent.props.xalign = 0.5
        roll_box.pack_start(self.mod_ent, False, False, 0)
        self.mod_error_popover = Gtk.Popover()
        self.mod_error_popover.set_relative_to(self.mod_ent)
        self.mod_chk = Gtk.CheckButton('Add modifier to every roll')
        self.mod_chk.set_active(True)
        self.mod_chk.set_margin_left(12)
        roll_box.pack_start(self.mod_chk, False, False, 0)
        add_grid.attach_next_to(
            roll_box,
            roll_row_lbl,
            Gtk.PositionType.RIGHT,
            2,
            1,
        )

        # Create the critical row.
        crit_lbl = Gtk.Label('On critical')
        crit_lbl.set_alignment(1, 0.5)
        crit_store = Gtk.ListStore(str, int)
        for crit_option in CRITICAL_OPTIONS:
            crit_store.append(crit_option)
        self.crit_cbox = Gtk.ComboBox.new_with_model(crit_store)
        self.crit_cbox.set_active(0)
        crit_renderer = Gtk.CellRendererText()
        self.crit_cbox.pack_start(crit_renderer, True)
        self.crit_cbox.add_attribute(crit_renderer, 'text', 0)
        add_grid.attach_next_to(
            crit_lbl,
            roll_row_lbl,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )
        add_grid.attach_next_to(
            self.crit_cbox,
            crit_lbl,
            Gtk.PositionType.RIGHT,
            2,
            1,
        )

        # Create the critical multiplier row.
        crit_placeholder_lbl = Gtk.Label('')
        crit_mult_lbl = Gtk.Label('Multiplier')
        crit_mult_lbl.set_margin_right(12)
        self.crit_ent = Gtk.Entry()
        self.crit_ent.set_width_chars(4)
        self.crit_ent.props.xalign = 0.5
        crit_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.crit_error_popover = Gtk.Popover()
        self.crit_error_popover.set_relative_to(self.crit_ent)
        crit_box.pack_start(crit_mult_lbl, False, False, 0)
        crit_box.pack_start(self.crit_ent, False, False, 0)
        add_grid.attach_next_to(
            crit_placeholder_lbl,
            crit_lbl,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )
        add_grid.attach_next_to(
            crit_box,
            crit_placeholder_lbl,
            Gtk.PositionType.RIGHT,
            2,
            1,
        )

        # Create the minimum value row.
        min_value_lbl = Gtk.Label('Minimum value')
        min_value_lbl.set_alignment(1, 0.5)
        self.min_value_ent = Gtk.Entry()
        self.min_value_ent.set_placeholder_text('No minimum value')
        self.min_value_ent.set_hexpand(True)
        add_grid.attach_next_to(
            min_value_lbl,
            crit_placeholder_lbl,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )
        add_grid.attach_next_to(
            self.min_value_ent,
            min_value_lbl,
            Gtk.PositionType.RIGHT,
            2,
            1,
        )

        # Create the description row.
        desc_lbl = Gtk.Label('Name')
        desc_lbl.set_alignment(1, 0.5)
        desc_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        Gtk.StyleContext.add_class(desc_box.get_style_context(), 'linked')
        self.desc_ent = Gtk.Entry()
        self.desc_ent.set_hexpand(True)
        desc_box.add(self.desc_ent)
        self.desc_error_popover = Gtk.Popover()
        self.desc_error_popover.set_relative_to(self.desc_ent)
        self.add_btn = Gtk.Button('Add Roll')
        desc_box.add(self.add_btn)
        add_grid.attach_next_to(
            desc_lbl,
            min_value_lbl,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )
        add_grid.attach_next_to(
            desc_box,
            desc_lbl,
            Gtk.PositionType.RIGHT,
            2,
            1,
        )

        # Create the rolls grid.
        roll_grid = Gtk.Grid()
        roll_grid.set_row_spacing(0)
        roll_grid.set_column_spacing(12)
        dlg_grid.attach(roll_grid, 0, 1, 1, 1)

        # Create the rolls main label.
        roll_lbl = Gtk.Label()
        roll_lbl.set_markup('<span size=\'x-large\'>Rolls</span>')
        roll_lbl.set_alignment(0, 0.5)
        roll_lbl.set_margin_bottom(10)
        roll_grid.attach_next_to(roll_lbl, None, Gtk.PositionType.RIGHT, 1, 1)

        # Create the rolls list.
        roll_scroll_win = Gtk.ScrolledWindow()
        roll_scroll_win.set_hexpand(True)
        roll_scroll_win.set_vexpand(True)
        roll_grid.attach_next_to(
            roll_scroll_win,
            roll_lbl,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )
        self.roll_store = Gtk.ListStore(int, str, str, str)
        self.roll_tree = Gtk.TreeView(model=self.roll_store)
        self.roll_tree.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
        self.roll_tree.set_reorderable(True)
        desc_text = Gtk.CellRendererText()
        desc_text.set_padding(5, 5)
        self.desc_col = Gtk.TreeViewColumn('Name', desc_text, text=1)
        self.desc_col.set_expand(True)
        self.roll_tree.append_column(self.desc_col)
        roll_text = Gtk.CellRendererText()
        roll_text.set_padding(5, 5)
        self.roll_col = Gtk.TreeViewColumn('Roll', roll_text, text=2)
        self.roll_col.set_expand(True)
        self.roll_tree.append_column(self.roll_col)
        crit_text = Gtk.CellRendererText()
        crit_text.set_padding(5, 5)
        self.crit_col = Gtk.TreeViewColumn('Critical', crit_text, text=3)
        self.crit_col.set_expand(True)
        self.roll_tree.append_column(self.crit_col)
        roll_scroll_win.add(self.roll_tree)

        # Create the roll list action bar.
        self.roll_action_bar = Gtk.ActionBar()
        self.roll_action_bar.get_style_context().add_class("inline-toolbar")
        roll_grid.attach_next_to(
            self.roll_action_bar,
            roll_scroll_win,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )

        # Create the template list buttons.
        roll_btn_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        Gtk.StyleContext.add_class(roll_btn_box.get_style_context(), 'linked')
        self.roll_action_bar.pack_start(roll_btn_box)
        self.edit_btn = Gtk.Button()
        self.edit_btn.add(load_symbolic('edit'))
        self.edit_btn.set_tooltip_text('Edit selected roll')
        self.delete_btn = Gtk.Button()
        self.delete_btn.add(load_symbolic('list-remove'))
        self.delete_btn.set_tooltip_text('Remove selected roll')
        roll_btn_box.add(self.edit_btn)
        roll_btn_box.add(self.delete_btn)

        # Create the roll drag and drop help text.
        drag_roll_lbl = Gtk.Label('Drag and drop to rearrange roll order', )
        drag_roll_lbl.set_margin_top(10)
        roll_grid.attach_next_to(
            drag_roll_lbl,
            self.roll_action_bar,
            Gtk.PositionType.BOTTOM,
            1,
            1,
        )

        self.style_provider = Gtk.CssProvider()
        self.style_context = Gtk.StyleContext()
        self.style_context.add_provider_for_screen(
            Gdk.Screen.get_default(),
            self.style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
        )
        self.style_provider.load_from_data(style_css)

        save_btn = self.get_widget_for_response(
            response_id=Gtk.ResponseType.OK, )
        save_btn.set_can_default(True)
        save_btn.grab_default()

        self.add_btn.connect(
            'clicked',
            lambda x: self.add_roll(),
        )
        self.edit_btn.connect(
            'clicked',
            lambda x: self.edit_roll(),
        )
        self.delete_btn.connect(
            'clicked',
            lambda x: self.remove_roll(),
        )
        self.crit_cbox.connect(
            'changed',
            lambda x: self.update_multipler_active(),
        )
        self.roll_tree.connect(
            'row-activated',
            lambda x, y, z: self.edit_roll(),
        )
        self.roll_tree.connect(
            'drag-end',
            lambda x, y: self.reorder_rolls(),
        )
        self.desc_ent.connect(
            'changed',
            lambda x: self.check_edit_name(),
        )

        self.register_limit_inputs()

        if self.name is not None:
            self.name_ent.set_text(self.name)
        self.update_list()

        self.show_all()
Пример #11
0
    def __init__(self):
        super().__init__(title="还原备份")
        self.set_default_size(640, 480)
        self.set_deletable(False)
        self.skip_next = False
        self.exit_code = 0

        paned = Gtk.Paned()
        self.add(paned)
        paned.show()

        scrolled = Gtk.ScrolledWindow()
        paned.pack1(scrolled, True, False)
        scrolled.show()

        textview = Gtk.TextView()
        textview.set_editable(False)
        scrolled.add(textview)
        textview.show()

        self.buffer = textview.get_buffer()
        self.log("日志开始")

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        paned.pack2(vbox, False, False)
        vbox.show()

        scrolled = Gtk.ScrolledWindow(hscrollbar_policy=Gtk.PolicyType.NEVER)
        vbox.pack_start(scrolled, True, True, 0)
        scrolled.show()

        self.store = Gtk.ListStore(str, int, str)
        listiter = self.store.append(["", 0, "1970-01-01 08:00:00"])
        for i in sorted(map(self.parse_backup, os.listdir(BACKUPS_DIR)),
                        reverse=True):
            self.store.append(i[1:])
        GLib.idle_add(self.store.remove, listiter)

        self.treeview = Gtk.TreeView(model=self.store)
        self.treeview.append_column(
            Gtk.TreeViewColumn("存档", Gtk.CellRendererText(), text=1))
        self.treeview.append_column(
            Gtk.TreeViewColumn("时间", Gtk.CellRendererText(), text=2))
        scrolled.add(self.treeview)
        self.treeview.show()

        hbox = Gtk.Box()
        vbox.pack_start(hbox, False, True, 0)
        hbox.show()

        button = Gtk.Button(label="删除")
        button.connect("clicked", self.delete_clicked)
        hbox.pack_start(button, True, True, 0)
        button.show()

        button = Gtk.Button(label="还原")
        button.connect("clicked", self.restore_clicked)
        hbox.pack_start(button, True, True, 0)
        button.show()

        # 如果不保存FileMonitor,就不会生效(Bug?)
        self.monitor = Gio.File.new_for_path(SAVES_DIR).monitor(
            Gio.FileMonitorFlags.NONE, None)
        self.monitor.connect("changed", self.monitor_changed)

        threading.Thread(target=self.open_process).start()
Пример #12
0
    def __init__(self):
        Gtk.Window.__init__(self, title="ListBox Demo")
        self.set_border_width(10)

        # Create the box widget
        box_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(box_outer)

        # Create the listbox widget
        listbox = Gtk.ListBox()
        listbox.set_selection_mode(Gtk.SelectionMode.NONE)
        # Add the listbox widget to the box widget
        box_outer.pack_start(listbox, True, True, 0)

        # Create a list box row
        row = Gtk.ListBoxRow()
        # Create another box widget to add to the box_outer
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        # Add a horizontal box to the row
        row.add(hbox)
        # Create a vertical box
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox.pack_start(vbox, True, True, 0)

        # Create two label widgets
        label1 = Gtk.Label(label="Automatic Date & Time", xalign=0)
        label2 = Gtk.Label(label="Requires internet access", xalign=0)
        # Add the two label widgets to the vertical box
        vbox.pack_start(label1, True, True, 0)
        vbox.pack_start(label2, True, True, 0)

        # Create a switch widget
        switch = Gtk.Switch()
        switch.props.valign = Gtk.Align.CENTER
        # Add the switch to the horizontal box
        hbox.pack_start(switch, False, True, 0)

        listbox.add(row)

        # Create another row widget
        row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        row.add(hbox)
        label = Gtk.Label(label="Enable Automatic Update", xalign=0)
        check = Gtk.CheckButton()
        # Add the label and check button to the row with relative positions
        hbox.pack_start(label, True, True, 0)
        # Expand is set to False
        hbox.pack_start(check, False, True, 0)

        # Add this row to the listbox widget
        listbox.add(row)

        # Create the final row
        row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        row.add(hbox)
        label = Gtk.Label(label="Date Format", xalign=0)
        # Create a combo box
        combo = Gtk.ComboBoxText()
        combo.insert(0, "0", "24-hour")
        combo.insert(1, "1", "AM/PM")
        hbox.pack_start(label, True, True, 0)
        hbox.pack_start(combo, False, True, 0)

        listbox.add(row)
Пример #13
0
    def __init__(self):
        super(MessageArea, self).__init__()

        self.set_name("MessageArea")
        self.hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL)
        self.hbox.show()

        self.text = ""

        self.set_app_paintable(True)

        self.anim = WidgetFade(
            self.hbox,
            self.hbox.get_style_context().get_background_color(
                Gtk.StateFlags.NORMAL))
        self.hl_anim = WidgetFade(self.hbox, Gdk.RGBA(1, 0, 0, 1))

        self.setting_style = False

        self.hbox.props.spacing = 4
        self.hbox.set_border_width(2)

        self.icon = Gtk.Image()
        self.label = Gtk.Label()
        self.label.props.xalign = 0
        self.label.set_ellipsize(Pango.EllipsizeMode.END)
        self.label.set_single_line_mode(True)
        self.label.set_selectable(True)

        self.b_more = Gtk.Button(_("More"))
        im = Gtk.Image()
        im.set_from_icon_name("dialog-information", Gtk.IconSize.MENU)
        im.show()
        self.b_more.set_image(im)
        self.b_more.props.relief = Gtk.ReliefStyle.NONE

        im = Gtk.Image()
        im.set_from_icon_name("window-close", Gtk.IconSize.MENU)
        im.show()
        self.b_close = Gtk.Button()
        self.b_close.add(im)
        self.b_close.props.relief = Gtk.ReliefStyle.NONE
        self.b_close.props.tooltip_text = _("Close")

        self.hbox.pack_start(self.icon, False, False, 4)
        self.hbox.pack_start(self.label, True, False, 0)
        self.hbox.pack_start(self.b_more, False, False, 0)
        self.hbox.pack_start(self.b_close, False, False, 0)

        self.add(self.hbox)

        self.icon.show()
        self.b_close.show()
        self.label.show()
        self.b_more.show()

        self.b_close.connect("clicked", self.on_close)
        self.b_more.connect("clicked", self.on_more)

        self.hbox.connect("draw", self.draw)
        self.b_close.connect("style-set", self.style_set)
    def __init__(self, parent, collection_type, spices, window):
        super(DownloadSpicesPage, self).__init__()
        self.expand = True
        self.set_spacing(0)
        self.set_margin_top(5)

        self.parent = parent
        self.collection_type = collection_type
        self.spices = spices
        self.window = window
        self.has_filter = False
        self.extension_rows = []
        self._signals = []

        self.top_box = Gtk.Box()
        self.pack_start(self.top_box, False, False, 10)

        sort_label = Gtk.Label()
        sort_label.set_text(_("Sort by"))
        self.top_box.pack_start(sort_label, False, False, 4)

        self.sort_combo = Gtk.ComboBox()
        sort_types = Gtk.ListStore(str, str)
        self.sort_combo.set_model(sort_types)
        renderer_text = Gtk.CellRendererText()
        self.sort_combo.pack_start(renderer_text, True)
        self.sort_combo.add_attribute(renderer_text, "text", 1)
        self.sort_combo.set_id_column(0)
        sort_types.append(['name', _("Name")])
        sort_types.append(['score', _("Popularity")])
        sort_types.append(['date', _("Date")])
        sort_types.append(['installed', _("Installed")])
        sort_types.append(['update', _("Upgradable")])
        self.sort_combo.set_active(1)  #Rating
        self.sort_combo.connect('changed', self.sort_changed)
        self.top_box.pack_start(self.sort_combo, False, False, 4)

        self.search_entry = Gtk.Entry()
        self.search_entry.set_icon_from_icon_name(
            Gtk.EntryIconPosition.PRIMARY, 'edit-find-symbolic')
        self.search_entry.set_placeholder_text(_("Search"))
        self.search_entry.connect('changed', self.on_entry_refilter)

        self.top_box.pack_end(self.search_entry, False, False, 4)

        frame = Gtk.Frame()
        frame.set_shadow_type(Gtk.ShadowType.IN)
        frame_style = frame.get_style_context()
        frame_style.add_class('view')
        self.pack_start(frame, True, True, 0)

        main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        frame.add(main_box)

        scw = Gtk.ScrolledWindow()
        scw.expand = True
        scw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scw.set_shadow_type(Gtk.ShadowType.NONE)
        main_box.pack_start(scw, True, True, 0)
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        scw.add(self.box)

        self.infobar_holder = Gtk.Frame(shadow_type=Gtk.ShadowType.NONE)
        self.box.add(self.infobar_holder)

        self.list_box = Gtk.ListBox()
        self.list_box.set_selection_mode(Gtk.SelectionMode.SINGLE)
        self.list_box.set_header_func(list_header_func, None)
        self.list_box.connect('row-selected', self.on_row_selected)
        self.box.add(self.list_box)

        button_toolbar = Gtk.Toolbar.new()
        Gtk.StyleContext.add_class(
            Gtk.Widget.get_style_context(button_toolbar), 'inline-toolbar')
        self.add(button_toolbar)

        button_holder = Gtk.ToolItem()
        button_holder.set_expand(True)
        button_toolbar.add(button_holder)
        box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        box.set_halign(Gtk.Align.CENTER)
        button_holder.add(box)

        # buttons
        self.more_info_button = Gtk.Button.new_from_icon_name(
            "dialog-information-symbolic", Gtk.IconSize.MENU)
        self.more_info_button.set_size_request(50, -1)
        self.more_info_button.set_tooltip_text(_("More info"))
        self.more_info_button.connect('clicked', self.get_more_info)
        box.add(self.more_info_button)
        self.more_info_button.set_sensitive(False)

        self.uninstall_button = Gtk.Button.new_from_icon_name(
            "edit-delete-symbolic", Gtk.IconSize.MENU)
        self.uninstall_button.set_size_request(50, -1)
        self.uninstall_button.set_tooltip_text(_("Uninstall"))
        self.uninstall_button.connect('clicked', self.uninstall)
        box.add(self.uninstall_button)
        self.uninstall_button.set_sensitive(False)

        self.update_all_button = Gtk.Button.new_from_icon_name(
            "software-update-available-symbolic", Gtk.IconSize.MENU)
        self.update_all_button.set_size_request(50, -1)
        self.update_all_button.connect('clicked', self.update_all)
        box.add(self.update_all_button)
        self.update_all_button.set_sensitive(False)

        self.refresh_button = Gtk.Button.new_from_icon_name(
            "emblem-synchronizing-symbolic", Gtk.IconSize.MENU)
        self.refresh_button.set_size_request(50, -1)
        self.refresh_button.set_tooltip_text(_("Refresh"))
        self.refresh_button.connect('clicked', self.refresh)
        box.add(self.refresh_button)

        # progress bar
        self.progress_bar = self.spices.get_progressbar()
        pb_container = Gtk.Box()
        pb_container.set_margin_top(20)
        pb_container.pack_start(self.progress_bar, True, True, 0)
        self.pack_end(pb_container, False, False, 0)

        self.install_list = []
        self.update_list = {}
        self.current_num_updates = 0

        self.sort_changed()

        self.connect('map', self.on_page_map)

        self.spices.connect('cache-loaded', self.build_list)
        self.spices.connect('installed-changed', self.build_list)
        self.build_list()
 def on_open_clicked(self, open_button):
     if (self.first_run is False):
         self.context_id = self.status_bar.push(self.context_id,\
             _("Go on to open a new Database"))
     backup_url = self.choose_database_file()
     if (backup_url is None):
         self.context_id = self.status_bar.push(self.context_id,\
             _("No Database chosen, try again"))
         return
     self.backup_path = os.path.dirname(backup_url)
     manifest_file = os.path.join(self.backup_path, 'Manifest.plist')
     self.manifest = self.read_binary_plist(manifest_file)
     status_file = os.path.join(self.backup_path, 'Status.plist')
     self.status = self.read_binary_plist(status_file)
     try:
         sqliteConnection = sqlite3.connect(backup_url)
         cursor = sqliteConnection.cursor()
         self.context_id = self.status_bar.push(self.context_id,\
             _("Database created and successfully connected to SQLite"))
         query = "SELECT * FROM Files"
         cursor.execute(query)
         self.records = cursor.fetchall()
         # order column names into first tuple of the list
         self.names = list(zip(*cursor.description))
         # truncate list to first tuple
         del self.names[1:]
         cursor.close()
     except sqlite3.Error as error:
         self.context_id = self.status_bar.push(self.context_id,\
             _("Error while connecting to sqlite"))
     finally:
         if (sqliteConnection):
             sqliteConnection.close()
             self.context_id = self.status_bar.push(self.context_id,\
                 _("The SQLite connection is closed after reading"))
     listmodel = self.combo.get_model()
     treemodel = self.treeview.get_model()
     if (len(self.naked_domains)):
         del self.naked_domains[:]
         # clear entry and models
         self.combo.set_active(-1)
         entry = self.combo.get_child()
         entry.set_text(str())
         entry.set_placeholder_text(_("Please select domain to display"))
         listmodel.clear()
         treemodel.clear()
     # filter out "naked" domains where relativePath is empty
     for record in self.records:
         path = record[2]
         if (not path):
             self.naked_domains.append(record[1])
     # sort in ascending order
     self.naked_domains.sort()
     # fill combobox listmodel
     index = 0
     for naked_domain in self.naked_domains:
         index += 1
         listmodel.append([naked_domain, index])
     self.context_id = self.status_bar.push(self.context_id,\
         f(_('Combobox filled with {index} domain names, please select one')))
     self.remove(self.vbox)
     if (self.first_run):
         # prepare scrolled window
         self.scrolled_window.add(self.treeview)
         self.scrolled_window.show()
         # add new widgets and reorder
         self.vbox.remove(self.label_box)
         # add horizontal combobox
         self.vbox.pack_start(self.domain_box, False, False, 0)
         self.vbox.pack_start(self.scrolled_window, False, True, 0)
         self.vbox.pack_start(self.label_box, True, True, 0)
         # generate horizontal box at bottom for manifest, status, export
         self.bottom_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                   spacing=0)
         self.bottom_box.set_border_width(0)
         # prepare button for Manifest.plist
         self.manifest_button = Gtk.Button.new_with_label("Manifest.plist")
         self.manifest_button.connect("clicked",
                                      self.on_manifest_show_clicked, True)
         self.bottom_box.pack_start(self.manifest_button, False, True, 0)
         # prepare button for Status.plist
         self.status_button = Gtk.Button.new_with_label("Status.plist")
         self.status_button.connect("clicked", self.on_status_show_clicked,
                                    True)
         self.bottom_box.pack_start(self.status_button, True, False, 0)
         export_button = Gtk.Button.new_with_label(_("Export CSV..."))
         export_button.connect("clicked", self.on_export_csv_clicked)
         self.bottom_box.pack_end(export_button, False, True, 0)
         self.bottom_box.pack_end(export_button, True, True, 0)
         self.vbox.pack_start(self.bottom_box, False, True, 0)
         self.first_run = False
     self.manifest_button.set_sensitive(self.manifest is not None)
     self.status_button.set_sensitive(self.status is not None)
     self.add(self.vbox)
     self.show_all()
Пример #16
0
    def __build_window(self):
        """Build up the widget"""
        # toplevel widget
        self.top_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(self.top_vbox)
        # header line: icon, grid with name and "hide in wv"
        # FIXME
        self.hdr_align = Gtk.Alignment()
        self.top_vbox.pack_start(self.hdr_align, False, True, 0)
        self.hdr_align.set_padding(0, 5, 0, 0)
        self.hdr_box = Gtk.Box()
        self.clear_box = Gtk.Box()
        self.hdr_align.add(self.hdr_box)
        self.hdr_box.set_spacing(10)
        # Button to tag icon selector
        self.ti_bt = Gtk.Button()
        self.ti_bt_label = Gtk.Label()
        self.ti_bt.add(self.ti_bt_label)
        self.hidden_entry = Gtk.Entry()
        self.hidden_entry.set_width_chars(1)
        self.ti_bt_label.get_style_context().add_class('icon')
        self.hidden_entry.get_style_context().add_class('hidden')
        self.hdr_box.pack_start(self.ti_bt, False, False, 0)
        self.hdr_box.pack_start(self.hidden_entry, False, False, 0)
        self.ti_bt.set_size_request(64, 64)
        self.hidden_entry.set_size_request(0, 0)
        self.ti_bt.set_relief(Gtk.ReliefStyle.HALF)
        self.ti_bt_clear = Gtk.Button()
        self.ti_bt_clear.set_label(_('Remove icon'))
        self.clear_box.add(self.ti_bt_clear)

        # vbox for tag name and hid in WV
        self.tp_grid = Gtk.Grid()
        self.hdr_box.pack_start(self.tp_grid, False, True, 0)
        self.tp_grid.set_column_spacing(5)
        self.tn_entry_lbl_align = Gtk.Alignment.new(0, 0.5, 0, 0)
        self.tp_grid.add(self.tn_entry_lbl_align)
        self.tn_entry_lbl = Gtk.Label()
        self.tn_entry_lbl.set_markup("<span weight='bold'>%s</span>" %
                                     _("Name : "))
        self.tn_entry_lbl_align.add(self.tn_entry_lbl)
        self.tn_entry = Gtk.Entry()
        self.tn_entry.set_width_chars(20)
        self.tp_grid.attach(self.tn_entry, 1, 0, 1, 1)
        self.tn_cb_lbl_align = Gtk.Alignment.new(0, 0.5, 0, 0)
        self.tp_grid.attach(self.tn_cb_lbl_align, 0, 1, 1, 1)
        self.tn_cb_lbl = Gtk.Label(label=_('Show Tag in "Actionable" view:'))
        self.tn_cb_lbl_align.add(self.tn_cb_lbl)
        self.tn_cb = Gtk.CheckButton()
        self.tp_grid.attach(self.tn_cb, 1, 1, 1, 1)
        # Tag color
        self.tc_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.top_vbox.pack_start(self.clear_box, False, False, 0)
        self.top_vbox.pack_start(self.tc_vbox, False, True, 0)
        self.tc_label_align = Gtk.Alignment()
        self.tc_vbox.pack_start(self.tc_label_align, False, True, 0)
        self.tc_label_align.set_padding(25, 0, 0, 0)
        self.tc_label = Gtk.Label()
        self.tc_label_align.add(self.tc_label)
        self.tc_label.set_markup("<span weight='bold'>%s</span>" %
                                 _("Select Tag Color:"))
        self.tc_label.set_alignment(0, 0.5)
        # Tag color chooser
        self.tc_cc_align = Gtk.Alignment.new(0.5, 0.5, 0, 0)
        self.tc_vbox.pack_start(self.tc_cc_align, False, False, 0)
        self.tc_cc_align.set_padding(25, 15, 10, 10)
        self.tc_cc_colsel = SimpleColorSelector()
        # self.tc_cc_colsel = Gtk.ColorChooserWidget()
        self.tc_cc_align.add(self.tc_cc_colsel)
Пример #17
0
    def load(self, persp):
        self.persp = persp
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.tv = Gtk.TreeView()

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Title"), renderer, text=1)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Source"), renderer, text=2)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererProgress()
        column = Gtk.TreeViewColumn(_("Progress"), renderer, text=3, value=4)
        self.tv.append_column(column)

        self.tv.connect("row-activated", self.row_activated)

        def on_progress_updated(solving_progress, key, progress):
            for i, row in enumerate(self.store):
                if row[0] == key:
                    solved = progress.count(1)
                    percent = 0 if not solved else round(
                        (solved * 100.) / len(progress))
                    treeiter = self.store.get_iter(Gtk.TreePath(i))
                    self.store[treeiter][3] = "%s / %s" % (solved,
                                                           len(progress))
                    self.store[treeiter][4] = percent

        puzzles_solving_progress.connect("progress_updated",
                                         on_progress_updated)

        self.store = Gtk.ListStore(str, str, str, str, int)

        @asyncio.coroutine
        def coro():
            for file_name, title, author in PUZZLES:
                progress = puzzles_solving_progress.get(file_name)
                solved = progress.count(1)
                percent = 0 if not solved else round(
                    (solved * 100.) / len(progress))
                self.store.append([
                    file_name, title, author,
                    "%s / %s" % (solved, len(progress)), percent
                ])
                yield from asyncio.sleep(0)

        asyncio. async (coro())

        self.tv.set_model(self.store)
        self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE)
        self.tv.set_cursor(conf.get("learncombo%s" % PUZZLE))

        scrollwin = Gtk.ScrolledWindow()
        scrollwin.add(self.tv)
        scrollwin.show_all()

        self.box.pack_start(scrollwin, True, True, 0)
        self.box.show_all()

        return self.box
Пример #18
0
    def _setup_view(self):
        self._search = Search()
        self._searchbar = SearchBar()
        self._searchbar.props.stack = self._stack
        self._headerbar = HeaderBar()

        self._search.bind_property(
            "search-mode-active", self._headerbar, "search-mode-active",
            GObject.BindingFlags.BIDIRECTIONAL
            | GObject.BindingFlags.SYNC_CREATE)
        self._search.bind_property("search-mode-active", self._searchbar,
                                   "search-mode-enabled",
                                   GObject.BindingFlags.SYNC_CREATE)
        self._search.bind_property("state", self._searchbar, "search-state",
                                   GObject.BindingFlags.SYNC_CREATE)

        self._player_toolbar = PlayerToolbar()
        self._player_toolbar.props.player = self._player

        self._headerbar.connect('back-button-clicked',
                                self._switch_back_from_childview)

        self.bind_property('selected-items-count', self._headerbar,
                           'selected-items-count')
        self.bind_property("selected-items-count", self._selection_toolbar,
                           "selected-items-count")
        self.bind_property(
            'selection-mode', self._headerbar, 'selection-mode',
            GObject.BindingFlags.BIDIRECTIONAL
            | GObject.BindingFlags.SYNC_CREATE)
        self.bind_property("selection-mode", self._player_toolbar, "visible",
                           GObject.BindingFlags.INVERT_BOOLEAN)
        self.bind_property("selection-mode", self._selection_toolbar,
                           "visible")
        self.connect("notify::selection-mode", self._on_selection_mode_changed)

        self.views = [Gtk.Box()] * len(View)
        # Create only the empty view at startup
        # if no music, switch to empty view and hide stack
        # if some music is available, populate stack with mainviews,
        # show stack and set empty_view to empty_search_view
        self.views[View.EMPTY] = EmptyView()
        self._stack.add_named(self.views[View.EMPTY], "emptyview")

        # Add the 'background' styleclass so it properly hides the
        # bottom line of the searchbar
        self._stack.get_style_context().add_class('background')

        # FIXME: Need to find a proper way to do this.
        self._overlay.add_overlay(self._searchbar._dropdown)

        self._box.pack_start(self._searchbar, False, False, 0)
        self._box.reorder_child(self._searchbar, 0)
        self._box.pack_end(self._player_toolbar, False, False, 0)

        self.set_titlebar(self._headerbar)

        self._selection_toolbar.connect('add-to-playlist',
                                        self._on_add_to_playlist)
        self._search.connect("notify::state", self._on_search_state_changed)

        self._headerbar.props.state = HeaderBar.State.MAIN
        self._headerbar.show()

        def songs_available_cb(available):
            if available:
                self._switch_to_player_view()
            else:
                self._switch_to_empty_view()

        if Query().music_folder:
            grilo.songs_available(songs_available_cb)
        else:
            self._switch_to_empty_view()
Пример #19
0
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk


def cliquer(bouton):
    print('clic')
    print('Bouton> ' + str(bouton))


win = Gtk.Window(title='Foody')
win.set_title('Foody')
print(dir(win))
win.connect("destroy", Gtk.main_quit)

b1 = Gtk.Button(label='clic')
b1.connect('clicked', cliquer)

b2 = Gtk.Button(label='clic')
b2.connect('clicked', cliquer)

box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
box.pack_start(b1, False, False, 2)
box.pack_start(b2, False, False, 2)

win.add(box)

win.show_all()
Gtk.main()
Пример #20
0
    def __init__(self):
        Controller.__init__(self)

        self.prefs_dialog = None  # preferences dialog controller

        self.window.set_position(gtk.WindowPosition.CENTER)
        self.window.set_default_icon_name("org.gnome.Hamster.GUI")
        self.window.set_default_size(700, 500)

        self.storage = hamster.client.Storage()
        self.storage.connect("facts-changed", self.on_facts_changed)
        self.storage.connect("activities-changed", self.on_facts_changed)

        self.header_bar = HeaderBar()
        self.window.set_titlebar(self.header_bar)

        main = gtk.Box(orientation=1)
        self.window.add(main)

        self.report_chooser = None

        self.search_box = gtk.Revealer()

        space = gtk.Box(border_width=5)
        self.search_box.add(space)
        self.filter_entry = gtk.Entry()
        self.filter_entry.set_icon_from_icon_name(
            gtk.EntryIconPosition.PRIMARY, "edit-find-symbolic")
        self.filter_entry.connect("changed", self.on_search_changed)
        self.filter_entry.connect("icon-press", self.on_search_icon_press)

        space.pack_start(self.filter_entry, True, True, 0)
        main.pack_start(self.search_box, False, True, 0)

        window = gtk.ScrolledWindow()
        window.set_policy(gtk.PolicyType.NEVER, gtk.PolicyType.AUTOMATIC)
        self.fact_tree = FactTree()
        self.fact_tree.connect("on-activate-row", self.on_row_activated)
        self.fact_tree.connect("on-delete-called", self.on_row_delete_called)

        window.add(self.fact_tree)
        main.pack_start(window, True, True, 1)

        self.totals = Totals()
        main.pack_start(self.totals, False, True, 1)

        # FIXME: should store and recall date_range from hamster.lib.configuration.conf
        hamster_day = dt.hday.today()
        self.header_bar.range_pick.set_range(hamster_day)
        self.header_bar.range_pick.connect("range-selected",
                                           self.on_range_selected)
        self.header_bar.add_activity_button.connect(
            "clicked", self.on_add_activity_clicked)
        self.header_bar.stop_button.connect("clicked", self.on_stop_clicked)
        self.header_bar.search_button.connect("toggled",
                                              self.on_search_toggled)

        self.header_bar.menu_prefs.connect("activate", self.on_prefs_clicked)
        self.header_bar.menu_export.connect("activate", self.on_export_clicked)
        self.header_bar.menu_help.connect("activate", self.on_help_clicked)

        self.window.connect("key-press-event", self.on_key_press)

        self.facts = []
        self.find_facts()

        # update every minute (necessary if an activity is running)
        gobject.timeout_add_seconds(60, self.on_timeout)
        self.window.show_all()
Пример #21
0
    def __init__(self):
        gtk.Window.__init__(self, title="Logs")
        self.set_border_width(10)
        self.set_position(gtk.WindowPosition.CENTER)
        self.set_default_size(300, 450)

        #self.outter_box = gtk.Box(gtk.Orientation.HORIZONTAL, spacing=10)
        self.outter_box = gtk.VBox(False, spacing=10)
        self.add(self.outter_box)

        c.execute("select * from Logs")
        software_list = c.fetchall()
        self.software_liststore = gtk.ListStore(str, str, int)
        for software_ref in software_list:
            self.software_liststore.append(list(software_ref))

        self.tree = gtk.TreeView(self.software_liststore)
        self.tree_selection = self.tree.get_selection()
        self.tree_selection.connect("changed", self.onSelectionChanged)

        for i, column_title in enumerate(["Plate", "Entry Time", "Inside"]):
            renderer = gtk.CellRendererText()
            column = gtk.TreeViewColumn(column_title, renderer, text=i)
            self.tree.append_column(column)

        self.scrollable_treelist = gtk.ScrolledWindow()
        self.scrollable_treelist.set_vexpand(True)
        self.scrollable_treelist.set_hexpand(True)
        self.outter_box.pack_start(self.scrollable_treelist, False, True, 0)
        self.scrollable_treelist.add(self.tree)

        hbox2 = gtk.Box(gtk.Orientation.HORIZONTAL)
        self.outter_box.pack_start(hbox2, False, False, 0)
        #hbox2.set_layout(gtk.CENTER)
        self.entryid = gtk.Entry()
        self.entry = gtk.Entry()
        self.entry2 = gtk.Entry()
        hbox2.add(self.entry)
        hbox2.add(self.entry2)

        hbox = gtk.ButtonBox.new(gtk.Orientation.HORIZONTAL)
        hbox.set_layout(gtk.ButtonBoxStyle.CENTER)
        self.outter_box.pack_start(hbox, False, True, 0)

        # Add CSS "linked" class
        hbox.get_style_context().add_class("linked")

        button_add = gtk.Button(label="Add")
        hbox.add(button_add)
        button_add.connect("clicked", self.add_btn_clicked)

        button_update = gtk.Button(label="Update")
        hbox.add(button_update)
        button_update.connect("clicked", self.update_btn_clicked)

        button_remove = gtk.Button(label="Remove")
        hbox.add(button_remove)
        button_remove.connect("clicked", self.remove_btn_clicked)

        button_quit = gtk.Button(label="Quit", stock=gtk.STOCK_QUIT)
        button_quit.show()
        hbox.add(button_quit)
        button_quit.connect("clicked", self.on_close_clicked)

        button_refresh = gtk.Button(label="Refresh")
        hbox.add(button_refresh)
        button_refresh.connect("clicked", self.refresh_btn_clicked)
Пример #22
0
    def create_window(self):

        if os.path.exists('data/xpander.svg'):
            self.set_icon_from_file(os.path.abspath('data/xpander.svg'))
        else:
            self.set_icon_name('xpander')

        # General layout
        main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(main_box)
        stack = Gtk.Stack(
            transition_type=Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
        paned = Gtk.Paned()
        stack.add_titled(paned, 'manager', _('Manager'))
        prefs_grid = Gtk.Grid(column_spacing=10,
                              row_spacing=10,
                              margin=10,
                              halign=Gtk.Align.START)
        stack.add_titled(prefs_grid, 'prefs', _('Preferences'))
        stack_switcher = Gtk.StackSwitcher(halign=Gtk.Align.CENTER)
        stack_switcher.set_stack(stack)
        main_box.pack_start(stack_switcher, False, True, 0)
        main_box.pack_start(stack, True, True, 0)

        # Manager
        left_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        treeview_frame = Gtk.Frame(shadow_type=Gtk.ShadowType.IN)
        scrollable_treelist = Gtk.ScrolledWindow(width_request=200)
        scrollable_treelist.set_vexpand(True)
        # Treeview
        self.treestore = Gtk.TreeStore(str, str, str, Gdk.RGBA)
        self.treeview = Gtk.TreeView.new_with_model(self.treestore)
        self.add_mnemonic(Gdk.KEY_m, self.treeview)
        self.treeview.set_headers_visible(False)
        self.treeview.set_search_column(1)
        icon_renderer = Gtk.CellRendererPixbuf()
        icon_column = Gtk.TreeViewColumn('', icon_renderer, icon_name=0)
        self.treeview.append_column(icon_column)
        text_renderer = Gtk.CellRendererText()
        text_renderer.set_property('editable', True)
        text_column = Gtk.TreeViewColumn('Phrases', text_renderer, text=1)
        self.treeview.append_column(text_column)
        string_renderer = Gtk.CellRendererText()
        context = self.treeview.get_style_context()
        self.color_normal = context.get_background_color(Gtk.StateFlags.NORMAL)
        self.color_disabled = context.get_background_color(
            Gtk.StateFlags.INSENSITIVE)
        string_renderer.set_property('editable', False)
        string_column = Gtk.TreeViewColumn('Abbreviatios',
                                           string_renderer,
                                           text=2,
                                           background_rgba=3)
        self.treeview.append_column(string_column)
        self.load_phrases()
        # Drag and drop
        target = Gtk.TargetEntry.new('row', Gtk.TargetFlags.SAME_WIDGET, 0)
        self.treeview.enable_model_drag_source(
            Gdk.ModifierType.BUTTON1_MASK, [target],
            Gdk.DragAction.DEFAULT | Gdk.DragAction.MOVE)
        self.treeview.enable_model_drag_dest([target], Gdk.DragAction.DEFAULT
                                             | Gdk.DragAction.MOVE)
        # Selection
        self.selection = self.treeview.get_selection()
        # Toolbar
        toolbar = Gtk.Box(margin=2, spacing=2)
        remove_icon = Gtk.Image.new_from_icon_name('list-remove-symbolic', 0)
        remove_button = Gtk.Button()
        remove_button.add_accelerator('clicked', self.gui_hotkeys,
                                      Gdk.KEY_Delete,
                                      Gdk.ModifierType.CONTROL_MASK,
                                      Gtk.AccelFlags.VISIBLE)
        remove_button.add(remove_icon)
        toolbar.pack_end(remove_button, False, False, 0)
        add_menu = Gtk.Menu()
        add_phrase = Gtk.MenuItem('New phrase')
        add_phrase.add_accelerator('activate', self.gui_hotkeys, Gdk.KEY_n,
                                   Gdk.ModifierType.CONTROL_MASK,
                                   Gtk.AccelFlags.VISIBLE)
        add_folder = Gtk.MenuItem('New folder')
        add_folder.add_accelerator(
            'activate', self.gui_hotkeys, Gdk.KEY_n,
            Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK,
            Gtk.AccelFlags.VISIBLE)
        add_menu.append(add_phrase)
        add_menu.append(add_folder)
        add_menu.show_all()
        add_icon = Gtk.Image.new_from_icon_name('list-add-symbolic', 0)
        add_button = Gtk.MenuButton()
        add_button.add(add_icon)
        add_button.set_popup(add_menu)
        toolbar.pack_end(add_button, False, False, 0)
        # Editor
        editor_frame = Gtk.Frame(shadow_type=Gtk.ShadowType.IN)
        self.right_grid = Gtk.Grid(column_spacing=6, row_spacing=6, margin=6)
        self.right_grid.set_sensitive(False)
        self.plain_text = Gtk.RadioButton.new_with_mnemonic_from_widget(
            None, _('_Plain text'))
        self.right_grid.attach(self.plain_text, 0, 0, 1, 1)
        self.command = Gtk.RadioButton.new_with_label_from_widget(
            self.plain_text, _('Command'))
        self.right_grid.attach(self.command, 1, 0, 1, 1)
        text_wrap = Gtk.CheckButton.new_with_mnemonic(_('_Wrap text'))
        self.right_grid.attach(text_wrap, 5, 0, 1, 1)
        scrollable_textview = Gtk.ScrolledWindow()
        scrollable_textview.set_hexpand(True)
        scrollable_textview.set_vexpand(True)
        self.textview = Gtk.TextView()
        self.add_mnemonic(Gdk.KEY_b, self.textview)
        scrollable_textview.add(self.textview)
        self.right_grid.attach(scrollable_textview, 0, 1, 6, 5)
        token_label = Gtk.Label(
            _('$| marks cursor position. $C inserts clipboard contents.'))
        self.right_grid.attach(token_label, 0, 6, 3, 1)
        string_label = Gtk.Label.new_with_mnemonic(_('_Abbreviation:'))
        self.right_grid.attach(string_label, 0, 7, 1, 1)
        self.string = Gtk.Entry(max_length=128)
        string_label.set_mnemonic_widget(self.string)
        self.right_grid.attach_next_to(self.string, string_label,
                                       Gtk.PositionType.RIGHT, 2, 1)
        send_label = Gtk.Label.new_with_mnemonic(_('_Send via:'))
        self.right_grid.attach(send_label, 3, 7, 1, 1)
        self.send = Gtk.ComboBoxText()
        send_label.set_mnemonic_widget(self.send)
        self.send.set_entry_text_column(0)
        for method in SEND:
            self.send.append_text(method)
        self.right_grid.attach_next_to(self.send, send_label,
                                       Gtk.PositionType.RIGHT, 2, 1)
        filter_class_label = Gtk.Label.new_with_mnemonic(
            _('Filter by window _class:'))
        self.right_grid.attach(filter_class_label, 0, 8, 1, 1)
        self.filter_class = Gtk.Entry()
        self.right_grid.attach_next_to(self.filter_class, filter_class_label,
                                       Gtk.PositionType.RIGHT, 2, 1)
        set_filter_class = Gtk.ToggleButton(_('Select'))
        filter_class_label.set_mnemonic_widget(set_filter_class)
        self.right_grid.attach_next_to(set_filter_class, self.filter_class,
                                       Gtk.PositionType.RIGHT, 1, 1)
        filter_title_label = Gtk.Label.new_with_mnemonic(
            _('_Filter by window title:'))
        self.right_grid.attach(filter_title_label, 0, 9, 1, 1)
        self.filter_title = Gtk.Entry()
        self.right_grid.attach_next_to(self.filter_title, filter_title_label,
                                       Gtk.PositionType.RIGHT, 2, 1)
        set_filter_title = Gtk.ToggleButton(_('Select'))
        filter_title_label.set_mnemonic_widget(set_filter_title)
        self.right_grid.attach_next_to(set_filter_title, self.filter_title,
                                       Gtk.PositionType.RIGHT, 1, 1)
        self.filter_case = Gtk.CheckButton.new_with_mnemonic(
            _('Case _sensitive'))
        self.right_grid.attach_next_to(self.filter_case, set_filter_title,
                                       Gtk.PositionType.RIGHT, 1, 1)
        save_phrase = Gtk.Button(_('Save'))
        save_phrase.add_accelerator('clicked', self.gui_hotkeys, Gdk.KEY_s,
                                    Gdk.ModifierType.CONTROL_MASK,
                                    Gtk.AccelFlags.VISIBLE)
        self.right_grid.attach(save_phrase, 0, 10, 6, 1)

        # Preferences
        phrase_dir_label = Gtk.Label.new_with_mnemonic(
            _('Phrase _directory (needs restart)'))
        phrase_dir_label.set_xalign(0)
        prefs_grid.attach(phrase_dir_label, 0, 0, 2, 1)
        phrase_dir = Gtk.FileChooserButton.new(
            _('Phrase directory'), Gtk.FileChooserAction.SELECT_FOLDER)
        phrase_dir.set_create_folders(True)
        phrase_dir.set_current_folder(shared.config['phrases_dir'])
        phrase_dir_label.set_mnemonic_widget(phrase_dir)
        prefs_grid.attach(phrase_dir, 4, 0, 1, 1)
        indicator_theme_label = Gtk.Label.new_with_mnemonic(
            _('Prefer light _indicator icon theme'))
        prefs_grid.attach(indicator_theme_label, 0, 1, 2, 1)
        indicator_theme = Gtk.Switch()
        indicator_theme.set_active(shared.config['indicator_theme_light'])
        indicator_theme_label.set_mnemonic_widget(indicator_theme)
        hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 5)
        hbox.pack_start(indicator_theme, False, False, 0)
        prefs_grid.attach(hbox, 4, 1, 1, 1)
        folder_warning_label = Gtk.Label.new_with_mnemonic(
            _('_Warn when deleting a folder'))
        folder_warning_label.set_xalign(0)
        prefs_grid.attach(folder_warning_label, 0, 2, 2, 1)
        folder_warning_switch = Gtk.Switch()
        folder_warning_switch.set_active(shared.config['warn_folder_delete'])
        folder_warning_label.set_mnemonic_widget(folder_warning_switch)
        hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 5)
        hbox.pack_start(folder_warning_switch, False, False, 0)
        prefs_grid.attach(hbox, 4, 2, 1, 1)
        pause_expansion_label = Gtk.Label.new_with_mnemonic(
            _('_Pause expansion'))
        pause_expansion_label.set_xalign(0)
        prefs_grid.attach(pause_expansion_label, 0, 5, 1, 1)
        self.pause_expansion = Gtk.Entry()
        self.pause_expansion.set_editable(False)
        key, mod_strings = shared.config['key_pause']
        key = self.get_key(key)
        if key:
            self.pause_expansion.set_text(''.join(mod_strings) + key)
        else:
            self.pause_expansion.set_text('')
        prefs_grid.attach(self.pause_expansion, 2, 5, 2, 1)
        pause_expansion_set = Gtk.Button(_('Set'))
        pause_expansion_label.set_mnemonic_widget(pause_expansion_set)
        prefs_grid.attach(pause_expansion_set, 4, 5, 1, 1)
        show_manager_label = Gtk.Label.new_with_mnemonic(_('_Show manager'))
        show_manager_label.set_xalign(0)
        prefs_grid.attach(show_manager_label, 0, 6, 1, 1)
        self.show_manager = Gtk.Entry()
        self.show_manager.set_editable(False)
        key, mod_strings = shared.config['key_show_manager']
        key = self.get_key(key)
        if key:
            self.show_manager.set_text(''.join(mod_strings) + key)
        else:
            self.show_manager.set_text('')
        prefs_grid.attach(self.show_manager, 2, 6, 2, 1)
        show_manager_set = Gtk.Button(_('Set'))
        show_manager_label.set_mnemonic_widget(show_manager_set)
        prefs_grid.attach(show_manager_set, 4, 6, 1, 1)

        # Packing
        scrollable_treelist.add(self.treeview)
        treeview_frame.add(scrollable_treelist)
        left_box.pack_start(treeview_frame, True, True, 0)
        toolbar_frame = Gtk.Frame(shadow_type=Gtk.ShadowType.IN)
        toolbar_frame.add(toolbar)
        left_box.pack_start(toolbar_frame, False, True, 0)
        paned.add1(left_box)
        editor_frame.add(self.right_grid)
        paned.add2(editor_frame)

        # Signals
        # Manager
        text_renderer.connect('edited', self.row_edited)
        self.treeview.connect('drag-data-get', self.drag_data_get)
        self.treeview.connect('drag-data-received', self.drag_data_received)
        self.treeview.connect('button-press-event', self.treeview_clicked)
        add_phrase.connect('activate', self.new_phrase)
        add_folder.connect('activate', self.new_folder)
        remove_button.connect('clicked', self.remove_item)
        self.selection.connect('changed', self.selection_changed)
        # Editor
        self.string.connect('key-press-event', self.string_handle_keypress)
        text_wrap.connect('toggled', self.wrap_text)
        set_filter_class.connect('toggled', self.set_window_class)
        set_filter_title.connect('toggled', self.set_window_title)
        save_phrase.connect('clicked', self.save_phrase)
        # Preferences
        phrase_dir.connect('file-set', self.set_phrase_dir)
        indicator_theme.connect('notify::active', self.set_indicator_theme)
        folder_warning_switch.connect('notify::active',
                                      self.folder_warning_toggle)
        pause_expansion_set.connect('clicked', self.get_pause_expansion)
        show_manager_set.connect('clicked', self.get_show_manager)
        # Avoid deleting window, causes segfault
        self.connect('delete-event', self.close_window)
Пример #23
0
    def __init__(self, **options):
        name = _("Workspaces")
        Gtk.ListBox.__init__(self)
        Tweak.__init__(
            self,
            _("Display Handling"),
            _("Workspaces span displays"),
            loaded=_shell_loaded,
        )
        _GSettingsTweak.__init__(self,
                                 name,
                                 "org.gnome.mutter",
                                 "workspaces-only-on-primary",
                                 loaded=_shell_loaded)

        self.set_selection_mode(Gtk.SelectionMode.NONE)

        # Needs other page elements to get margins too
        # self.props.margin_left = 50
        # self.props.margin_right = 50

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(_("Workspaces on primary display only"), xalign=0)
        lbl.props.xalign = 0.0
        desc = _("Additional displays are treated as independent workspaces.")
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check1 = Gtk.Image.new_from_icon_name("object-select-symbolic",
                                                   Gtk.IconSize.SMALL_TOOLBAR)
        self.check1.set_no_show_all(True)
        self.check1.set_visible(self.settings[self.key_name])

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check1, False, False, 0)

        self.add(row)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box()
        hbox.props.margin = 10
        row.add(hbox)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        lbl = Gtk.Label(_("Workspaces span displays"), xalign=0)
        lbl.props.xalign = 0.0
        desc = _("The current workspace includes additional displays.")
        lbl_desc = Gtk.Label()
        lbl_desc.set_line_wrap(True)
        lbl_desc.get_style_context().add_class("dim-label")
        lbl_desc.set_markup("<span size='small'>" +
                            GLib.markup_escape_text(desc) + "</span>")

        self.check2 = Gtk.Image.new_from_icon_name("object-select-symbolic",
                                                   Gtk.IconSize.SMALL_TOOLBAR)
        self.check2.set_no_show_all(True)
        self.check2.set_visible(not self.settings[self.key_name])

        vbox.pack_start(lbl, False, False, 0)
        vbox.pack_start(lbl_desc, False, False, 0)
        hbox.pack_start(vbox, False, False, 0)
        hbox.pack_end(self.check2, False, False, 0)

        self.add(row)
        self.connect('row-activated', self.on_row_clicked)
Пример #24
0
    def do_load(self, parentWidget, enclosures):
        if parentWidget == None:
            print("ERROR: Could not find media player insertion widget!")

        # Test whether Media Player widget already exists
        childList = Gtk.Container.get_children(parentWidget)

        if len(childList) == 1:
            # We need to add a media player...
            vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
            vbox.props.margin = GMARGIN
            vbox.props.spacing = GMARGIN
            Gtk.Box.pack_start(parentWidget, vbox, True, True, 0)

            image = Gtk.Image()
            image.set_from_icon_name("media-skip-backward",
                                     Gtk.IconSize.BUTTON)
            self.prevButton = Gtk.Button.new()
            self.prevButton.add(image)
            self.prevButton.connect("clicked", self.prev)
            self.prevButton.set_direction(Gtk.TextDirection.LTR)
            Gtk.Box.pack_start(vbox, self.prevButton, False, False, 0)

            self.playButtonImage = Gtk.Image()
            self.playButtonImage.set_from_icon_name("media-playback-start",
                                                    Gtk.IconSize.BUTTON)
            self.playButton = Gtk.Button.new()
            self.playButton.add(self.playButtonImage)
            self.playButton.connect("clicked", self.playToggled)
            self.playButton.set_direction(Gtk.TextDirection.LTR)
            Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)

            image = Gtk.Image()
            image.set_from_icon_name("media-skip-forward", Gtk.IconSize.BUTTON)
            self.nextButton = Gtk.Button.new()
            self.nextButton.add(image)
            self.nextButton.connect("clicked", self.next)
            self.nextButton.set_direction(Gtk.TextDirection.LTR)
            Gtk.Box.pack_start(vbox, self.nextButton, False, False, 0)

            self.slider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL)
            self.slider.set_draw_value(False)
            self.slider.set_range(0, 100)
            self.slider.set_increments(1, 10)
            self.slider.connect("change-value", self.on_slider_change_value)
            self.slider.connect("button-press-event",
                                self.on_slider_button_press)
            self.slider.connect("button-release-event",
                                self.on_slider_button_release)
            self.slider.set_direction(Gtk.TextDirection.LTR)
            Gtk.Box.pack_start(vbox, self.slider, True, True, 0)

            self.label = Gtk.Label()
            self.set_label(0)
            Gtk.Box.pack_start(vbox, self.label, False, False, 0)

            Gtk.Widget.show_all(vbox)

        self.enclosures = enclosures
        self.pos = 0
        self.player.set_state(Gst.State.NULL)  # FIXME: Make this configurable?
        self.on_finished(self.player)
Пример #25
0
from gi.repository import Gtk


def calendar_change(checkbutton, option):
    display_options = []

    if checkbutton.get_active():
        display_options.append(option)

    calendar.set_display_options(Gtk.CalendarDisplayOptions.SHOW_HEADING)


window = Gtk.Window()
window.connect("destroy", lambda q: Gtk.main_quit())

hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=2)
window.add(hbox)

calendar = Gtk.Calendar()
hbox.pack_start(calendar, True, True, 0)

vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
hbox.pack_start(vbox, False, False, 0)

checkbutton_heading = Gtk.CheckButton(label="Show heading")
checkbutton_heading.connect("toggled", calendar_change,
                            Gtk.CalendarDisplayOptions.SHOW_HEADING)
vbox.pack_start(checkbutton_heading, False, False, 0)

checkbutton_daynames = Gtk.CheckButton(label="Show day names")
checkbutton_daynames.connect("toggled", calendar_change,
Пример #26
0
    def show_drivers(self):
        self.driver_changes = []
        self.orig_selection = {}
        # HACK: the case where the selection is actually "Do not use"; is a little
        #       tricky to implement because you can't check for whether a package is
        #       installed or any such thing. So let's keep a list of all the
        #       "Do not use" radios, set those active first, then iterate through
        #       orig_selection when doing a Reset.
        self.no_drv = []
        self.nonfree_drivers = 0
        self.ui_building = True
        self.dynamic_device_status = {}
        drivers_found = False
        if len(self.devices) != 0:
            for device in sorted(self.devices.keys()):
                (overall_status, icon,
                 drivers) = self.gather_device_data(self.devices[device])
                is_cpu = False
                if "intel-microcode" in self.devices[device][
                        'drivers'] or "amd64-microcode" in self.devices[
                            device]['drivers']:
                    is_cpu = True
                    overall_status = _("Processor microcode")
                brand_icon = Gtk.Image()
                brand_icon.set_valign(Gtk.Align.START)
                brand_icon.set_halign(Gtk.Align.CENTER)
                brand_icon.set_from_pixbuf(
                    self.get_device_icon(self.devices[device]))
                driver_status = Gtk.Image()
                driver_status.set_valign(Gtk.Align.START)
                driver_status.set_halign(Gtk.Align.CENTER)
                driver_status.set_from_icon_name(icon, Gtk.IconSize.MENU)
                device_box = Gtk.Box(spacing=6,
                                     orientation=Gtk.Orientation.HORIZONTAL)
                device_box.pack_start(brand_icon, False, False, 6)
                device_detail = Gtk.Box(spacing=6,
                                        orientation=Gtk.Orientation.VERTICAL)
                device_box.pack_start(device_detail, True, True, 0)
                model_name = self.devices[device].get('model', None)
                vendor_name = self.devices[device].get('vendor', None)
                if is_cpu:
                    device_name = self.get_cpu_name()
                elif vendor_name is None and model_name is None:
                    device_name = _("Unknown")
                elif vendor_name is None:
                    device_name = model_name
                elif model_name is None:
                    device_name = vendor_name
                else:
                    device_name = "%s: %s" % (vendor_name, model_name)
                if "vmware" in device_name.lower(
                ) or "virtualbox" in device_name.lower():
                    print("Ignoring device %s" % device_name)
                    continue
                if drivers["manually_installed"]:
                    print("Ignoring device: %s (manually_installed)" %
                          device_name)
                    continue
                drivers_found = True
                widget = Gtk.Label(label=device_name)
                widget.set_halign(Gtk.Align.START)
                device_detail.pack_start(widget, True, False, 0)
                widget = Gtk.Label(
                    label="<small>{}</small>".format(overall_status))
                widget.set_halign(Gtk.Align.START)
                widget.set_use_markup(True)
                device_detail.pack_start(widget, True, False, 0)
                self.dynamic_device_status[device] = (driver_status, widget)

                option_group = None
                # define the order of introspection
                for section in ('recommended', 'alternative',
                                'manually_installed', 'no_driver'):
                    for driver in sorted(drivers[section],
                                         key=lambda x: self.sort_string(
                                             drivers[section], x)):
                        if str(driver).startswith("nvidia-driver") and str(
                                driver).endswith("-server"):
                            print("Ignoring server NVIDIA driver: ", driver)
                            continue
                        radio_button = Gtk.RadioButton.new(None)
                        label = Gtk.Label()
                        label.set_markup(
                            drivers[section][driver]['description'])
                        radio_button.add(label)
                        if option_group:
                            radio_button.join_group(option_group)
                        else:
                            option_group = radio_button
                        device_detail.pack_start(radio_button, True, False, 0)
                        radio_button.set_active(
                            drivers[section][driver]['selected'])

                        if section == 'no_driver':
                            self.no_drv.append(radio_button)
                            if is_cpu:
                                label.set_markup(
                                    _("Do not update the CPU microcode"))
                        if section in ('manually_install', 'no_driver') or (
                                'builtin' in drivers[section][driver]
                                and drivers[section][driver]['builtin']):
                            radio_button.connect(
                                "toggled", self.on_driver_selection_changed,
                                device)
                        else:
                            radio_button.connect(
                                "toggled", self.on_driver_selection_changed,
                                device, driver)
                        if drivers[
                                'manually_installed'] and section != 'manually_installed' and "firmware" not in str(
                                    driver):
                            radio_button.set_sensitive(False)

                self.box_driver_detail.pack_start(device_box, False, False, 6)
                self.stack.set_visible_child_name("drivers_page")

        if not drivers_found:
            self.stack.set_visible_child_name("no_drivers_page")
            print("Your computer does not need any additional drivers")

        self.spinner.stop()

        self.ui_building = False
        self.box_driver_detail.show_all()
        self.set_driver_action_status()
Пример #27
0
    def __init__(self, uuid):
        Budgie.Applet.__init__(self)
        self.red_time = 60
        self.yellow_time = 300
        # --- panelgrid ---
        self.panelgrid = Gtk.Grid()
        # space section. make it depend on panel size?
        spacer_img = Gtk.Image.new_from_file(
            os.path.join(path, "cr_spacer.png"))
        self.panelgrid.attach(spacer_img, 0, 0, 2, 1)
        self.panelgrid.set_row_spacing(10)  # <-- make depend on panel height
        # icons
        grey = os.path.join(path, "cr_grey.png")
        green = os.path.join(path, "cr_green.png")
        yellow = os.path.join(path, "cr_yellow.png")
        red = os.path.join(path, "cr_red.png")
        # pixbuf
        self.iconset = [
            GdkPixbuf.Pixbuf.new_from_file(ic)
            for ic in [red, yellow, green, grey]
        ]
        # initial icon
        self.seticon = Gtk.Image.new_from_pixbuf(self.iconset[0])
        self.panelgrid.attach(self.seticon, 0, 1, 1, 1)
        # menu label
        self.timer = Gtk.Label("  00:00:00")
        self.panelgrid.attach(self.timer, 1, 1, 1, 1)
        # --- menugrid ---
        self.menugrid = Gtk.Grid()
        self.menugrid.set_column_spacing(15)
        self.menugrid.set_row_spacing(5)
        # left space
        self.menugrid.attach(Gtk.Label(""), 1, 0, 1, 1)
        # hrs
        self.hrs_label = Gtk.Label("Hours: ", xalign=0)
        self.menugrid.attach(self.hrs_label, 1, 2, 1, 1)
        adjustment = Gtk.Adjustment(0, 0, 23, 1)
        self.hoursbutton = Gtk.SpinButton()
        self.hoursbutton.set_adjustment(adjustment)
        self.menugrid.attach(self.hoursbutton, 2, 2, 1, 1)
        # mins
        self.mins_label = Gtk.Label("Minutes: ", xalign=0)
        self.menugrid.attach(self.mins_label, 1, 3, 1, 1)
        adjustment = Gtk.Adjustment(0, 0, 59, 1)
        self.minsbutton = Gtk.SpinButton()
        self.minsbutton.set_adjustment(adjustment)
        self.menugrid.attach(self.minsbutton, 2, 3, 1, 1)
        # secs
        self.secs_label = Gtk.Label("Seconds: ", xalign=0)
        self.menugrid.attach(self.secs_label, 1, 4, 1, 1)
        adjustment = Gtk.Adjustment(0, 0, 59, 1)
        self.secsbutton = Gtk.SpinButton()
        self.secsbutton.set_adjustment(adjustment)
        self.menugrid.attach(self.secsbutton, 2, 4, 1, 1)

        for sp in [self.hoursbutton, self.minsbutton, self.secsbutton]:
            sp.set_numeric(True)
            sp.set_update_policy(True)

        # prevent pause
        self.sleep = Gtk.CheckButton("Prevent pausing countdown")
        self.menugrid.attach(self.sleep, 1, 6, 2, 1)

        sep = Gtk.Separator()
        self.menugrid.attach(sep, 4, 1, 1, 8)

        self.bbox = Gtk.Box()
        self.menugrid.attach(self.bbox, 0, 10, 9, 2)
        self.menugrid.attach(Gtk.Label(""), 1, 9, 1, 1)
        # apply
        self.applybutton = Gtk.Button("Run")
        # set style start/stop
        self.context_start = self.applybutton.get_style_context()
        self.applybutton.set_size_request(80, 20)
        self.bbox.pack_end(self.applybutton, False, False, 0)
        self.applybutton.connect("clicked", self.handle_apply)
        self.nf_bell = Gtk.CheckButton("Ring bell")
        self.menugrid.attach(self.nf_bell, 5, 2, 1, 1)
        self.nf_icon = Gtk.CheckButton("Flash icon")
        self.menugrid.attach(self.nf_icon, 5, 3, 1, 1)
        self.nf_message = Gtk.CheckButton("Display window")
        self.menugrid.attach(self.nf_message, 5, 4, 1, 1)

        self.runcomm = Gtk.CheckButton("Run command:")
        self.menugrid.attach(self.runcomm, 5, 5, 1, 1)
        self.command_entry = Gtk.Entry()
        self.command_entry.connect("key-release-event", self.update_command)
        self.menugrid.attach(self.command_entry, 5, 6, 1, 1)
        # button, file, related variable-key
        self.settingsdata = [
            [self.nf_bell, "mute_ringbell", "ringbell"],
            [self.nf_icon, "mute_flashicon", "flashicon"],
            [self.nf_message, "mute_showwindow", "showwindow"],
            [self.sleep, "mute_nosleep", "keeprun"],
            [self.runcomm, "runcommand", "runcmd"],
        ]
        self.vals = []
        # fetch values for checkbuttons (except command: separate)
        for item in self.settingsdata[:-1]:
            val = True if self.get_setting(item) is False else False
            subj = item[0]
            item[0].set_active(val)
            self.vals.append(val)
            item[0].connect("toggled", self.manage_checkbox)
        # fetch command if True, set checkbutton
        command_set = self.settingsdata[-1]
        commandval = self.get_setting(command_set, True)
        try:
            data = ast.literal_eval(commandval[1])
        except TypeError:
            self.runcomm.set_active(False)
            self.command_entry.set_sensitive(False)
        else:
            self.runcmd = data[0]
            self.command_entry.set_text(data[1])
            self.runcomm.set_active(self.runcmd)
            self.command_entry.set_sensitive(self.runcmd)
        self.runcomm.connect("toggled", self.manage_checkbox)
        self.runvars = {
            "ringbell": self.vals[0],
            "flashicon": self.vals[1],
            "showwindow": self.vals[2],
            "keeprun": self.vals[3],
            "runcmd": self.runcomm.get_active(),
        }
        self.countdown, self.span = 0, 0
        self.cancel = True
        # panel
        self.box = Gtk.EventBox()
        self.box.add(self.panelgrid)
        self.add(self.box)
        # menu
        self.popover = Budgie.Popover.new(self.box)
        self.popover.add(self.menugrid)
        self.popover.get_child().show_all()

        self.box.show_all()
        self.show_all()
        self.box.connect("button-press-event", self.on_press)

        GObject.threads_init()
        # thread
        self.update = Thread(target=self.run_countdown)
        # daemonize the thread to make the indicator stopable
        self.update.setDaemon(True)
        self.update.start()
        self.seticon.set_from_pixbuf(self.iconset[1])
    def __init__(self):
        Gtk.Window.__init__(self, title="Gtk+: iOS Backup - Read Manifest.db")
        self.set_border_width(8)
        self.set_default_size(1024, 768)
        loader = GdkPixbuf.PixbufLoader()
        loader.write(svg.encode())
        loader.close()
        pixbuf = loader.get_pixbuf()
        self.set_icon(pixbuf)
        # vertical box to hold the widgets
        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
        # a toolbar created in the method create_toolbar (see below)
        toolbar = self.create_toolbar()
        # with extra horizontal space
        toolbar.set_hexpand(True)
        # show the toolbar
        toolbar.show()
        # add the toolbar to the vertical box
        self.vbox.pack_start(toolbar, False, True, 0)
        label = Gtk.Label()
        label.set_markup(
            "<span face=\"mono\" weight=\"bold\">iOSBackup </span>")
        self.label_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                 spacing=8)
        self.label_box.pack_start(label, True, True, 0)
        self.vbox.pack_start(self.label_box, True, True, 0)
        # some needed stuff
        self.first_run = True
        self.backup_path = str()
        # records of 'naked' domains
        self.naked_domains = []
        self.domain_items = []
        self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
        self.dialog_label = Gtk.Label()
        self.dialog_label.set_justify(Gtk.Justification.LEFT)
        # create combobox with entry
        listmodel = Gtk.ListStore(str, int)
        self.combo = Gtk.ComboBox.new_with_model_and_entry(model=listmodel)
        # cellrenderers to render the data
        renderer_text = Gtk.CellRendererText()
        self.combo.pack_start(renderer_text, True)
        self.combo.add_attribute(renderer_text, "text", 1)
        # active row at the beginning is undefined
        self.combo.set_active(-1)
        self.combo.connect("changed", self.on_combo_changed)
        self.combo.set_entry_text_column(0)
        entry = self.combo.get_child()
        # handles Enter pressed
        entry.connect("activate", self.on_entry_activate)
        entry.set_placeholder_text(_("Please select domain to display"))
        # button extract domain
        domain_button = Gtk.Button.new_with_label(_("Extract Domain..."))
        domain_button.set_tooltip_text(_("Extract domain content"))
        # label is shown
        domain_button.show()
        # set the name of the action associated with the button.
        domain_button.connect("clicked", self.on_extract_domain_clicked)
        # combination of combobox and button
        self.domain_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                  spacing=8)
        self.domain_box.pack_start(self.combo, True, True, 0)
        self.domain_box.pack_end(domain_button, False, True, 0)
        # create scrolled_window for treeview under the combobox
        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.set_size_request(-1, 384)
        self.scrolled_window.set_border_width(0)
        # there is always the scrollbar (otherwise: ALWAYS NEVER)
        self.scrolled_window.set_policy(\
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        # model creation for the treeview
        treemodel = Gtk.ListStore(str, str, 'glong')
        # create TreeView
        self.treeview = Gtk.TreeView(model=treemodel)
        # treeview column headers
        rendererText = Gtk.CellRendererText()
        treeview_cols = ['fileID', 'relativePath', 'flags']
        for num, name in enumerate(treeview_cols):
            column_name = Gtk.TreeViewColumn(name, rendererText, text=num)
            self.treeview.append_column(column_name)
        # make all the columns reorderable and resizable
        # this is not necessary, but it's nice to show the feature
        for column in self.treeview.get_columns():
            column.set_reorderable(True)
            column.set_resizable(True)
            column.set_alignment(0.7)
        # Connect signal handler
        self.treeview.connect("row_activated", self.on_row_activated)
        '''
        # create the Text Buffer
        text_buffer = Gtk.TextBuffer.new()
        text_view = Gtk.TextView()
        text_view.set_buffer(text_buffer);
        # add the TextView, inside a ScrolledWindow under the tableview
        text_window = Gtk.ScrolledWindow()
        text_window.set_size_request(-1, 60)
        text_window.add(text_view);
        # only show the scrollbars when they are necessary:
        text_window.set_policy(\
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) '''

        self.status_frame = Gtk.Frame()
        self.status_bar = Gtk.Statusbar()
        self.status_frame.add(self.status_bar)
        self.vbox.pack_end(self.status_frame, False, True, 0)
        self.context_id = self.status_bar.push(
            0, _("Choose a Database, click Open"))
        self.add(self.vbox)
        self.show_all()
Пример #29
0
    def __init__(self):
        Gtk.Window.__init__(self, title="Registrar un Usuario")
        self.set_border_width(10)

        self.bbdd = dbapi2.connect("TiendaInformatica.db")
        self.cursor = self.bbdd.cursor()

        cajaCrearClientes = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                    spacing=6)
        grid = Gtk.Grid()
        grid.set_row_spacing(20)
        grid.set_column_spacing(10)
        """
        Etiquetas con los nombres de los datos que queremos insertar
        """

        lblNombre = Gtk.Label("Nombre:")
        lblApellido = Gtk.Label("Apellidos:")
        lblDni = Gtk.Label("DNI:")
        lblDireccion = Gtk.Label("Direccion:")
        lblNumeroCliente = Gtk.Label("Numero de cliente:")
        lblSexo = Gtk.Label("Sexo:")
        """
        Componentes entry para introducir los datos.
        ComboBox para el sexo.
        """
        self.txtNombre = Gtk.Entry()
        self.txtApellido = Gtk.Entry()
        self.txtDni = Gtk.Entry()
        self.txtDireccion = Gtk.Entry()
        self.txtNumeroCliente = Gtk.Entry()

        self.cmbSexo = Gtk.ComboBoxText()
        self.cmbSexo.insert(0, '0', "M")
        self.cmbSexo.insert(1, '1', "H")

        btnInsertar = Gtk.Button("Insertar Cliente")
        btnInsertar.connect("clicked", self.on_btnInsertar_clicked)

        btnVolver = Gtk.Button("Volver")
        btnVolver.connect("clicked", self.on_btnVolver_clicked)
        """
        Con grid attach lo que hacemos es establecer el orden en los que se colocan los componentes en el grid
        """
        grid.attach(lblNombre, 0, 0, 1, 1)
        grid.attach(self.txtNombre, 1, 0, 1, 1)
        grid.attach_next_to(lblApellido, self.txtNombre,
                            Gtk.PositionType.RIGHT, 1, 1)
        grid.attach_next_to(self.txtApellido, lblApellido,
                            Gtk.PositionType.RIGHT, 1, 1)
        grid.attach_next_to(lblDni, lblNombre, Gtk.PositionType.BOTTOM, 1, 1)
        grid.attach_next_to(self.txtDni, lblDni, Gtk.PositionType.RIGHT, 1, 1)
        grid.attach_next_to(lblDireccion, self.txtDni, Gtk.PositionType.RIGHT,
                            1, 1)
        grid.attach_next_to(self.txtDireccion, lblDireccion,
                            Gtk.PositionType.RIGHT, 1, 1)

        grid.attach_next_to(lblNumeroCliente, lblDni, Gtk.PositionType.BOTTOM,
                            1, 1)
        grid.attach_next_to(self.txtNumeroCliente, lblNumeroCliente,
                            Gtk.PositionType.RIGHT, 1, 1)

        grid.attach_next_to(lblSexo, self.txtNumeroCliente,
                            Gtk.PositionType.RIGHT, 1, 1)
        grid.attach_next_to(self.cmbSexo, lblSexo, Gtk.PositionType.RIGHT, 1,
                            1)

        grid.attach_next_to(btnInsertar, self.lblSexo, Gtk.PositionType.BOTTOM,
                            1, 1)
        grid.attach_next_to(btnVolver, btnInsertar, Gtk.PositionType.RIGHT, 1,
                            1)

        cajaCrearClientes.add(grid)

        self.add(cajaCrearClientes)
        self.show_all()
    def __init__(self, parent, collection_type, spices, window):
        super(ManageSpicesPage, self).__init__()
        self.expand = True
        self.set_spacing(0)
        self.set_margin_top(5)

        self.parent = parent
        self.collection_type = collection_type
        self.spices = spices
        self.has_filter = False
        self.window = window
        self.extension_rows = []

        self.top_box = Gtk.Box()
        self.pack_start(self.top_box, False, False, 10)

        self.search_entry = Gtk.Entry()
        self.search_entry.set_icon_from_icon_name(
            Gtk.EntryIconPosition.PRIMARY, 'edit-find-symbolic')
        self.search_entry.set_placeholder_text(_("Search"))
        self.search_entry.connect('changed', self.on_entry_refilter)

        self.top_box.pack_end(self.search_entry, False, False, 4)

        frame = Gtk.Frame()
        frame.set_shadow_type(Gtk.ShadowType.IN)
        frame_style = frame.get_style_context()
        frame_style.add_class('view')
        self.pack_start(frame, True, True, 0)

        main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        frame.add(main_box)

        scw = Gtk.ScrolledWindow()
        scw.expand = True
        scw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scw.set_shadow_type(Gtk.ShadowType.NONE)
        main_box.pack_start(scw, True, True, 0)
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        scw.add(self.box)

        self.infobar_holder = Gtk.Frame(shadow_type=Gtk.ShadowType.NONE)
        self.box.add(self.infobar_holder)

        def sort_rows(row1, row2):
            if row1.writable == row2.writable:
                name1 = row1.name.lower()
                name2 = row2.name.lower()
                if name1 < name2:
                    return -1
                elif name2 < name1:
                    return 1
                else:
                    return 0
            elif row1.writable:
                return -1
            else:
                return 1

        self.list_box = Gtk.ListBox()
        self.list_box.set_selection_mode(Gtk.SelectionMode.SINGLE)
        self.list_box.set_sort_func(sort_rows)
        self.list_box.set_header_func(list_header_func, None)
        self.list_box.connect('row-selected', self.update_button_states)
        self.box.add(self.list_box)

        button_toolbar = Gtk.Toolbar.new()
        Gtk.StyleContext.add_class(
            Gtk.Widget.get_style_context(button_toolbar), 'inline-toolbar')
        self.add(button_toolbar)

        button_holder = Gtk.ToolItem()
        button_holder.set_expand(True)
        button_toolbar.add(button_holder)
        box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        box.set_halign(Gtk.Align.CENTER)
        button_holder.add(box)

        # buttons
        self.instance_button = Gtk.Button.new_from_icon_name(
            "list-add-symbolic", Gtk.IconSize.MENU)
        self.instance_button.set_size_request(50, -1)
        self.instance_button.set_tooltip_text(self.instance_button_text)
        self.instance_button.connect('clicked', self.add_instance)
        box.add(self.instance_button)
        self.instance_button.set_sensitive(False)

        self.remove_button = Gtk.Button.new_from_icon_name(
            "list-remove-symbolic", Gtk.IconSize.MENU)
        self.remove_button.set_size_request(50, -1)
        self.remove_button.set_tooltip_text(self.remove_button_text)
        self.remove_button.connect('clicked', self.remove_all_instances)
        box.add(self.remove_button)
        self.remove_button.set_sensitive(False)

        self.uninstall_button = Gtk.Button.new_from_icon_name(
            "edit-delete-symbolic", Gtk.IconSize.MENU)
        self.uninstall_button.set_size_request(50, -1)
        self.uninstall_button.set_tooltip_text(self.uninstall_button_text)
        self.uninstall_button.connect('clicked', self.uninstall_extension)
        box.add(self.uninstall_button)
        self.uninstall_button.set_sensitive(False)

        self.restore_button = Gtk.Button.new_from_icon_name(
            "edit-undo-symbolic", Gtk.IconSize.MENU)
        self.restore_button.set_size_request(50, -1)
        self.restore_button.set_tooltip_text(self.restore_button_text)
        self.restore_button.connect('clicked', self.restore_to_default)
        box.add(self.restore_button)

        self.about_button = Gtk.Button.new_from_icon_name(
            "help-about-symbolic", Gtk.IconSize.MENU)
        self.about_button.set_size_request(50, -1)
        self.about_button.set_tooltip_text(_("About"))
        self.about_button.connect('clicked', self.about)
        box.add(self.about_button)
        self.about_button.set_sensitive(False)

        # progress bar
        self.progress_bar = self.spices.get_progressbar()
        pb_container = Gtk.Box()
        pb_container.set_margin_top(20)
        pb_container.pack_start(self.progress_bar, True, True, 0)
        self.pack_end(pb_container, False, False, 0)

        self.load_extensions()

        self.connect('map', self.on_page_map)

        self.spices.connect('installed-changed', self.load_extensions)
        self.spices.connect('status-changed', self.update_status)