示例#1
0
文件: notify.py 项目: yaoml/quodlibet
    def __init__(self, parent, plugin_instance):
        GObject.GObject.__init__(self, spacing=12)
        self.plugin_instance = plugin_instance

        # notification text settings
        table = Gtk.Table(n_rows=2, n_columns=3)
        table.set_col_spacings(6)
        table.set_row_spacings(6)

        text_frame = qltk.Frame(_("Notification text"), child=table)

        title_entry = UndoEntry()
        title_entry.set_text(pconfig.gettext("titlepattern"))

        def on_entry_changed(entry, cfgname):
            pconfig.settext(cfgname, gdecode(entry.get_text()))

        title_entry.connect("changed", on_entry_changed, "titlepattern")
        table.attach(title_entry, 1, 2, 0, 1)

        title_label = Gtk.Label(label=_("_Title:"))
        title_label.set_use_underline(True)
        title_label.set_alignment(0, 0.5)
        title_label.set_mnemonic_widget(title_entry)
        table.attach(title_label, 0, 1, 0, 1,
                     xoptions=Gtk.AttachOptions.FILL |
                     Gtk.AttachOptions.SHRINK)

        title_revert = Gtk.Button()
        title_revert.add(Gtk.Image.new_from_icon_name(
            Icons.DOCUMENT_REVERT, Gtk.IconSize.MENU))
        title_revert.set_tooltip_text(_("Revert to default pattern"))
        title_revert.connect(
            "clicked", lambda *x: title_entry.set_text(
                pconfig.defaults.gettext("titlepattern")))
        table.attach(title_revert, 2, 3, 0, 1,
                     xoptions=Gtk.AttachOptions.SHRINK)

        body_textbuffer = TextBuffer()
        body_textview = TextView(buffer=body_textbuffer)
        body_textview.set_size_request(-1, 85)
        body_textview.get_buffer().set_text(pconfig.gettext("bodypattern"))

        def on_textbuffer_changed(text_buffer, cfgname):
            start, end = text_buffer.get_bounds()
            text = gdecode(text_buffer.get_text(start, end, True))
            pconfig.settext(cfgname, text)

        body_textbuffer.connect("changed", on_textbuffer_changed,
                                "bodypattern")
        body_scrollarea = Gtk.ScrolledWindow()
        body_scrollarea.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        body_scrollarea.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        body_scrollarea.add(body_textview)
        table.attach(body_scrollarea, 1, 2, 1, 2)

        body_label = Gtk.Label(label=_("_Body:"))
        body_label.set_padding(0, 3)
        body_label.set_use_underline(True)
        body_label.set_alignment(0, 0)
        body_label.set_mnemonic_widget(body_textview)
        table.attach(body_label, 0, 1, 1, 2, xoptions=Gtk.AttachOptions.SHRINK)

        body_revert = Gtk.Button()
        body_revert.add(Gtk.Image.new_from_icon_name(
                        Icons.DOCUMENT_REVERT, Gtk.IconSize.MENU))
        body_revert.set_tooltip_text(_("Revert to default pattern"))
        body_revert.connect("clicked", lambda *x:
            body_textbuffer.set_text(pconfig.defaults.gettext("bodypattern")))
        table.attach(
            body_revert, 2, 3, 1, 2,
            xoptions=Gtk.AttachOptions.SHRINK,
            yoptions=Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK)

        # preview button
        preview_button = qltk.Button(
            _("_Show notification"), Icons.SYSTEM_RUN)
        preview_button.set_sensitive(app.player.info is not None)
        preview_button.connect("clicked", self.on_preview_button_clicked)
        self.qlplayer_connected_signals = [
            app.player.connect("paused", self.on_player_state_changed,
                             preview_button),
            app.player.connect("unpaused", self.on_player_state_changed,
                             preview_button),
        ]

        table.attach(
            preview_button, 0, 3, 2, 3,
            xoptions=Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK)

        self.pack_start(text_frame, True, True, 0)

        # notification display settings
        display_box = Gtk.VBox(spacing=12)
        display_frame = qltk.Frame(_("Show notifications"), child=display_box)

        radio_box = Gtk.VBox(spacing=6)
        display_box.pack_start(radio_box, True, True, 0)

        only_user_radio = Gtk.RadioButton(label=_(
            "Only on <i>_manual</i> song changes"
        ), use_underline=True)
        only_user_radio.get_child().set_use_markup(True)
        only_user_radio.connect("toggled", self.on_radiobutton_toggled,
                                "show_notifications", "user")
        radio_box.pack_start(only_user_radio, True, True, 0)

        only_auto_radio = Gtk.RadioButton(group=only_user_radio, label=_(
            "Only on <i>_automatic</i> song changes"
        ), use_underline=True)
        only_auto_radio.get_child().set_use_markup(True)
        only_auto_radio.connect("toggled", self.on_radiobutton_toggled,
                                "show_notifications", "auto")
        radio_box.pack_start(only_auto_radio, True, True, 0)

        all_radio = Gtk.RadioButton(group=only_user_radio, label=_(
            "On <i>a_ll</i> song changes"
        ), use_underline=True)
        all_radio.get_child().set_use_markup(True)
        all_radio.connect("toggled", self.on_radiobutton_toggled,
                          "show_notifications", "all")
        radio_box.pack_start(all_radio, True, True, 0)

        {
            "user": only_user_radio,
            "auto": only_auto_radio,
            "all": all_radio
        }.get(pconfig.gettext("show_notifications"),
              all_radio).set_active(True)

        focus_check = Gtk.CheckButton(
            label=_("Only when the main window is not _focused"),
            use_underline=True)
        focus_check.set_active(pconfig.getboolean("show_only_when_unfocused"))
        focus_check.connect("toggled", self.on_checkbutton_toggled,
                            "show_only_when_unfocused")
        display_box.pack_start(focus_check, True, True, 0)

        show_next = Gtk.CheckButton(
            label=_("Show \"_Next\" button"),
            use_underline=True)
        show_next.set_active(pconfig.getboolean("show_next_button"))
        show_next.connect("toggled", self.on_checkbutton_toggled,
                            "show_next_button")
        display_box.pack_start(show_next, True, True, 0)

        self.pack_start(display_frame, True, True, 0)

        self.show_all()
        self.connect("destroy", self.on_destroyed)
示例#2
0
    def __init__(self, namespace, dbstate, uistate, track, filterdb, val,
                 label, update, filter_name):
        ManagedWindow.__init__(self, uistate, track, EditRule)
        self.namespace = namespace
        self.dbstate = dbstate
        self.db = dbstate.db
        self.filterdb = filterdb
        self.update_rule = update
        self.filter_name = filter_name

        self.active_rule = val
        self.define_glade('rule_editor', RULE_GLADE)

        self.set_window(self.get_widget('rule_editor'),
                        self.get_widget('rule_editor_title'), label)
        self.setup_configs('interface.edit-rule', 600, 450)
        self.window.hide()
        self.valuebox = self.get_widget('valuebox')
        self.rname_filter = self.get_widget('ruletreefilter')
        self.rname = self.get_widget('ruletree')
        self.rule_name = self.get_widget('rulename')
        self.description = self.get_widget('description')

        self.notebook = Gtk.Notebook()
        self.notebook.set_show_tabs(0)
        self.notebook.set_show_border(0)
        self.notebook.show()
        self.valuebox.pack_start(self.notebook, True, True, 0)
        self.page_num = 0
        self.page = []
        self.class2page = {}

        if self.namespace == 'Person':
            class_list = rules.person.editor_rule_list
        elif self.namespace == 'Family':
            class_list = rules.family.editor_rule_list
        elif self.namespace == 'Event':
            class_list = rules.event.editor_rule_list
        elif self.namespace == 'Source':
            class_list = rules.source.editor_rule_list
        elif self.namespace == 'Citation':
            class_list = rules.citation.editor_rule_list
        elif self.namespace == 'Place':
            class_list = rules.place.editor_rule_list
        elif self.namespace == 'Media':
            class_list = rules.media.editor_rule_list
        elif self.namespace == 'Repository':
            class_list = rules.repository.editor_rule_list
        elif self.namespace == 'Note':
            class_list = rules.note.editor_rule_list

        for class_obj in class_list:
            arglist = class_obj.labels
            vallist = []
            tlist = []
            pos = 0
            l2 = Gtk.Label(label=class_obj.name, halign=Gtk.Align.START)
            l2.show()
            grid = Gtk.Grid()
            grid.set_border_width(12)
            grid.set_column_spacing(6)
            grid.set_row_spacing(6)
            grid.show()
            for v in arglist:
                l = Gtk.Label(label=v, halign=Gtk.Align.END)
                l.show()
                if v == _('Place:'):
                    t = MyPlaces([])
                elif v in [_('Reference count:'), _('Number of instances:')]:
                    t = MyInteger(0, 999)
                elif v == _('Reference count must be:'):
                    t = MyLesserEqualGreater()
                elif v == _('Number must be:'):
                    t = MyLesserEqualGreater(2)
                elif v == _('Number of generations:'):
                    t = MyInteger(1, 32)
                elif v == _('ID:'):
                    t = MyID(self.dbstate, self.uistate, self.track,
                             self.namespace)
                elif v == _('Source ID:'):
                    t = MySource(self.dbstate, self.uistate, self.track)
                elif v == _('Filter name:'):
                    t = MyFilters(self.filterdb.get_filters(self.namespace),
                                  self.filter_name)
                # filters of another namespace, name may be same as caller!
                elif v == _('Person filter name:'):
                    t = MyFilters(self.filterdb.get_filters('Person'))
                elif v == _('Event filter name:'):
                    t = MyFilters(self.filterdb.get_filters('Event'))
                elif v == _('Source filter name:'):
                    t = MyFilters(self.filterdb.get_filters('Source'))
                elif v == _('Repository filter name:'):
                    t = MyFilters(self.filterdb.get_filters('Repository'))
                elif v == _('Place filter name:'):
                    t = MyFilters(self.filterdb.get_filters('Place'))
                elif v in _name2typeclass:
                    additional = None
                    if v in (_('Event type:'), _('Personal event:'),
                             _('Family event:')):
                        additional = self.db.get_event_types()
                    elif v == _('Personal attribute:'):
                        additional = self.db.get_person_attribute_types()
                    elif v == _('Family attribute:'):
                        additional = self.db.get_family_attribute_types()
                    elif v == _('Event attribute:'):
                        additional = self.db.get_event_attribute_types()
                    elif v == _('Media attribute:'):
                        additional = self.db.get_media_attribute_types()
                    elif v == _('Relationship type:'):
                        additional = self.db.get_family_relation_types()
                    elif v == _('Note type:'):
                        additional = self.db.get_note_types()
                    elif v == _('Name type:'):
                        additional = self.db.get_name_types()
                    elif v == _('Surname origin type:'):
                        additional = self.db.get_origin_types()
                    elif v == _('Place type:'):
                        additional = sorted(self.db.get_place_types(),
                                            key=lambda s: s.lower())
                    t = MySelect(_name2typeclass[v], additional)
                elif v == _('Inclusive:'):
                    t = MyBoolean(_('Include selected Gramps ID'))
                elif v == _('Case sensitive:'):
                    t = MyBoolean(_('Use exact case of letters'))
                elif v == _('Regular-Expression matching:'):
                    t = MyBoolean(_('Use regular expression'))
                elif v == _('Include Family events:'):
                    t = MyBoolean(
                        _('Also family events where person is spouse'))
                elif v == _('Primary Role:'):
                    t = MyBoolean(_('Only include primary participants'))
                elif v == _('Tag:'):
                    taglist = ['']
                    taglist = taglist + [
                        tag.get_name() for tag in dbstate.db.iter_tags()
                    ]
                    t = MyList(taglist, taglist)
                elif v == _('Confidence level:'):
                    t = MyList(list(map(str, list(range(5)))),
                               [_(conf_strings[i]) for i in range(5)])
                elif v == _('Date:'):
                    t = DateEntry(self.uistate, self.track)
                elif v == _('Day of Week:'):
                    long_days = displayer.long_days
                    days_of_week = long_days[2:] + long_days[1:2]
                    t = MyList(list(map(str, range(7))), days_of_week)
                elif v == _('Units:'):
                    t = MyList(
                        [0, 1, 2],
                        [_('kilometers'),
                         _('miles'), _('degrees')])
                else:
                    t = MyEntry()
                t.set_hexpand(True)
                tlist.append(t)
                grid.attach(l, 0, pos, 1, 1)
                grid.attach(t, 1, pos, 1, 1)
                pos += 1

            use_regex = None
            if class_obj.allow_regex:
                use_regex = Gtk.CheckButton(label=_('Use regular expressions'))
                tip = _('Interpret the contents of string fields as regular '
                        'expressions.\n'
                        'A decimal point will match any character. '
                        'A question mark will match zero or one occurences '
                        'of the previous character or group. '
                        'An asterisk will match zero or more occurences. '
                        'A plus sign will match one or more occurences. '
                        'Use parentheses to group expressions. '
                        'Specify alternatives using a vertical bar. '
                        'A caret will match the start of a line. '
                        'A dollar sign will match the end of a line.')
                use_regex.set_tooltip_text(tip)
                grid.attach(use_regex, 1, pos, 1, 1)

            self.page.append((class_obj, vallist, tlist, use_regex))

            # put the grid into a scrollable area:
            scrolled_win = Gtk.ScrolledWindow()
            scrolled_win.add(grid)
            scrolled_win.set_policy(Gtk.PolicyType.AUTOMATIC,
                                    Gtk.PolicyType.AUTOMATIC)
            scrolled_win.show()
            self.notebook.append_page(scrolled_win,
                                      Gtk.Label(label=class_obj.name))
            self.class2page[class_obj] = self.page_num
            self.page_num = self.page_num + 1
        self.page_num = 0
        self.store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_PYOBJECT)
        self.ruletree_filter = self.store.filter_new()
        self.ruletree_filter.set_visible_func(self.rtree_visible_func)
        self.selection = self.rname.get_selection()
        col = Gtk.TreeViewColumn(_('Rule Name'),
                                 Gtk.CellRendererText(),
                                 text=0)
        self.rname.append_column(col)
        self.rname.set_model(self.ruletree_filter)

        prev = None
        last_top = None

        top_level = {}
        top_node = {}

        #
        # If editing a rule, get the name so that we can select it later
        #
        sel_node = None
        if self.active_rule is not None:
            self.sel_class = self.active_rule.__class__
        else:
            self.sel_class = None

        keys = sorted(class_list, key=lambda x: x.name, reverse=True)
        catlist = sorted(set(class_obj.category for class_obj in keys))

        for category in catlist:
            top_node[category] = self.store.insert_after(None, last_top)
            top_level[category] = []
            last_top = top_node[category]
            self.store.set(last_top, 0, category, 1, '')

        for class_obj in keys:
            category = class_obj.category
            top_level[category].append(class_obj.name)
            node = self.store.insert_after(top_node[category], prev)
            self.store.set(node, 0, class_obj.name, 1, class_obj)

            # if this is an edit rule, save the node
            if class_obj == self.sel_class:
                sel_node = (top_node[category], node)

        if sel_node:
            self.select_iter(sel_node)
            page = self.class2page[self.active_rule.__class__]
            self.notebook.set_current_page(page)
            self.display_values(self.active_rule.__class__)
            (class_obj, vallist, tlist, use_regex) = self.page[page]
            r = list(self.active_rule.values())
            for i in range(0, min(len(tlist), len(r))):
                tlist[i].set_text(r[i])
            if class_obj.allow_regex:
                use_regex.set_active(self.active_rule.use_regex)

        self.selection.connect('changed', self.on_node_selected)
        self.rname.connect('button-press-event', self._button_press)
        self.rname.connect('key-press-event', self._key_press)
        self.get_widget('rule_editor_ok').connect('clicked', self.rule_ok)
        self.get_widget('rule_editor_cancel').connect('clicked',
                                                      self.close_window)
        self.get_widget('rule_editor_help').connect('clicked',
                                                    self.on_help_clicked)
        self.rname_filter.connect('changed', self.on_rname_filter_changed)

        self._set_size()
        self.show()
示例#3
0
 def create_widget(self):
     widget = Gtk.CheckButton()
     widget.connect('toggled', self.parent_widget.sig_activate)
     widget.connect('focus-out-event',
                    lambda w, e: self.parent_widget._focus_out())
     return widget
示例#4
0
 def __init__(self, start=False, change_handler=None):
     self.control = gtk.CheckButton()
     self.control.set_active(start)
     self.connect("toggled", change_handler)
示例#5
0
    def __init__(self, url_, parent_):
        Gtk.Window.__init__(self, title="Smells")
        self.set_border_width(5)
        self.set_size_request(600, 300)
        self.set_resizable(False)
        self.url = url_
        self.parent = parent_

        r = requests.get(self.url)
        data = r.text.split('\n')
        self.prj_name = data[3]
        self.prj_id = data[4]
        self.api = data[2]
        self.suse_path = (
            os.environ['HOME']
        ) + '/.sawtooth_projects/.' + self.prj_name + '_' + self.prj_id + '/etc/.suse'

        box_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(box_outer)

        # ListStore (lists that TreeViews can display) and specify data types
        projects_list_store = Gtk.ListStore(str, str)

        # Top Section
        self.listbox = Gtk.ListBox()
        self.listbox.set_selection_mode(Gtk.SelectionMode.NONE)
        box_outer.pack_start(self.listbox, True, True, 0)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        #self.tog_pro_act = Gtk.CheckButton("Proposal active days:")
        #self.tog_pro_act.set_active(True)
        #self.tog_pro_act.connect("toggled", self.on_tog_pro_act)
        self.lbl_pro_act = Gtk.Label('Proposal active days:')
        hbox.pack_start(self.lbl_pro_act, True, True, 0)
        self.txt_pro_act = Gtk.Entry()
        self.txt_pro_act.set_text("0")
        hbox.pack_start(self.txt_pro_act, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        #self.tog_app_tre = Gtk.CheckButton("Approval threshold:")
        #self.tog_app_tre.set_active(True)
        #self.tog_app_tre.connect("toggled", self.on_tog_app_tre)
        self.lbl_app_tre = Gtk.Label('Approval treshold:')
        hbox.pack_start(self.lbl_app_tre, True, True, 0)
        self.txt_app_tre = Gtk.Entry()
        self.txt_app_tre.set_text("0")
        hbox.pack_start(self.txt_app_tre, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_large_class = Gtk.CheckButton("Large class:")
        self.tog_large_class.set_active(True)
        self.tog_large_class.connect("toggled", self.on_tog_large_class)
        hbox.pack_start(self.tog_large_class, True, True, 0)
        self.txt_large_class = Gtk.Entry()
        self.txt_large_class.set_text("0")
        hbox.pack_start(self.txt_large_class, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_small_class = Gtk.CheckButton("Small class:")
        self.tog_small_class.set_active(True)
        self.tog_small_class.connect("toggled", self.on_tog_small_class)
        hbox.pack_start(self.tog_small_class, True, True, 0)
        self.txt_small_class = Gtk.Entry()
        self.txt_small_class.set_text("0")
        hbox.pack_start(self.txt_small_class, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_large_method = Gtk.CheckButton("Large method:")
        self.tog_large_method.set_active(True)
        self.tog_large_method.connect("toggled", self.on_tog_large_method)
        hbox.pack_start(self.tog_large_method, True, True, 0)
        self.txt_large_method = Gtk.Entry()
        self.txt_large_method.set_text("0")
        hbox.pack_start(self.txt_large_method, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_small_method = Gtk.CheckButton("Small method:")
        self.tog_small_method.set_active(True)
        self.tog_small_method.connect("toggled", self.on_tog_small_method)
        hbox.pack_start(self.tog_small_method, True, True, 0)
        self.txt_small_method = Gtk.Entry()
        self.txt_small_method.set_text("0")
        hbox.pack_start(self.txt_small_method, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_large_param = Gtk.CheckButton("Large param:")
        self.tog_large_param.set_active(True)
        self.tog_large_param.connect("toggled", self.on_tog_large_param)
        hbox.pack_start(self.tog_large_param, True, True, 0)
        self.txt_large_param = Gtk.Entry()
        self.txt_large_param.set_text("0")
        hbox.pack_start(self.txt_large_param, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_god_class = Gtk.CheckButton("God class:")
        self.tog_god_class.set_active(True)
        self.tog_god_class.connect("toggled", self.on_tog_god_class)
        hbox.pack_start(self.tog_god_class, True, True, 0)
        self.txt_god_class = Gtk.Entry()
        self.txt_god_class.set_text("0")
        hbox.pack_start(self.txt_god_class, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_inapp_intm = Gtk.CheckButton("Inappropriate Intimacy:")
        self.tog_inapp_intm.set_active(True)
        hbox.pack_start(self.tog_inapp_intm, True, True, 0)
        self.tog_inapp_intm.connect("toggled", self.on_tog_inapp_intm)
        self.txt_inapp_intm = Gtk.Entry()
        self.txt_inapp_intm.set_text("0")
        hbox.pack_start(self.txt_inapp_intm, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_ctc_up = Gtk.CheckButton("Comments to code ratio [upper]:")
        self.tog_ctc_up.set_active(True)
        self.tog_ctc_up.connect("toggled", self.on_tog_ctc_up)
        hbox.pack_start(self.tog_ctc_up, True, True, 0)
        self.txt_ctc_up = Gtk.Entry()
        self.txt_ctc_up.set_text("0.0")
        hbox.pack_start(self.txt_ctc_up, False, True, 0)
        self.listbox.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
        self.row.add(hbox)
        self.tog_ctc_lw = Gtk.CheckButton("Comments to code ratio [lower]:")
        self.tog_ctc_lw.set_active(True)
        self.tog_ctc_lw.connect("toggled", self.on_tog_ctc_lw)
        hbox.pack_start(self.tog_ctc_lw, True, True, 0)
        self.txt_ctc_lw = Gtk.Entry()
        self.txt_ctc_lw.set_text("0.0")
        hbox.pack_start(self.txt_ctc_lw, False, True, 0)
        self.listbox.add(self.row)

        # keep going if more rows are required.

        # Bottom section
        self.listbox_3 = Gtk.ListBox()
        self.listbox_3.set_selection_mode(Gtk.SelectionMode.NONE)
        box_outer.pack_start(self.listbox_3, False, True, 0)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
        self.row.add(hbox)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox.pack_start(vbox, True, True, 0)
        self.lbl_project = Gtk.Label(
            'Update the code smells values for the project')
        vbox.pack_start(self.lbl_project, True, False, 0)

        self.button = Gtk.Button.new_with_label("Save")
        self.button.connect("clicked", self.save_smells)
        hbox.pack_start(self.button, False, True, 0)
        self.listbox_3.add(self.row)

        self.row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
        self.row.add(hbox)

        self.lbl_add_fields = Gtk.Label()
        self.lbl_add_fields.set_markup(
            "<a href=\"mailto:[email protected]\" title=\"Email [email protected]\">Contact support ([email protected]) to add more fields</a>"
        )
        hbox.pack_start(self.lbl_add_fields, True, True, 0)
        self.listbox_3.add(self.row)

        self.connect("delete-event", Gtk.main_quit)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.show_all()
示例#6
0
    def prepare_dialog(self, options):

        self.options = options

        grid = Gtk.Grid()
        grid.set_row_spacing(3)
        grid.set_column_spacing(10)
        grid.set_hexpand(True)
        grid.set_border_width(10)
        self.add(grid)

        row_count = 0
        box0 = Gtk.Box(spacing=6)
        grid.attach(Gtk.Label(label="Preamble File"), 0, row_count, 1, 1)
        self.entryPreamble = Gtk.Entry()
        self.entryPreamble.set_text(options.preamble)
        self.entryPreamble.set_hexpand(True)
        box0.pack_start(self.entryPreamble, True, True, 0)
        btnSelectPreamble = Gtk.Button(label="...")
        btnSelectPreamble.set_hexpand(False)
        btnSelectPreamble.connect("clicked", self.on_select_preamble)
        box0.pack_start(btnSelectPreamble, False, False, 0)
        grid.attach(box0, 1, row_count, 1, 1)

        row_count += 1
        grid.attach(Gtk.Label(label="Additional Packages"), 0, row_count, 1, 1)
        self.entryPackages = Gtk.Entry()
        self.entryPackages.set_text(options.packages)
        self.entryPackages.set_hexpand(True)
        grid.attach(self.entryPackages, 1, row_count, 1, 1)

        row_count += 1
        grid.attach(Gtk.Label(label="Document base font size"), 0, row_count, 1, 1)
        self.entryFontsize = Gtk.SpinButton.new_with_range(1, 32, 1)
        self.entryFontsize.set_value(options.fontsize)
        self.entryFontsize.set_hexpand(False)
        grid.attach(self.entryFontsize, 1, row_count, 1, 1)

        row_count += 1
        self.entryScale = Gtk.SpinButton.new_with_range(0.01, 20.0, 0.05)
        self.entryScale.set_digits(2)
        self.entryScale.set_value(options.scale)
        grid.attach(Gtk.Label(label="Scale factor"), 0, row_count, 1, 1)
        grid.attach(self.entryScale, 1, row_count, 1, 1)

        row_count += 1
        self.entryDepth = Gtk.SpinButton.new_with_range(0, 100, 1)
        self.entryDepth.set_value(options.depth)
        grid.attach(Gtk.Label(label="SVG/XML tree max. depth"), 0, row_count, 1, 1)
        grid.attach(self.entryDepth, 1, row_count, 1, 1)

        row_count += 1
        grid.attach(Gtk.Label(label="Add \\\\ at every line break"), 0, row_count, 1, 1)
        self.btnNewline = Gtk.CheckButton()
        self.btnNewline.set_active(options.newline)
        grid.attach(self.btnNewline, 1, row_count, 1, 1)

        row_count += 1
        grid.attach(Gtk.Label(label="Encapsulate all text with ($..$)"), 0, row_count, 1, 1)
        self.btnMath = Gtk.CheckButton()
        self.btnMath.set_active(options.math)
        grid.attach(self.btnMath, 1, row_count, 1, 1)

        row_count += 1
        grid.attach(Gtk.Label(label="Show log messages"), 0, row_count, 1, 1)
        self.btnShowLog = Gtk.CheckButton()
        grid.attach(self.btnShowLog, 1, row_count, 1, 1)

        row_count += 2
        box1 = Gtk.Box(spacing=6)
        grid.attach(box1, 0, row_count, 2, 1)

        btnApply = Gtk.Button(label="Apply")
        btnApply.connect("clicked", self.on_btnApply_clicked)
        box1.pack_end(btnApply, False, False, 0)

        btnClose = Gtk.Button(label="Close")
        btnClose.connect("clicked", self.on_btnClose_clicked)
        box1.pack_end(btnClose, False, False, 0)

        self.show_all()
        self.entryScale.grab_focus()
        btnApply.set_can_default(True)
        btnApply.grab_default()
        btnApply.grab_focus()
        self.set_default(btnApply)
示例#7
0
    def convert_transcription_cb(self, button=None):
        if not self.controller.gui:
            self.message(_("Cannot convert the data: no associated package"))
            return True

        d = Gtk.Dialog(title=_("Converting transcription"),
                       parent=self.controller.gui.gui.win,
                       flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
                       buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                 Gtk.STOCK_OK, Gtk.ResponseType.OK,
                                 ))
        l=Gtk.Label(label=_("Choose the annotation-type where to create annotations.\n"))
        l.set_line_wrap(True)
        l.show()
        d.vbox.pack_start(l, False, True, 0)

        # Anticipated declaration of some widgets, which need to be
        # updated in the handle_new_type_selection callback.
        new_type_dialog=Gtk.VBox()
        delete_existing_toggle=Gtk.CheckButton(_("Delete existing annotations in this type"))
        delete_existing_toggle.set_active(False)

        ats=list(self.controller.package.annotationTypes)
        newat=helper.TitledElement(value=None,
                                   title=_("Create a new annotation type"))
        ats.append(newat)

        def handle_new_type_selection(combo):
            el=combo.get_current_element()
            if el == newat:
                new_type_dialog.show()
                delete_existing_toggle.set_sensitive(False)
            else:
                new_type_dialog.hide()
                delete_existing_toggle.set_sensitive(True)
            return True

        type_selection=dialog.list_selector_widget(members=[ (a, self.controller.get_title(a), self.controller.get_element_color(a)) for a in ats],
                                                   callback=handle_new_type_selection,
                                                   preselect=self.controller.package.get_element_by_id(self.options['annotation-type-id']))

        hb=Gtk.HBox()
        hb.pack_start(Gtk.Label(_("Select type") + " "), False, False, 0)
        hb.pack_start(type_selection, False, True, 0)
        d.vbox.pack_start(hb, False, True, 0)

        l=Gtk.Label(label=_("You want to create a new type. Please specify its schema and title."))
        l.set_line_wrap(True)
        l.show()
        new_type_dialog.pack_start(l, False, True, 0)

        hb=Gtk.HBox()
        hb.pack_start(Gtk.Label(_("Title") + " "), False, False, 0)
        new_title=Gtk.Entry()
        hb.pack_start(new_title, True, True, 0)
        new_type_dialog.pack_start(hb, False, True, 0)

        hb=Gtk.HBox()
        hb.pack_start(Gtk.Label(_("Containing schema") + " "), False, False, 0)
        schemas=list(self.controller.package.schemas)
        schema_selection=dialog.list_selector_widget(members=[ (s, self.controller.get_title(s)) for s in schemas])
        hb.pack_start(schema_selection, False, True, 0)
        new_type_dialog.pack_start(hb, False, True, 0)

        new_type_dialog.show_all()
        new_type_dialog.set_no_show_all(True)
        new_type_dialog.hide()

        d.vbox.pack_start(new_type_dialog, True, True, 0)

        l=Gtk.Label()
        l.set_markup("<b>" + _("Export options") + "</b>")
        d.vbox.pack_start(l, False, True, 0)

        d.vbox.pack_start(delete_existing_toggle, False, True, 0)

        empty_contents_toggle=Gtk.CheckButton(_("Generate annotations for empty contents"))
        empty_contents_toggle.set_active(self.options['empty-annotations'])
        d.vbox.pack_start(empty_contents_toggle, False, True, 0)

        d.connect('key-press-event', dialog.dialog_keypressed_cb)

        d.show_all()
        dialog.center_on_mouse(d)

        finished=None
        while not finished:
            res=d.run()
            if res == Gtk.ResponseType.OK:
                at=type_selection.get_current_element()
                if at == newat:
                    new_type_title=new_title.get_text()
                    if new_type_title == '':
                        # Empty title. Generate one.
                        id_=self.controller.package._idgenerator.get_id(AnnotationType)
                        new_type_title=id_
                    else:
                        id_=helper.title2id(new_type_title)
                        # Check that the id is available
                        if self.controller.package._idgenerator.exists(id_):
                            dialog.message_dialog(
                                _("The %s identifier already exists. Choose another one.") % id_,
                                icon=Gtk.MessageType.WARNING)
                            at=None
                            continue
                    # Creating a new type
                    s=schema_selection.get_current_element()
                    at=s.createAnnotationType(ident=id_)
                    at.author=config.data.userid
                    at.date=helper.get_timestamp()
                    at.title=new_type_title
                    at.mimetype='text/plain'
                    at.setMetaData(config.data.namespace, 'color', next(s.rootPackage._color_palette))
                    at.setMetaData(config.data.namespace, 'item_color', 'here/tag_color')
                    s.annotationTypes.append(at)
                    self.controller.notify('AnnotationTypeCreate', annotationtype=at)

                if delete_existing_toggle.get_active():
                    # Remove all annotations of at type
                    batch_id=object()
                    for a in at.annotations:
                        self.controller.delete_element(a, batch=batch_id)

                self.options['empty-annotations']=empty_contents_toggle.get_active()
                finished=True
            else:
                at=None
                finished=True
        d.destroy()

        if at is not None:
            self.options['annotation-type-id'] = at.id
            ti=TranscriptionImporter(package=self.controller.package,
                                     controller=self.controller,
                                     defaulttype=at,
                                     transcription_edit=self)
            ti.process_file('transcription')

            self.controller.package._modified=True
            self.controller.notify("PackageActivate", package=ti.package)
            self.message(_('Notes converted'))
            self.log(ti.statistics_formatted())
            # Feedback
            dialog.message_dialog(
                _("Conversion completed.\n%s annotations generated.") % ti.statistics['annotation'])

        return True
    def _init_ui(self):
        app = self.app

        # Dialog for showing and editing the axis value directly
        buttons = (Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
        dialog = gui.windowing.Dialog(
            app, C_(
                "symmetry axis options panel: "
                "axis position dialog: window title",
                u"X axis Position",
            ),
            app.drawWindow,
            buttons=buttons,
        )
        dialog.connect('response', self._axis_pos_dialog_response_cb)
        grid = Gtk.Grid()
        grid.set_border_width(gui.widgets.SPACING_LOOSE)
        grid.set_column_spacing(gui.widgets.SPACING)
        grid.set_row_spacing(gui.widgets.SPACING)
        label = Gtk.Label(label=self._POSITION_LABEL_X_TEXT)
        label.set_hexpand(False)
        label.set_vexpand(False)
        grid.attach(label, 0, 0, 1, 1)
        entry = Gtk.SpinButton(
            adjustment=self._axis_pos_adj_x,
            climb_rate=0.25,
            digits=0
        )
        entry.set_hexpand(True)
        entry.set_vexpand(False)
        grid.attach(entry, 1, 0, 1, 1)
        dialog_content_box = dialog.get_content_area()
        dialog_content_box.pack_start(grid, True, True, 0)
        self._axis_pos_x_dialog = dialog

        # Dialog for showing and editing the axis value directly
        buttons = (Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
        dialog = gui.windowing.Dialog(
            app, C_(
                "symmetry axis options panel: "
                "axis position dialog: window title",
                u"Y axis Position",
            ),
            app.drawWindow,
            buttons=buttons,
        )
        dialog.connect('response', self._axis_pos_dialog_response_cb)
        grid = Gtk.Grid()
        grid.set_border_width(gui.widgets.SPACING_LOOSE)
        grid.set_column_spacing(gui.widgets.SPACING)
        grid.set_row_spacing(gui.widgets.SPACING)
        label = Gtk.Label(label=self._POSITION_LABEL_Y_TEXT)
        label.set_hexpand(False)
        label.set_vexpand(False)
        grid.attach(label, 0, 0, 1, 1)
        entry = Gtk.SpinButton(
            adjustment=self._axis_pos_adj_y,
            climb_rate=0.25,
            digits=0
        )
        entry.set_hexpand(True)
        entry.set_vexpand(False)
        grid.attach(entry, 1, 0, 1, 1)
        dialog_content_box = dialog.get_content_area()
        dialog_content_box.pack_start(grid, True, True, 0)
        self._axis_pos_y_dialog = dialog

        # Layout grid
        row = 0
        grid = Gtk.Grid()
        grid.set_border_width(gui.widgets.SPACING_CRAMPED)
        grid.set_row_spacing(gui.widgets.SPACING_CRAMPED)
        grid.set_column_spacing(gui.widgets.SPACING_CRAMPED)
        self.add(grid)

        row += 1
        label = Gtk.Label(label=self._ALPHA_LABEL_TEXT)
        label.set_hexpand(False)
        label.set_halign(Gtk.Align.START)
        grid.attach(label, 0, row, 1, 1)
        scale = Gtk.Scale.new_with_range(
            orientation = Gtk.Orientation.HORIZONTAL,
            min = 0,
            max = 1,
            step = 0.1,
        )
        scale.set_draw_value(False)
        line_alpha = self.app.preferences.get(_ALPHA_PREFS_KEY, _DEFAULT_ALPHA)
        scale.set_value(line_alpha)
        scale.set_hexpand(True)
        scale.set_vexpand(False)
        scale.connect("value-changed", self._scale_value_changed_cb)
        grid.attach(scale, 1, row, 1, 1)

        row += 1
        store = Gtk.ListStore(int, str)
        sym_types = lib.tiledsurface.SYMMETRY_TYPES
        active_idx = 0
        rootstack = self.app.doc.model.layer_stack
        starts_with_rotate = (
            rootstack.symmetry_type in
            {
                lib.mypaintlib.SymmetryRotational,
                lib.mypaintlib.SymmetrySnowflake,
            }
        )
        for i, sym_type in enumerate(sym_types):
            label = lib.tiledsurface.SYMMETRY_STRINGS.get(sym_type)
            store.append([sym_type, label])
            if sym_type == rootstack.symmetry_type:
                active_idx = i
        self._symmetry_type_combo = Gtk.ComboBox()
        self._symmetry_type_combo.set_model(store)
        self._symmetry_type_combo.set_active(active_idx)
        self._symmetry_type_combo.set_hexpand(True)
        cell = Gtk.CellRendererText()
        self._symmetry_type_combo.pack_start(cell, True)
        self._symmetry_type_combo.add_attribute(cell, "text", 1)
        self._symmetry_type_combo.connect(
            'changed',
            self._symmetry_type_combo_changed_cb
        )
        label = Gtk.Label(label=self._SYMMETRY_TYPE_TEXT)
        label.set_hexpand(False)
        label.set_halign(Gtk.Align.START)
        grid.attach(label, 0, row, 1, 1)
        grid.attach(self._symmetry_type_combo, 1, row, 1, 1)

        row += 1
        label = Gtk.Label(label=self._SYMMETRY_ROT_LINES_TEXT)
        label.set_hexpand(False)
        label.set_halign(Gtk.Align.START)
        self._axis_rot_sym_lines_entry = Gtk.SpinButton(
            adjustment=self._axis_rot_symmetry_lines,
            climb_rate=0.25
        )
        grid.attach(label, 0, row, 1, 1)
        grid.attach(self._axis_rot_sym_lines_entry, 1, row, 1, 1)

        row += 1
        label = Gtk.Label(label=self._POSITION_LABEL_X_TEXT)
        label.set_hexpand(False)
        label.set_halign(Gtk.Align.START)
        button = Gtk.Button(label=self._POSITION_BUTTON_TEXT_INACTIVE)
        button.set_vexpand(False)
        button.connect("clicked", self._axis_pos_x_button_clicked_cb)
        button.set_hexpand(True)
        button.set_vexpand(False)
        grid.attach(label, 0, row, 1, 1)
        grid.attach(button, 1, row, 1, 1)
        self._axis_pos_x_button = button

        row += 1
        label = Gtk.Label(label=self._POSITION_LABEL_Y_TEXT)
        label.set_hexpand(False)
        label.set_halign(Gtk.Align.START)
        button = Gtk.Button(label=self._POSITION_BUTTON_TEXT_INACTIVE)
        button.set_vexpand(False)
        button.connect("clicked", self._axis_pos_y_button_clicked_cb)
        button.set_hexpand(True)
        button.set_vexpand(False)
        grid.attach(label, 0, row, 1, 1)
        grid.attach(button, 1, row, 1, 1)
        self._axis_pos_y_button = button

        row += 1
        button = Gtk.CheckButton()
        toggle_action = self.app.find_action("SymmetryActive")
        button.set_related_action(toggle_action)
        button.set_label(C_(
            "symmetry axis options panel: axis active checkbox",
            u'Enabled',
        ))
        button.set_hexpand(True)
        button.set_vexpand(False)
        grid.attach(button, 1, row, 2, 1)
        self._axis_active_button = button
示例#9
0
    def __init__(self, win):
        # Show the Display brand and model
        self.model = get_model()
        info_message = _(" (Changing this requires a reboot)")

        # And the current display resolution
        try:
            current_resolution = get_status()['resolution']
            info_message += _("\n\nCurrent resolution: {}").format(_(current_resolution))
        except:
            pass

        Template.__init__(
            self,
            _("Display"),
            self.model + info_message,
            _("APPLY CHANGES")
        )

        self.win = win
        self.win.set_main_widget(self)

        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        self.kano_button.connect('button-release-event', self.apply_changes)
        self.kano_button.connect('key-release-event', self.apply_changes)

        horizontal_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                       spacing=40)
        horizontal_container.set_valign(Gtk.Align.CENTER)

        # HDMI mode combo box
        self.mode_combo = KanoComboBox(max_display_items=7)
        self.mode_combo.connect('changed', self.on_mode_changed)

        # Fill list of modes
        modes = list_supported_modes()
        self.mode_combo.append('auto')
        if modes:
            for v in modes:
                self.mode_combo.append(v)

        horizontal_container.pack_start(self.mode_combo, False, False, 0)
        self.mode_combo.props.valign = Gtk.Align.CENTER

        # Select the current setting in the dropdown list
        saved_group, saved_mode = read_hdmi_mode()
        active_item = find_matching_mode(modes, saved_group, saved_mode)
        self.mode_combo.set_selected_item_index(active_item)
        self.init_item = active_item
        self.mode_index = active_item
        # Overscan button
        overscan_button = OrangeButton(_("Overscan"))
        horizontal_container.pack_end(overscan_button, False, False, 0)
        overscan_button.connect('button-release-event', self.go_to_overscan)

        self.box.pack_start(horizontal_container, False, False, 0)

        # Create Flip 180 checkbox
        flip_button = Gtk.CheckButton(_("Flip Screen"))
        flip_button.set_can_focus(False)
        flip_button.props.valign = Gtk.Align.CENTER
        flip_button.set_active(get_screen_value('display_rotate') == 2)
        flip_button.connect('clicked', self.flip)

        self.box.pack_start(flip_button, False, False, 0)
        self.kano_button.set_sensitive(False)

        # Add apply changes button under the main settings content
        self.win.show_all()
    def __init__(self,
                 element_obj,
                 value='',
                 title='',
                 description='',
                 editable=True,
                 deletable=False,
                 deleted=False):

        self._element_obj = element_obj

        self._deletable = True

        self._widget = Gtk.Box()
        self._widget.set_orientation(Gtk.Orientation.VERTICAL)
        self._widget.set_margin_top(5)
        self._widget.set_margin_start(5)
        self._widget.set_margin_end(5)
        self._widget.set_margin_bottom(5)
        self._widget.set_spacing(5)

        self._value_widget = Gtk.Image()
        self._value_widget_sw = Gtk.ScrolledWindow()
        self._value_widget_sw.set_size_request(200, 200)
        self._value_widget_sw.add(self._value_widget)

        self._image_buttons = Gtk.ButtonBox()
        self._image_buttons.set_orientation(Gtk.Orientation.HORIZONTAL)

        open_img_button = Gtk.Button("Open..")
        open_img_button.set_no_show_all(True)
        self._open_img_button = open_img_button
        open_img_button.connect('clicked', self._on_open_img_button_clicked)

        save_img_button = Gtk.Button("Save..")

        self._image_buttons.pack_start(open_img_button, False, False, 0)
        self._image_buttons.pack_start(save_img_button, False, False, 0)

        self._title_widget_box = Gtk.Box()
        self._title_widget_box.set_orientation(Gtk.Orientation.HORIZONTAL)
        self._title_widget_box.show_all()

        present_button = Gtk.CheckButton()
        self._present_button = present_button
        present_button.set_no_show_all(True)
        present_button.hide()

        self._title = Gtk.Label()
        self._title.set_alignment(0, 0.5)
        self._title.set_no_show_all(True)
        self._title.hide()

        self._description = Gtk.Label()
        self._description.set_alignment(0, 0.5)
        self._description.set_no_show_all(True)
        self._description.hide()

        self._title_widget_box.pack_start(present_button, False, False, 0)
        self._title_widget_box.pack_start(self._title, True, True, 0)

        self._widget.pack_start(self._value_widget_sw, False, False, 0)
        self._widget.pack_start(self._image_buttons, False, False, 0)
        self._widget.pack_start(self._description, False, False, 0)

        self._frame = Gtk.Frame()
        self._frame.set_no_show_all(True)
        self._frame.hide()
        self._frame.add(self._widget)
        self._frame.set_label_widget(self._title_widget_box)

        self._widget.show_all()

        self.set_value(value)
        self.set_title(title)
        self.set_description(description)
        self.set_deletable(deletable)
        self.set_deleted(deleted)
        self.set_editable(editable)

        return
示例#11
0
    def __init__(self, setting):

        super().__init__()
        self.setting = setting
        # maingrid
        maingrid = Gtk.Grid()
        maingrid.set_column_homogeneous(False)
        maingrid.set_border_width(10)
        self.add(maingrid)
        # uptime section
        uptime_label = Gtk.Label("Work time (min):\t", xalign=0)
        maingrid.attach(uptime_label, 0, 0, 1, 1)
        uptime_set = tab_settings.get_int("awaketime")
        uptime = Gtk.SpinButton.new_with_range(1, 90, 1)
        uptime.set_value(uptime_set)
        uptime.connect("value-changed", self.update_setting, "awaketime")
        maingrid.attach(uptime, 1, 0, 1, 1)
        # breaktime section
        breaktime_label = Gtk.Label("Break time (min):\t", xalign=0)
        maingrid.attach(breaktime_label, 0, 1, 1, 1)
        breaktime_set = tab_settings.get_int("sleeptime")
        breaktime = Gtk.SpinButton.new_with_range(1, 90, 1)
        breaktime.set_value(breaktime_set)
        breaktime.connect("value-changed", self.update_setting, "sleeptime")
        maingrid.attach(breaktime, 1, 1, 1, 1)
        # sep below time section
        maingrid.attach(Gtk.Label("\n"), 0, 5, 1, 1)
        # show notifications checkbox
        shownotify = Gtk.CheckButton("Show notifications")
        notify_set = tab_settings.get_boolean("showmessage")
        shownotify.set_active(notify_set)
        shownotify.connect("toggled", self.update_setting, "showmessage")
        maingrid.attach(shownotify, 0, 6, 4, 1)
        # smart resume checkbox
        smartres = Gtk.CheckButton("Smart resume")
        smartres_set = tab_settings.get_boolean("smartresume")
        smartres.set_active(smartres_set)
        smartres.connect("toggled", self.update_setting, "smartresume")
        smartres.set_tooltip_text(
            "After a break, start count down when user is active")
        maingrid.attach(smartres, 0, 7, 4, 1)
        # automatically unlock checkbox
        autounlock = Gtk.CheckButton("Automatically unlock after break")
        autounlock_set = tab_settings.get_boolean("unlockafterbreak")
        autounlock.set_active(autounlock_set)
        autounlock.connect("toggled", self.update_setting, "unlockafterbreak")
        autounlock.set_tooltip_text(
            "After a break, automatically unlock screen")
        maingrid.attach(autounlock, 0, 8, 4, 1)
        # sep below  section
        maingrid.attach(Gtk.Label("\n"), 0, 9, 1, 1)
        # option label
        breaktime_label = Gtk.Label("Effect:\n", xalign=0)
        maingrid.attach(breaktime_label, 0, 10, 1, 1)
        # dropdown
        self.effect_options = [
            ["rotate", "Screen upside down"],
            ["dim", "Dim screen"],
            ["message", "Countdown message"],
            ["lock", "Lock screen"],
        ]
        effect_set = tab_settings.get_string("mode")
        effect_index = [s[0] for s in self.effect_options].index(effect_set)
        effect_box = Gtk.Box()
        command_combo = Gtk.ComboBoxText()
        command_combo.set_entry_text_column(0)
        for cmd in self.effect_options:
            command_combo.append_text(cmd[1])
        command_combo.set_active(effect_index)
        command_combo.connect("changed", self.update_setting, "mode")
        maingrid.attach(effect_box, 0, 11, 2, 1)
        effect_box.pack_start(command_combo, False, True, 0)
        self.show_all()
    def __init__(self,
                 element_obj,
                 value='',
                 title='',
                 description='',
                 editable=True,
                 deletable=False,
                 deleted=False,
                 momentarily_deletable=None):
        """
        momentarily_deletable must be None or callable with one parameter,
        which receives instance of object to remove (self)
        """

        self._element_obj = element_obj
        self._momentarily_deletable = momentarily_deletable

        self._deletable = True

        self._widget = Gtk.Box()
        self._widget.set_orientation(Gtk.Orientation.VERTICAL)
        self._widget.set_margin_top(5)
        self._widget.set_margin_start(5)
        self._widget.set_margin_end(5)
        self._widget.set_margin_bottom(5)
        self._widget.set_spacing(5)

        self._value_widget = Gtk.Label()

        self._title_widget_box = Gtk.Box()
        self._title_widget_box.set_orientation(Gtk.Orientation.HORIZONTAL)
        self._title_widget_box.show_all()

        present_button = Gtk.CheckButton()
        self._present_button = present_button
        present_button.set_no_show_all(True)
        present_button.hide()

        self._title = Gtk.Label()
        self._title.set_alignment(0, 0.5)
        self._title.set_no_show_all(True)
        self._title.hide()

        self._description = Gtk.Label()
        self._description.set_alignment(0, 0.5)
        self._description.set_no_show_all(True)
        self._description.hide()

        self._title_widget_box.pack_start(present_button, False, False, 0)
        self._title_widget_box.pack_start(self._title, True, True, 0)

        delete_button = Gtk.Button('x')
        delete_button.set_no_show_all(True)
        delete_button.hide()
        self._delete_button = delete_button
        delete_button.connect('clicked', self._on_delete_button_clicked)
        self._title_widget_box.pack_start(delete_button, False, False, 0)

        self._widget.pack_start(self._value_widget, False, False, 0)
        self._widget.pack_start(self._description, False, False, 0)

        self._frame = Gtk.Frame()
        self._frame.set_no_show_all(True)
        self._frame.hide()
        self._frame.add(self._widget)
        self._frame.set_label_widget(self._title_widget_box)

        self._widget.show_all()

        self.set_value(value)
        self.set_title(title)
        self.set_description(description)
        self.set_deletable(deletable)
        self.set_deleted(deleted)
        self.set_editable(editable)

        return
示例#13
0
    def __init__(self):
        Gtk.Window.__init__(self, title="ListBox 测试")
        self.set_border_width(10)

        box_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(box_outer)

        listbox = Gtk.ListBox()
        listbox.set_selection_mode(Gtk.SelectionMode.NONE)
        box_outer.pack_start(listbox, True, True, 0)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        row.add(hbox)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox.pack_start(vbox, True, True, 0)

        label1 = Gtk.Label("Automatic Date & Time", xalign=0)
        label2 = Gtk.Label("Requires internet access", xalign=0)
        vbox.pack_start(label1, True, True, 0)
        vbox.pack_start(label2, True, True, 0)

        switch = Gtk.Switch()
        switch.props.valign = Gtk.Align.CENTER
        hbox.pack_start(switch, False, True, 0)

        listbox.add(row)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        row.add(hbox)
        label = Gtk.Label("Enable Automatic Update", xalign=0)
        check = Gtk.CheckButton()
        hbox.pack_start(label, True, True, 0)
        hbox.pack_start(check, False, True, 0)

        listbox.add(row)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        row.add(hbox)
        label = Gtk.Label("Date Format", xalign=0)
        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)

        listbox_2 = Gtk.ListBox()
        items = 'This is a sorted ListBox Fail'.split()

        for item in items:
            listbox_2.add(ListBoxRowWithData(item))

        def sort_func(row_1, row_2, data, notify_destroy):
            return row_1.data.lower() > row_2.data.lower()

        def filter_func(row, data, notify_destroy):
            return False if row.data == 'Fail' else True

        listbox_2.set_sort_func(sort_func, None, False)
        listbox_2.set_filter_func(filter_func, None, False)

        def on_row_activated(listbox_widget, row):
            print(row.data)

        listbox_2.connect('row-activated', on_row_activated)

        box_outer.pack_start(listbox_2, True, True, 0)
        listbox_2.show_all()
示例#14
0
文件: liveusb.py 项目: Mrmohanak/occ
    def __init__(self,ccw):
        self.__dev = bus.get_object(interface, "/org/freedesktop/UDisks")
        PluginsClass.__init__(self, ccw, caption, category, priority)
        vb=Gtk.VBox(False,2)
        self.add(vb)
        h=Gtk.HBox(False,2); vb.pack_start(h,False,False,6)
        l=Gtk.Label(description)
        h.pack_start(l,False,False,2)
        hb=Gtk.HBox(False,2); vb.pack_start(hb,False,False,6)
        hb.pack_start(Gtk.Label(_('Source:')), False,False,2)
        self.src_iso_file=Gtk.RadioButton.new_with_label_from_widget(None, label=_('from iso file'))
        hb.pack_start(self.src_iso_file, False,False,2)
        h=Gtk.HBox(False,2); hb.pack_start(h,False,False,2)
        self.iso_file_b=Gtk.FileChooserButton(_('Choose live iso file'))
        h.pack_start(self.iso_file_b, False,False,2)
        self.src_iso_file.connect('toggled', lambda b: self.iso_file_b.set_sensitive(b.get_active()))
        
        self.src_iso_dev=Gtk.RadioButton.new_with_label_from_widget(self.src_iso_file, label=_('from CD/DVD device'))
        hb.pack_start(self.src_iso_dev, False,False,2)
        self.src_iso_dev_h=h=Gtk.HBox(False,2); hb.pack_start(h,False,False,2)
        self.src_iso_dev.connect('toggled', lambda b: self.src_iso_dev_h.set_sensitive(b.get_active()))
        self.iso_dev_ls=Gtk.ComboBoxText()
        h.pack_start(self.iso_dev_ls, False,False,2)
        b=Gtk.Button(stock=Gtk.STOCK_REFRESH)
        b.connect('clicked', self.refresh_src_dev)
        h.pack_start(b, False,False,2)
        self.src_iso_dev.set_active(True)
        self.src_iso_file.set_active(True)

        h=Gtk.HBox(False,2); vb.pack_start(h,False,False,6)
        h.pack_start(Gtk.Label(_('Target Device:')), False,False,2)
        self.target_dev_ls=Gtk.ComboBoxText()
        h.pack_start(self.target_dev_ls, True,True,2)
        b=Gtk.Button(stock=Gtk.STOCK_REFRESH)
        b.connect('clicked', self.refresh_target_dev)
        h.pack_start(b, False,False,2)

        h=Gtk.HBox(False,2); vb.pack_start(h,False,False,6)
        h.pack_start(Gtk.Label(_('Target Options:')), False,False,2)
        self.format=Gtk.CheckButton(_('Format target partition'))
        self.format.set_tooltip_text(_('uncheck this button to preserve data on target device'))
        h.pack_start(self.format, False,False,2)
        self.reset_mbr=Gtk.CheckButton(_('Reset MBR'))
        self.reset_mbr.set_active(True)
        h.pack_start(self.reset_mbr, False,False,2)
        h.pack_start(Gtk.Label(_('Overlay size:')), False,False,2)
        self.overlay_size=Gtk.SpinButton()
        self.overlay_size.set_tooltip_text(_('size of persistent overlay in MB, 0 to disable'))
        self.overlay_size.set_adjustment(Gtk.Adjustment(200, 0, 10240, 10, 0, 0))
        h.pack_start(self.overlay_size, False,False,2)
        h.pack_start(Gtk.Label(_('MB')), False,False,0)
#        TODO: all the below options needs interaction to enter the pass-phrase
#        h.pack_start(Gtk.Label('Home image size:'), False,False,2)
#        self.home_size=Gtk.SpinButton()
#        self.home_size.set_tooltip_text(_('size of home image in MB, 0 to use the overlay'))
#        self.home_size.set_range(0,10240)
#        self.home_size.set_value(0)
#        h.pack_start(self.home_size, False,False,2)
#        self.home_enc=Gtk.CheckButton(_('encrypted'))
#        self.home_enc.set_tooltip_text(_('Encrypt Home image'))
        h=Gtk.HBox(False,2); vb.pack_start(h,False,False,6)
        b=Gtk.Button(stock=Gtk.STOCK_EXECUTE)
        b.connect('clicked', self.execute)
        h.pack_start(b, False,False,2)
        h.pack_start(Gtk.Label(_("This will take some time.")), False,False,2)

        ff=Gtk.FileFilter(); ff.add_pattern('*.[Ii][Ss][Oo]')
        self.iso_file_b.set_filter(ff)
        self.refresh_src_dev()
        self.refresh_target_dev()
示例#15
0
    def __init__(self):
        Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL)

        self.set_default_size(500, 500)
        self.connect("destroy", lambda x: Gtk.main_quit())
        self.set_title("OpenStreetMap GPS Mapper")

        self.vbox = Gtk.VBox(homogeneous=False, spacing=0)
        self.add(self.vbox)

        if 0:
            self.osm = DummyMapNoGpsPoint()
        else:
            self.osm = osmgpsmap.Map()
        self.osm.layer_add(
            osmgpsmap.MapOsd(show_dpad=True,
                             show_zoom=True,
                             show_crosshair=True))
        self.osm.set_property("map-source",
                              osmgpsmap.MapSource_t.OPENSTREETMAP)
        self.osm.layer_add(DummyLayer())

        self.last_image = None

        self.osm.connect("button_press_event", self.on_button_press)
        self.osm.connect("changed", self.on_map_change)

        # connect keyboard shortcuts
        self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.FULLSCREEN,
                                       Gdk.keyval_from_name("F11"))
        self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.UP,
                                       Gdk.keyval_from_name("Up"))
        self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.DOWN,
                                       Gdk.keyval_from_name("Down"))
        self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.LEFT,
                                       Gdk.keyval_from_name("Left"))
        self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.RIGHT,
                                       Gdk.keyval_from_name("Right"))

        # connect to tooltip
        self.osm.props.has_tooltip = True
        self.osm.connect("query-tooltip", self.on_query_tooltip)

        self.latlon_entry = Gtk.Entry()

        zoom_in_button = Gtk.Button.new_from_icon_name("zoom-in",
                                                       Gtk.IconSize.BUTTON)
        zoom_in_button.connect("clicked", self.zoom_in_clicked)
        zoom_out_button = Gtk.Button.new_from_icon_name(
            "zoom-out", Gtk.IconSize.BUTTON)
        zoom_out_button.connect("clicked", self.zoom_out_clicked)
        home_button = Gtk.Button.new_from_icon_name("go-home",
                                                    Gtk.IconSize.BUTTON)
        home_button.connect("clicked", self.home_clicked)
        cache_button = Gtk.Button(label="Cache")
        cache_button.connect("clicked", self.cache_clicked)

        self.vbox.pack_start(self.osm, True, True, 0)
        hbox = Gtk.HBox(homogeneous=False, spacing=0)
        hbox.pack_start(zoom_in_button, False, True, 0)
        hbox.pack_start(zoom_out_button, False, True, 0)
        hbox.pack_start(home_button, False, True, 0)
        hbox.pack_start(cache_button, False, True, 0)

        # add ability to test custom map URIs
        ex = Gtk.Expander(label="<b>Map Repository URI</b>")
        ex.props.use_markup = True
        vb = Gtk.VBox()
        self.repouri_entry = Gtk.Entry()
        self.repouri_entry.set_text(self.osm.props.repo_uri)
        self.image_format_entry = Gtk.Entry()
        self.image_format_entry.set_text(self.osm.props.image_format)

        lbl = Gtk.Label(label="""Enter an repository URL to fetch map tiles \
from in the box below. Special metacharacters may be included in this url

<i>Metacharacters:</i>
\t#X\tMax X location
\t#Y\tMax Y location
\t#Z\tMap zoom (0 = min zoom, fully zoomed out)
\t#S\tInverse zoom (max-zoom - #Z)
\t#Q\tQuadtree encoded tile (qrts)
\t#W\tQuadtree encoded tile (1234)
\t#U\tEncoding not implemeted
\t#R\tRandom integer, 0-4""")
        lbl.props.xalign = 0
        lbl.props.use_markup = True
        lbl.props.wrap = True

        ex.add(vb)
        vb.pack_start(lbl, False, True, 0)

        hb = Gtk.HBox()
        hb.pack_start(Gtk.Label(label="URI: "), False, True, 0)
        hb.pack_start(self.repouri_entry, True, True, 0)
        vb.pack_start(hb, False, True, 0)

        hb = Gtk.HBox()
        hb.pack_start(Gtk.Label(label="Image Format: "), False, True, 0)
        hb.pack_start(self.image_format_entry, True, True, 0)
        vb.pack_start(hb, False, True, 0)

        gobtn = Gtk.Button(label="Load Map URI")
        gobtn.connect("clicked", self.load_map_clicked)
        vb.pack_start(gobtn, False, True, 0)

        self.show_tooltips = False
        cb = Gtk.CheckButton(label="Show Location in Tooltips")
        cb.props.active = self.show_tooltips
        cb.connect("toggled", self.on_show_tooltips_toggled)
        self.vbox.pack_end(cb, False, True, 0)

        cb = Gtk.CheckButton(label="Disable Cache")
        cb.props.active = False
        cb.connect("toggled", self.disable_cache_toggled)
        self.vbox.pack_end(cb, False, True, 0)

        self.vbox.pack_end(ex, False, True, 0)
        self.vbox.pack_end(self.latlon_entry, False, True, 0)
        self.vbox.pack_end(hbox, False, True, 0)

        GLib.timeout_add(500, self.print_tiles)
示例#16
0
 def add(self, key):
     sections = key.split('-')
     if sections[1] == 'display':
         item = Gtk.CheckButton(label=_('Display'))
         item.set_active(self.schema.get_boolean(key))
         self.hbox0.add(item)
         item.connect('toggled', set_boolean, self.schema, key)
     elif sections[1] == 'refresh':
         item = IntSelect(_('Refresh Time'))
         item.set_args(50, 100000, 100, 1000)
         item.set_value(self.schema.get_int(key))
         self.hbox1.add(item.actor)
         item.spin.connect('output', set_int, self.schema, key)
     elif sections[1] == 'graph' and sections[2] == 'width':
         item = IntSelect(_('Graph Width'))
         item.set_args(1, 1000, 1, 10)
         item.set_value(self.schema.get_int(key))
         self.hbox1.add(item.actor)
         item.spin.connect('output', set_int, self.schema, key)
     elif sections[1] == 'show' and sections[2] == 'text':
         item = Gtk.CheckButton(label=_('Show Text'))
         item.set_active(self.schema.get_boolean(key))
         self.hbox0.add(item)
         item.connect('toggled', set_boolean, self.schema, key)
     elif sections[1] == 'style':
         item = Select(_('Display Style'))
         item.add((_('digit'), _('graph'), _('both')))
         item.set_value(self.schema.get_enum(key))
         self.hbox1.add(item.actor)
         item.selector.connect('changed', set_enum, self.schema, key)
     elif sections[1] == 'speed':
         item = Gtk.CheckButton(label=_('Show network speed in bits'))
         item.set_active(self.schema.get_boolean(key))
         self.hbox3.add(item)
         item.connect('toggled', set_boolean, self.schema, key)
     elif len(sections) == 3 and sections[2] == 'color':
         item = ColorSelect(_(sections[1].capitalize()))
         item.set_value(self.schema.get_string(key))
         self.hbox2.pack_end(item.actor, True, False, 0)
         item.picker.connect('color-set', set_color, self.schema, key)
     elif sections[1] == 'sensor':
         _slist, _strlist = check_sensors()
         item = Select(_('Sensor'))
         if (len(_slist) == 0):
             item.add((_('Please install lm-sensors'), ))
         if (len(_slist) == 1):
             self.schema.set_string(key, _slist[0])
         item.add(_strlist)
         try:
             item.set_value(_slist.index(self.schema.get_string(key)))
         except ValueError:
             item.set_value(0)
         self.hbox3.add(item.actor)
         item.selector.connect('changed', set_string, self.schema, key,
                               _slist)
     elif sections[1] == 'time':
         item = Gtk.CheckButton(label=_('Show Time Remaining'))
         item.set_active(self.schema.get_boolean(key))
         self.hbox3.add(item)
         item.connect('toggled', set_boolean, self.schema, key)
     elif sections[1] == 'hidesystem':
         item = Gtk.CheckButton(label=_('Hide System Icon'))
         item.set_active(self.schema.get_boolean(key))
         self.hbox3.add(item)
         item.connect('toggled', set_boolean, self.schema, key)
     elif sections[1] == 'usage':
         item = Select(_('Display disk usage as'))
         item.add((_('pie'), _('bar'), _('none')))
         item.set_value(self.schema.get_enum(key))
         self.hbox3.add(item.actor)
         item.selector.connect('changed', set_enum, self.schema, key)
# test Gtk.RadioButton:

radio_1 = Gtk.RadioButton.new_with_label_from_widget(None, 'Radio 1')
box.pack_start(radio_1, False, False, 1)
radio_1.show()
radio_2 = Gtk.RadioButton.new_with_label_from_widget(radio_1, 'Radio 2')
box.pack_start(radio_2, False, False, 1)
radio_2.show()
radio_3 = Gtk.RadioButton.new_with_label_from_widget(radio_1, 'Radio 3')
box.pack_start(radio_3, False, False, 1)
radio_3.show()

# test Gtk.CheckButton:

check_1 = Gtk.CheckButton('Check 1')
box.pack_start(check_1, False, False, 1)
check_1.show()

check_2 = Gtk.CheckButton('Check 2')
box.pack_start(check_2, False, False, 1)
check_2.show()

# test Gtk.Button:

button = Gtk.Button('Button')
box.pack_start(button, False, False, 1)
button.show()

# test Gtk.Button insensitive:
示例#18
0
    def __init__(self, main):
        Gtk.Window.__init__(self)
        self.progress_dict = {}
        self.progress_phase = 0
        self.progress_books_in_file = 0
        self.progress_element = 0
        self.add_dlg = None
        self.set_size_request(-1, 400)
        ## prepare dnd
        self.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY)
        self.drag_dest_set_target_list(targets)
        self.connect('drag-data-received', self.drop_data_cb)
        self.set_title(_('Import Shamela .bok files'))
        self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
        self.set_modal(True)
        self.set_transient_for(main)
        self.main = main
        self.connect('delete-event', self.close_cb)
        self.connect('destroy', self.close_cb)
        vb = Gtk.VBox(False, 2)
        self.add(vb)
        hb0 = Gtk.HBox(False, 2)
        vb.pack_start(hb0, False, False, 2)
        self.tool = hb = Gtk.HBox(False, 2)
        hb0.pack_start(hb, False, False, 2)
        b = Gtk.Button(stock=Gtk.STOCK_ADD)
        b.connect('clicked', self.add_cb, self)
        hb.pack_start(b, False, False, 2)
        b = Gtk.Button(stock=Gtk.STOCK_REMOVE)
        b.connect('clicked', self.rm)
        hb.pack_start(b, False, False, 2)
        b = Gtk.Button(stock=Gtk.STOCK_CLEAR)
        b.connect('clicked', lambda *a: self.ls.clear())
        hb.pack_start(b, False, False, 2)
        b = Gtk.Button(stock=Gtk.STOCK_CONVERT)
        b.connect('clicked', self.start)
        hb.pack_start(b, False, False, 2)
        self.progress = Gtk.ProgressBar()
        self.progress.set_fraction(0.0)
        hb0.pack_start(self.progress, True, True, 2)
        self.cancel_b = b = Gtk.Button(stock=Gtk.STOCK_CANCEL)
        b.connect('clicked', self.stop)
        b.set_sensitive(False)
        hb0.pack_start(b, False, False, 2)

        self.close_b = b = Gtk.Button(stock=Gtk.STOCK_CLOSE)
        b.connect('clicked', self.close_cb)
        hb0.pack_start(b, False, False, 2)

        self.ls = Gtk.ListStore(str, str, float, int,
                                str)  # fn, basename, percent, pulse, label
        self.lsv = Gtk.TreeView(self.ls)
        #self.lsv.set_size_request(250, -1)
        cells = []
        cols = []
        cells.append(Gtk.CellRendererText())
        cols.append(Gtk.TreeViewColumn('Files', cells[-1], text=1))
        cols[-1].set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
        cols[-1].set_resizable(True)
        cols[-1].set_expand(True)
        cells.append(Gtk.CellRendererProgress())
        cols.append(
            Gtk.TreeViewColumn('%', cells[-1], value=2, pulse=3, text=4))
        cols[-1].set_expand(False)
        self.lsv.set_headers_visible(True)
        self.lsv.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)

        for i in cols:
            self.lsv.insert_column(i, -1)

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scroll.add(self.lsv)
        vb.pack_start(scroll, True, True, 2)

        self.x = x = Gtk.Expander.new(_("Advanced options"))
        vb.pack_start(x, False, False, 2)

        xvb = Gtk.VBox(False, 2)
        x.add(xvb)

        f = Gtk.Frame.new(_('Performance tuning:'))
        xvb.add(f)
        fvb = Gtk.VBox(False, 2)
        f.add(fvb)
        hb = Gtk.HBox(False, 2)
        fvb.add(hb)

        self.in_mem = Gtk.CheckButton(_('in memory'))
        self.in_mem.set_tooltip_text(
            _("faster but consumes more memory and harder to debug."))
        hb.pack_start(self.in_mem, False, False, 2)

        f = Gtk.Frame.new('Version Control:')
        xvb.add(f)
        fvb = Gtk.VBox(False, 2)
        f.add(fvb)
        hb = Gtk.HBox(False, 2)
        fvb.add(hb)

        hb.pack_start(Gtk.Label(_('Release Major:')), False, False, 2)
        adj = Gtk.Adjustment(0, 0, 10000, 1, 10, 0)
        self.releaseMajor = s = Gtk.SpinButton()
        s.set_adjustment(adj)
        hb.pack_start(self.releaseMajor, False, False, 2)
        hb.pack_start(Gtk.Label(_('Release Minor:')), False, False, 2)
        self.releaseMinor = s = Gtk.SpinButton()
        s.set_adjustment(adj)
        hb.pack_start(self.releaseMinor, False, False, 2)

        f = Gtk.Frame.new('Footnotes:')
        xvb.add(f)
        fvb = Gtk.VBox(False, 2)
        f.add(fvb)
        hb = Gtk.HBox(False, 2)
        fvb.add(hb)

        hb.pack_start(Gtk.Label(_('Prefix:')), False, False, 2)
        self.ft_prefix = Gtk.Entry()
        self.ft_prefix.set_text('(')
        self.ft_prefix.set_width_chars(3)
        hb.pack_start(self.ft_prefix, False, False, 2)

        hb.pack_start(Gtk.Label(_('Suffix:')), False, False, 2)
        self.ft_suffix = Gtk.Entry()
        self.ft_suffix.set_text(')')
        self.ft_suffix.set_width_chars(3)
        hb.pack_start(self.ft_suffix, False, False, 2)

        self.ft_at_line_start = Gtk.CheckButton(_('only at line start'))
        hb.pack_start(self.ft_at_line_start, False, False, 2)

        hb = Gtk.HBox(False, 2)
        fvb.add(hb)
        hb.pack_start(Gtk.Label(_('in between spaces:')), False, False, 2)
        self.ft_sp = [Gtk.RadioButton(group=None, label=_('no spaces'))]
        self.ft_sp.append(
            Gtk.RadioButton(group=self.ft_sp[0],
                            label=_('optional white-space')))
        self.ft_sp.append(
            Gtk.RadioButton(group=self.ft_sp[0],
                            label=_('optional white-spaces')))
        for i in self.ft_sp:
            hb.pack_start(i, False, False, 2)

        f = Gtk.Frame.new('Footnote anchors in body:')
        xvb.add(f)
        fvb = Gtk.VBox(False, 2)
        f.add(fvb)
        hb = Gtk.HBox(False, 2)
        fvb.add(hb)

        hb.pack_start(Gtk.Label(_('Prefix:')), False, False, 2)
        self.bft_prefix = Gtk.Entry()
        self.bft_prefix.set_text('(')
        self.bft_prefix.set_width_chars(3)
        hb.pack_start(self.bft_prefix, False, False, 2)

        hb.pack_start(Gtk.Label(_('Suffix:')), False, False, 2)
        self.bft_suffix = Gtk.Entry()
        self.bft_suffix.set_text(')')
        self.bft_suffix.set_width_chars(3)
        hb.pack_start(self.bft_suffix, False, False, 2)

        hb = Gtk.HBox(False, 2)
        fvb.add(hb)
        hb.pack_start(Gtk.Label(_('in between spaces:')), False, False, 2)
        self.bft_sp = [Gtk.RadioButton(group=None, label=_('no spaces'))]
        self.bft_sp.append(
            Gtk.RadioButton(group=self.bft_sp[0],
                            label=_('optional white-space')))
        self.bft_sp.append(
            Gtk.RadioButton(group=self.bft_sp[0],
                            label=_('optional white-spaces')))
        for i in self.bft_sp:
            hb.pack_start(i, False, False, 2)

        # TODO: add options to specify version and revision
        # TODO: add options to specify wither to break by hno
        # TODO: add options for handling existing files (overwrite?)

        ft_at_line_start = False
        ft_prefix = u'('
        ft_suffix = u')'
        ft_sp = u''  # can be ur'\s?' or ur'\s*'
        body_footnote_re = re.escape(
            ft_prefix) + ft_sp + ur'(\d+)' + ft_sp + re.escape(ft_suffix)
        footnote_re = (ft_at_line_start and u'^\s*' or u'') + body_footnote_re
        ft_prefix_len = len(ft_prefix)
        ft_suffix_len = len(ft_suffix)
示例#19
0
    def create_main_window(self):

        self.get_banner()
        self.monitors_list, self.monitor_primary = monitors.get_monitors()

        self.main_window = Gtk.Window(
            title = _("Games Nebula"),
            type = Gtk.WindowType.TOPLEVEL,
            window_position = Gtk.WindowPosition.CENTER_ALWAYS,
            resizable = False,
            icon = app_icon,
            )
        self.main_window.connect('delete-event', self.quit_app)

        self.grid = Gtk.Grid(
            margin_left = 10,
            margin_right = 10,
            margin_top = 10,
            margin_bottom = 10,
            row_spacing = 10,
            column_spacing = 10,
            column_homogeneous = True,
            )

        self.banner = Gtk.Image(
            file = self.banner_path,
            no_show_all = True
            )

        self.banner.set_visible(self.show_banner)

        self.expander = Gtk.Expander(
            label = _("Wine")
            )

        self.frame = Gtk.Frame(
            #label = _("Wine"),
            label_xalign = 0.5,
            #margin_bottom = 10,
            margin_left = 10,
            margin_right = 10,
            )

        self.frame_grid = Gtk.Grid(
            column_homogeneous = True,
            #row_homogeneous = True,
            row_spacing = 10,
            column_spacing = 10,
            margin_top = 10,
            margin_bottom = 10,
            margin_left = 10,
            margin_right = 10,
            )

        self.rbutton_global = Gtk.RadioButton(
            name = 'global',
            label = _("Global settings")
            )

        self.rbutton_sys = Gtk.RadioButton(
            name = 'system',
            label = _("System version")
            )
        self.rbutton_sys.join_group(self.rbutton_global)

        self.rbutton_path = Gtk.RadioButton(
            name = 'path',
            label = _("From directory")
            )
        self.rbutton_path.join_group(self.rbutton_global)

        if self.wine == 'global':
            self.rbutton_global.set_active(True)
        elif self.wine == 'system':
            self.rbutton_sys.set_active(True)
        if self.wine == 'path':
            self.rbutton_path.set_label(_("From directory:"))
            self.rbutton_path.set_active(True)

        self.filechooser_button = Gtk.FileChooserButton(
            title = _("Select a directory"),
            action =  Gtk.FileChooserAction.SELECT_FOLDER,
            no_show_all = True
            )
        self.filechooser_button.set_filename(self.wine_path)

        self.combobox_version = Gtk.ComboBoxText(
            no_show_all = True
            )

        self.populate_wine_versions_combobox()

        self.filechooser_button.connect('file-set', self.cb_filechooser_button)
        self.combobox_version.connect('changed', self.cb_combobox_version)

        self.label_win_ver = Gtk.Label(
            label = _("Windows version")
            )

        self.combobox_win_ver = Gtk.ComboBoxText()

        self.populate_win_ver_combobox()

        self.combobox_win_ver.connect('changed', self.cb_combobox_win_ver)

        self.checkbutton_prefix = Gtk.CheckButton(
            label = _("Use own wine prefix"),
            active = self.own_prefix
            )
        self.checkbutton_prefix.connect('toggled', self.cb_checkbutton_prefix)

        self.combobox_winearch = Gtk.ComboBoxText(
            tooltip_text = _("WINEARCH"),
            no_show_all = True
            )
        self.combobox_winearch.connect('changed', self.cb_combobox_winearch)

        self.win64_available()

        self.combobox_winearch.append_text('win32')
        self.combobox_winearch.append_text('win64')

        if self.winearch == 'win32':
            self.combobox_winearch.set_active(0)
        elif self.winearch == 'win64':
            self.combobox_winearch.set_active(1)

        self.checkbutton_mouse = Gtk.CheckButton(
            label = _("Capture the mouse in fullscreen windows"),
            active = self.mouse_capture
            )
        self.checkbutton_mouse.connect('toggled', self.cb_checkbutton_mouse)

        self.checkbutton_virtual_desktop = Gtk.CheckButton(
            label = _("Emulate a virtual desktop"),
            active = self.virtual_desktop
            )
        self.checkbutton_virtual_desktop.connect('toggled', self.cb_checkbutton_virtual_desktop)

        self.entry_virt_width = Gtk.Entry(
            placeholder_text = _("Width"),
            max_length = 4,
            max_width_chars = 4,
            xalign = 0.5,
            text = self.virtual_desktop_width,
            no_show_all = True
            )
        self.entry_virt_width.set_visible(self.virtual_desktop)
        self.entry_virt_width.connect('changed', self.cb_entry_virt_width)

        self.entry_virt_height = Gtk.Entry(
            placeholder_text = _("Height"),
            max_length = 4,
            max_width_chars = 4,
            xalign = 0.5,
            text = self.virtual_desktop_height,
            no_show_all = True
            )
        self.entry_virt_height.set_visible(self.virtual_desktop)
        self.entry_virt_height.connect('changed', self.cb_entry_virt_height)

        self.label_version = Gtk.Label(
            label = _("Version:"),
            halign = Gtk.Align.CENTER,
            )

        self.label_specific_settings = Gtk.Label(
            label = _("Game specific Wine settings:"),
            halign = Gtk.Align.CENTER,
            )

        self.button_wine_settings = Gtk.Button(
            label = _("Current wine prefix settings")
            )
        self.button_wine_settings.connect('clicked', self.cb_button_wine_settings)

        self.frame_grid.attach(self.label_version, 0, 0, 2, 1)
        self.frame_grid.attach(self.rbutton_global, 0, 1, 2, 1)
        self.frame_grid.attach(self.rbutton_sys, 0, 2, 2, 1)
        self.frame_grid.attach(self.rbutton_path, 0, 3, 2, 1)
        self.frame_grid.attach(self.filechooser_button, 0, 4, 1, 1)
        self.frame_grid.attach(self.combobox_version, 1, 4, 1, 1)
        self.frame_grid.attach(self.label_specific_settings, 0, 5, 2, 1)
        self.frame_grid.attach(self.checkbutton_prefix, 0, 6, 1, 1)
        self.frame_grid.attach(self.combobox_winearch, 1, 6, 1, 1)
        self.frame_grid.attach(self.checkbutton_mouse, 0, 7, 2, 1)
        self.frame_grid.attach(self.checkbutton_virtual_desktop, 0, 8, 2, 1)
        self.frame_grid.attach(self.entry_virt_width, 0, 9, 1, 1)
        self.frame_grid.attach(self.entry_virt_height, 1, 9, 1, 1)
        self.frame_grid.attach(self.label_win_ver, 0, 10, 1, 1)
        self.frame_grid.attach(self.combobox_win_ver, 1, 10, 1, 1)
        self.frame_grid.attach(self.button_wine_settings, 0, 11, 2, 1)
        self.frame.add(self.frame_grid)
        self.expander.add(self.frame)

        self.rbutton_global.connect('toggled', self.cb_rbuttons)
        self.rbutton_sys.connect('toggled', self.cb_rbuttons)
        self.rbutton_path.connect('toggled', self.cb_rbuttons)

        if (self.wine == 'global') or (self.wine == 'system'):
            self.filechooser_button.set_visible(False)
            self.combobox_version.set_visible(False)
        else:
            self.filechooser_button.set_visible(True)
            self.combobox_version.set_visible(True)

        self.label_monitor = Gtk.Label(
            label = _("Monitor"),
            )
        self.combobox_monitor = Gtk.ComboBoxText()

        for output in self.monitors_list:
            self.combobox_monitor.append_text(output.replace('\n', ''))

        self.combobox_monitor.set_active(self.monitor)

        self.combobox_monitor.connect('changed', self.cb_combobox_monitor)

        self.button_settings = Gtk.Button(
            label = _("Game settings"),
            no_show_all = True
            )

        if not os.path.exists(self.install_dir + '/' + self.game_name + '/settings.sh'):
            self.button_settings.set_visible(False)
        else:
            self.button_settings.set_visible(True)

        self.button_settings.connect('clicked', self.cb_button_settings)

        expander_before = Gtk.Expander(
            label = _("Execute before launching the game")
            )
        grid_before = Gtk.Grid(
            margin_top = 10,
            row_spacing = 10,
            column_spacing = 5,
            )

        entry_before = Gtk.Entry(
            name = 'command_before',
            hexpand = True,
            text = self.command_before,
            sensitive = False
            )
        entry_before.connect('changed', self.cb_entries)

        def cb_button_edit_before(button):
            if entry_before.get_sensitive():
                entry_before.set_sensitive(False)
            else:
                entry_before.set_sensitive(True)

        img = Gtk.Image.new_from_icon_name("document-new", Gtk.IconSize.SMALL_TOOLBAR)
        button_edit_before = Gtk.Button(
            image = img,
            tooltip_text = _("Edit")
            )
        button_edit_before.connect('clicked', cb_button_edit_before)

        combobox_before = Gtk.ComboBoxText(
            hexpand = True,
            tooltip_text = _("Commands templates")
            )

        for command in sample_commands_list:
            combobox_before.append_text(command)
        combobox_before.set_active(0)

        def cb_button_add_before(button):
            new_command = sample_commands[combobox_before.get_active_text()]
            current_command = entry_before.get_text()
            if current_command == '':
                entry_before.set_text(new_command)
            else:
                entry_before.set_text(current_command + ' && ' + new_command)

        img = Gtk.Image.new_from_icon_name("go-up", Gtk.IconSize.SMALL_TOOLBAR)
        button_add_before = Gtk.Button(
            image = img,
            tooltip_text = _("Add command template")
            )
        button_add_before.connect('clicked', cb_button_add_before)

        grid_before.attach(entry_before, 0, 0, 1, 1)
        grid_before.attach(button_edit_before, 1, 0, 1, 1)
        grid_before.attach(combobox_before, 0, 1, 1, 1)
        grid_before.attach(button_add_before, 1, 1, 1, 1)
        expander_before.add(grid_before)

        expander_after = Gtk.Expander(
            label = _("Execute after exiting the game")
            )
        grid_after = Gtk.Grid(
            margin_top = 10,
            row_spacing = 10,
            column_spacing = 5,
            )
        entry_after = Gtk.Entry(
            name = 'command_after',
            hexpand = True,
            text = self.command_after,
            sensitive = False
            )
        entry_after.connect('changed', self.cb_entries)

        def cb_button_edit_after(button):
            if entry_after.get_sensitive():
                entry_after.set_sensitive(False)
            else:
                entry_after.set_sensitive(True)

        img = Gtk.Image.new_from_icon_name("document-new", Gtk.IconSize.SMALL_TOOLBAR)
        button_edit_after = Gtk.Button(
            image = img,
            tooltip_text = _("Edit")
            )
        button_edit_after.connect('clicked', cb_button_edit_after)

        combobox_after = Gtk.ComboBoxText(
            hexpand = True,
            tooltip_text = _("Commands templates")
            )

        for command in sample_commands_list:
            combobox_after.append_text(command)
        combobox_after.set_active(0)

        def cb_button_add_after(button):
            new_command = sample_commands[combobox_after.get_active_text()]
            current_command = entry_after.get_text()
            if current_command == '':
                entry_after.set_text(new_command)
            else:
                entry_after.set_text(current_command + ' && ' + new_command)

        img = Gtk.Image.new_from_icon_name("go-up", Gtk.IconSize.SMALL_TOOLBAR)
        button_add_after = Gtk.Button(
            image = img,
            tooltip_text = _("Add command template")
            )
        button_add_after.connect('clicked', cb_button_add_after)

        grid_after.attach(entry_after, 0, 0, 1, 1)
        grid_after.attach(button_edit_after, 1, 0, 1, 1)
        grid_after.attach(combobox_after, 0, 1, 1, 1)
        grid_after.attach(button_add_after, 1, 1, 1, 1)
        expander_after.add(grid_after)

        self.button_game = Gtk.Button(
            label = _("Launch game")
            )

        self.button_game.connect('clicked', self.cb_button_game)

        self.checkbutton_show_launcher = Gtk.CheckButton(
            label = _("Always show launcher")
            )

        self.checkbutton_show_launcher.set_active(self.launcher)

        self.checkbutton_show_launcher.connect('clicked', self.cb_checkbutton_show_launcher)

        self.checkbutton_show_banner = Gtk.CheckButton(
            halign = Gtk.Align.END,
            valign = Gtk.Align.START,
            active = self.show_banner
            )

        self.checkbutton_show_banner.connect('toggled', self.cb_checkbutton_show_banner)

        self.grid.attach(self.checkbutton_show_banner, 0, 0, 2, 1)
        self.grid.attach(self.banner, 0, 0, 2, 1)
        self.grid.attach(self.expander, 0, 1, 2, 1)
        self.grid.attach(expander_before, 0, 2, 2, 1)
        self.grid.attach(expander_after, 0, 3, 2, 1)
        self.grid.attach(self.label_monitor, 0, 4, 1, 1)
        self.grid.attach(self.combobox_monitor, 1, 4, 1, 1)
        self.grid.attach(self.button_settings, 0, 5, 2, 1)
        self.grid.attach(self.button_game, 0, 6, 2, 1)
        self.grid.attach(self.checkbutton_show_launcher, 0, 7, 2, 1)
        self.main_window.add(self.grid)

        if self.launcher == True:
            self.main_window.show_all()
        else:
            self.launch_game()
示例#20
0
def handle_savedpd(event, paramdb, guis, configfiles):
    if hasattr(gtk, "FileChooserAction") and hasattr(gtk.FileChooserAction,
                                                     "OPEN"):
        # gtk3
        saveparamschooser = gtk.FileChooserDialog(
            title="Save parameters",
            action=gtk.FileChooserAction.SAVE,
            buttons=(gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL, gtk.STOCK_SAVE,
                     gtk.ResponseType.OK))
        pass
    else:
        saveparamschooser = gtk.FileChooserDialog(
            title="Save parameters",
            action=gtk.FILE_CHOOSER_ACTION_SAVE,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE,
                     gtk.RESPONSE_OK))
        pass
    #saveparamschooser.set_current_folder(os.path.abspath(os.path.join(thisdir, '..', 'conf')))
    dpdfilter = gtk.FileFilter()
    dpdfilter.set_name("Datacollect parameter database (*.dpd) files")
    dpdfilter.add_pattern("*.dpd")
    saveparamschooser.add_filter(dpdfilter)

    checkboxvbox = gtk.VBox()

    nonsettablecheckbox = gtk.CheckButton("Include non-settable fields")
    checkboxvbox.pack_start(nonsettablecheckbox)

    dcccheckbox = gtk.CheckButton("Include dcc files")
    dcccheckbox.set_active(True)
    checkboxvbox.pack_start(dcccheckbox)

    guicheckbox = gtk.CheckButton("Include guis")
    guicheckbox.set_active(True)
    checkboxvbox.pack_start(guicheckbox)

    saveparamschooser.set_extra_widget(checkboxvbox)

    checkboxvbox.show_all()
    #saveparamschooser.add_button("FooButton",5)

    result = saveparamschooser.run()
    fname = saveparamschooser.get_filename()
    saveparamschooser.destroy()

    if result == RESPONSE_OK:

        # load config file here...
        # imp.load_source("datacollect_config",fname)
        paramdbfile.save_params(configfiles,
                                guis,
                                paramdb,
                                fname,
                                None,
                                None,
                                non_settable=nonsettablecheckbox.get_active(),
                                dcc=dcccheckbox.get_active(),
                                gui=guicheckbox.get_active(),
                                chx=False,
                                xlg=False)

        pass

    pass
示例#21
0
    def __init__(self, operation, view):
        Gtk.Grid.__init__(self)
        self.set_orientation(Gtk.Orientation.VERTICAL)
        self.set_row_spacing(style.DEFAULT_SPACING)
        self.set_valign(Gtk.Align.CENTER)
        self.set_halign(Gtk.Align.CENTER)

        self._view = view
        self._operation = operation
        self._backend = None

        _icon = Icon(icon_name='backup-%s' % operation,
                     pixel_size=style.XLARGE_ICON_SIZE)
        self.add(_icon)
        _icon.show()

        self._message_label = Gtk.Label()
        self._message_label.set_line_wrap(True)
        self._message_label.set_width_chars(40)
        self._message_label.set_single_line_mode(False)
        align = Gtk.Alignment.new(0.5, 0.5, 0, 0)
        align.set_padding(0, 0, style.GRID_CELL_SIZE * 2,
                          style.GRID_CELL_SIZE * 2)
        align.show()
        align.add(self._message_label)
        self.add(align)
        self._message_label.show()

        self._options_combo = Gtk.ComboBox()
        cell = Gtk.CellRendererText()
        self._options_combo.pack_start(cell, True)
        self._options_combo.add_attribute(cell, 'text', 0)
        self.add(self._options_combo)

        self._progress_bar = Gtk.ProgressBar()
        self.add(self._progress_bar)
        self._progress_bar.set_size_request(
            Gdk.Screen.width() - style.GRID_CELL_SIZE * 6, -1)

        self._confirm_restore_chkbtn = Gtk.CheckButton()
        align = Gtk.Alignment()
        align.set_padding(0, 0, style.GRID_CELL_SIZE * 2,
                          style.GRID_CELL_SIZE * 2)
        align.show()
        align.add(self._confirm_restore_chkbtn)
        self.add(align)

        btn_box = Gtk.ButtonBox()
        btn_box.show()
        self._continue_btn = Gtk.Button(_('Continue'))
        btn_box.add(self._continue_btn)
        self.add(btn_box)
        self._continue_btn_handler_id = 0

        self.show()

        # check if there are activities running
        # and request close them if any.
        if self._view.manager.need_stop_activities():
            self._message_label.set_text(
                _('Please close all the activities, and start again'))

        # check the backend availables, if there are more than one
        # show to the user to select one
        if len(self._view.manager.get_backends()) > 1:
            if operation == OPERATION_BACKUP:
                message = _('Select where you want create your backup')
            if operation == OPERATION_RESTORE:
                message = _('Select where you want retrieve your restore')
            combo_options = []
            for backend in self._view.manager.get_backends():
                option = {}
                option['description'] = backend.get_name()
                option['value'] = backend
                combo_options.append(option)

            self._ask_options(message, combo_options, self._select_backend)
        else:
            self._backend = self._view.manager.get_backends()[0]
            GObject.idle_add(self._start_operation)
示例#22
0
    def __init__(self, ccw):
        PluginsClass.__init__(self, ccw, caption, category, priority)
        self.__lspci = None
        vb = Gtk.VBox(False, 2)
        self.add(vb)
        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, True, True, 2)
        l = Gtk.Label()
        l.set_markup(
            _("""This is an advanced tool that should <b>NOT</b> be used in normal cases.
If you tried other tools and it fails you may use this tool."""))
        hb.pack_start(l, False, False, 2)
        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        self.advanced = Gtk.Expander()
        self.advanced.set_label(_("Show Advanced options"))
        hb.pack_start(self.advanced, False, False, 2)
        vbe = Gtk.VBox(False, 2)
        self.advanced.add(vbe)

        f = Gtk.Frame()
        f.set_label(_('initrd generation'))
        vbe.pack_start(f, False, False, 2)
        vb = Gtk.VBox(False, 2)
        f.add(vb)
        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        l = Gtk.Label(
            _("""initrd file could contain old modules that conflict some proprietary drivers.
You may want to generate a new initrd file."""))
        hb.pack_start(l, False, False, 2)
        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        b = Gtk.Button(_("Generate initrd"))
        b.set_image(
            Gtk.Image.new_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.BUTTON))
        b.connect('clicked', self.mkinitrd)
        hb.pack_start(b, False, False, 2)

        f = Gtk.Frame()
        f.set_label(_('Xorg.conf creation tool'))
        vbe.pack_start(f, False, False, 2)
        vb = Gtk.VBox(False, 2)
        f.add(vb)
        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        l = Gtk.Label(
            _("""Xorg.conf is the file that controls X server which is the base of the graphical environment.
This tool will overwrite xorg.conf with a new one that is not based on your working one."""
              ))
        hb.pack_start(l, False, False, 2)
        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        hb.pack_start(Gtk.Label(_('Driver:')), False, False, 2)
        self.driver = Gtk.Entry()
        d, tip = self.default_driver()
        self.driver.set_text(d)
        self.driver.set_tooltip_text(
            _('usually a single lower case word like: %s') % tip)
        hb.pack_start(self.driver, False, False, 2)

        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        self.compiz = Gtk.CheckButton(_("Enable Composite extension"))
        self.compiz.set_active(True)
        self.compiz.set_tooltip_text(
            _('This extention is needed by special effects but could case problems in rare cases.'
              ))
        hb.pack_start(self.compiz, False, False, 2)
        self.aiglx = Gtk.CheckButton(_("Enable AIGLX"))
        self.aiglx.set_active(True)
        self.aiglx.set_tooltip_text(
            _('Enable Accelerated indirect rendering.'))
        hb.pack_start(self.aiglx, False, False, 2)

        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        hb.pack_start(Gtk.Label(_('Vertical Refresh Rate:')), False, False, 2)
        self.auto_vref = Gtk.CheckButton(_('auto'))
        self.auto_vref.set_active(True)
        hb.pack_start(self.auto_vref, False, False, 2)
        self.m_vref = Gtk.CheckButton(_('manual:'))
        self.m_vref.set_active(True)
        hb.pack_start(self.m_vref, False, False, 2)
        self.vref = Gtk.SpinButton()
        self.vref.set_tooltip_text(
            _('a value of 85Hz would be nicer on your eyes, lower values like 60Hz would work with LCD or old CRT monitors.'
              ))
        self.vref.set_adjustment(Gtk.Adjustment(85, 50, 120, 5, 0, 0))
        hb.pack_start(self.vref, False, False, 2)
        self.m_vref.connect(
            'toggled',
            lambda b: self.vref.set_sensitive(self.m_vref.get_active()))

        self.res = []
        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        hb.pack_start(Gtk.Label(_('HD Resolutions:')), False, False, 2)
        for i in ['1920×1080', '1280x1024', '1280×720']:
            self.res.append(Gtk.CheckButton(i))
            hb.pack_start(self.res[-1], False, False, 2)

        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        hb.pack_start(Gtk.Label(_('LCD Wide Resolutions:')), False, False, 2)
        for i in [
                '2560x1600', '1920x1200', '1680x1050', '1440x900', '1280x800'
        ]:
            self.res.append(Gtk.CheckButton(i))
            hb.pack_start(self.res[-1], False, False, 2)

        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        hb.pack_start(Gtk.Label(_('Normal Resolutions:')), False, False, 2)
        res = [
            '1600x1200', '1280x960', '1024x768', '800x600', '640x400',
            '320x240', '320x200'
        ]

        for n, i in enumerate(res):
            c = Gtk.CheckButton(i)
            self.res.append(c)
            if n > 1: c.set_active(True)
            hb.pack_start(c, False, False, 2)

        hb = Gtk.HBox(False, 2)
        vb.pack_start(hb, False, False, 2)
        b = Gtk.Button(stock=Gtk.STOCK_SAVE)
        b.connect('clicked', self.save)
        hb.pack_start(b, False, False, 2)
        b = Gtk.Button(_('Delete xorg.conf'))
        b.set_image(
            Gtk.Image.new_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.BUTTON))
        b.set_tooltip_text(_('This will make X use default settings.'))
        b.connect('clicked', self.delete)
        hb.pack_start(b, False, False, 2)
示例#23
0
    def PluginPreferences(self, parent):
        red = Gdk.RGBA()
        red.parse("#ff0000")

        def validate_color(entry):
            text = entry.get_text()

            if not Gdk.RGBA().parse(text):
                # Invalid color, make text red
                entry.override_color(Gtk.StateFlags.NORMAL, red)
            else:
                # Reset text color
                entry.override_color(Gtk.StateFlags.NORMAL, None)

        def elapsed_color_changed(entry):
            validate_color(entry)

            CONFIG.elapsed_color = entry.get_text()

        def hover_color_changed(entry):
            validate_color(entry)

            CONFIG.hover_color = entry.get_text()

        def remaining_color_changed(entry):
            validate_color(entry)

            CONFIG.remaining_color = entry.get_text()

        def on_show_pos_toggled(button, *args):
            CONFIG.show_current_pos = button.get_active()

        def seek_amount_changed(spinbox):
            CONFIG.seek_amount = spinbox.get_value_as_int()

        vbox = Gtk.VBox(spacing=6)

        def on_show_time_labels_toggled(button, *args):
            CONFIG.show_time_labels = button.get_active()
            if self._bar is not None:
                self._bar.set_time_label_visibility(CONFIG.show_time_labels)

        def create_color(label_text, color, callback):
            hbox = Gtk.HBox(spacing=6)
            hbox.set_border_width(6)
            label = Gtk.Label(label=label_text)
            hbox.pack_start(label, False, True, 0)
            entry = Gtk.Entry()
            if color:
                entry.set_text(color)
            entry.connect('changed', callback)
            hbox.pack_start(entry, True, True, 0)
            return hbox

        box = create_color(_("Override foreground color:"),
                           CONFIG.elapsed_color, elapsed_color_changed)
        vbox.pack_start(box, True, True, 0)

        box = create_color(_("Override hover color:"), CONFIG.hover_color,
                           hover_color_changed)
        vbox.pack_start(box, True, True, 0)

        box = create_color(_("Override remaining color:"),
                           CONFIG.remaining_color, remaining_color_changed)
        vbox.pack_start(box, True, True, 0)

        show_current_pos = Gtk.CheckButton(label=_("Show current position"))
        show_current_pos.set_active(CONFIG.show_current_pos)
        show_current_pos.connect("toggled", on_show_pos_toggled)
        vbox.pack_start(show_current_pos, True, True, 0)

        show_time_labels = Gtk.CheckButton(label=_("Show time labels"))
        show_time_labels.set_active(CONFIG.show_time_labels)
        show_time_labels.connect("toggled", on_show_time_labels_toggled)
        vbox.pack_start(show_time_labels, True, True, 0)

        hbox = Gtk.HBox(spacing=6)
        hbox.set_border_width(6)
        label = Gtk.Label(
            label=_("Seek amount when scrolling (milliseconds):"))
        hbox.pack_start(label, False, True, 0)
        seek_amount = Gtk.SpinButton(adjustment=Gtk.Adjustment(
            CONFIG.seek_amount, 0, 60000, 1000, 1000, 0))
        seek_amount.set_numeric(True)
        seek_amount.connect("changed", seek_amount_changed)
        hbox.pack_start(seek_amount, True, True, 0)
        vbox.pack_start(hbox, True, True, 0)

        return vbox
示例#24
0
    def __init__(self):
        Gtk.Window.__init__(self, title=info.__appname__)
        self.connect("destroy", Gtk.main_quit)
        log.info(info.__appname__ + ' başlatıldı', info.__appname__)

        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(self.box)

        self.menu = Gtk.MenuBar()  ## Menu

        self.filemenu = Gtk.Menu()
        self.file = Gtk.MenuItem(label="Dosya")
        self.file.set_submenu(self.filemenu)

        self.exittab = Gtk.MenuItem(label="Kapat")
        self.exittab.connect("activate", Gtk.main_quit)
        self.filemenu.append(self.exittab)

        self.helpmenu = Gtk.Menu()  ## Yardım Menusu
        self.help = Gtk.MenuItem(label="Yardım")
        self.help.set_submenu(self.helpmenu)

        self.about = Gtk.MenuItem(label="Sürüm Notları")
        self.about.connect("activate", self.surum_notlari)
        self.helpmenu.append(self.about)

        self.about = Gtk.MenuItem(label="Hakkında")
        self.about.connect("activate", self.hakkinda)
        self.helpmenu.append(self.about)

        self.menu.append(self.file)
        self.menu.append(self.help)

        self.notebook = Gtk.Notebook()  # Notebook oluşturuldu

        self.box.pack_start(self.menu, False, False, 0)
        self.box.pack_start(self.notebook, False, False, 0)

        # Dosya Şifreleme Sekmesi
        self.page1 = Gtk.Grid(
        )  #column_homogeneous=True) # Hizalamak için box oluşturuldu.
        self.page1.set_border_width(15)  # Kenar boşluğu eklendi
        self.page1.set_row_spacing(3)  # Satır arasındaki boşluk ayarlandı
        self.page1.set_column_spacing(3)  # Sutun arasındaki boşluk ayarlandı

        self.sifrelenecek_dosya = None
        self.dosya_metin = Gtk.Label(label='Dosya Seçimi')
        self.dosya_metin.set_alignment(0, 0.5)  # Sola Hizalandı

        self.dosya_entry = Gtk.Entry()
        self.dosya_entry.set_placeholder_text('Dosya Seçilmedi')
        self.dosya_entry.set_sensitive(False)  # Entry kullanımı kaldırıldı

        self.dosya_buton = Gtk.Button(label='..')
        self.dosya_buton.connect('clicked', self.dosya_secim)

        self.cipher_secilen = None
        self.cipher_metin = Gtk.Label(label='Cipher Seçimi')
        self.cipher_metin.set_alignment(0, 0.5)

        self.cipher_list = Gtk.ComboBoxText()
        self.cipher_list.connect('changed', self.cipher_enc)
        for i in info.cipher_list:
            self.cipher_list.append_text(i)

        self.digest_secilen = None
        self.digest_metin = Gtk.Label(label='Digest Seçimi')
        self.digest_metin.set_alignment(0, 0.5)

        self.digest_list = Gtk.ComboBoxText()
        self.digest_list.connect('changed', self.digest_enc)
        for i in info.digest_list:
            self.digest_list.append_text(i)

        self.parola_metin = Gtk.Label(label='Parola Oluşturun')
        self.parola_metin.set_alignment(0, 0.5)
        self.parola_entry = Gtk.Entry()
        self.parola_entry.set_visibility(False)  # Entry görünürlüğü kaldırıldı
        self.parola_entry.set_placeholder_text('Parola Giriniz')

        self.parola2_metin = Gtk.Label(label='Parolayı Yeniden Oluşturun')
        self.parola2_metin.set_alignment(0, 0.5)
        self.parola2_entry = Gtk.Entry()
        self.parola2_entry.set_visibility(False)
        self.parola2_entry.set_placeholder_text('Parolanızı Yeniden Giriniz')

        self.onay_buton = Gtk.Button(label='Dosyayı Şifrele')
        self.onay_buton.connect("clicked",
                                self.sifreleme_kontrol)  # Surum notu geçici

        self.page1.add(self.dosya_metin)  # PAGE1 Grid alanı için yerleşim
        self.page1.attach(
            self.dosya_entry, 2, 0, 1, 1
        )  # (WİDGET, YATAY-SIRA, DİKEY- SIRA, YATAY-HANGI-SUTUN-KAPSAYACAGI, DİKEY-GENİŞLİK)
        self.page1.attach(self.dosya_buton, 3, 0, 1, 1)

        self.page1.attach(self.cipher_metin, 0, 1, 1, 1)
        self.page1.attach(self.cipher_list, 2, 1, 2, 1)

        self.page1.attach(self.digest_metin, 0, 2, 2, 1)
        self.page1.attach(self.digest_list, 2, 2, 2, 1)

        self.page1.attach(self.parola_metin, 0, 3, 2, 1)
        self.page1.attach(self.parola_entry, 2, 3, 2, 1)

        self.page1.attach(self.parola2_metin, 0, 4, 2, 1)
        self.page1.attach(self.parola2_entry, 2, 4, 2, 1)
        self.page1.attach(self.onay_buton, 0, 5, 4, 1)

        self.notebook.append_page(self.page1, Gtk.Label(
            label='Dosya Şifreleme'))  # page1 Box'u NoteBook'a eklendi.

        # Dosya Şifre Çözme Sekmesi
        self.page2 = Gtk.Grid()

        self.page2.set_border_width(15)
        self.page2.set_row_spacing(3)
        self.page2.set_column_spacing(3)

        self.cozulecek_dosya = None
        self.dosya_metin_dec = Gtk.Label(label='Şifrelenmiş Dosya Seçimi')
        self.dosya_metin_dec.set_alignment(0, 0.5)

        self.dosya_entry_dec = Gtk.Entry()
        self.dosya_entry_dec.set_placeholder_text('Dosya Seçilmedi')
        self.dosya_entry_dec.set_sensitive(False)

        self.dosya_entry_dec.set_editable(False)

        self.dosya_buton_dec = Gtk.Button(label='..')
        self.dosya_buton_dec.connect("clicked", self.dosya_secim_dec)

        self.cipher_secilen_dec = None
        self.cipher_metin_dec = Gtk.Label(label='Şifrelenmiş Cipher Seçimi')
        self.cipher_metin_dec.set_alignment(0, 0.5)

        self.cipher_list_dec = Gtk.ComboBoxText()
        self.cipher_list_dec.connect('changed', self.cipher_dec)
        for i in info.cipher_list:
            self.cipher_list_dec.append_text(i)

        self.digest_secilen_dec = None
        self.digest_metin_dec = Gtk.Label(label='Şifrelenmiş Digest Seçimi')
        self.digest_metin_dec.set_alignment(0, 0.5)

        self.digest_list_dec = Gtk.ComboBoxText()
        self.digest_list_dec.connect('changed', self.digest_dec)
        for i in info.digest_list:
            self.digest_list_dec.append_text(i)

        self.parola_metin_dec = Gtk.Label(label='Oluşturduğunuz Parola')
        self.parola_metin_dec.set_alignment(0, 0.5)
        self.parola_entry_dec = Gtk.Entry()
        self.parola_entry_dec.set_placeholder_text('Parolanızı giriniz')
        self.parola_entry_dec.set_visibility(False)

        self.onay_buton_dec = Gtk.Button(label='Dosyanın Şifresini Çöz')
        self.onay_buton_dec.connect("clicked", self.cozme_kontrol)

        self.page2.add(self.dosya_metin_dec)
        self.page2.attach(self.dosya_entry_dec, 2, 0, 1, 1)
        self.page2.attach(self.dosya_buton_dec, 3, 0, 1, 1)
        self.page2.attach(self.cipher_metin_dec, 0, 1, 1, 1)
        self.page2.attach(self.cipher_list_dec, 2, 1, 2, 1)
        self.page2.attach(self.digest_metin_dec, 0, 2, 1, 1)
        self.page2.attach(self.digest_list_dec, 2, 2, 2, 1)
        self.page2.attach(self.parola_metin_dec, 0, 3, 1, 1)
        self.page2.attach(self.parola_entry_dec, 2, 3, 2, 1)
        self.page2.attach(self.onay_buton_dec, 0, 4, 4, 1)

        self.notebook.append_page(self.page2, Gtk.Label(label='Dosya Çözme'))

        ## RSA Oluşturma Grid
        self.page3 = Gtk.Grid()
        self.page3.set_border_width(15)
        self.page3.set_row_spacing(3)
        self.page3.set_column_spacing(3)

        self.genrsa_label1 = Gtk.Label(label='Kayıt Yeri')
        self.genrsa_label1.set_alignment(0, 0.5)

        self.kayit_dosya = None
        self.genrsa_kayit_yeri = Gtk.Entry()
        self.genrsa_kayit_yeri.set_placeholder_text('Dosya Seçilmedi')
        self.genrsa_kayit_yeri.set_sensitive(False)

        self.genrsa_button1 = Gtk.Button(label='..')
        self.genrsa_button1.connect('clicked', self.rsa_kayit_yeri)

        self.genrsa_cipher_secilen = None
        self.genrsa_anahtaradi = Gtk.Entry()
        self.genrsa_anahtaradi.set_placeholder_text('Anahtar Adı Belirleyiniz')

        self.genrsa_label2 = Gtk.Label(label='Cipher Seçimi')
        self.genrsa_label2.set_alignment(0, 0.5)

        self.genrsa_size_secilen = None
        self.genrsa_cipher = Gtk.ComboBoxText()
        self.genrsa_cipher.connect('changed', self.genrsa_cipher_)
        for i in info.genrsa_list:
            self.genrsa_cipher.append_text(i)

        self.genrsa_label3 = Gtk.Label(label='Anahtar Boyutu')
        self.genrsa_label3.set_alignment(0, 0.5)

        self.genrsa_size = None
        self.genrsa_size = Gtk.ComboBoxText()
        self.genrsa_size.connect('changed', self.genrsa_size_)
        for i in info.genrsa_size_list:
            self.genrsa_size.append_text(i)

        self.genrsa_label4 = Gtk.Label(label='Parola Oluşturun')
        self.genrsa_label4.set_alignment(0, 0.5)

        self.genrsa_parola1 = Gtk.Entry()
        self.genrsa_parola1.set_placeholder_text('Parola Giriniz')
        self.genrsa_parola1.set_visibility(False)

        self.genrsa_label5 = Gtk.Label(label='Parolayı Yeniden Oluşturun')
        self.genrsa_label5.set_alignment(0, 0.5)

        self.genrsa_parola2 = Gtk.Entry()
        self.genrsa_parola2.set_placeholder_text('Parolanızı Yeniden Giriniz')
        self.genrsa_parola2.set_visibility(False)

        self.genrsa_label7 = Gtk.Label(label='Açık Anahtar')
        self.genrsa_label7.set_alignment(0, 0.5)

        self.genrsa_acik_anahtar = Gtk.CheckButton(label="Oluşturulsun")
        self.genrsa_acik_anahtar.set_active(False)

        self.genrsa_olustur = Gtk.Button(label='Anahtarı Oluştur')
        self.genrsa_olustur.connect("clicked", self.genrsa_kontrol)
        # self.genrsa_olustur.connect("clicked", self.genrsa_kontrol)

        self.page3.add(self.genrsa_label1)
        self.page3.attach(self.genrsa_kayit_yeri, 1, 0, 1, 1)
        self.page3.attach(self.genrsa_button1, 2, 0, 1, 1)
        self.page3.attach(self.genrsa_label2, 0, 1, 1, 1)
        self.page3.attach(self.genrsa_cipher, 1, 1, 2, 1)
        self.page3.attach(self.genrsa_label3, 0, 2, 1, 1)
        self.page3.attach(self.genrsa_size, 1, 2, 2, 1)
        self.page3.attach(self.genrsa_label4, 0, 3, 1, 1)
        self.page3.attach(self.genrsa_parola1, 1, 3, 2, 1)
        self.page3.attach(self.genrsa_label5, 0, 4, 1, 1)
        self.page3.attach(self.genrsa_parola2, 1, 4, 2, 1)
        self.page3.attach(self.genrsa_label7, 0, 5, 1, 1)
        self.page3.attach(self.genrsa_acik_anahtar, 1, 5, 2, 1)
        self.page3.attach(self.genrsa_olustur, 0, 6, 3, 1)

        self.notebook.append_page(self.page3, Gtk.Label(label='GenRSA'))
示例#25
0
    def __init__(self, *args, **kwargs):
        Operation.__init__(self, *args, **kwargs)
        self._grid = Gtk.Grid(border_width=5,
                              row_spacing=5,
                              column_spacing=5,
                              halign=Gtk.Align.FILL,
                              valign=Gtk.Align.CENTER,
                              hexpand=True,
                              vexpand=False)
        self.add(self._grid)

        # we need boxes for at least
        # hostname
        # port
        # username
        # password
        # auto add new host keys
        # remote directory
        # create remote directory if necessary

        # Hostname
        tempgrid = Gtk.Grid(row_spacing=5,
                            column_spacing=5,
                            halign=Gtk.Align.FILL,
                            valign=Gtk.Align.CENTER,
                            hexpand=True,
                            vexpand=False)
        self._grid.attach(tempgrid, 0, 0, 1, 1)
        tempgrid.attach(
            Gtk.Label(
                label='Hostname',
                halign=Gtk.Align.START,
                valign=Gtk.Align.CENTER,
                hexpand=False,
                vexpand=False,
            ), 0, 0, 1, 1)
        widget = self.register_widget(
            Gtk.Entry(
                halign=Gtk.Align.FILL,
                valign=Gtk.Align.CENTER,
                hexpand=True,
                vexpand=False,
            ), 'hostname')
        tempgrid.attach(widget, 1, 0, 1, 1)

        # Port
        tempgrid.attach(
            Gtk.Label(
                label='Port',
                halign=Gtk.Align.CENTER,
                valign=Gtk.Align.CENTER,
                hexpand=False,
                vexpand=False,
            ), 2, 0, 1, 1)
        widget = self.register_widget(
            Gtk.SpinButton(adjustment=Gtk.Adjustment(lower=1,
                                                     upper=10000,
                                                     value=5,
                                                     page_size=0,
                                                     step_increment=1),
                           value=22,
                           update_policy=Gtk.SpinButtonUpdatePolicy.IF_VALID,
                           numeric=True,
                           climb_rate=5,
                           halign=Gtk.Align.CENTER,
                           valign=Gtk.Align.CENTER,
                           hexpand=False,
                           vexpand=False), 'port')
        tempgrid.attach(widget, 3, 0, 1, 1)

        # Username
        tempgrid = Gtk.Grid(
            row_spacing=5,
            column_spacing=5,
            halign=Gtk.Align.FILL,
            valign=Gtk.Align.CENTER,
            hexpand=True,
            vexpand=False,
        )
        self._grid.attach(tempgrid, 0, 1, 1, 1)
        tempgrid.attach(
            Gtk.Label(
                label='Username',
                halign=Gtk.Align.CENTER,
                valign=Gtk.Align.CENTER,
                hexpand=False,
                vexpand=False,
            ), 0, 0, 1, 1)
        widget = self.register_widget(
            Gtk.Entry(
                halign=Gtk.Align.FILL,
                valign=Gtk.Align.CENTER,
                hexpand=True,
                vexpand=False,
            ), 'username')
        tempgrid.attach(widget, 1, 0, 1, 1)

        # Password
        tempgrid.attach(
            Gtk.Label(
                label='Password',
                halign=Gtk.Align.CENTER,
                valign=Gtk.Align.CENTER,
                hexpand=False,
                vexpand=False,
            ), 2, 0, 1, 1)
        widget = self.register_widget(Gtk.Entry(
            visibility=False,
            halign=Gtk.Align.FILL,
            valign=Gtk.Align.CENTER,
            hexpand=True,
            vexpand=False,
        ),
                                      'password',
                                      exportable=False)
        tempgrid.attach(widget, 3, 0, 1, 1)

        # Remote directory
        tempgrid = Gtk.Grid(
            row_spacing=5,
            column_spacing=5,
            halign=Gtk.Align.FILL,
            valign=Gtk.Align.CENTER,
            hexpand=True,
            vexpand=False,
        )
        self._grid.attach(tempgrid, 0, 2, 1, 1)
        tempgrid.attach(
            Gtk.Label(
                label='Destination folder',
                halign=Gtk.Align.CENTER,
                valign=Gtk.Align.CENTER,
                hexpand=False,
                vexpand=False,
            ), 0, 0, 1, 1)
        widget = self.register_widget(
            Gtk.Entry(
                halign=Gtk.Align.FILL,
                valign=Gtk.Align.CENTER,
                hexpand=True,
                vexpand=False,
            ), 'destination')
        tempgrid.attach(widget, 1, 0, 1, 1)

        # Create directory
        widget = self.register_widget(
            Gtk.CheckButton(
                active=True,
                label="Create destination folder if necessary",
                halign=Gtk.Align.END,
                valign=Gtk.Align.CENTER,
                hexpand=False,
                vexpand=False,
            ), 'force_folder_creation')
        tempgrid.attach(widget, 2, 0, 1, 1)

        # Automatically accept new host keys
        tempgrid = Gtk.Grid(
            row_spacing=5,
            column_spacing=5,
            halign=Gtk.Align.FILL,
            valign=Gtk.Align.CENTER,
            hexpand=True,
            vexpand=False,
        )
        self._grid.attach(tempgrid, 0, 3, 1, 1)
        widget = self.register_widget(
            Gtk.CheckButton(
                active=False,
                label="Automatically accept new host keys (dangerous!!)",
                halign=Gtk.Align.END,
                valign=Gtk.Align.CENTER,
                hexpand=False,
                vexpand=False,
            ), 'auto_add_keys')
        tempgrid.attach(widget, 0, 0, 1, 1)
示例#26
0
    def __init__(self, filename=None):
        Gtk.Dialog.__init__(
            self, _('Paginate'), None,
            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
            (Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT, Gtk.STOCK_CANCEL,
             Gtk.ResponseType.CANCEL))
        self.set_size_request(500, 140)
        self.set_resizable(False)
        self.set_icon_from_file(comun.ICON)
        self.connect('destroy', self.close_application)
        #
        vbox0 = Gtk.VBox(spacing=5)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)
        #
        notebook = Gtk.Notebook()
        vbox0.add(notebook)
        #
        frame = Gtk.Frame()
        notebook.append_page(frame, tab_label=Gtk.Label(_('Paginate')))
        #
        table = Gtk.Table(rows=4, columns=2, homogeneous=False)
        table.set_border_width(5)
        table.set_col_spacings(5)
        table.set_row_spacings(5)
        frame.add(table)
        #
        frame1 = Gtk.Frame()
        table.attach(frame1,
                     0,
                     1,
                     0,
                     1,
                     xoptions=Gtk.AttachOptions.EXPAND,
                     yoptions=Gtk.AttachOptions.SHRINK)
        self.scrolledwindow1 = Gtk.ScrolledWindow()
        self.scrolledwindow1.set_size_request(420, 420)
        frame1.add(self.scrolledwindow1)
        #
        self.viewport1 = MiniView()
        self.scrolledwindow1.add(self.viewport1)
        #
        frame2 = Gtk.Frame()
        table.attach(frame2,
                     1,
                     2,
                     0,
                     1,
                     xoptions=Gtk.AttachOptions.EXPAND,
                     yoptions=Gtk.AttachOptions.SHRINK)
        scrolledwindow2 = Gtk.ScrolledWindow()
        scrolledwindow2.set_size_request(420, 420)
        frame2.add(scrolledwindow2)
        #
        self.viewport2 = MiniView()
        scrolledwindow2.add(self.viewport2)
        self.viewport2.set_text('1/1')
        #
        self.scale = 100

        #
        vertical_options = Gtk.ListStore(str, int)
        vertical_options.append([_('Top'), TOP])
        vertical_options.append([_('Middle'), MIDLE])
        vertical_options.append([_('Bottom'), BOTTOM])
        #
        horizontal_options = Gtk.ListStore(str, int)
        horizontal_options.append([_('Left'), LEFT])
        horizontal_options.append([_('Center'), CENTER])
        horizontal_options.append([_('Right'), RIGHT])
        #
        self.rbutton0 = Gtk.CheckButton(_('Overwrite original file?'))
        table.attach(self.rbutton0,
                     0,
                     2,
                     1,
                     2,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        # Font 2 3
        vbox1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
        table.attach(vbox1,
                     0,
                     2,
                     2,
                     3,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        button_font = Gtk.Button(_('Select font'))
        button_font.connect('clicked', self.on_button_font_activated)
        vbox1.pack_start(button_font, False, False, 0)
        button_color = Gtk.Button(_('Select color'))
        button_color.connect('clicked', self.on_button_color_activated)
        vbox1.pack_start(button_color, False, False, 0)
        #
        label = Gtk.Label(_('Horizontal position') + ':')
        label.set_alignment(0, .5)
        table.attach(label,
                     0,
                     1,
                     5,
                     6,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        #
        self.horizontal = Gtk.ComboBox.new_with_model_and_entry(
            horizontal_options)
        self.horizontal.set_entry_text_column(0)
        self.horizontal.set_active(0)
        self.horizontal.connect('changed', self.on_value_changed)
        table.attach(self.horizontal,
                     1,
                     2,
                     5,
                     6,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        #
        label = Gtk.Label(_('Vertical position') + ':')
        label.set_alignment(0, .5)
        table.attach(label,
                     0,
                     1,
                     6,
                     7,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        #
        self.vertical = Gtk.ComboBox.new_with_model_and_entry(vertical_options)
        self.vertical.set_entry_text_column(0)
        self.vertical.set_active(0)
        self.vertical.connect('changed', self.on_value_changed)
        table.attach(self.vertical,
                     1,
                     2,
                     6,
                     7,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        #
        label = Gtk.Label(_('Set horizontal margin') + ':')
        label.set_alignment(0, .5)
        table.attach(label,
                     0,
                     1,
                     7,
                     8,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        self.horizontal_margin = Gtk.SpinButton()
        self.horizontal_margin.set_adjustment(
            Gtk.Adjustment(5, 0, 100, 1, 10, 10))
        table.attach(self.horizontal_margin,
                     1,
                     2,
                     7,
                     8,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        self.horizontal_margin.connect('value-changed', self.on_margin_changed)
        label = Gtk.Label(_('Set vertical margin') + ':')
        label.set_alignment(0, .5)
        table.attach(label,
                     0,
                     1,
                     8,
                     9,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        self.vertical_margin = Gtk.SpinButton()
        self.vertical_margin.set_adjustment(
            Gtk.Adjustment(5, 0, 100, 1, 10, 10))
        table.attach(self.vertical_margin,
                     1,
                     2,
                     8,
                     9,
                     xoptions=Gtk.AttachOptions.FILL,
                     yoptions=Gtk.AttachOptions.SHRINK)
        self.vertical_margin.connect('value-changed', self.on_margin_changed)

        self.show_all()
        if filename is not None:
            uri = "file://" + filename
            document = Poppler.Document.new_from_file(uri, None)
            if document.get_n_pages() > 0:
                self.viewport1.set_page(document.get_page(0))
                self.viewport2.set_page(document.get_page(0))
示例#27
0
 def add_csv_header_param(self, box):
     self.add_field_names = Gtk.CheckButton(label=_("Add field names"))
     self.add_field_names.set_active(True)
     box.pack_start(
         self.add_field_names, expand=False, fill=True, padding=0)
示例#28
0
    def __init__(self, parent):
        Gtk.Dialog.__init__(self, _('Permissions'), parent, 0,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.set_default_size(150, 200)

        box = self.get_content_area()

        frame = Gtk.Frame()
        box.pack_start(frame, False, False, 0)

        label = Gtk.Label()
        label.props.use_markup = True
        label.set_markup('<b>' + _('Permissions') + '</b>')
        frame.props.label_widget = label

        alignment = Gtk.Alignment()
        alignment.props.left_padding = 15
        alignment.props.top_padding = 15

        frame.add(alignment)

        hbox = Gtk.HBox()
        alignment.add(hbox)

        frame1 = Gtk.Frame()
        label = Gtk.Label()
        label.props.use_markup = True
        label.set_markup('<b>' + _('User') + '</b>')

        frame1.props.label_widget = label
        frame1.props.shadow_type = Gtk.ShadowType.NONE

        alignment = Gtk.Alignment()
        alignment.props.left_padding = 15

        frame1.add(alignment)

        vbox = Gtk.VBox()
        self.u_r = Gtk.CheckButton(_('Read'))
        vbox.pack_start(self.u_r, False, False, 0)
        self.u_w = Gtk.CheckButton(_('Write'))
        vbox.pack_start(self.u_w, False, False, 0)
        self.u_x = Gtk.CheckButton(_('Execute'))
        vbox.pack_start(self.u_x, False, False, 0)
        alignment.add(vbox)

        hbox.pack_start(frame1, False, False, 0)

        frame1 = Gtk.Frame()
        label = Gtk.Label()
        label.props.use_markup = True
        label.set_markup('<b>' + _('Group') + '</b>')

        frame1.props.label_widget = label
        frame1.props.shadow_type = Gtk.ShadowType.NONE

        alignment = Gtk.Alignment()
        alignment.props.left_padding = 15

        frame1.add(alignment)

        vbox = Gtk.VBox()
        self.g_r = Gtk.CheckButton(_('Read'))
        vbox.pack_start(self.g_r, False, False, 0)
        self.g_w = Gtk.CheckButton(_('Write'))
        vbox.pack_start(self.g_w, False, False, 0)
        self.g_x = Gtk.CheckButton(_('Execute'))
        vbox.pack_start(self.g_x, False, False, 0)
        alignment.add(vbox)

        hbox.pack_start(frame1, False, False, 0)

        frame1 = Gtk.Frame()
        label = Gtk.Label()
        label.props.use_markup = True
        label.set_markup('<b>' + _('Others') + '</b>')

        frame1.props.label_widget = label
        frame1.props.shadow_type = Gtk.ShadowType.NONE

        alignment = Gtk.Alignment()
        alignment.props.left_padding = 15

        frame1.add(alignment)

        vbox = Gtk.VBox()
        self.o_r = Gtk.CheckButton(_('Read'))
        vbox.pack_start(self.o_r, False, False, 0)
        self.o_w = Gtk.CheckButton(_('Write'))
        vbox.pack_start(self.o_w, False, False, 0)
        self.o_x = Gtk.CheckButton(_('Execute'))
        vbox.pack_start(self.o_x, False, False, 0)
        alignment.add(vbox)

        hbox.pack_start(frame1, False, False, 0)
示例#29
0
    def createTraceToolBar(self):
        toolbar = Gtk.Toolbar()
        #toolbar.set_orientation(Gtk.Orientation.VERTICAL)
        #toolbar.set_icon_size(Gtk.IconSize.MENU)
        toolbar.set_icon_size(Gtk.IconSize.LARGE_TOOLBAR)
        toolbar.set_style(Gtk.ToolbarStyle.ICONS)
        toolbar.set_show_arrow(False)

        # build the zoom controls
        self.zoomin_button = Gtk.ToolButton(Gtk.STOCK_ZOOM_IN)
        self.zoomin_button.set_homogeneous(False)
        self.zoomin_button.set_tooltip_text('Zoom in')
        self.zoomin_button.connect('clicked', self.zoomButtons, 1)
        toolbar.insert(self.zoomin_button, -1)

        self.zoomout_button = Gtk.ToolButton(Gtk.STOCK_ZOOM_OUT)
        self.zoomout_button.set_homogeneous(False)
        self.zoomout_button.set_tooltip_text('Zoom out')
        self.zoomout_button.connect('clicked', self.zoomButtons, -1)
        toolbar.insert(self.zoomout_button, -1)

        self.zoom_combo = Gtk.ComboBoxText()
        for zoom in self.zoom_levels:
            self.zoom_combo.append_text(str(zoom) + '%')
        self.zoom_combo.set_active(self.curr_zoom)
        self.zoom_combo.connect('changed', self.zoomComboBox)

        # Place the combo box in a VButtonBox to prevent it from expanding
        # vertically.
        vbox = Gtk.VButtonBox()
        vbox.pack_start(self.zoom_combo, False, True, 0)
        t_item = Gtk.ToolItem()
        t_item.add(vbox)
        t_item.set_tooltip_text('Adjust the zoom level')
        t_item.set_expand(False)
        toolbar.insert(t_item, -1)

        toolbar.insert(Gtk.SeparatorToolItem(), -1)

        # build the y scale adjustment slider
        t_item = Gtk.ToolItem()
        t_item.add(Gtk.Label(label='Y:'))
        toolbar.insert(t_item, -1)

        self.vscale_adj = Gtk.Adjustment(0, 0, 0)
        hslider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
                            adjustment=self.vscale_adj)
        hslider.set_draw_value(False)
        self.initYScaleSlider(self.selected_seqtv)

        sizereq = hslider.get_size_request()
        hslider.set_size_request(60, sizereq.height)

        self.y_slider = Gtk.ToolItem()
        self.y_slider.add(hslider)
        self.y_slider.set_tooltip_text('Adjust the Y scale of the trace view')
        toolbar.insert(self.y_slider, -1)

        self.vscale_adj.connect('value_changed', self.yScaleChanged)

        toolbar.insert(Gtk.SeparatorToolItem(), -1)

        # build the toggle button for phred scores
        toggle = Gtk.CheckButton()
        toggle.set_label('conf. scores')
        toggle.set_active(True)
        toggle.connect('toggled', self.showConfToggled)

        # Place the toggle button in a VButtonBox to prevent it from expanding
        # vertically.
        vbox = Gtk.VButtonBox()
        vbox.pack_start(toggle, False, True, 0)
        t_item = Gtk.ToolItem()
        t_item.add(vbox)
        t_item.set_tooltip_text('Turn the display of phred scores on or off')
        t_item.set_expand(False)
        toolbar.insert(t_item, -1)

        # if we got two sequences, build a combo box to choose between them
        if len(self.seqt_viewers) == 2:
            trace_combo = Gtk.ComboBoxText()

            # see if the forward trace is first or second
            if self.seqt_viewers[0].getSequenceTrace().isReverseComplemented():
                trace_combo.append_text('Reverse:')
                trace_combo.append_text('Forward:')
            else:
                trace_combo.append_text('Forward:')
                trace_combo.append_text('Reverse:')
            trace_combo.append_text('Both:')
            trace_combo.set_active(0)
            trace_combo.connect('changed', self.traceComboBox)

            # Place the combo box in a VButtonBox to prevent it from expanding
            # vertically.
            vbox = Gtk.VButtonBox()
            vbox.pack_start(trace_combo, False, True, 0)
            t_item = Gtk.ToolItem()
            t_item.add(vbox)
            #t_item.set_tooltip_text('Adjust the zoom level')
            toolbar.insert(t_item, 0)

            trace_combo.set_active(2)

        return toolbar
示例#30
0
def _general_options_panel():
    prefs = editorpersistance.prefs

    # Widgets
    open_in_last_opened_check = Gtk.CheckButton()
    open_in_last_opened_check.set_active(prefs.open_in_last_opended_media_dir)

    open_in_last_rendered_check = Gtk.CheckButton()
    open_in_last_rendered_check.set_active(prefs.remember_last_render_dir)

    default_profile_combo = Gtk.ComboBoxText()
    profiles = mltprofiles.get_profiles()
    for profile in profiles:
        default_profile_combo.append_text(profile[0])
    default_profile_combo.set_active(mltprofiles.get_default_profile_index())

    spin_adj = Gtk.Adjustment(prefs.undos_max,
                              editorpersistance.UNDO_STACK_MIN,
                              editorpersistance.UNDO_STACK_MAX, 1)
    undo_max_spin = Gtk.SpinButton.new_with_range(
        editorpersistance.UNDO_STACK_MIN, editorpersistance.UNDO_STACK_MAX, 1)
    undo_max_spin.set_adjustment(spin_adj)
    undo_max_spin.set_numeric(True)

    autosave_combo = Gtk.ComboBoxText()
    # Aug-2019 - SvdB - AS - This is now initialized in app.main
    # Using editorpersistance.prefs.AUTO_SAVE_OPTS as source
    # AUTO_SAVE_OPTS = ((-1, _("No Autosave")),(1, _("1 min")),(2, _("2 min")),(5, _("5 min")))

    for i in range(0, len(editorpersistance.prefs.AUTO_SAVE_OPTS)):
        time, desc = editorpersistance.prefs.AUTO_SAVE_OPTS[i]
        autosave_combo.append_text(desc)
    autosave_combo.set_active(prefs.auto_save_delay_value_index)

    load_order_combo = Gtk.ComboBoxText()
    load_order_combo.append_text(_("Absolute paths first, relative second"))
    load_order_combo.append_text(_("Relative paths first, absolute second"))
    load_order_combo.append_text(_("Absolute paths only"))
    load_order_combo.set_active(prefs.media_load_order)

    # Layout
    row1 = _row(
        guiutils.get_two_column_box(Gtk.Label(label=_("Default Profile:")),
                                    default_profile_combo, PREFERENCES_LEFT))
    row2 = _row(
        guiutils.get_checkbox_row_box(
            open_in_last_opened_check,
            Gtk.Label(label=_("Remember last media directory"))))
    row3 = _row(
        guiutils.get_two_column_box(Gtk.Label(label=_("Undo stack size:")),
                                    undo_max_spin, PREFERENCES_LEFT))
    row5 = _row(
        guiutils.get_checkbox_row_box(
            open_in_last_rendered_check,
            Gtk.Label(label=_("Remember last render directory"))))
    row6 = _row(
        guiutils.get_two_column_box(
            Gtk.Label(label=_("Autosave for crash recovery every:")),
            autosave_combo, PREFERENCES_LEFT))
    row9 = _row(
        guiutils.get_two_column_box(
            Gtk.Label(label=_("Media look-up order on load:")),
            load_order_combo, PREFERENCES_LEFT))

    vbox = Gtk.VBox(False, 2)
    vbox.pack_start(row1, False, False, 0)
    vbox.pack_start(row6, False, False, 0)
    vbox.pack_start(row2, False, False, 0)
    vbox.pack_start(row5, False, False, 0)
    vbox.pack_start(row3, False, False, 0)
    vbox.pack_start(row9, False, False, 0)
    vbox.pack_start(Gtk.Label(), True, True, 0)

    guiutils.set_margins(vbox, 12, 0, 12, 12)

    # Aug-2019 - SvdB - AS - Added autosave_combo
    return vbox, (default_profile_combo, open_in_last_opened_check,
                  open_in_last_rendered_check, undo_max_spin, load_order_combo,
                  autosave_combo)