def __init__(self, project):
        gtk.Dialog.__init__(self, 'Project Settings', None,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL,
                             gtk.RESPONSE_CANCEL))
        self.set_default_response(gtk.RESPONSE_OK)

        self.project = project

        # Set up some spacing values for the UI layout.
        insideframe_padding = 14
        tabpadding_tops = 24
        tabpadding_sides = 18

        # Set up the tabs ("notebook") for the project settings.
        nb = gtk.Notebook()
        nb.set_border_width(8)
        nb.set_tab_pos(gtk.POS_TOP)

        # Create the UI elements for the trace file settings tab.
        mainvb = gtk.VBox(False, 16)
        tracevb = gtk.VBox(False, 20)
        tracevb.set_border_width(insideframe_padding)

        # Get the consensus sequence settings from the project.
        cssettings = self.project.getConsensSeqSettings()

        # Set up UI components for the trace file location.
        vb = gtk.VBox()
        tf_hb1 = gtk.HBox()
        tf_hb1.pack_start(gtk.Label('Location of trace files:'), False)
        tf_hb2 = gtk.HBox()
        self.fc_entry = gtk.Entry()
        self.fc_entry.set_width_chars(40)
        self.fc_entry.set_text(self.project.getTraceFileDir())
        tf_hb2.pack_start(self.fc_entry)

        # use the STOCK_DIRECTORY icon for the button
        gtk.stock_add([('choose_dir', 'C_hoose...', 0, 0, None)])
        icfact = gtk.IconFactory()
        icfact.add_default()
        icfact.add('choose_dir',
                   self.get_style().lookup_icon_set(gtk.STOCK_DIRECTORY))
        fc_button = gtk.Button(stock='choose_dir')
        fc_button.connect('clicked', self.chooseDirectory, self.fc_entry)

        #fc_button.set_label('Choose...')
        tf_hb2.pack_start(fc_button)
        vb.pack_start(tf_hb1)
        vb.pack_start(tf_hb2)

        self.fc_checkbox = gtk.CheckButton('Use relative folder path')
        if os.path.isabs(self.project.getTraceFileDir()):
            self.fc_checkbox.set_active(False)
        else:
            self.fc_checkbox.set_active(True)
        self.fc_cb_hid = self.fc_checkbox.connect('toggled',
                                                  self.useRelPathToggled)
        vb.pack_start(self.fc_checkbox)

        tracevb.pack_start(vb)

        # Set up UI components for the forward/reverse trace file search strings.
        vb = gtk.VBox()
        tfs_hb1 = gtk.HBox()
        tfs_hb1.pack_start(
            gtk.Label(
                'Search strings for identifying forward and reverse trace files:'
            ), False)

        # Create a layout table for the labels and text entries.
        table = gtk.Table(2, 2)

        self.tfs_fwd_entry = gtk.Entry()
        self.tfs_fwd_entry.set_width_chars(12)
        self.tfs_fwd_entry.set_text(self.project.getFwdTraceSearchStr())
        table.attach(gtk.Label('Forward: '), 0, 1, 0, 1, xoptions=0)
        table.attach(self.tfs_fwd_entry, 1, 2, 0, 1, xoptions=0)

        self.tfs_rev_entry = gtk.Entry()
        self.tfs_rev_entry.set_width_chars(12)
        self.tfs_rev_entry.set_text(self.project.getRevTraceSearchStr())
        table.attach(gtk.Label('Reverse: '), 0, 1, 1, 2, xoptions=0)
        table.attach(self.tfs_rev_entry, 1, 2, 1, 2, xoptions=0)

        vb.pack_start(tfs_hb1)
        vb.pack_start(table)

        tracevb.pack_start(vb)

        frame = gtk.Frame('Trace files')
        frame.add(tracevb)
        mainvb.pack_start(frame)

        # Set up UI components for the forward/reverse primer strings.
        vb = gtk.VBox()
        vb = gtk.VBox(False, 20)
        vb.set_border_width(insideframe_padding)

        # Create a layout table for the labels and text entries.
        table = gtk.Table(2, 2)

        self.fwdprimer_entry = gtk.Entry()
        self.fwdprimer_entry.set_width_chars(38)
        self.fwdprimer_entry.set_text(cssettings.getForwardPrimer())
        table.attach(gtk.Label('Forward primer: '), 0, 1, 0, 1, xoptions=0)
        table.attach(self.fwdprimer_entry, 1, 2, 0, 1, xoptions=0)

        self.revprimer_entry = gtk.Entry()
        self.revprimer_entry.set_width_chars(38)
        self.revprimer_entry.set_text(cssettings.getReversePrimer())
        table.attach(gtk.Label('Reverse primer: '), 0, 1, 1, 2, xoptions=0)
        table.attach(self.revprimer_entry, 1, 2, 1, 2, xoptions=0)

        vb.pack_start(table)

        frame = gtk.Frame("Primer sequences (5' to 3')")
        frame.add(vb)
        mainvb.pack_start(frame)

        # Use another VBox to get extra padding on the sides.
        vbpad = gtk.VBox(False, 0)
        vbpad.set_border_width(tabpadding_sides)
        vbpad.pack_start(mainvb,
                         expand=False,
                         padding=(tabpadding_tops - tabpadding_sides))

        nb.append_page(vbpad, gtk.Label('Trace settings'))

        # Create the UI components for the sequence processing tab.
        mainvb = gtk.VBox(False, 16)

        # Set up UI components for choosing the confidence score cutoff value.
        vb = gtk.VBox(False, 12)
        vb.set_border_width(insideframe_padding)
        hb1 = gtk.HBox()
        hb1.pack_start(gtk.Label('Min. confidence score:  '), False)

        self.ph_adj = gtk.Adjustment(cssettings.getMinConfScore(), 1, 61, 1)
        spin = gtk.SpinButton(self.ph_adj)
        hb1.pack_start(spin, False, False)

        vb.pack_start(hb1)

        # Create the UI components for choosing a consensus algorithm.
        hb1 = gtk.HBox()
        hb1.pack_start(gtk.Label('Consensus algorithm:  '), False)
        self.cons_bayes_rb = gtk.RadioButton(None, 'Bayesian   ')
        hb1.pack_start(self.cons_bayes_rb, False)
        self.cons_legacy_rb = gtk.RadioButton(self.cons_bayes_rb,
                                              'SeqTrace 0.8')

        if cssettings.getConsensusAlgorithm() == 'Bayesian':
            self.cons_bayes_rb.set_active(True)
        else:
            self.cons_legacy_rb.set_active(True)

        hb1.pack_start(self.cons_legacy_rb)

        vb.pack_start(hb1)

        frame = gtk.Frame('Consensus settings')
        frame.add(vb)
        mainvb.pack_start(frame)

        # Set up UI components for sequence trimming settings.
        vb = gtk.VBox(False, 24)
        vb.set_border_width(insideframe_padding)
        self.autotrim_checkbox = gtk.CheckButton(
            'Automatically trim sequence ends')
        self.autotrim_checkbox.connect('toggled', self.autoTrimToggled)
        vb.pack_start(self.autotrim_checkbox)

        # Create UI components for primer trimming.
        vb2 = gtk.VBox(False, 6)
        hb2 = gtk.HBox()
        self.trimprimers_checkbox = gtk.CheckButton('Trim primers if ')
        self.trimprimers_checkbox.set_active(cssettings.getTrimPrimers())
        hb2.pack_start(self.trimprimers_checkbox, False)
        self.primermatch_th_adj = gtk.Adjustment(
            int(cssettings.getPrimerMatchThreshold() * 100), 1, 100, 1)
        self.primermatch_th_spin = gtk.SpinButton(self.primermatch_th_adj)
        hb2.pack_start(self.primermatch_th_spin, False, False)
        self.trimprimers_label = gtk.Label(
            ' % of the primer alignment matches.')
        hb2.pack_start(self.trimprimers_label, False)

        vb2.pack_start(hb2)

        # Check box for end gap trimming.
        self.trimgaps_checkbox = gtk.CheckButton(
            'Trim alignment end gap regions')
        self.trimgaps_checkbox.set_active(cssettings.getTrimEndGaps())
        vb2.pack_start(self.trimgaps_checkbox)

        qualtrim_winsize, qualtrim_basecnt = cssettings.getQualityTrimParams()

        # Check box and spin buttons for end quality trimming.
        hb2 = gtk.HBox()
        self.qualtrim_checkbox = gtk.CheckButton('Trim until at least ')
        self.qualtrim_checkbox.set_active(cssettings.getDoQualityTrim())
        hb2.pack_start(self.qualtrim_checkbox, False)
        self.qualtrim_basecnt_adj = gtk.Adjustment(qualtrim_basecnt, 1,
                                                   qualtrim_winsize, 1)
        self.qualtrim_basecnt_spin = gtk.SpinButton(self.qualtrim_basecnt_adj)
        hb2.pack_start(self.qualtrim_basecnt_spin, False, False)

        self.qualtrim_label1 = gtk.Label(' out of ')
        hb2.pack_start(self.qualtrim_label1, False)
        self.qualtrim_winsize_adj = gtk.Adjustment(qualtrim_winsize, 1, 20, 1)
        self.qualtrim_winsize_spin = gtk.SpinButton(self.qualtrim_winsize_adj)
        hb2.pack_start(self.qualtrim_winsize_spin, False, False)
        self.qualtrim_winsize_adj.connect('value_changed',
                                          self.autoTrimWinSizeChanged)

        self.qualtrim_label2 = gtk.Label(' bases are correctly called.')
        hb2.pack_start(self.qualtrim_label2, False)
        vb2.pack_start(hb2)

        self.autotrim_checkbox.set_active(cssettings.getTrimConsensus())
        self.autotrim_checkbox.toggled()

        vb.pack_start(vb2)
        frame = gtk.Frame('Sequence trimming')
        frame.add(vb)

        mainvb.pack_start(frame)

        # Use another VBox to get extra padding on the sides.
        vbpad = gtk.VBox(False, 0)
        vbpad.set_border_width(tabpadding_sides)
        vbpad.pack_start(mainvb,
                         expand=False,
                         padding=(tabpadding_tops - tabpadding_sides))

        nb.append_page(vbpad, gtk.Label('Sequence processing'))

        self.vbox.pack_start(nb)

        self.vbox.show_all()
    def dialog_codeboxhandle(self, title):
        """Opens the CodeBox Handle Dialog"""
        dialog = gtk.Dialog(
            title=title,
            parent=self.dad.window,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
                     gtk.RESPONSE_ACCEPT))
        dialog.set_default_size(300, -1)
        dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        button_prog_lang = gtk.Button()
        button_label = self.dad.codebox_syn_highl if self.dad.codebox_syn_highl != cons.PLAIN_TEXT_ID else self.dad.auto_syn_highl
        button_stock_id = config.get_stock_id_for_code_type(button_label)
        button_prog_lang.set_label(button_label)
        button_prog_lang.set_image(
            gtk.image_new_from_stock(button_stock_id, gtk.ICON_SIZE_MENU))
        radiobutton_plain_text = gtk.RadioButton(label=_("Plain Text"))
        radiobutton_auto_syntax_highl = gtk.RadioButton(
            label=_("Automatic Syntax Highlighting"))
        radiobutton_auto_syntax_highl.set_group(radiobutton_plain_text)
        if self.dad.codebox_syn_highl == cons.PLAIN_TEXT_ID:
            radiobutton_plain_text.set_active(True)
            button_prog_lang.set_sensitive(False)
        else:
            radiobutton_auto_syntax_highl.set_active(True)
        type_vbox = gtk.VBox()
        type_vbox.pack_start(radiobutton_plain_text)
        type_vbox.pack_start(radiobutton_auto_syntax_highl)
        type_vbox.pack_start(button_prog_lang)
        type_frame = gtk.Frame(label="<b>" + _("Type") + "</b>")
        type_frame.get_label_widget().set_use_markup(True)
        type_frame.set_shadow_type(gtk.SHADOW_NONE)
        type_frame.add(type_vbox)

        label_width = gtk.Label(_("Width"))
        adj_width = gtk.Adjustment(value=self.dad.codebox_width,
                                   lower=1,
                                   upper=10000,
                                   step_incr=1)
        spinbutton_width = gtk.SpinButton(adj_width)
        spinbutton_width.set_value(self.dad.codebox_width)
        label_height = gtk.Label(_("Height"))
        adj_height = gtk.Adjustment(value=self.dad.codebox_height,
                                    lower=1,
                                    upper=10000,
                                    step_incr=1)
        spinbutton_height = gtk.SpinButton(adj_height)
        spinbutton_height.set_value(self.dad.codebox_height)

        radiobutton_codebox_pixels = gtk.RadioButton(label=_("pixels"))
        radiobutton_codebox_percent = gtk.RadioButton(label="%")
        radiobutton_codebox_percent.set_group(radiobutton_codebox_pixels)
        radiobutton_codebox_pixels.set_active(self.dad.codebox_width_pixels)
        radiobutton_codebox_percent.set_active(
            not self.dad.codebox_width_pixels)

        vbox_pix_perc = gtk.VBox()
        vbox_pix_perc.pack_start(radiobutton_codebox_pixels)
        vbox_pix_perc.pack_start(radiobutton_codebox_percent)
        hbox_width = gtk.HBox()
        hbox_width.pack_start(label_width, expand=False)
        hbox_width.pack_start(spinbutton_width, expand=False)
        hbox_width.pack_start(vbox_pix_perc)
        hbox_width.set_spacing(5)
        hbox_height = gtk.HBox()
        hbox_height.pack_start(label_height, expand=False)
        hbox_height.pack_start(spinbutton_height, expand=False)
        hbox_height.set_spacing(5)
        vbox_size = gtk.VBox()
        vbox_size.pack_start(hbox_width)
        vbox_size.pack_start(hbox_height)
        size_align = gtk.Alignment()
        size_align.set_padding(0, 6, 6, 6)
        size_align.add(vbox_size)

        size_frame = gtk.Frame(label="<b>" + _("Size") + "</b>")
        size_frame.get_label_widget().set_use_markup(True)
        size_frame.set_shadow_type(gtk.SHADOW_NONE)
        size_frame.add(size_align)

        checkbutton_codebox_linenumbers = gtk.CheckButton(
            label=_("Show Line Numbers"))
        checkbutton_codebox_linenumbers.set_active(self.dad.codebox_line_num)
        checkbutton_codebox_matchbrackets = gtk.CheckButton(
            label=_("Highlight Matching Brackets"))
        checkbutton_codebox_matchbrackets.set_active(
            self.dad.codebox_match_bra)
        vbox_options = gtk.VBox()
        vbox_options.pack_start(checkbutton_codebox_linenumbers)
        vbox_options.pack_start(checkbutton_codebox_matchbrackets)
        opt_align = gtk.Alignment()
        opt_align.set_padding(6, 6, 6, 6)
        opt_align.add(vbox_options)

        options_frame = gtk.Frame(label="<b>" + _("Options") + "</b>")
        options_frame.get_label_widget().set_use_markup(True)
        options_frame.set_shadow_type(gtk.SHADOW_NONE)
        options_frame.add(opt_align)

        content_area = dialog.get_content_area()
        content_area.set_spacing(5)
        content_area.pack_start(type_frame)
        content_area.pack_start(size_frame)
        content_area.pack_start(options_frame)
        content_area.show_all()

        def on_button_prog_lang_clicked(button):
            icon_n_key_list = []
            for key in self.dad.available_languages:
                stock_id = config.get_stock_id_for_code_type(key)
                icon_n_key_list.append([key, stock_id, key])
            sel_key = support.dialog_choose_element_in_list(
                self.dad.window, _("Automatic Syntax Highlighting"), [], "",
                icon_n_key_list)
            if sel_key:
                button.set_label(sel_key)
                button.set_image(
                    gtk.image_new_from_stock(sel_key, gtk.ICON_SIZE_MENU))

        button_prog_lang.connect('clicked', on_button_prog_lang_clicked)

        def on_radiobutton_auto_syntax_highl_toggled(radiobutton):
            button_prog_lang.set_sensitive(radiobutton.get_active())

        def on_key_press_codeboxhandle(widget, event):
            keyname = gtk.gdk.keyval_name(event.keyval)
            if keyname == cons.STR_KEY_RETURN:
                spinbutton_width.update()
                spinbutton_height.update()
                try:
                    dialog.get_widget_for_response(
                        gtk.RESPONSE_ACCEPT).clicked()
                except:
                    print cons.STR_PYGTK_222_REQUIRED
                return True
            return False

        def on_radiobutton_codebox_pixels_toggled(radiobutton):
            if radiobutton.get_active():
                spinbutton_width.set_value(700)
            else:
                if spinbutton_width.get_value() > 100:
                    spinbutton_width.set_value(90)

        radiobutton_auto_syntax_highl.connect(
            "toggled", on_radiobutton_auto_syntax_highl_toggled)
        dialog.connect('key_press_event', on_key_press_codeboxhandle)
        radiobutton_codebox_pixels.connect(
            'toggled', on_radiobutton_codebox_pixels_toggled)
        response = dialog.run()
        dialog.hide()
        if response == gtk.RESPONSE_ACCEPT:
            self.dad.codebox_width = spinbutton_width.get_value()
            self.dad.codebox_width_pixels = radiobutton_codebox_pixels.get_active(
            )
            self.dad.codebox_height = spinbutton_height.get_value()
            self.dad.codebox_line_num = checkbutton_codebox_linenumbers.get_active(
            )
            self.dad.codebox_match_bra = checkbutton_codebox_matchbrackets.get_active(
            )
            if radiobutton_plain_text.get_active():
                self.dad.codebox_syn_highl = cons.PLAIN_TEXT_ID
            else:
                self.dad.codebox_syn_highl = button_prog_lang.get_label()
            return True
        return False
Exemple #3
0
    def dialog_tablecolhandle(self, title, rename_text):
        """Opens the Table Column Handle Dialog"""
        dialog = gtk.Dialog(
            title=title,
            parent=self.dad.window,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
                     gtk.RESPONSE_ACCEPT))
        dialog.set_default_size(300, -1)
        dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        hbox_column_rename = gtk.HBox()
        image_column_rename = gtk.Image()
        image_column_rename.set_from_stock(gtk.STOCK_EDIT,
                                           gtk.ICON_SIZE_BUTTON)
        table_column_rename_radiobutton = gtk.RadioButton(
            label=_("Rename Column"))
        table_column_rename_entry = gtk.Entry()
        table_column_rename_entry.set_text(rename_text)
        table_column_rename_entry.set_sensitive(
            self.dad.table_column_mode == 'rename')
        hbox_column_rename.pack_start(image_column_rename, expand=False)
        hbox_column_rename.pack_start(table_column_rename_radiobutton)
        hbox_column_rename.pack_start(table_column_rename_entry)

        hbox_column_delete = gtk.HBox()
        image_column_delete = gtk.Image()
        image_column_delete.set_from_stock(gtk.STOCK_CLEAR,
                                           gtk.ICON_SIZE_BUTTON)
        table_column_delete_radiobutton = gtk.RadioButton(
            label=_("Delete Column"))
        table_column_delete_radiobutton.set_group(
            table_column_rename_radiobutton)
        hbox_column_delete.pack_start(image_column_delete, expand=False)
        hbox_column_delete.pack_start(table_column_delete_radiobutton)

        hbox_column_add = gtk.HBox()
        image_column_add = gtk.Image()
        image_column_add.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
        table_column_add_radiobutton = gtk.RadioButton(label=_("Add Column"))
        table_column_add_radiobutton.set_group(table_column_rename_radiobutton)
        table_column_new_entry = gtk.Entry()
        hbox_column_add.pack_start(image_column_add, expand=False)
        hbox_column_add.pack_start(table_column_add_radiobutton)
        hbox_column_add.pack_start(table_column_new_entry)
        table_column_new_entry.set_sensitive(
            self.dad.table_column_mode == 'add')

        hbox_column_left = gtk.HBox()
        image_column_left = gtk.Image()
        image_column_left.set_from_stock(gtk.STOCK_GO_BACK,
                                         gtk.ICON_SIZE_BUTTON)
        table_column_left_radiobutton = gtk.RadioButton(
            label=_("Move Column Left"))
        table_column_left_radiobutton.set_group(
            table_column_rename_radiobutton)
        hbox_column_left.pack_start(image_column_left, expand=False)
        hbox_column_left.pack_start(table_column_left_radiobutton)

        hbox_column_right = gtk.HBox()
        image_column_right = gtk.Image()
        image_column_right.set_from_stock(gtk.STOCK_GO_FORWARD,
                                          gtk.ICON_SIZE_BUTTON)
        table_column_right_radiobutton = gtk.RadioButton(
            label=_("Move Column Right"))
        table_column_right_radiobutton.set_group(
            table_column_rename_radiobutton)
        hbox_column_right.pack_start(image_column_right, expand=False)
        hbox_column_right.pack_start(table_column_right_radiobutton)

        table_column_rename_radiobutton.set_active(
            self.dad.table_column_mode == "rename")
        table_column_delete_radiobutton.set_active(
            self.dad.table_column_mode == "delete")
        table_column_add_radiobutton.set_active(
            self.dad.table_column_mode == "add")
        table_column_left_radiobutton.set_active(
            self.dad.table_column_mode == cons.TAG_PROP_LEFT)
        table_column_right_radiobutton.set_active(
            self.dad.table_column_mode == cons.TAG_PROP_RIGHT)
        if self.dad.table_column_mode == "rename":
            table_column_rename_entry.grab_focus()
        elif self.dad.table_column_mode == "add":
            table_column_new_entry.grab_focus()

        tablehandle_vbox_col = gtk.VBox()
        tablehandle_vbox_col.pack_start(hbox_column_rename)
        tablehandle_vbox_col.pack_start(hbox_column_delete)
        tablehandle_vbox_col.pack_start(hbox_column_add)
        tablehandle_vbox_col.pack_start(hbox_column_left)
        tablehandle_vbox_col.pack_start(hbox_column_right)

        content_area = dialog.get_content_area()
        content_area.set_spacing(5)
        content_area.pack_start(tablehandle_vbox_col)
        content_area.show_all()

        def on_key_press_tablecolhandle(widget, event):
            keyname = gtk.gdk.keyval_name(event.keyval)
            if keyname == cons.STR_KEY_RETURN:
                try:
                    dialog.get_widget_for_response(
                        gtk.RESPONSE_ACCEPT).clicked()
                except:
                    print cons.STR_PYGTK_222_REQUIRED
                return True
            elif keyname == cons.STR_KEY_TAB:
                if self.dad.table_column_mode == "rename":
                    table_column_delete_radiobutton.set_active(True)
                elif self.dad.table_column_mode == "delete":
                    table_column_add_radiobutton.set_active(True)
                elif self.dad.table_column_mode == "add":
                    table_column_left_radiobutton.set_active(True)
                elif self.dad.table_column_mode == cons.TAG_PROP_LEFT:
                    table_column_right_radiobutton.set_active(True)
                else:
                    table_column_rename_radiobutton.set_active(True)
                return True
            return False

        def on_table_column_rename_radiobutton_toggled(radiobutton):
            if radiobutton.get_active():
                table_column_rename_entry.set_sensitive(True)
                self.dad.table_column_mode = "rename"
                table_column_rename_entry.grab_focus()
            else:
                table_column_rename_entry.set_sensitive(False)

        def on_table_column_delete_radiobutton_toggled(radiobutton):
            if radiobutton.get_active(): self.dad.table_column_mode = "delete"

        def on_table_column_add_radiobutton_toggled(radiobutton):
            if radiobutton.get_active():
                table_column_new_entry.set_sensitive(True)
                self.dad.table_column_mode = "add"
                table_column_new_entry.grab_focus()
            else:
                table_column_new_entry.set_sensitive(False)

        def on_table_column_left_radiobutton_toggled(radiobutton):
            if radiobutton.get_active():
                self.dad.table_column_mode = cons.TAG_PROP_LEFT

        def on_table_column_right_radiobutton_toggled(radiobutton):
            if radiobutton.get_active():
                self.dad.table_column_mode = cons.TAG_PROP_RIGHT

        dialog.connect('key_press_event', on_key_press_tablecolhandle)
        table_column_rename_radiobutton.connect(
            'toggled', on_table_column_rename_radiobutton_toggled)
        table_column_delete_radiobutton.connect(
            'toggled', on_table_column_delete_radiobutton_toggled)
        table_column_add_radiobutton.connect(
            'toggled', on_table_column_add_radiobutton_toggled)
        table_column_left_radiobutton.connect(
            'toggled', on_table_column_left_radiobutton_toggled)
        table_column_right_radiobutton.connect(
            'toggled', on_table_column_right_radiobutton_toggled)
        response = dialog.run()
        dialog.hide()
        if response == gtk.RESPONSE_ACCEPT:
            ret_rename = unicode(table_column_rename_entry.get_text(),
                                 cons.STR_UTF8, cons.STR_IGNORE)
            ret_add = unicode(table_column_new_entry.get_text(), cons.STR_UTF8,
                              cons.STR_IGNORE)
            return [True, ret_rename, ret_add]
        return [False, None, None]
    def getScreen(self, anaconda):
        self.neededSwap = 0
        self.storage = anaconda.storage
        self.intf = anaconda.intf
        self.dispatch = anaconda.dispatch

        rc = anaconda.upgradeSwapInfo

        self.neededSwap = 1
        self.row = 0
        box = gtk.VBox(False, 5)
        box.set_border_width(5)

        label = gtk.Label(
            _("Recent kernels (2.4 or newer) need significantly more "
              "swap than older kernels, up to twice "
              "the amount of RAM on the system.  "
              "You currently have %dMB of swap configured, but "
              "you may create additional swap space on one of "
              "your file systems now.") % (iutil.swapAmount() / 1024) +
            _("\n\nThe installer has detected %s MB of RAM.\n") %
            (iutil.memInstalled() / 1024))

        label.set_alignment(0.5, 0.0)
        #        label.set_size_request(400, 200)
        label.set_line_wrap(True)
        box.pack_start(label, False)

        hs = gtk.HSeparator()
        box.pack_start(hs, False)

        self.option1 = gtk.RadioButton(None,
                                       (_("I _want to create a swap file")))
        box.pack_start(self.option1, False)

        (fsList, suggSize, suggMntPoint) = rc

        self.swapbox = gtk.VBox(False, 5)
        box.pack_start(self.swapbox, False)

        label = gui.MnemonicLabel(
            _("Select the _partition to put the swap file on:"))
        a = gtk.Alignment(0.2, 0.5)
        a.add(label)
        self.swapbox.pack_start(a, False)

        self.store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                                   gobject.TYPE_STRING)

        for (dev, size) in fsList:
            iter = self.store.append()
            self.store.set_value(iter, 0, dev)
            self.store.set_value(iter, 1, str(size))

        self.view = gtk.TreeView(self.store)
        label.set_mnemonic_widget(self.view)

        i = 0
        for title in [(_("Mount Point")), (_("Partition")),
                      (_("Free Space (MB)"))]:
            col = gtk.TreeViewColumn(title, gtk.CellRendererText(), text=i)
            self.view.append_column(col)
            i = i + 1

        sw = gtk.ScrolledWindow()
        sw.add(self.view)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.set_size_request(300, 90)
        a = gtk.Alignment(0.5, 0.5)
        a.add(sw)
        self.swapbox.pack_start(a, False, True, 10)

        rootiter = self.store.get_iter_first()
        sel = self.view.get_selection()
        sel.select_iter(rootiter)

        label = gtk.Label(
            _("A minimum swap file size of "
              "%d MB is recommended.  Please enter a size for the swap "
              "file:") % suggSize)
        label.set_size_request(400, 40)
        label.set_line_wrap(True)
        a = gtk.Alignment(0.5, 0.5)
        a.add(label)
        self.swapbox.pack_start(a, False, True, 10)

        hbox = gtk.HBox(False, 5)
        a = gtk.Alignment(0.4, 0.5)
        a.add(hbox)
        self.swapbox.pack_start(a, False)

        label = gui.MnemonicLabel(_("Swap file _size (MB):"))
        hbox.pack_start(label, False)

        self.entry = gtk.Entry(4)
        label.set_mnemonic_widget(self.entry)
        self.entry.set_size_request(40, 25)
        self.entry.set_text(str(suggSize))
        hbox.pack_start(self.entry, False, True, 10)

        self.option2 = gtk.RadioButton(self.option1,
                                       (_("I _don't want to create a swap "
                                          "file")))
        box.pack_start(self.option2, False, True, 20)

        self.option1.connect("toggled", self.toggle)
        return box
Exemple #5
0
 def create_widgets(self):
     self.VB = gtk.VBox()
     if not self.upgrade:
         self.modeVBox = gtk.VBox()
         self.modeHBox = gtk.HBox(homogeneous=True)
         self.mode0 = gtk.RadioButton(group=None, label='Mode: 0')
         self.modeHBox.pack_start(self.mode0)
         self.mode1 = gtk.RadioButton(group=self.mode0, label='Mode: 1')
         self.modeHBox.pack_start(self.mode1)
         self.mode2 = gtk.RadioButton(group=self.mode0, label='Mode: 2')
         self.modeHBox.pack_start(self.mode2)
         self.modeLabel = gtk.Label('Use arc voltage for both arc-OK and THC')
         self.modeLabel.set_alignment(0,0)
         modeBlank = gtk.Label('')
         self.modeVBox.pack_start(self.modeHBox)
         self.modeVBox.pack_start(self.modeLabel)
         self.modeVBox.pack_start(modeBlank)
         self.VB.pack_start(self.modeVBox,expand=False)
         self.nameVBox = gtk.VBox()
         nameLabel = gtk.Label('Machine Name:')
         nameLabel.set_alignment(0,0)
         self.nameFile = gtk.Entry()
         self.nameFile.set_width_chars(60)
         self.nameFile.set_tooltip_markup(\
             'The <b>name</b> of the new or existing machine.\n'\
             'If not existing, this creates a directory ~/linuxcnc/configs/<b>name</b>.\n'\
             '<b>name</b>.ini and <b>name</b>.hal are then written to this directory '\
             'as well as other required files and links to appplication files.\n\n')
         nameBlank = gtk.Label('')
         self.nameVBox.pack_start(nameLabel)
         self.nameVBox.pack_start(self.nameFile)
         self.nameVBox.pack_start(nameBlank)
         self.VB.pack_start(self.nameVBox,expand=False)
     self.iniVBox = gtk.VBox()
     if self.upgrade:
         self.iniLabel = gtk.Label('INI file of configuration to upgrade:')
     else:
         self.iniLabel = gtk.Label('INI file in existing working config:')
     self.iniLabel.set_alignment(0,0)
     self.iniFile = gtk.Entry()
     self.iniFile.set_width_chars(60)
     self.iniBlank = gtk.Label('')
     self.iniVBox.pack_start(self.iniLabel)
     self.iniVBox.pack_start(self.iniFile)
     self.iniVBox.pack_start(self.iniBlank)
     self.VB.pack_start(self.iniVBox,expand=False)
     if not self.upgrade:
         self.halVBox = gtk.VBox()
         halLabel = gtk.Label('HAL file in existing working config:')
         halLabel.set_alignment(0,0)
         self.halFile = gtk.Entry()
         self.halFile.set_width_chars(60)
         halBlank = gtk.Label('')
         self.halVBox.pack_start(halLabel)
         self.halVBox.pack_start(self.halFile)
         self.halVBox.pack_start(halBlank)
         self.VB.pack_start(self.halVBox,expand=False)
         self.arcVoltVBox = gtk.VBox()
         self.arcVoltLabel = gtk.Label('Arc Voltage HAL pin:')
         self.arcVoltLabel.set_alignment(0,0)
         self.arcVoltPin = gtk.Entry()
         self.arcVoltPin.set_width_chars(60)
         arcVoltBlank = gtk.Label('')
         self.arcVoltVBox.pack_start(self.arcVoltLabel)
         self.arcVoltVBox.pack_start(self.arcVoltPin)
         self.arcVoltVBox.pack_start(arcVoltBlank)
         self.VB.pack_start(self.arcVoltVBox,expand=False)
         self.arcOkVBox = gtk.VBox()
         self.arcOkLabel = gtk.Label('Arc OK HAL pin:')
         self.arcOkLabel.set_alignment(0,0)
         self.arcOkPin = gtk.Entry()
         self.arcOkPin.set_width_chars(60)
         arcOkBlank = gtk.Label('')
         self.arcOkVBox.pack_start(self.arcOkLabel)
         self.arcOkVBox.pack_start(self.arcOkPin)
         self.arcOkVBox.pack_start(arcOkBlank)
         self.VB.pack_start(self.arcOkVBox,expand=False)
         self.ohmicInVBox = gtk.VBox()
         ohmicInLabel = gtk.Label('Ohmic Probe HAL pin (optional):')
         ohmicInLabel.set_alignment(0,0)
         self.ohmicInPin = gtk.Entry()
         self.ohmicInPin.set_width_chars(60)
         ohmicInBlank = gtk.Label('')
         self.ohmicInVBox.pack_start(ohmicInLabel)
         self.ohmicInVBox.pack_start(self.ohmicInPin)
         self.ohmicInVBox.pack_start(ohmicInBlank)
         self.VB.pack_start(self.ohmicInVBox,expand=False)
         self.ohmicOutVBox = gtk.VBox()
         ohmicOutLabel = gtk.Label('Ohmic Probe Enable HAL pin (optional):')
         ohmicOutLabel.set_alignment(0,0)
         self.ohmicOutPin = gtk.Entry()
         self.ohmicOutPin.set_width_chars(60)
         ohmicOutBlank = gtk.Label('')
         self.ohmicOutVBox.pack_start(ohmicOutLabel)
         self.ohmicOutVBox.pack_start(self.ohmicOutPin)
         self.ohmicOutVBox.pack_start(ohmicOutBlank)
         self.VB.pack_start(self.ohmicOutVBox,expand=False)
         self.floatVBox = gtk.VBox()
         floatLabel = gtk.Label('Float Switch HAL pin (optional):')
         floatLabel.set_alignment(0,0)
         self.floatPin = gtk.Entry()
         self.floatPin.set_width_chars(60)
         floatBlank = gtk.Label('')
         self.floatVBox.pack_start(floatLabel)
         self.floatVBox.pack_start(self.floatPin)
         self.floatVBox.pack_start(floatBlank)
         self.VB.pack_start(self.floatVBox,expand=False)
         self.breakVBox = gtk.VBox()
         breakLabel = gtk.Label('Breakaway Switch HAL pin (optional):')
         breakLabel.set_alignment(0,0)
         self.breakPin = gtk.Entry()
         self.breakPin.set_width_chars(60)
         breakBlank = gtk.Label('')
         self.breakVBox.pack_start(breakLabel)
         self.breakVBox.pack_start(self.breakPin)
         self.breakVBox.pack_start(breakBlank)
         self.VB.pack_start(self.breakVBox,expand=False)
         self.torchVBox = gtk.VBox()
         torchLabel = gtk.Label('Torch On HAL pin:')
         torchLabel.set_alignment(0,0)
         self.torchPin = gtk.Entry()
         self.torchPin.set_width_chars(60)
         torchBlank = gtk.Label('')
         self.torchVBox.pack_start(torchLabel)
         self.torchVBox.pack_start(self.torchPin)
         self.torchVBox.pack_start(torchBlank)
         self.VB.pack_start(self.torchVBox,expand=False)
         self.moveUpVBox = gtk.VBox()
         self.moveUpLabel = gtk.Label('Move Up HAL pin:')
         self.moveUpLabel.set_alignment(0,0)
         self.moveUpPin = gtk.Entry()
         self.moveUpPin.set_width_chars(60)
         moveUpBlank = gtk.Label('')
         self.moveUpVBox.pack_start(self.moveUpLabel)
         self.moveUpVBox.pack_start(self.moveUpPin)
         self.moveUpVBox.pack_start(moveUpBlank)
         self.VB.pack_start(self.moveUpVBox,expand=False)
         self.moveDownVBox = gtk.VBox()
         self.moveDownLabel = gtk.Label('Move Down HAL pin:')
         self.moveDownLabel.set_alignment(0,0)
         self.moveDownPin = gtk.Entry()
         self.moveDownPin.set_width_chars(60)
         moveDownBlank = gtk.Label('')
         self.moveDownVBox.pack_start(self.moveDownLabel)
         self.moveDownVBox.pack_start(self.moveDownPin)
         self.moveDownVBox.pack_start(moveDownBlank)
         self.VB.pack_start(self.moveDownVBox,expand=False)
         self.tabPanelVBox = gtk.VBox()
         self.tabPanelHBox = gtk.HBox(homogeneous=True)
         self.tabPanel0 = gtk.RadioButton(group=None, label='Run Tab')
         self.tabPanelHBox.pack_start(self.tabPanel0)
         self.tabPanel1 = gtk.RadioButton(group=self.tabPanel0, label='Run Panel')
         self.tabPanelHBox.pack_start(self.tabPanel1)
         self.tabPanelLabel = gtk.Label('Run Frame is a tab behind preview')
         self.tabPanelLabel.set_alignment(0,0)
         tabPanelBlank = gtk.Label('')
         self.tabPanelVBox.pack_start(self.tabPanelHBox)
         self.tabPanelVBox.pack_start(self.tabPanelLabel)
         self.tabPanelVBox.pack_start(tabPanelBlank)
         self.VB.pack_start(self.tabPanelVBox,expand=False)
     BB = gtk.HButtonBox()
     if self.upgrade:
         self.create = gtk.Button('Upgrade')
     else:
         self.create = gtk.Button('Create')
     self.cancel = gtk.Button('Exit')
     BB.pack_start(self.create, True, True, 0)
     BB.pack_start(self.cancel, True, True, 0)
     BB.set_border_width(5)
     self.VB.pack_start(BB,expand=False)
     self.W.add(self.VB)
     self.W.show_all()
     if not self.upgrade:
         self.modeLabel.set_text('Use arc voltage for both arc-OK and THC')
         self.tabPanelLabel.set_text('Run Frame is a tab behind preview')
         self.arcVoltVBox.show()
         self.arcOkVBox.hide()
         self.moveUpVBox.hide()
         self.moveDownVBox.hide()
     else:
         self.W.set_title('PlasmaC Upgrader')
Exemple #6
0
    def __init_gui(self):
        ''' പൂമുഖം തുറന്ന്, ദര്‍ശനം നല്‍കാം... '''
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.set_title(title)
        self.set_default_size(340, 160)
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        self.connect("destroy", self.__quit)

        # ലേബലടിക്ക്.
        ascii_lbl = gtk.Label(_("ASCII File : "))
        mapping_lbl = gtk.Label(_("Mapping File : "))
        unicode_lbl = gtk.Label(_("Unicode File : "))

        # പ്രമാണോം പത്രോം ആധാരോം എടുക്ക്വാ..
        #ascii_btn   = gtk.FileChooserButton(_("Select the ASCII File (.txt,.pdf)"))
        ascii_btn = gtk.Button("ASCII File...", None)
        ascii_btn.connect("clicked", self.__choose_ascii_file)
        unicode_btn = gtk.Button("Unicode File...", None)
        unicode_btn.connect("clicked", self.__choose_unicode_file)
        mapping_btn = gtk.FileChooserButton(
            _("Select the ASCII-Unicode Mapping File"))
        #unicode_btn = gtk.FileChooserButton(_("Select Output Unicode File"))

        # ആസ്കി-യൂണിക്കോഡ് ആണോ, അതോ യൂണിക്കോഡ്-ആസ്കിയോ?
        a2u_radio = gtk.RadioButton(None, (_("ASCII-to-Unicode")))
        u2a_radio = gtk.RadioButton(a2u_radio, (_("Unicode-to-ASCII")))

        # മാപ്പ്, സാധാരണ എവിടെ കിട്ടും? അല്ല, എവിടെ കിട്ടും?
        mapping_dir = sys.prefix + "/share/payyans/maps/"
        mapping_btn.set_current_folder(mapping_dir)

        # Define the Actions. Lets get some action, baby!
        convert_btn = gtk.Button(_("Convert"), gtk.STOCK_CONVERT)
        convert_btn.connect("clicked", self.__convert_file)
        cancel_btn = gtk.Button(_("Quit"), gtk.STOCK_QUIT)
        cancel_btn.connect("clicked", self.__quit)
        about_btn = gtk.Button(_("About"), gtk.STOCK_ABOUT)
        about_btn.connect("clicked", self.__show_about)

        self.a2u_radio = a2u_radio
        self.u2a_radio = u2a_radio

        self.ascii_btn = ascii_btn
        self.mapping_btn = mapping_btn
        self.unicode_btn = unicode_btn

        # Pack the widgets. പാക്കു ചെയ്യ്, പാക്കു വെട്ട്.
        hbox1 = gtk.HBox()
        hbox1.set_border_width(4)
        hbox1.pack_start(ascii_lbl)
        hbox1.pack_end(ascii_btn)

        hbox2 = gtk.HBox()
        hbox2.set_border_width(4)
        hbox2.pack_start(mapping_lbl)
        hbox2.pack_end(mapping_btn)

        hbox3 = gtk.HBox()
        hbox3.set_border_width(4)
        hbox3.pack_start(unicode_lbl)
        hbox3.pack_end(unicode_btn)

        radio_box = gtk.HBox()
        radio_box.set_border_width(12)
        radio_box.pack_start(a2u_radio)
        radio_box.pack_start(u2a_radio)

        btn_box = gtk.HButtonBox()
        btn_box.set_border_width(4)
        btn_box.pack_start(convert_btn)
        btn_box.pack_start(about_btn)
        btn_box.pack_start(cancel_btn)

        vbox1 = gtk.VBox()
        vbox1.set_border_width(4)
        vbox1.pack_start(hbox1)
        vbox1.pack_start(hbox2)
        vbox1.pack_start(hbox3)
        vbox1.pack_start(radio_box)
        vbox1.pack_end(btn_box)

        frame = gtk.Frame()
        frame.set_border_width(5)
        frame.add(vbox1)
        self.add(frame)

        self.show_all()
Exemple #7
0
 def do_triangle(self, fWizard, tmpDir):
     self.tmpDir = tmpDir
     self.fWizard = fWizard
     self.W = gtk.Dialog('Triangle',
                         None,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         buttons = None)
     self.W.set_keep_above(True)
     self.W.set_position(gtk.WIN_POS_CENTER_ALWAYS)
     self.W.set_default_size(250, 200)
     t = gtk.Table(1, 1, True)
     t.set_row_spacings(6)
     self.W.vbox.add(t)
     cutLabel = gtk.Label('Cut Type')
     cutLabel.set_alignment(0.95, 0.5)
     cutLabel.set_width_chars(10)
     t.attach(cutLabel, 0, 1, 0, 1)
     self.outside = gtk.RadioButton(None, 'Outside')
     t.attach(self.outside, 1, 2, 0, 1)
     inside = gtk.RadioButton(self.outside, 'Inside')
     t.attach(inside, 2, 3, 0, 1)
     offsetLabel = gtk.Label('Offset')
     offsetLabel.set_alignment(0.95, 0.5)
     offsetLabel.set_width_chars(10)
     t.attach(offsetLabel, 3, 4, 0, 1)
     self.offset = gtk.CheckButton('Kerf Width')
     t.attach(self.offset, 4, 5, 0, 1)
     lLabel = gtk.Label('Lead In')
     lLabel.set_alignment(0.95, 0.5)
     lLabel.set_width_chars(10)
     t.attach(lLabel, 0, 1, 1, 2)
     self.liEntry = gtk.Entry()
     self.liEntry.set_width_chars(10)
     t.attach(self.liEntry, 1, 2, 1, 2)
     loLabel = gtk.Label('Lead Out')
     loLabel.set_alignment(0.95, 0.5)
     loLabel.set_width_chars(10)
     t.attach(loLabel, 0, 1, 2, 3)
     self.loEntry = gtk.Entry()
     self.loEntry.set_width_chars(10)
     t.attach(self.loEntry, 1, 2, 2, 3)
     xSLabel = gtk.Label('X start')
     xSLabel.set_alignment(0.95, 0.5)
     xSLabel.set_width_chars(10)
     t.attach(xSLabel, 0, 1, 3, 4)
     self.xSEntry = gtk.Entry()
     self.xSEntry.set_width_chars(10)
     t.attach(self.xSEntry, 1, 2, 3, 4)
     ySLabel = gtk.Label('Y start')
     ySLabel.set_alignment(0.95, 0.5)
     ySLabel.set_width_chars(10)
     t.attach(ySLabel, 0, 1, 4, 5)
     self.ySEntry = gtk.Entry()
     self.ySEntry.set_width_chars(10)
     t.attach(self.ySEntry, 1, 2, 4, 5)
     ALabel = gtk.Label('A angle')
     ALabel.set_alignment(0.95, 0.5)
     ALabel.set_width_chars(10)
     t.attach(ALabel, 0, 1, 5, 6)
     self.AEntry = gtk.Entry()
     self.AEntry.set_width_chars(10)
     t.attach(self.AEntry, 1, 2, 5, 6)
     BLabel = gtk.Label('B angle')
     BLabel.set_alignment(0.95, 0.5)
     BLabel.set_width_chars(10)
     t.attach(BLabel, 0, 1, 6, 7)
     self.BEntry = gtk.Entry()
     self.BEntry.set_width_chars(10)
     t.attach(self.BEntry, 1, 2, 6, 7)
     CLabel = gtk.Label('C angle')
     CLabel.set_alignment(0.95, 0.5)
     CLabel.set_width_chars(10)
     t.attach(CLabel, 0, 1, 7, 8)
     self.CEntry = gtk.Entry()
     self.CEntry.set_width_chars(10)
     t.attach(self.CEntry, 1, 2, 7, 8)
     aLabel = gtk.Label('a length')
     aLabel.set_alignment(0.95, 0.5)
     aLabel.set_width_chars(10)
     t.attach(aLabel, 0, 1, 8, 9)
     self.aEntry = gtk.Entry()
     self.aEntry.set_width_chars(10)
     t.attach(self.aEntry, 1, 2, 8, 9)
     bLabel = gtk.Label('b length')
     bLabel.set_alignment(0.95, 0.5)
     bLabel.set_width_chars(10)
     t.attach(bLabel, 0, 1, 9, 10)
     self.bEntry = gtk.Entry()
     self.bEntry.set_width_chars(10)
     t.attach(self.bEntry, 1, 2, 9, 10)
     cLabel = gtk.Label('c length')
     cLabel.set_alignment(0.95, 0.5)
     cLabel.set_width_chars(10)
     t.attach(cLabel, 0, 1, 10, 11)
     self.cEntry = gtk.Entry()
     self.cEntry.set_width_chars(10)
     t.attach(self.cEntry, 1, 2, 10, 11)
     angLabel = gtk.Label('Angle')
     angLabel.set_alignment(0.95, 0.5)
     angLabel.set_width_chars(10)
     t.attach(angLabel, 0, 1, 11, 12)
     self.angEntry = gtk.Entry()
     self.angEntry.set_width_chars(10)
     self.angEntry.set_text('0')
     t.attach(self.angEntry, 1, 2, 11, 12)
     preview = gtk.Button('Preview')
     preview.connect('pressed', self.send_preview)
     t.attach(preview, 0, 1, 13, 14)
     self.add = gtk.Button('Add')
     self.add.set_sensitive(False)
     self.add.connect('pressed', self.add_shape_to_file)
     t.attach(self.add, 2, 3, 13, 14)
     end = gtk.Button('Return')
     end.connect('pressed', self.end_this_shape)
     t.attach(end, 4, 5, 13, 14)
     pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
             filename='./wizards/images/triangle.png', 
             width=240, 
             height=240)
     image = gtk.Image()
     image.set_from_pixbuf(pixbuf)
     t.attach(image, 2, 5, 1, 9)
     self.xSEntry.grab_focus()
     self.W.show_all()
     if os.path.exists(self.configFile):
         f_in = open(self.configFile, 'r')
         for line in f_in:
             if line.startswith('preamble'):
                 self.preamble = line.strip().split('=')[1]
             elif line.startswith('postamble'):
                 self.postamble = line.strip().split('=')[1]
             elif line.startswith('lead-in'):
                 self.liEntry.set_text(line.strip().split('=')[1])
             elif line.startswith('lead-out'):
                 self.loEntry.set_text(line.strip().split('=')[1])
     response = self.W.run()
Exemple #8
0
 def star_show(self, parent, entries, fNgc, fNgcBkp, fTmp, rowS, xOrigin,
               yOrigin):
     entries.set_row_spacings(rowS)
     self.parent = parent
     for child in entries.get_children():
         entries.remove(child)
     self.fNgc = fNgc
     self.fNgcBkp = fNgcBkp
     self.fTmp = fTmp
     cLabel = gtk.Label('Cut Type')
     cLabel.set_alignment(0.95, 0.5)
     cLabel.set_width_chars(8)
     entries.attach(cLabel, 0, 1, 0, 1)
     self.outside = gtk.RadioButton(None, 'Outside')
     self.outside.connect('toggled', self.auto_preview)
     entries.attach(self.outside, 1, 2, 0, 1)
     inside = gtk.RadioButton(self.outside, 'Inside')
     entries.attach(inside, 2, 3, 0, 1)
     oLabel = gtk.Label('Offset')
     oLabel.set_alignment(0.95, 0.5)
     oLabel.set_width_chars(8)
     entries.attach(oLabel, 3, 4, 0, 1)
     self.offset = gtk.CheckButton('Kerf')
     self.offset.connect('toggled', self.auto_preview)
     entries.attach(self.offset, 4, 5, 0, 1)
     lLabel = gtk.Label('Lead In')
     lLabel.set_alignment(0.95, 0.5)
     lLabel.set_width_chars(8)
     entries.attach(lLabel, 0, 1, 1, 2)
     self.liEntry = gtk.Entry()
     self.liEntry.set_width_chars(8)
     self.liEntry.connect('activate', self.auto_preview)
     self.liEntry.connect('changed', self.entry_changed)
     entries.attach(self.liEntry, 1, 2, 1, 2)
     loLabel = gtk.Label('Lead Out')
     loLabel.set_alignment(0.95, 0.5)
     loLabel.set_width_chars(8)
     entries.attach(loLabel, 0, 1, 2, 3)
     self.loEntry = gtk.Entry()
     self.loEntry.set_width_chars(8)
     self.loEntry.connect('activate', self.auto_preview)
     self.loEntry.connect('changed', self.parent.entry_changed)
     entries.attach(self.loEntry, 1, 2, 2, 3)
     xSLabel = gtk.Label()
     xSLabel.set_markup('X <span foreground="red">origin</span>')
     xSLabel.set_alignment(0.95, 0.5)
     xSLabel.set_width_chars(8)
     entries.attach(xSLabel, 0, 1, 3, 4)
     self.xSEntry = gtk.Entry()
     self.xSEntry.set_width_chars(8)
     self.xSEntry.connect('activate', self.auto_preview)
     self.xSEntry.connect('changed', self.parent.entry_changed)
     entries.attach(self.xSEntry, 1, 2, 3, 4)
     ySLabel = gtk.Label()
     ySLabel.set_markup('Y <span foreground="red">origin</span>')
     ySLabel.set_alignment(0.95, 0.5)
     ySLabel.set_width_chars(8)
     entries.attach(ySLabel, 0, 1, 4, 5)
     self.ySEntry = gtk.Entry()
     self.ySEntry.set_width_chars(8)
     self.ySEntry.connect('activate', self.auto_preview)
     self.ySEntry.connect('changed', self.parent.entry_changed)
     entries.attach(self.ySEntry, 1, 2, 4, 5)
     self.centre = gtk.RadioButton(None, 'Centre')
     self.centre.connect('toggled', self.auto_preview)
     entries.attach(self.centre, 1, 2, 5, 6)
     self.bLeft = gtk.RadioButton(self.centre, 'Btm Lft')
     entries.attach(self.bLeft, 0, 1, 5, 6)
     pLabel = gtk.Label('# of Points')
     pLabel.set_alignment(0.95, 0.5)
     pLabel.set_width_chars(8)
     entries.attach(pLabel, 0, 1, 6, 7)
     self.pEntry = gtk.Entry()
     self.pEntry.set_width_chars(8)
     self.pEntry.connect('activate', self.auto_preview)
     self.pEntry.connect('changed', self.parent.entry_changed)
     entries.attach(self.pEntry, 1, 2, 6, 7)
     self.odLabel = gtk.Label('Outer Dia')
     self.odLabel.set_alignment(0.95, 0.5)
     self.odLabel.set_width_chars(8)
     entries.attach(self.odLabel, 0, 1, 7, 8)
     self.odEntry = gtk.Entry()
     self.odEntry.set_width_chars(8)
     self.odEntry.connect('activate', self.auto_preview)
     self.odEntry.connect('changed', self.parent.entry_changed)
     entries.attach(self.odEntry, 1, 2, 7, 8)
     self.idLabel = gtk.Label('Inner Dia')
     self.idLabel.set_alignment(0.95, 0.5)
     self.idLabel.set_width_chars(8)
     entries.attach(self.idLabel, 0, 1, 8, 9)
     self.idEntry = gtk.Entry()
     self.idEntry.set_width_chars(8)
     self.idEntry.connect('activate', self.auto_preview)
     self.idEntry.connect('changed', self.parent.entry_changed)
     entries.attach(self.idEntry, 1, 2, 8, 9)
     aLabel = gtk.Label('Angle')
     aLabel.set_alignment(0.95, 0.5)
     aLabel.set_width_chars(8)
     entries.attach(aLabel, 0, 1, 9, 10)
     self.aEntry = gtk.Entry()
     self.aEntry.set_width_chars(8)
     self.aEntry.set_text('0')
     self.aEntry.connect('activate', self.auto_preview)
     self.aEntry.connect('changed', self.parent.entry_changed)
     entries.attach(self.aEntry, 1, 2, 9, 10)
     preview = gtk.Button('Preview')
     preview.connect('pressed', self.star_preview)
     entries.attach(preview, 0, 1, 13, 14)
     self.add = gtk.Button('Add')
     self.add.set_sensitive(False)
     self.add.connect('pressed', self.parent.add_shape_to_file, self.add)
     entries.attach(self.add, 2, 3, 13, 14)
     undo = gtk.Button('Undo')
     undo.connect('pressed', self.parent.undo_shape, self.add)
     entries.attach(undo, 4, 5, 13, 14)
     pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
         filename='./wizards/images/star.png', width=240, height=240)
     image = gtk.Image()
     image.set_from_pixbuf(pixbuf)
     entries.attach(image, 2, 5, 1, 9)
     if os.path.exists(self.configFile):
         f_in = open(self.configFile, 'r')
         for line in f_in:
             if line.startswith('preamble'):
                 self.preamble = line.strip().split('=')[1]
             elif line.startswith('postamble'):
                 self.postamble = line.strip().split('=')[1]
             elif line.startswith('origin'):
                 if line.strip().split('=')[1] == 'True':
                     self.centre.set_active(1)
                 else:
                     self.bLeft.set_active(1)
             elif line.startswith('lead-in'):
                 self.liEntry.set_text(line.strip().split('=')[1])
             elif line.startswith('lead-out'):
                 self.loEntry.set_text(line.strip().split('=')[1])
     self.xSEntry.set_text('{:0.3f}'.format(float(xOrigin)))
     self.ySEntry.set_text('{:0.3f}'.format(float(yOrigin)))
     if not self.liEntry.get_text() or float(self.liEntry.get_text()) == 0:
         self.offset.set_sensitive(False)
     self.parent.undo_shape(None, self.add)
     self.parent.W.show_all()
     self.pEntry.grab_focus()
    def __init__(self):
        ''' Init. '''

        # Init widgets.
        self.window = self.initMainWindow()
        self.window.connect("destroy", lambda w: gtk.main_quit())
        # self.window.connect("size-allocate", lambda w, a: updateShape(w, a, 4))
        self.generalMainbox = gtk.VBox(False, 10)
        # setup


        self.bodyAlign = gtk.Alignment()
        self.bodyAlign.set_padding(10, 20, 10, 10)

        imageSetupFrame = gtk.Frame("图片格式")

        imageSetupMainBox = gtk.VBox()
        imageQualityHbox = gtk.HBox(False,40)
        self.adj1 = gtk.Adjustment(0, 0, 110, 10, 10, 10)
        self.imageQualityLabel  = gtk.Label("质量:")
        self.imageQualityHscale = gtk.HScale(self.adj1)
        self.imageQualityHscale.set_size_request(190, -1)
        self.imageQualityHscale.set_value_pos(gtk.POS_RIGHT)
        self.imageQualityHscale.set_digits(0)
        self.imageQualityHscale.set_draw_value(True)
        self.imageQualityHscale.set_update_policy(gtk.UPDATE_CONTINUOUS)
        imageQualityHbox.pack_start(self.imageQualityLabel, False, False)
        imageQualityHbox.pack_start(self.imageQualityHscale, False, False)

        imageFormatHbox = gtk.HBox(False, 10)
        imageFormatLabel = gtk.Label("图片格式:")


        imageFormatList = gtk.OptionMenu()
        imageFormatList.set_size_request(180, -1)
        menu = gtk.Menu()
        pngItem = gtk.MenuItem("png - PNG 图像格式")
        jpegItem = gtk.MenuItem("jpeg - JPEG 图像格式")
        bmpItem = gtk.MenuItem("bmp - BMP 图像格式")
        menu.append(pngItem)
        menu.append(jpegItem)
        menu.append(bmpItem)
        imageFormatList.set_menu(menu)
        imageFormatHbox.pack_start(imageFormatLabel, False, False)
        imageFormatHbox.pack_start(imageFormatList, False, False)


        imageSetupMainBox.pack_start(imageQualityHbox)
        imageSetupMainBox.pack_start(imageFormatHbox)

        imageQualityAlign = gtk.Alignment()
        imageQualityAlign.set_padding(10, 10, 10, 10)
        imageQualityAlign.add(imageSetupMainBox)
        imageSetupFrame.add(imageQualityAlign)

        # save
        saveProjectFrame = gtk.Frame("保存方案")
        saveProjectMainbox = gtk.VBox()
        self.tipsaveRadio = gtk.RadioButton(None, "提示保存")
        self.autosaveRadio = gtk.RadioButton(self.tipsaveRadio, "自动保存")
        saveFilenameHbox = gtk.HBox(False, 26)
        saveFilenameLabel = gtk.Label("文件名:")
        self.saveFilenameEntry = gtk.Entry()
        saveFilenameHbox.pack_start(saveFilenameLabel, False, False)
        saveFilenameHbox.pack_start(self.saveFilenameEntry)

        saveDirHbox = gtk.HBox(False, 10)
        saveDirLabel = gtk.Label("保存目录:")
        self.saveDirButton = gtk.FileChooserButton("dir")
        self.saveDirButton.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        saveDirHbox.pack_start(saveDirLabel, False, False)
        saveDirHbox.pack_start(self.saveDirButton)
        saveDirMainbox = gtk.VBox()

        saveDirMainbox.pack_start(saveFilenameHbox)
        saveDirMainbox.pack_start(saveDirHbox)
        saveDirAlign = gtk.Alignment()
        saveDirAlign.set_padding(0, 0, 20, 10)
        saveDirAlign.add(saveDirMainbox)

        saveProjectAlign = gtk.Alignment()
        saveProjectAlign.set_padding(10, 10, 10, 10)

        saveProjectFrame.add(saveProjectAlign)
        saveProjectAlign.add(saveProjectMainbox)
        saveProjectMainbox.pack_start(self.tipsaveRadio)
        saveProjectMainbox.pack_start(self.autosaveRadio)
        saveProjectMainbox.pack_start(saveDirAlign)

        # buttons
        controlBox = gtk.HBox(True, 5)
        controlAlign = gtk.Alignment()
        controlAlign.set(1.0, 0.0, 0.0, 0.0)
        controlAlign.add(controlBox)

        okButton = gtk.Button(None, gtk.STOCK_OK)
        cancelButton = gtk.Button(None, gtk.STOCK_CANCEL)
        applyButton = gtk.Button(None, gtk.STOCK_APPLY)
        controlBox.pack_start(okButton)
        controlBox.pack_start(cancelButton)
        controlBox.pack_start(applyButton)



        self.window.add(self.bodyAlign)
        self.bodyAlign.add(self.generalMainbox)
        self.generalMainbox.pack_start(imageSetupFrame)
        self.generalMainbox.pack_start(saveProjectFrame)
        self.generalMainbox.pack_start(controlAlign)





        self.window.show_all()
        gtk.main()
Exemple #10
0
    def show_builded_images_dialog(self, widget, primary_action=""):
        title = primary_action if primary_action else "Your builded images"
        dialog = CrumbsDialog(
            title, self.builder,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        dialog.set_border_width(12)

        label = gtk.Label()
        label.set_use_markup(True)
        label.set_alignment(0.0, 0.5)
        label.set_padding(12, 0)
        if primary_action == "Run image":
            label.set_markup(
                "<span font_desc='12'>Select the image file you want to run:</span>"
            )
        elif primary_action == "Deploy image":
            label.set_markup(
                "<span font_desc='12'>Select the image file you want to deploy:</span>"
            )
        else:
            label.set_markup(
                "<span font_desc='12'>Select the image file you want to %s</span>"
                % primary_action)
        dialog.vbox.pack_start(label, expand=False, fill=False)

        # filter created images as action attribution (deploy or run)
        action_attr = ""
        action_images = []
        for fileitem in self.image_store:
            action_attr = fileitem['action_attr']
            if  (action_attr == 'run' and primary_action == "Run image") \
             or (action_attr == 'deploy' and primary_action == "Deploy image"):
                action_images.append(fileitem)
        if (len(action_images) == 0 and primary_action == "Run image"):
            # if there are no qemu runnable images, let the user choose any of the existing images for custom run
            action_images = self.image_store
        # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file.
        # assume that there does not both have 'deploy' and 'runnable' files in the same building result
        # in possible as design.
        curr_row = 0
        rows = (len(action_images)) if len(action_images) < 10 else 10
        table = gtk.Table(rows, 10, True)
        table.set_row_spacings(6)
        table.set_col_spacing(0, 12)
        table.set_col_spacing(5, 12)

        sel_parent_btn = None
        for fileitem in action_images:
            sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
            sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
            if curr_row == 0:
                sel_btn.set_active(True)
                self.toggled_image = fileitem['name']
            sel_btn.connect('toggled', self.table_selected_cb, fileitem)
            if curr_row < 10:
                table.attach(sel_btn,
                             0,
                             4,
                             curr_row,
                             curr_row + 1,
                             xpadding=24)
            else:
                table.attach(sel_btn,
                             5,
                             9,
                             curr_row - 10,
                             curr_row - 9,
                             xpadding=24)
            curr_row += 1

        dialog.vbox.pack_start(table, expand=False, fill=False, padding=6)

        button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
        HobAltButton.style_button(button)

        if primary_action:
            button = dialog.add_button(primary_action, gtk.RESPONSE_YES)
            HobButton.style_button(button)

        dialog.show_all()

        response = dialog.run()
        dialog.destroy()

        if response != gtk.RESPONSE_YES:
            return
        # perform the primary action on the image selected by the user
        for fileitem in self.image_store:
            if fileitem['name'] == self.toggled_image:
                if (fileitem['action_attr'] == 'run'
                        and primary_action == "Run image"):
                    self.builder.runqemu_image(fileitem['name'],
                                               self.sel_kernel)
                elif (fileitem['action_attr'] == 'deploy'
                      and primary_action == "Deploy image"):
                    self.builder.deploy_image(fileitem['name'])
                elif (primary_action == "Run image"):
                    self.builder.run_custom_image(fileitem['name'],
                                                  self.run_script_path)
Exemple #11
0
 def do_circle(self, fWizard, tmpDir):
     self.tmpDir = tmpDir
     self.fWizard = fWizard
     self.sRadius = 0.0
     self.hSpeed = 100
     self.W = gtk.Dialog('Circle',
                         None,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         buttons=None)
     self.W.set_keep_above(True)
     self.W.set_position(gtk.WIN_POS_CENTER_ALWAYS)
     self.W.set_default_size(250, 200)
     t = gtk.Table(1, 1, True)
     t.set_row_spacings(6)
     self.W.vbox.add(t)
     cutLabel = gtk.Label('Cut Type')
     cutLabel.set_alignment(0.95, 0.5)
     cutLabel.set_width_chars(10)
     t.attach(cutLabel, 0, 1, 0, 1)
     self.outside = gtk.RadioButton(None, 'Outside')
     self.outside.connect('toggled', self.outside_toggled)
     t.attach(self.outside, 1, 2, 0, 1)
     inside = gtk.RadioButton(self.outside, 'Inside')
     t.attach(inside, 2, 3, 0, 1)
     offsetLabel = gtk.Label('Offset')
     offsetLabel.set_alignment(0.95, 0.5)
     offsetLabel.set_width_chars(10)
     t.attach(offsetLabel, 3, 4, 0, 1)
     self.offset = gtk.CheckButton('Kerf Width')
     t.attach(self.offset, 4, 5, 0, 1)
     lLabel = gtk.Label('Lead In')
     lLabel.set_alignment(0.95, 0.5)
     lLabel.set_width_chars(10)
     t.attach(lLabel, 0, 1, 1, 2)
     self.liEntry = gtk.Entry()
     self.liEntry.set_width_chars(10)
     t.attach(self.liEntry, 1, 2, 1, 2)
     loLabel = gtk.Label('Lead Out')
     loLabel.set_alignment(0.95, 0.5)
     loLabel.set_width_chars(10)
     t.attach(loLabel, 0, 1, 2, 3)
     self.loEntry = gtk.Entry()
     self.loEntry.set_width_chars(10)
     t.attach(self.loEntry, 1, 2, 2, 3)
     xSLabel = gtk.Label('X start')
     xSLabel.set_alignment(0.95, 0.5)
     xSLabel.set_width_chars(10)
     t.attach(xSLabel, 0, 1, 3, 4)
     self.xSEntry = gtk.Entry()
     self.xSEntry.set_width_chars(10)
     t.attach(self.xSEntry, 1, 2, 3, 4)
     ySLabel = gtk.Label('Y start')
     ySLabel.set_alignment(0.95, 0.5)
     ySLabel.set_width_chars(10)
     t.attach(ySLabel, 0, 1, 4, 5)
     self.ySEntry = gtk.Entry()
     self.ySEntry.set_width_chars(10)
     t.attach(self.ySEntry, 1, 2, 4, 5)
     self.centre = gtk.RadioButton(None, 'Centre')
     t.attach(self.centre, 1, 2, 5, 6)
     bLeft = gtk.RadioButton(self.centre, 'Bottom Left')
     t.attach(bLeft, 0, 1, 5, 6)
     dLabel = gtk.Label('Diameter')
     dLabel.set_alignment(0.95, 0.5)
     dLabel.set_width_chars(10)
     t.attach(dLabel, 0, 1, 6, 7)
     self.dEntry = gtk.Entry()
     self.dEntry.set_width_chars(10)
     self.dEntry.connect('changed', self.diameter_changed)
     t.attach(self.dEntry, 1, 2, 6, 7)
     ocDesc = gtk.Label('Over Cut')
     ocDesc.set_alignment(0.95, 0.5)
     ocDesc.set_width_chars(10)
     t.attach(ocDesc, 0, 1, 7, 8)
     self.overcut = gtk.CheckButton('')
     self.overcut.connect('toggled', self.overcut_toggled)
     self.overcut.set_sensitive(False)
     t.attach(self.overcut, 1, 2, 7, 8)
     ocLabel = gtk.Label('OC Length')
     ocLabel.set_alignment(0.95, 0.5)
     ocLabel.set_width_chars(10)
     t.attach(ocLabel, 0, 1, 8, 9)
     self.ocEntry = gtk.Entry()
     self.ocEntry.set_width_chars(10)
     self.ocEntry.set_sensitive(False)
     self.ocEntry.connect('changed', self.ocentry_changed)
     t.attach(self.ocEntry, 1, 2, 8, 9)
     preview = gtk.Button('Preview')
     preview.connect('pressed', self.send_preview)
     t.attach(preview, 0, 1, 9, 10)
     self.add = gtk.Button('Add')
     self.add.set_sensitive(False)
     self.add.connect('pressed', self.add_shape_to_file)
     t.attach(self.add, 2, 3, 9, 10)
     end = gtk.Button('Return')
     end.connect('pressed', self.end_this_shape)
     t.attach(end, 4, 5, 9, 10)
     pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
         filename='./wizards/images/circle.png', width=240, height=240)
     image = gtk.Image()
     image.set_from_pixbuf(pixbuf)
     t.attach(image, 2, 5, 1, 9)
     self.xSEntry.grab_focus()
     self.W.show_all()
     if os.path.exists(self.configFile):
         f_in = open(self.configFile, 'r')
         for line in f_in:
             if line.startswith('preamble'):
                 self.preamble = line.strip().split('=')[1]
             elif line.startswith('postamble'):
                 self.postamble = line.strip().split('=')[1]
             elif line.startswith('lead-in'):
                 self.liEntry.set_text(line.strip().split('=')[1])
             elif line.startswith('lead-out'):
                 self.loEntry.set_text(line.strip().split('=')[1])
             elif line.startswith('hole-diameter'):
                 self.sRadius = float(line.strip().split('=')[1]) / 2
             elif line.startswith('hole-speed'):
                 self.hSpeed = float(line.strip().split('=')[1])
     response = self.W.run()
Exemple #12
0
    def create_cvar_filter(self):
        """
        Creates the ui-elements for the custom server cvars filtering
        """

        cvar_frame = gtk.Frame('Custom Sever CVARS Filtering')

        cvar_main_hbox = gtk.HBox()
        cvar_frame.add(cvar_main_hbox)

        #settings editing area
        cvar_set_vbox = gtk.VBox()
        cvar_main_hbox.pack_start(cvar_set_vbox)

        variable_label = gtk.Label('Variable:')
        value_label = gtk.Label('Value:')

        self.variable_entry = gtk.Entry()
        self.value_entry = gtk.Entry()

        editing_table = gtk.Table(5, 2)
        editing_table.attach(variable_label, 0, 1, 0, 1)
        editing_table.attach(self.variable_entry, 1, 2, 0, 1)
        editing_table.attach(value_label, 0, 1, 1, 2)
        editing_table.attach(self.value_entry, 1, 2, 1, 2)
        editing_table.set_border_width(10)
        cvar_set_vbox.pack_start(editing_table)

        self.radio_cvar_include = gtk.RadioButton(None, 'Include (equals)')
        self.radio_cvar_include.set_border_width(5)
        self.radio_cvar_exclude = gtk.RadioButton(self.radio_cvar_include, \
                                                         'Exclude (not equals)')
        self.radio_cvar_exclude.set_border_width(5)

        editing_table.attach(self.radio_cvar_include, 1, 2, 2, 3)
        editing_table.attach(self.radio_cvar_exclude, 1, 2, 3, 4)

        add_button = gtk.Button('Add')
        editing_table.attach(add_button, 1, 2, 4, 5)
        add_button.connect('clicked', self.on_add_var_filter_clicked)

        #the treeview displaying current CVAR filter settings
        cvar_values_vbox = gtk.VBox()
        cvar_main_hbox.pack_start(cvar_values_vbox)
        cvar_scrolled_window = gtk.ScrolledWindow()
        cvar_scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        cvar_values_vbox.pack_start(cvar_scrolled_window)

        self.cvarliststore = gtk.ListStore(str, str, str, object)
        cvar_set_treeview = gtk.TreeView(model=self.cvarliststore)
        self.varfilterview = cvar_set_treeview
        cvar_scrolled_window.add(cvar_set_treeview)

        self.column_cvar_variable = gtk.TreeViewColumn('Variable')
        self.column_cvar_value = gtk.TreeViewColumn('Value')
        self.column_cvar_type = gtk.TreeViewColumn('Type')

        cvar_set_treeview.append_column(self.column_cvar_variable)
        cvar_set_treeview.append_column(self.column_cvar_value)
        cvar_set_treeview.append_column(self.column_cvar_type)

        var_cell0 = gtk.CellRendererText()
        var_cell1 = gtk.CellRendererText()
        var_cell2 = gtk.CellRendererText()

        self.column_cvar_variable.pack_start(var_cell0, expand=True)
        self.column_cvar_value.pack_start(var_cell1, expand=False)
        self.column_cvar_type.pack_start(var_cell2, expand=False)

        self.column_cvar_variable.add_attribute(var_cell0, 'text', 0)
        self.column_cvar_value.add_attribute(var_cell1, 'text', 1)
        self.column_cvar_type.add_attribute(var_cell2, 'text', 2)

        btn_hbox = gtk.HBox()
        cvar_values_vbox.pack_start(btn_hbox, False, False)

        clear_button = gtk.Button('Clear')
        clear_button.set_border_width(5)
        btn_hbox.pack_start(clear_button, True, True)
        clear_button.connect('clicked', self.on_clear_var_list_clicked)

        remove_button = gtk.Button('Remove Selected')
        remove_button.set_border_width(5)
        btn_hbox.pack_start(remove_button, True, True)
        remove_button.connect('clicked', self.on_remove_selected_var)

        self.vbox.pack_start(cvar_frame, False, False)
Exemple #13
0
    def create_gear_chooser(self):
        """
        Creates the ui elements to choose a g_gear configuration
        """

        gear_frame = gtk.Frame('Gear Settings Filter')

        gear_type_box = gtk.HBox()
        #the include exclude chooser
        self.radio_gear_disable = gtk.RadioButton(None, 'Disabled')
        self.radio_gear_include = gtk.RadioButton(self.radio_gear_disable, \
                                                             'Include (equals)')
        self.radio_gear_exclude = gtk.RadioButton(self.radio_gear_disable, \
                                                         'Exclude (not equals)')
        gear_type_box.pack_start(self.radio_gear_disable)
        gear_type_box.pack_start(self.radio_gear_include)
        gear_type_box.pack_start(self.radio_gear_exclude)
        gear_type_box.set_border_width(5)

        gearhbox = gtk.HBox()

        gear_frame.add(gearhbox)

        gear_choose_area_vbox = gtk.VBox()

        gear_table = gtk.Table(4, 2)
        gear_table.set_border_width(15)
        gearhbox.pack_start(gear_choose_area_vbox)
        gear_choose_area_vbox.pack_start(gear_type_box)

        gear_choose_area_vbox.pack_start(gear_table)

        #the checkboxes
        self.checkbox_grenades = gtk.CheckButton('Grenades')
        self.checkbox_snipers = gtk.CheckButton('Snipers')
        self.checkbox_spas = gtk.CheckButton('Spas')
        self.checkbox_pistols = gtk.CheckButton('Pistols')
        self.checkbox_automatics = gtk.CheckButton('Automatic Guns')
        self.checkbox_negev = gtk.CheckButton('Negev')

        #connect to the toggled signal
        self.checkbox_grenades.connect('toggled',
                                       self.on_gear_checkbox_changed)
        self.checkbox_snipers.connect('toggled', self.on_gear_checkbox_changed)
        self.checkbox_spas.connect('toggled', self.on_gear_checkbox_changed)
        self.checkbox_pistols.connect('toggled', self.on_gear_checkbox_changed)
        self.checkbox_automatics.connect('toggled', \
                                                  self.on_gear_checkbox_changed)
        self.checkbox_negev.connect('toggled', self.on_gear_checkbox_changed)

        #the value textfield
        self.gearvalue = gtk.Entry()
        self.gearvalue.set_width_chars(4)
        self.gearvalue.set_editable(False)

        #the add button
        add_button = gtk.Button('Add')
        add_button.set_border_width(5)
        add_button.connect('clicked', self.on_add_gear_value_clicked)

        #now put all into the table
        gear_table.attach(self.checkbox_grenades, 0, 1, 0, 1)
        gear_table.attach(self.checkbox_snipers, 0, 1, 1, 2)
        gear_table.attach(self.checkbox_spas, 0, 1, 2, 3)
        gear_table.attach(self.gearvalue, 0, 1, 3, 4)

        gear_table.attach(self.checkbox_pistols, 1, 2, 0, 1)
        gear_table.attach(self.checkbox_automatics, 1, 2, 1, 2)
        gear_table.attach(self.checkbox_negev, 1, 2, 2, 3)
        gear_table.attach(add_button, 1, 2, 3, 4)

        #gear settings treeview area
        gear_values_vbox = gtk.VBox()
        gearhbox.pack_start(gear_values_vbox)
        gear_scrolled_window = gtk.ScrolledWindow()
        gear_scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        gear_values_vbox.pack_start(gear_scrolled_window)

        self.gearliststore = gtk.ListStore(str)
        gear_set_treeview = gtk.TreeView(model=self.gearliststore)
        self.gearlistview = gear_set_treeview
        gear_scrolled_window.add(gear_set_treeview)

        self.column_gear_value = gtk.TreeViewColumn("Gear Value")

        gear_set_treeview.append_column(self.column_gear_value)

        var_cell0 = gtk.CellRendererText()

        self.column_gear_value.pack_start(var_cell0, expand=True)
        self.column_gear_value.add_attribute(var_cell0, 'text', 0)
        self.column_gear_value.set_reorderable(True)

        btn_hbox = gtk.HBox()
        gear_values_vbox.pack_start(btn_hbox, False, False)

        clear_button = gtk.Button('Clear')
        clear_button.set_border_width(5)
        btn_hbox.pack_start(clear_button, True, True)
        clear_button.connect('clicked', self.on_clear_gear_list_clicked)

        remove_button = gtk.Button('Remove Selected')
        remove_button.set_border_width(5)
        btn_hbox.pack_start(remove_button, True, True)
        remove_button.connect('clicked', self.on_remove_selected_gear_value)

        self.vbox.pack_start(gear_frame, False, False)
Exemple #14
0
    def __init__(self, controller):
        GLIScreen.GLIScreen.__init__(self, controller)
        vert = gtk.VBox(False, 0)
        vert.set_border_width(10)

        content_str = _(
            """On this screen, you will set all your pre-install options such as networking,
		chroot directory, logfile location, architecture, etc.""")

        content_label = gtk.Label(content_str)
        vert.pack_start(content_label, expand=False, fill=False, padding=5)

        self.notebook = gtk.Notebook()

        basicbox = gtk.VBox(False, 0)
        basicbox.set_border_width(10)
        hbox = gtk.HBox(False, 0)
        tmplabel = gtk.Label()
        tmplabel.set_markup("<b><u>" + _("Network setup (for install only):") +
                            "</u></b>")
        hbox.pack_start(tmplabel, expand=False, fill=False, padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=0)
        hbox = gtk.HBox(False, 0)
        self.already_setup_check = gtk.CheckButton()
        self.already_setup_check.set_active(False)
        self.already_setup_check.connect("toggled", self.already_setup_toggled)
        hbox.pack_start(self.already_setup_check,
                        expand=False,
                        fill=False,
                        padding=0)
        hbox.pack_start(gtk.Label(
            "My network is already setup and running (or no network)"),
                        expand=False,
                        fill=False,
                        padding=10)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        hbox = gtk.HBox(False, 0)
        hbox.pack_start(gtk.Label(_("Interface:")),
                        expand=False,
                        fill=False,
                        padding=0)
        self.interface_combo = gtk.combo_box_entry_new_text()
        self.interface_combo.get_child().set_width_chars(9)
        self.interface_combo.connect("changed", self.interface_changed)
        self.interfaces = GLIUtility.get_eth_devices()
        for device in self.interfaces:
            self.interface_combo.append_text(device)
        hbox.pack_start(self.interface_combo,
                        expand=False,
                        fill=False,
                        padding=10)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=7)
        hbox = gtk.HBox(False, 0)
        self.basic_dhcp_radio = gtk.RadioButton(label=_("DHCP"))
        self.basic_dhcp_radio.connect("toggled", self.dhcp_static_toggled,
                                      "dhcp")
        hbox.pack_start(self.basic_dhcp_radio,
                        expand=False,
                        fill=False,
                        padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=0)
        hbox = gtk.HBox(False, 0)
        tmptable = gtk.Table(rows=1, columns=3)
        tmptable.set_col_spacings(6)
        tmptable.set_row_spacings(5)
        tmptable.attach(gtk.Label("        "), 0, 1, 0, 1)
        tmplabel = gtk.Label(_("DHCP options:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 1, 2, 0, 1)
        self.dhcp_options_entry = gtk.Entry()
        self.dhcp_options_entry.set_width_chars(35)
        tmptable.attach(self.dhcp_options_entry, 2, 3, 0, 1)
        hbox.pack_start(tmptable, expand=False, fill=False, padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        hbox = gtk.HBox(False, 0)
        self.basic_static_radio = gtk.RadioButton(group=self.basic_dhcp_radio,
                                                  label=_("Static"))
        self.basic_static_radio.connect("toggled", self.dhcp_static_toggled,
                                        "static")
        hbox.pack_start(self.basic_static_radio,
                        expand=False,
                        fill=False,
                        padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        hbox = gtk.HBox(False, 0)
        tmptable = gtk.Table(rows=5, columns=1)
        tmptable.set_col_spacings(6)
        tmptable.set_row_spacings(5)
        tmptable.attach(gtk.Label("        "), 0, 1, 0, 1)
        tmplabel = gtk.Label(_("IP address:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 1, 2, 0, 1)
        self.ip_address_entry = gtk.Entry()
        self.ip_address_entry.set_width_chars(20)
        tmptable.attach(self.ip_address_entry, 2, 3, 0, 1)
        tmptable.attach(gtk.Label("        "), 3, 4, 0, 1)
        tmplabel = gtk.Label(_("Netmask:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 4, 5, 0, 1)
        self.netmask_entry = gtk.Entry()
        self.netmask_entry.set_width_chars(20)
        tmptable.attach(self.netmask_entry, 5, 6, 0, 1)
        tmplabel = gtk.Label(_("Broadcast:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 1, 2, 1, 2)
        self.broadcast_entry = gtk.Entry()
        self.broadcast_entry.set_width_chars(20)
        tmptable.attach(self.broadcast_entry, 2, 3, 1, 2)
        tmplabel = gtk.Label(_("Gateway:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 4, 5, 1, 2)
        self.gateway_entry = gtk.Entry()
        self.gateway_entry.set_width_chars(20)
        tmptable.attach(self.gateway_entry, 5, 6, 1, 2)
        tmplabel = gtk.Label(_("DNS servers:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 1, 2, 2, 3)
        self.dns_entry = gtk.Entry()
        self.dns_entry.set_width_chars(20)
        tmptable.attach(self.dns_entry, 2, 3, 2, 3)
        hbox.pack_start(tmptable, expand=False, fill=False, padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        hbox = gtk.HBox(False, 0)
        tmptable = gtk.Table(rows=1, columns=5)
        tmptable.set_col_spacings(6)
        tmptable.set_row_spacings(5)
        #		tmptable.attach(gtk.Label("   "), 0, 2, 0, 1)
        tmplabel = gtk.Label()
        tmplabel.set_markup("<b><u>" + _("Proxies:") + "</u></b>")
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 5, 0, 1)

        tmpbox = gtk.HBox(False, 5)
        tmplabel = gtk.Label(_("HTTP:"))
        tmplabel.set_alignment(0, 0.5)
        #		tmptable.attach(tmplabel, 0, 1, 2, 3)
        tmpbox.pack_start(tmplabel, expand=False, fill=False)
        self.http_proxy_entry = gtk.Entry()
        tmpbox.pack_start(self.http_proxy_entry, expand=False, fill=False)
        #		tmptable.attach(self.http_proxy_entry, 1, 2, 2, 3)
        tmptable.attach(tmpbox, 0, 1, 1, 2)
        tmptable.attach(gtk.Label("    "), 1, 2, 1, 2)

        tmpbox = gtk.HBox(False, 5)
        tmplabel = gtk.Label(_("FTP:"))
        tmplabel.set_alignment(0, 0.5)
        #		tmptable.attach(tmplabel, 0, 1, 3, 4)
        tmpbox.pack_start(tmplabel, expand=False, fill=False)
        self.ftp_proxy_entry = gtk.Entry()
        tmpbox.pack_start(self.ftp_proxy_entry, expand=False, fill=False)
        #		tmptable.attach(self.ftp_proxy_entry, 1, 2, 3, 4)
        tmptable.attach(tmpbox, 2, 3, 1, 2)
        tmptable.attach(gtk.Label("    "), 3, 4, 1, 2)

        tmpbox = gtk.HBox(False, 5)
        tmplabel = gtk.Label(_("Rsync:"))
        tmplabel.set_alignment(0, 0.5)
        #		tmptable.attach(tmplabel, 0, 1, 4, 5)
        tmpbox.pack_start(tmplabel, expand=False, fill=False)
        self.rsync_proxy_entry = gtk.Entry()
        tmpbox.pack_start(self.rsync_proxy_entry, expand=False, fill=False)
        #		tmptable.attach(self.rsync_proxy_entry, 1, 2, 4, 5)
        tmptable.attach(tmpbox, 4, 5, 1, 2)

        hbox.pack_start(tmptable, expand=False, fill=False, padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        self.notebook.append_page(basicbox, gtk.Label(_("Networking")))

        advbox = gtk.VBox(False, 0)
        advbox.set_border_width(10)
        hbox = gtk.HBox(False, 0)
        tmptable = gtk.Table(rows=5, columns=1)
        tmptable.set_col_spacings(6)
        tmptable.set_row_spacings(5)
        tmplabel = gtk.Label()
        tmplabel.set_markup("<b><u>" + _("Directories and logfiles:") +
                            "</u></b>")
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 2, 0, 1)
        tmplabel = gtk.Label(_("Chroot directory:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 1, 2)
        self.chroot_dir_entry = gtk.Entry()
        self.chroot_dir_entry.set_width_chars(25)
        tmptable.attach(self.chroot_dir_entry, 1, 2, 1, 2)
        tmplabel = gtk.Label(_("Logfile:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 2, 3)
        self.logfile_entry = gtk.Entry()
        self.logfile_entry.set_width_chars(25)
        tmptable.attach(self.logfile_entry, 1, 2, 2, 3)
        tmplabel = gtk.Label("   ")
        tmptable.attach(tmplabel, 0, 1, 3, 4)
        tmplabel = gtk.Label()
        tmplabel.set_markup("<b><u>" + _("SSH:") + "</u></b>")
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 2, 4, 5)
        tmplabel = gtk.Label(_("Start SSHd:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 5, 6)
        tmphbox = gtk.HBox(False, 0)
        self.sshd_yes_radio = gtk.RadioButton(label=_("Yes"))
        tmphbox.pack_start(self.sshd_yes_radio,
                           expand=False,
                           fill=False,
                           padding=0)
        self.sshd_no_radio = gtk.RadioButton(group=self.sshd_yes_radio,
                                             label=_("No"))
        tmphbox.pack_start(self.sshd_no_radio,
                           expand=False,
                           fill=False,
                           padding=15)
        tmptable.attach(tmphbox, 1, 2, 5, 6)
        tmplabel = gtk.Label(_("Root password:"******"Verify root password:"******"   ")
        tmptable.attach(tmplabel, 0, 1, 8, 9)
        tmplabel = gtk.Label()
        #		tmplabel.set_markup("<b><u>" + _("Kernel modules:") + "</u></b>")
        tmplabel.set_markup("<b><u>" + _("Other:") + "</u></b>")
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 2, 9, 10)
        tmplabel = gtk.Label(_("Kernel modules:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 10, 11)
        self.modules_entry = gtk.Entry()
        self.modules_entry.set_width_chars(25)
        tmptable.attach(self.modules_entry, 1, 2, 10, 11)
        #		tmplabel = gtk.Label("   ")
        #		tmptable.attach(tmplabel, 0, 1, 11, 12)
        #		tmplabel = gtk.Label()
        #		tmplabel.set_markup("<b><u>" + _("Debug:") + "</u></b>")
        #		tmplabel.set_alignment(0.0, 0.5)
        #		tmptable.attach(tmplabel, 0, 2, 12, 13)
        tmplabel = gtk.Label(_("Verbose logging:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 11, 12)
        tmphbox = gtk.HBox(False, 0)
        self.verbose_no_radio = gtk.RadioButton(label=_("No"))
        tmphbox.pack_start(self.verbose_no_radio,
                           expand=False,
                           fill=False,
                           padding=0)
        self.verbose_yes_radio = gtk.RadioButton(group=self.verbose_no_radio,
                                                 label=_("Yes"))
        tmphbox.pack_start(self.verbose_yes_radio,
                           expand=False,
                           fill=False,
                           padding=15)
        tmptable.attach(tmphbox, 1, 2, 11, 12)
        tmplabel = gtk.Label(_("Install mode:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 12, 13)
        self.install_mode_combo = gtk.combo_box_new_text()
        self._install_modes = ("Normal", "Chroot")
        for install_mode in self._install_modes:
            self.install_mode_combo.append_text(install_mode)
        self.install_mode_combo.set_active(0)
        tmptable.attach(self.install_mode_combo, 1, 2, 12, 13)

        hbox.pack_start(tmptable, expand=False, fill=False, padding=0)

        # Currently loaded modules
        loaded_mod_frame = gtk.Frame(label="Loaded modules")
        loaded_mod_frame.set_size_request(200, -1)
        module_list_box = gtk.VBox(False, 3)
        module_list_box.set_border_width(7)
        module_scroll = gtk.ScrolledWindow()
        module_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        module_scroll.set_shadow_type(gtk.SHADOW_NONE)
        module_viewport = gtk.Viewport()
        module_viewport.set_shadow_type(gtk.SHADOW_NONE)
        module_viewport.add(module_list_box)
        module_scroll.add(module_viewport)
        loaded_mod_frame.add(module_scroll)
        loaded_modules = GLIUtility.spawn(
            r"lsmod | grep -v ^Module | cut -d ' ' -f 1",
            return_output=True)[1].strip().split("\n")
        for module in loaded_modules:
            tmplabel = gtk.Label(module)
            tmplabel.set_alignment(0.0, 0.5)
            module_list_box.pack_start(tmplabel,
                                       expand=False,
                                       fill=False,
                                       padding=0)
        hbox.pack_end(loaded_mod_frame, expand=False, fill=False, padding=5)

        advbox.pack_start(hbox, expand=False, fill=False, padding=0)
        self.notebook.append_page(advbox, gtk.Label(_("Misc.")))

        vert.pack_start(self.notebook, expand=True, fill=True, padding=0)

        self.add_content(vert)
Exemple #15
0
    def __init__(self, prefs=None, applet=None):
        gtk.Window.__init__(self)

        if prefs is not None:
            self.prefs = prefs
            self.applet = prefs.applet
            self.set_transient_for(prefs)

        elif applet is not None:
            self.applet = applet

        self.google_source = None
        for source in self.applet.feeds.values():
            if isinstance(source, classes.GoogleFeed):
                self.google_source = source
                break

        self.site_images = {}

        self.set_border_width(12)
        self.set_title(_("Add Feed"))
        self.set_icon_from_file(icon_path)

        #Source: label and radio buttons
        source_label = gtk.Label(_("Source:"))
        source_label.set_alignment(1.0, 0.0)

        source_vbox = gtk.VBox(False, 3)

        #Search via Google Reader
        pb = self.icon_theme.load_icon("system-search", 16, 0)
        pb = classes.get_16x16(pb)

        search_radio = gtk.RadioButton(None)
        search_radio.add(self.get_radio_hbox(pb, _("Search")))
        if not self.google_source:
            search_radio.set_sensitive(False)
            search_radio.set_tooltip_text(
                _("You must sign in to a Google service to search for feeds."))

        #Regular RSS/Atom feed
        try:
            pb = self.icon_theme.load_icon('application-rss+xml', 16, 0)
            pb = classes.get_16x16(pb)
        except:
            pb = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 16, 16)
        webfeed_radio = gtk.RadioButton(search_radio, None)
        webfeed_radio.add(self.get_radio_hbox(pb, _("RSS/Atom")))

        #Google (Reader and Wave)
        pb = self.applet.get_favicon('www.google.com', True)

        google_radio = gtk.RadioButton(search_radio, None)
        google_radio.add(
            self.get_radio_hbox(pb, classes.GoogleFeed.title,
                                'www.google.com'))

        #Google Reader (CheckButton)
        pb = get_greader_icon()

        self.greader_check = gtk.CheckButton()
        self.greader_check.add(
            self.get_radio_hbox(pb, classes.GoogleReader.title,
                                'google-reader'))
        self.greader_check.set_active(True)
        self.greader_check.connect('toggled', self.check_toggled)

        #Google Wave
        pb = self.applet.get_favicon('wave.google.com', True)

        self.gwave_check = gtk.CheckButton()
        self.gwave_check.add(
            self.get_radio_hbox(pb, classes.GoogleWave.title,
                                'wave.google.com'))
        self.gwave_check.connect('toggled', self.check_toggled)

        google_vbox = gtk.VBox(False, 3)
        google_vbox.pack_start(self.greader_check, False)
        google_vbox.pack_start(self.gwave_check, False)
        google_vbox.show_all()

        self.google_align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        self.google_align.set_padding(0, 0, 12, 0)
        self.google_align.add(google_vbox)
        self.google_align.set_no_show_all(True)

        #Reddit Inbox
        pb = self.applet.get_favicon('www.reddit.com', True)

        reddit_radio = gtk.RadioButton(search_radio, None)
        reddit_radio.add(
            self.get_radio_hbox(pb, classes.Reddit.title, 'www.reddit.com'))

        #Twitter Timeline and/or Replies
        pb = gtk.gdk.pixbuf_new_from_file_at_size(twitter_path, 16, 16)

        twitter_radio = gtk.RadioButton(search_radio, None)
        twitter_radio.add(self.get_radio_hbox(pb, _("Twitter")))

        self.twitter_timeline_check = gtk.CheckButton(_("Timeline"))
        self.twitter_timeline_check.set_active(True)
        self.twitter_timeline_check.connect('toggled', self.check_toggled)
        self.twitter_timeline_check.show()

        self.twitter_replies_check = gtk.CheckButton(_("Replies"))
        self.twitter_replies_check.connect('toggled', self.check_toggled)
        self.twitter_replies_check.show()

        twitter_vbox = gtk.VBox(False, 3)
        twitter_vbox.pack_start(self.twitter_timeline_check, False)
        twitter_vbox.pack_start(self.twitter_replies_check, False)
        twitter_vbox.show_all()

        self.twitter_align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        self.twitter_align.set_padding(0, 0, 12, 0)
        self.twitter_align.add(twitter_vbox)
        self.twitter_align.set_no_show_all(True)

        num = 0
        for widget in (search_radio, webfeed_radio, google_radio,
                       self.google_align, reddit_radio, twitter_radio,
                       self.twitter_align):
            if isinstance(widget, gtk.RadioButton):
                widget.connect('toggled', self.radio_toggled)
                widget.num = num
                num += 1

            source_vbox.pack_start(widget, False, False, 0)

        source_hbox = gtk.HBox(False, 6)
        source_hbox.pack_start(source_label, False, False)
        source_hbox.pack_start(source_vbox)

        #"Search for" label and entry
        search_label = gtk.Label(_("Search for"))
        search_label.set_alignment(1.0, 0.5)
        search_label.show()

        self.search_entry = gtk.Entry()
        self.search_entry.show()
        self.search_entry.connect('changed', self.entry_changed)

        self.search_hbox = gtk.HBox(False, 6)
        self.search_hbox.pack_start(search_label, False)
        self.search_hbox.pack_start(self.search_entry)
        self.search_hbox.set_no_show_all(True)

        #URL: label and entry
        url_label = gtk.Label(_("URL:"))
        url_label.set_alignment(1.0, 0.5)
        url_label.show()

        self.url_entry = gtk.Entry()
        self.url_entry.show()
        self.url_entry.connect('changed', self.entry_changed)

        self.url_hbox = gtk.HBox(False, 6)
        self.url_hbox.pack_start(url_label, False, False)
        self.url_hbox.pack_start(self.url_entry)
        self.url_hbox.set_no_show_all(True)

        #Username: label and entry
        user_label = gtk.Label(_("Username:"******"Password:"******"Feed search by "))
        button = gtk.LinkButton(reader_url, _("Google Reader"))

        image.show()
        image_align.show()
        label.show()
        button.show()

        hbox = gtk.HBox()
        hbox.pack_start(image_align, False, False, 6)
        hbox.pack_start(label, False)
        hbox.pack_start(button, False)
        hbox.show()

        self.search_msg = gtk.HBox()
        self.search_msg.pack_start(hbox, True, False)
        self.search_msg.set_no_show_all(True)

        #Results VBox and ScrolledWindow for Feed Search
        self.results_vbox = gtk.VBox(False, 3)
        self.results_vbox.show()

        self.results_sw = gtk.ScrolledWindow()
        self.results_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.results_sw.add_with_viewport(self.results_vbox)
        self.results_sw.set_no_show_all(True)

        #Cancel and Add buttons
        cancel = gtk.Button(stock=gtk.STOCK_CLOSE)
        cancel.connect('clicked', self.close)

        self.add_button = gtk.Button(stock=gtk.STOCK_ADD)
        self.add_button.set_flags(gtk.CAN_DEFAULT)
        self.add_button.set_sensitive(False)
        self.add_button.set_no_show_all(True)
        self.add_button.connect('clicked', self.almost_add_feed)

        #If signed in to Google Reader
        self.search_button = gtk.Button(_("_Search"))
        image = gtk.image_new_from_icon_name('search', gtk.ICON_SIZE_BUTTON)
        self.search_button.set_image(image)
        self.search_button.set_flags(gtk.CAN_DEFAULT)
        self.search_button.set_sensitive(False)
        self.search_button.set_no_show_all(True)
        self.search_button.connect('clicked', self.do_search)

        if self.google_source is not None:
            self.search_button.show()
            self.search_hbox.show()
            self.search_msg.show()

        else:
            self.add_button.show()
            self.url_hbox.show()
            webfeed_radio.set_active(True)

        button_hbox = gtk.HBox(False, 6)
        button_hbox.pack_end(self.add_button, False, False)
        button_hbox.pack_end(self.search_button, False, False)
        button_hbox.pack_end(cancel, False, False)

        main_vbox = gtk.VBox(False, 6)
        main_vbox.pack_start(source_hbox, False, False)
        main_vbox.pack_start(self.search_hbox, False, False)
        main_vbox.pack_start(self.url_hbox, False, False)
        main_vbox.pack_start(self.user_hbox, False, False)
        main_vbox.pack_start(self.pass_hbox, False, False)
        main_vbox.pack_start(self.search_msg, False, False)
        main_vbox.pack_start(self.results_sw)
        main_vbox.pack_end(button_hbox, False, False)
        main_vbox.show_all()

        self.add(main_vbox)
        self.add_button.grab_default()

        #Make the labels the same size
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        sg.add_widget(source_label)
        sg.add_widget(search_label)
        sg.add_widget(url_label)
        sg.add_widget(user_label)
        sg.add_widget(pass_label)

        #Make the buttons the same size
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        sg.add_widget(cancel)
        sg.add_widget(self.add_button)
        sg.add_widget(self.search_button)

        self.show_all()

        #Update any downloaded favicons if necessary
        for siteid in ('www.google.com', 'google-reader', 'wave.google.com',
                       'www.reddit.com'):
            self.applet.fetch_favicon(self.fetched_favicon, siteid, siteid)
    def getScreen(self, dispatch, bl):
        self.dispatch = dispatch
        self.bl = bl
        self.intf = dispatch.intf

        (self.type, self.bootDev) = \
                    checkbootloader.getBootloaderTypeAndBoot(dispatch.instPath)

        self.update_radio = gtk.RadioButton(
            None, _("_Update boot loader configuration"))
        updatestr = _("This will update your current boot loader.")

        if self.type is not None and self.bootDev is not None:
            current = _(
                "The installer has detected the %s boot loader "
                "currently installed on %s.") % (self.type, self.bootDev)
            self.update_label = gtk.Label(
                "%s  %s" % (updatestr, _("This is the recommended option.")))
            self.update_radio.set_active(gtk.FALSE)
            update = 1
        else:
            current = _("The installer is unable to detect the boot loader "
                        "currently in use on your system.")
            self.update_label = gtk.Label("%s" % (updatestr, ))
            self.update_radio.set_sensitive(gtk.FALSE)
            self.update_label.set_sensitive(gtk.FALSE)
            update = 0

        self.newbl_radio = gtk.RadioButton(
            self.update_radio, _("_Create new boot loader "
                                 "configuration"))
        self.newbl_label = gtk.Label(
            _("This will let you create a "
              "new boot loader configuration.  If "
              "you wish to switch boot loaders, you "
              "should choose this."))

        self.newbl_radio.set_active(gtk.FALSE)
        self.nobl_radio = gtk.RadioButton(self.update_radio,
                                          _("_Skip boot loader updating"))
        self.nobl_label = gtk.Label(
            _("This will make no changes to boot "
              "loader configuration.  If you are "
              "using a third party boot loader, you "
              "should choose this."))
        self.nobl_radio.set_active(gtk.FALSE)

        for label in [self.update_label, self.nobl_label, self.newbl_label]:
            label.set_alignment(0.8, 0)
            label.set_size_request(275, -1)
            label.set_line_wrap(gtk.TRUE)

        str = _("What would you like to do?")
        # if they have one, the default is to update, otherwise the
        # default is to not touch anything
        if update == 1:
            default = self.update_radio
        else:
            default = self.nobl_radio

        if not dispatch.stepInSkipList("bootloader"):
            self.newbl_radio.set_active(gtk.TRUE)
        elif dispatch.stepInSkipList("instbootloader"):
            self.nobl_radio.set_active(gtk.TRUE)
        else:
            default.set_active(gtk.TRUE)

        box = gtk.VBox(gtk.FALSE, 5)

        label = gtk.Label(current)
        label.set_line_wrap(gtk.TRUE)
        label.set_alignment(0.5, 0.0)
        label.set_size_request(300, -1)
        label2 = gtk.Label(str)
        label2.set_line_wrap(gtk.TRUE)
        label2.set_alignment(0.5, 0.0)
        label2.set_size_request(300, -1)

        box.pack_start(label, gtk.FALSE)
        box.pack_start(label2, gtk.FALSE, padding=10)

        box.pack_start(self.update_radio, gtk.FALSE)
        box.pack_start(self.update_label, gtk.FALSE)
        box.pack_start(self.nobl_radio, gtk.FALSE)
        box.pack_start(self.nobl_label, gtk.FALSE)
        box.pack_start(self.newbl_radio, gtk.FALSE)
        box.pack_start(self.newbl_label, gtk.FALSE)

        a = gtk.Alignment(0.2, 0.1)
        a.add(box)

        return a
    def __init__(self, initial_value, parent):
        gtk.Dialog.__init__(self, _("Set transposition"), parent, 0, (
            gtk.STOCK_CANCEL,
            gtk.RESPONSE_CANCEL,
            gtk.STOCK_OK,
            gtk.RESPONSE_OK,
        ))
        dlg_vbox = gu.hig_dlg_vbox()
        self.vbox.pack_start(dlg_vbox)
        xbox, vbox = gu.hig_category_vbox(
            _("Select how to do random transposition"))
        dlg_vbox.pack_start(xbox)
        label = gtk.Label(
            _("""You can read about the different types of transposition in the lesson file documentation available on the Help menu."""
              ))
        spin_sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        label.set_line_wrap(True)
        vbox.pack_start(label)
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        self.m_buttons = {}
        self.m_spins = {}
        self.m_buttons['no'] = b1 = gtk.RadioButton(None, _("No"))
        self.m_spins['no'] = []
        vbox.pack_start(b1)
        self.m_buttons['yes'] = b2 = gtk.RadioButton(b1, _("Yes"))
        self.m_spins['yes'] = []
        hbox = gu.bHBox(vbox)
        label_b = gtk.Label()
        label_b.set_alignment(0.4, 0.5)
        label_b.set_markup('<span size="xx-large">♭</span>')
        label_x = gtk.Label()
        label_x.set_alignment(0.4, 0.5)
        label_x.set_markup('<span size="xx-large">♯</span>')
        spin_sg.add_widget(label_b)
        spin_sg.add_widget(label_x)
        hbox.pack_start(b2)
        hbox.pack_start(label_b)
        hbox.pack_start(label_x)

        self.m_buttons['accidentals'] = gtk.RadioButton(
            b1, _("Fifths relative to C major/a minor"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['accidentals'])
        self.m_spins['accidentals'] = [
            gtk.SpinButton(gtk.Adjustment(0, -7, 7, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -7, 7, 1, 1), 0.0, 0)
        ]
        spin_sg.add_widget(self.m_spins['accidentals'][0])
        spin_sg.add_widget(self.m_spins['accidentals'][1])
        hbox.pack_start(self.m_spins['accidentals'][0])
        hbox.pack_start(self.m_spins['accidentals'][1])
        gu.SpinButtonRangeController(self.m_spins['accidentals'][0],
                                     self.m_spins['accidentals'][1], -7, 7)

        self.m_buttons['key'] = gtk.RadioButton(
            b1, _i("Fifths relative to current key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['key'])
        self.m_spins['key'] = [
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0)
        ]
        hbox.pack_start(self.m_spins['key'][0])
        hbox.pack_start(self.m_spins['key'][1])
        gu.SpinButtonRangeController(self.m_spins['key'][0],
                                     self.m_spins['key'][1], -10, 10)

        self.m_buttons['atonal'] = gtk.RadioButton(
            b1, _i("Transpose notes without changing key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['atonal'])
        self.m_spins['atonal'] = [
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0)
        ]
        hbox.pack_start(self.m_spins['atonal'][0])
        hbox.pack_start(self.m_spins['atonal'][1])
        gu.SpinButtonRangeController(self.m_spins['atonal'][0],
                                     self.m_spins['atonal'][1], -10, 10)

        self.m_buttons['semitones'] = gtk.RadioButton(b1, _("Semitones"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['semitones'])
        self.m_spins['semitones'] = [
            gtk.SpinButton(gtk.Adjustment(0, -100, 100, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -100, 100, 1, 1), 0.0, 0)
        ]
        hbox.pack_start(self.m_spins['semitones'][0])
        hbox.pack_start(self.m_spins['semitones'][1])
        hbox.pack_start(self.m_spins['semitones'][0])
        hbox.pack_start(self.m_spins['semitones'][1])
        gu.SpinButtonRangeController(self.m_spins['semitones'][0],
                                     self.m_spins['semitones'][1], -100, 100)
        for n, w in self.m_buttons.items():
            sizegroup.add_widget(w)
            for ww in self.m_spins[n]:
                ww.set_sensitive(False)
            w.connect('clicked', self.on_spins_clicked, n)
        if initial_value[0] == False:
            k = 'no'
        elif initial_value[0] == True:
            k = 'yes'
        else:
            k = initial_value[0]
        self.m_buttons[k].set_active(True)
        if k in ('accidentals', 'key', 'semitones', 'atonal'):
            t, v1, v2 = initial_value
            # FIXME Because of the RangeController, we have to do this
            # twice to be sure both values are set properly.
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
        self.show_all()
Exemple #18
0
    def __init__(self, parent=None, path=None):
        gtk.Dialog.__init__(
            self, "Edit Path", parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            ("Cancel", gtk.RESPONSE_CANCEL, "OK", gtk.RESPONSE_OK))
        self.set_has_separator(False)
        self.set_default_size(400, -1)

        vbox = gtk.VBox(False, 12)
        vbox.set_border_width(12)
        self.vbox.add(vbox)

        group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        hbox = gtk.HBox(False, 6)
        vbox.pack_start(hbox, False, False, 0)
        label = gtk.Label("Type:")
        label.set_alignment(1, 0.5)
        group.add_widget(label)
        hbox.pack_start(label, False, False, 0)
        self.type_file_button = gtk.RadioButton(None, "File")
        hbox.pack_start(self.type_file_button, False, False, 0)
        self.type_directory_button = gtk.RadioButton(self.type_file_button,
                                                     "Directory")
        hbox.pack_start(self.type_directory_button, False, False, 0)

        if path and path.path_type == "directory":
            self.type_directory_button.set_active(True)

        self.type_file_button.connect("toggled", self.type_toggled_cb)

        hbox = gtk.HBox(False, 6)
        vbox.pack_start(hbox, False, False, 0)
        label = gtk.Label("Source:")
        label.set_alignment(1, 0.5)
        group.add_widget(label)
        hbox.pack_start(label, False, False, 0)
        self.source_entry = gtk.Entry()
        hbox.pack_start(self.source_entry, True, True, 0)
        if path:
            self.source_entry.set_text(path.source)

        button = gtk.FileChooserButton("Choose Source")
        if path and path.path_type == "directory":
            button.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        else:
            button.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
        self.source_button = button
        hbox.pack_start(button, True, True, 0)

        hbox = gtk.HBox(False, 6)
        vbox.pack_start(hbox, False, False, 0)
        label = gtk.Label("Destination:")
        label.set_alignment(1, 0.5)
        group.add_widget(label)
        hbox.pack_start(label, False, False, 0)
        self.dest_entry = gtk.Entry()
        hbox.pack_start(self.dest_entry, True, True, 0)
        if path:
            self.dest_entry.set_text(path.dest)

        button = gtk.FileChooserButton("Choose Destination")
        if path and path.path_type == "directory":
            button.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        else:
            button.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
        self.dest_button = button
        hbox.pack_start(button, True, True, 0)

        self.help_label = gtk.Label()
        self.help_label.set_line_wrap_mode(pango.WRAP_WORD_CHAR)
        self.help_label.set_line_wrap(True)
        self.help_label.set_alignment(0, 0.5)
        # Force the label to 3 lines so the window doesn't resize later.
        self.help_label.set_markup(
            "<span size='small' style='italic'>\n\n\n</span>")
        vbox.pack_start(self.help_label, False, False, 0)

        self.source_entry.connect("changed", self.entries_changed_cb)
        self.dest_entry.connect("changed", self.entries_changed_cb)

        self.connect("response", self.response_cb)

        if path:
            # Force sensitivity update
            self.entries_changed_cb(self.source_entry)
        else:
            self.set_response_sensitive(gtk.RESPONSE_OK, False)

            # Hack to allow creating an empty node, just for the UI.
            path = Path("/foo", "/bar")
            path.source = None
            path.dest = None
        self.path = path

        vbox.show_all()
Exemple #19
0
check_box.set_border_width(5)
#Known radars box
known_box = gtk.HBox(False, 0)
known_box.set_border_width(5)
#Packing the boxes
vbox.pack_start(elev_box, False)
vbox.pack_start(lon_box, False)
vbox.pack_start(lat_box, False)
vbox.pack_start(check_box, False)
vbox.pack_start(known_box, False)
#Topography 0 or 1
entry2 = gtk.Entry()
entry2.set_editable(True)
entry2.set_text("0")
#Check button for the Map
check_map = gtk.RadioButton(None, "Map")
check_map.connect("toggled", set_basemap, entry2, 0)
check_box.pack_start(check_map)
#Check button for the Topography
check_topography = gtk.RadioButton(check_map, "Topography")
check_topography.connect("toggled", set_basemap, entry2, 1)
check_box.pack_start(check_topography)
#Entry for the Elevation
entry1 = gtk.Entry()
entry1.set_editable(True)
entry1.set_text("0.3")
label = gtk.Label("Elevation:     ")
elev_box.pack_start(label)
elev_box.pack_start(entry1)
label = gtk.Label("degrees")
elev_box.pack_start(label)
Exemple #20
0
    def __init__(self):
        gtk.Frame.__init__(self, "Lattice")
        self.set_label_align (0.5, 0.5);
        TypeBox = gtk.VBox()
        HBox = gtk.HBox()
        TypeFrame  = gtk.Frame ("Type")
        ParamFrame = gtk.Frame ("Parameters")
        self.CubicRadio = gtk.RadioButton (None,            "Simple Cubic")
        self.TetraRadio = gtk.RadioButton (self.CubicRadio, "Tetragonal")
        self.FCCRadio   = gtk.RadioButton (self.CubicRadio, "FCC")
        self.BCCRadio   = gtk.RadioButton (self.CubicRadio, "BCC")
        self.OrthoRadio = gtk.RadioButton (self.CubicRadio, "Orthorhombic")
        self.ArbRadio   = gtk.RadioButton (self.CubicRadio, "Arbitrary")
        self.CubicRadio.connect ("toggled", self.RadioCallback, "Cubic")
        self.FCCRadio.connect   ("toggled", self.RadioCallback, "FCC")
        self.BCCRadio.connect   ("toggled", self.RadioCallback, "BCC")
        self.OrthoRadio.connect ("toggled", self.RadioCallback, "Ortho")
        self.ArbRadio.connect   ("toggled", self.RadioCallback, "Arb")
        TypeBox.pack_start (self.CubicRadio)
        TypeBox.pack_start (self.FCCRadio)
        TypeBox.pack_start (self.BCCRadio)
        TypeBox.pack_start (self.OrthoRadio)
        TypeBox.pack_start (self.ArbRadio)
        TypeFrame.add (TypeBox)

        # Setup the lattice vector table
        VectorTable=gtk.Table(3, 4, False)
        a0label = gtk.Label(); a0label.set_markup("a<small><sub>0</sub></small>")
        a1label = gtk.Label(); a1label.set_markup("a<small><sub>1</sub></small>")
        a2label = gtk.Label(); a2label.set_markup("a<small><sub>2</sub></small>")
        VectorTable.attach(a0label, 0, 1, 0, 1, gtk.SHRINK, gtk.SHRINK, 5);
        VectorTable.attach(a1label, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK, 5);
        VectorTable.attach(a2label, 0, 1, 2, 3, gtk.SHRINK, gtk.SHRINK, 5);
        self.SpinButtons = []
        for row in range(0,3):
            spinlist = []
            for col in range(1,4):
                spin = gtk.SpinButton(\
                    gtk.Adjustment(0.0, -1.0e5, 1.00e5, 0.01, 0.1))
                spinlist.append(spin)
                spin.set_digits(5)
                spin.set_width_chars(8)
                VectorTable.attach (spin, col, col+1, row, row+1)
            self.SpinButtons.append(spinlist)
        VectorFrame = gtk.Frame ("Lattice Vectors");
        VectorFrame.add(VectorTable)

        # Setup the parameters
        ParamBox = gtk.VBox()
        # Cubic parameters
        ParamTable = gtk.Table(6,4)
        self.aButton = gtk.SpinButton\
                       (gtk.Adjustment(1.0, 0.0, 1e5, 0.01, 0.1))
        self.aButton.set_digits(5); self.aButton.set_width_chars(8);
        self.bButton = gtk.SpinButton(gtk.Adjustment(1.0, 0.0, 1e5, 0.01, 0.1));
        self.bButton.set_digits(5); self.bButton.set_width_chars(8);
        self.cButton = gtk.SpinButton(gtk.Adjustment(1.0, 0.0, 1e5, 0.01, 0.1));
        self.cButton.set_digits(5); self.cButton.set_width_chars(8);
        self.alphaButton = gtk.SpinButton(gtk.Adjustment(90.0, 0.0, 180.0, 0.01, 0.1));
        self.alphaButton.set_digits(3)
        self.betaButton = gtk.SpinButton(gtk.Adjustment(90.0, 0.0, 180.0, 0.01, 0.1));
        self.betaButton.set_digits(3)
        self.gammaButton = gtk.SpinButton(gtk.Adjustment(90.0, 0.0, 180.0, 0.01, 0.1));
        self.gammaButton.set_digits(3)
        
        # Set parameters changing callback
        self.aButton.connect    ("value_changed", self.parameters_callback)
        self.bButton.connect    ("value_changed", self.parameters_callback)
        self.cButton.connect    ("value_changed", self.parameters_callback)        
        self.alphaButton.connect("value_changed", self.parameters_callback)
        self.betaButton.connect ("value_changed", self.parameters_callback)
        self.gammaButton.connect("value_changed", self.parameters_callback)        
                             
        ParamTable.attach(gtk.Label("a"), 0, 1, 0, 1)
        ParamTable.attach(gtk.Label("b"), 0, 1, 1, 2)
        ParamTable.attach(gtk.Label("c"), 0, 1, 2, 3)
        alphaLabel = gtk.Label();
        alphaLabel.set_markup("<span foreground=\"blue\" font_family=\"Standard Symbols L\">&#945;</span>")
        betaLabel = gtk.Label();
        betaLabel.set_markup("<span foreground=\"blue\" font_family=\"Standard Symbols L\">&#946;</span>")
        gammaLabel = gtk.Label();
        gammaLabel.set_markup("<span foreground=\"blue\" font_family=\"Standard Symbols L\">&#947;</span>")
        ParamTable.attach(alphaLabel,  2, 3, 0, 1, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamTable.attach(betaLabel ,  2, 3, 1, 2, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamTable.attach(gammaLabel,  2, 3, 2, 3, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamTable.attach(self.aButton,     1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamTable.attach(self.bButton,     1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamTable.attach(self.cButton,     1, 2, 2, 3, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamTable.attach(self.alphaButton, 3, 4, 0, 1, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamTable.attach(self.betaButton,  3, 4, 1, 2, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamTable.attach(self.gammaButton, 3, 4, 2, 3, gtk.SHRINK, gtk.SHRINK, 5, 2)
        ParamBox.pack_start(ParamTable)
        ParamFrame.add (ParamBox)

        # Pack the main Lattice box
        HBox.pack_start (TypeFrame,   False, False, 3)
        HBox.pack_start (ParamFrame,  False, False, 3)
        HBox.pack_start (VectorFrame, False, False, 3)
        self.set_cubic()
        self.lattice_sensitive(False)
        self.params_sensitive([True, False, False, False, False, False])
        self.add (HBox)
Exemple #21
0
    def __init__(self):
        super(PyApp, self).__init__()

        self.set_size_request(400, 800)
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_border_width(10)
        self.connect("destroy", gtk.main_quit)
        self.set_title("ListView")
        vbox = gtk.VBox(False, 0)

        # For Adding Scroll Bar

        sw = gtk.ScrolledWindow()
        sw.set_border_width(50)
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        vbox.pack_start(sw, True, True, 0)

        store = self.create_model()

        treeView = gtk.TreeView(store)
        treeView.connect("row-activated", self.on_activated)
        treeView.set_rules_hint(True)
        sw.add(treeView)

        self.create_columns(treeView)
        self.statusbar = gtk.Statusbar()

        vbox.pack_start(self.statusbar, False, False, 0)

        #for check Boxes
        button = gtk.CheckButton("check button 1")
        button.connect("toggled", self.callback, "check button 1")
        vbox.pack_start(button, True, True, 2)
        button.show()

        button = gtk.CheckButton("check button 2")
        button.connect("toggled", self.callback, "check button 2")
        vbox.pack_start(button, True, True, 2)
        button.show()

        # For Adding Buttons
        btn1 = gtk.Button("Py GTK")
        btn1.connect("clicked", self.fun, None)
        vbox.pack_start(btn1, True, True, 0)
        vbox.add(btn1)
        btn2 = gtk.Button("Py tkinter")
        btn2.connect("clicked", self.fun1, None)
        vbox.pack_start(btn1, True, True, 0)
        vbox.add(btn2)
        vbox.show()
        btn1.show()
        btn2.show()

        #For adding Radio Buttons

        button = gtk.RadioButton(None, "radio button1")
        button.connect("toggled", self.callback, "radio button 1")
        vbox.pack_start(button, True, True, 0)
        button.show()
        button = gtk.RadioButton(button, "radio button2")
        button.connect("toggled", self.callback, "radio button 2")
        #button.set_active(True)
        vbox.pack_start(button, True, True, 0)
        button.show()
        self.add(vbox)
        self.show_all()
Exemple #22
0
    def show(self, pkg):

        priority = sysconf.get(("package-priorities", pkg.name), {})

        table = self._table
        table.foreach(table.remove)

        label = gtk.Label(_("Package:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)

        label = gtk.Label()
        label.set_markup("<b>%s</b>" % pkg.name)
        label.set_alignment(0.0, 0.5)
        label.show()
        table.attach(label, 1, 2, 0, 1, gtk.FILL, gtk.FILL)

        def toggled(check, spin, alias):
            if check.get_active():
                priority[alias] = int(spin.get_value())
                spin.set_sensitive(True)
            else:
                if alias in priority:
                    del priority[alias]
                spin.set_sensitive(False)

        def value_changed(spin, alias):
            priority[alias] = int(spin.get_value())

        label = gtk.Label(_("Default priority:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        hbox = gtk.HBox()
        hbox.set_spacing(10)
        hbox.show()
        table.attach(hbox, 1, 2, 1, 2, gtk.FILL, gtk.FILL)

        radio = gtk.RadioButton(None, _("Channel default"))
        radio.set_active(None not in priority)
        radio.show()
        hbox.pack_start(radio, expand=False)

        radio = gtk.RadioButton(radio, _("Set to"))
        radio.set_active(None in priority)
        radio.show()
        hbox.pack_start(radio, expand=False)
        spin = gtk.SpinButton()
        if None not in priority:
            spin.set_sensitive(False)
        spin.set_increments(1, 10)
        spin.set_numeric(True)
        spin.set_range(-100000, +100000)
        spin.set_value(priority.get(None, 0))
        spin.connect("value-changed", value_changed, None)
        radio.connect("toggled", toggled, spin, None)
        spin.show()
        hbox.pack_start(spin, expand=False)

        label = gtk.Label(_("Channel priority:"))
        label.set_alignment(1.0, 0.0)
        label.show()
        table.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.FILL)

        chantable = gtk.Table()
        chantable.set_row_spacings(10)
        chantable.set_col_spacings(10)
        chantable.show()
        table.attach(chantable, 1, 2, 2, 3, gtk.FILL, gtk.FILL)

        pos = 0
        channels = sysconf.get("channels")
        for alias in channels:
            channel = channels[alias]
            if not getChannelInfo(channel.get("type")).kind == "package":
                continue
            name = channel.get("name")
            if not name:
                name = alias
            check = gtk.CheckButton(name)
            check.set_active(alias in priority)
            check.show()
            chantable.attach(check, 0, 1, pos, pos + 1, gtk.FILL, gtk.FILL)
            spin = gtk.SpinButton()
            if alias not in priority:
                spin.set_sensitive(False)
            spin.set_increments(1, 10)
            spin.set_numeric(True)
            spin.set_range(-100000, +100000)
            spin.set_value(int(priority.get(alias, 0)))
            spin.connect("value_changed", value_changed, alias)
            check.connect("toggled", toggled, spin, alias)
            spin.show()
            chantable.attach(spin, 1, 2, pos, pos + 1, gtk.FILL, gtk.FILL)
            pos += 1

        self._window.show()
        gtk.main()
        self._window.hide()

        if not priority:
            sysconf.remove(("package-priorities", pkg.name))
        else:
            sysconf.set(("package-priorities", pkg.name), priority)
    def getScreen (self, grpset):
        self.grpset = grpset
        self.pkgs = self.grpset.hdrlist
        self.allPkgs = None
        
        self.packageTreeView = gtk.TreeView()

        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn('Groups', renderer, text=0)
        column.set_clickable(gtk.TRUE)
        self.packageTreeView.append_column(column)
        self.packageTreeView.set_headers_visible(gtk.FALSE)
        self.packageTreeView.set_rules_hint(gtk.FALSE)
        self.packageTreeView.set_enable_search(gtk.FALSE)
        
        self.flat_groups = self.make_group_list(grpset)
        self.build_packagelists(self.flat_groups)

        selection = self.packageTreeView.get_selection()
        selection.connect("changed", self.select_group)

        self.packageTreeView.set_model(self.packageGroupStore)
        self.packageTreeView.expand_all()
        
        self.sw = gtk.ScrolledWindow ()
        self.sw.set_policy (gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.sw.set_shadow_type(gtk.SHADOW_IN)
        self.sw.add(self.packageTreeView)
        
        packageHBox = gtk.HBox()

        self.leftVBox = gtk.VBox(gtk.FALSE)

        # FIXME should these stay or go?
        # tree/flat radio buttons... 
        optionHBox = gtk.HBox()
        self.treeRadio = gtk.RadioButton(None, (_("_Tree View")))
        self.treeRadio.connect("clicked", self.changePkgView)
        self.flatRadio = gtk.RadioButton(self.treeRadio, (_("_Flat View")))
        optionHBox.pack_start(self.treeRadio)
        optionHBox.pack_start(self.flatRadio)
        self.leftVBox.pack_start(optionHBox, gtk.FALSE)
        
        self.leftVBox.pack_start(self.sw, gtk.TRUE)
        packageHBox.pack_start(self.leftVBox, gtk.FALSE)

        self.packageList = PackageCheckList(2)
        self.packageList.checkboxrenderer.connect("toggled",
						  self.toggled_package)

        self.packageList.set_enable_search(gtk.TRUE)

        self.sortType = "Package"
        self.packageList.set_column_title (1, (_("_Package")))
        self.packageList.set_column_sizing (1, gtk.TREE_VIEW_COLUMN_GROW_ONLY)
        self.packageList.set_column_title (2, (_("_Size (MB)")))
        self.packageList.set_column_sizing (2, gtk.TREE_VIEW_COLUMN_GROW_ONLY)
        self.packageList.set_headers_visible(gtk.TRUE)

        self.packageList.set_column_min_width(0, 16)
        self.packageList.set_column_clickable(0, gtk.FALSE)
        
        self.packageList.set_column_clickable(1, gtk.TRUE)
        self.packageList.set_column_sort_id(1, 1)
        self.packageList.set_column_clickable(2, gtk.TRUE)
        self.packageList.set_column_sort_id(2, 2)

	sort_id = 1
	sort_order = 0
	self.packageList.store.set_sort_column_id(sort_id, sort_order)

	### XXX Hack to keep up with state of sorting
	###     Remove when treeview is fixed
	self.sort_id = sort_id
	self.sort_order = sort_order
	col = self.packageList.get_column(1)
	col.connect("clicked", self.colClickedCB, None)
	col = self.packageList.get_column(2)
	col.connect("clicked", self.colClickedCB, None)

        selection = self.packageList.get_selection()
        selection.connect("changed", self.select_package)

	self.packageList.connect("key-release-event", self.keypressCB)
	self.ignoreKeypress = None

        self.packageListSW = gtk.ScrolledWindow ()
        self.packageListSW.set_border_width (5)
        self.packageListSW.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.packageListSW.set_shadow_type(gtk.SHADOW_IN)
        self.packageListSW.add(self.packageList)

        self.packageListVAdj = self.packageListSW.get_vadjustment ()
        self.packageListSW.set_vadjustment(self.packageListVAdj)
        self.packageListHAdj = self.packageListSW.get_hadjustment () 
        self.packageListSW.set_hadjustment(self.packageListHAdj)

        packageHBox.pack_start (self.packageListSW)

        descVBox = gtk.VBox ()        
        descVBox.pack_start (gtk.HSeparator (), gtk.FALSE, padding=2)

        hbox = gtk.HBox ()
        bb = gtk.HButtonBox ()
        bb.set_layout (gtk.BUTTONBOX_END)

        self.totalSizeLabel = gtk.Label (_("Total size: "))
        hbox.pack_start (self.totalSizeLabel, gtk.FALSE, gtk.FALSE, 0)

        self.selectAllButton = gtk.Button (_("Select _all in group"))
        bb.pack_start (self.selectAllButton, gtk.FALSE)
        self.selectAllButton.connect ('clicked', self.select_all, 1)

        self.unselectAllButton = gtk.Button(_("_Unselect all in group"))
        bb.pack_start(self.unselectAllButton, gtk.FALSE)
        self.unselectAllButton.connect ('clicked', self.select_all, 0)
        
        hbox.pack_start (bb)

        self.selectAllButton.set_sensitive (gtk.FALSE)
        self.unselectAllButton.set_sensitive (gtk.FALSE)

        descVBox.pack_start (hbox, gtk.FALSE)

        descSW = gtk.ScrolledWindow ()
        descSW.set_border_width (5)
        descSW.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        descSW.set_shadow_type(gtk.SHADOW_IN)

        self.packageDesc = gtk.TextView()

        buffer = gtk.TextBuffer(None)
        self.packageDesc.set_buffer(buffer)
        self.packageDesc.set_editable(gtk.FALSE)
        self.packageDesc.set_cursor_visible(gtk.FALSE)
        self.packageDesc.set_wrap_mode(gtk.WRAP_WORD)
        descSW.add (self.packageDesc)
        descSW.set_size_request (-1, 100)

        descVBox.pack_start (descSW)

        vbox = gtk.VBox ()
        vbox.pack_start (packageHBox)
        vbox.pack_start (descVBox, gtk.FALSE)

	self.updateSize()

        return vbox
Exemple #24
0
 def build_dialog(self):
     # Our parent creates widgets in a Analyze Color Range frame,
     # we add to that a dialog window we build.
     analysis_frame = color_analyzer.build_dialog(self)
     HOMOGENEOUS = True
     NOT_HOMOGENEOUS = False
     EXPAND = True
     NOT_EXPAND = False
     FILL = True
     NOT_FILL = False
     WINDOW_BORDER = 5
     V_SPACE = 3
     H_PAD = 3
     TABLE_X_SPACE = 3
     TABLE_Y_SPACE = 3
     TBL_BTN_SEC_H_SPACE = 30  # Between right of table and Btn section
     row_labels = ('Mid Vals:', 'Thresholds:')
     color_labels = ('  Red', ' Green', '  Blue')
     empty_labels = ('', ) * 3
     spinner_labels = color_labels, empty_labels
     self.mid_val_thresh_adj_lst = []
     self.range_thresh_adj_lst = []
     thresh_adj_lst = [
         self.mid_val_thresh_adj_lst, self.range_thresh_adj_lst
     ]
     self.diag_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
     self.diag_window.set_title('Analyze & Select by Color Range')
     self.diag_window.set_border_width(WINDOW_BORDER)
     self.diag_window.connect('destroy', self.delete_event)
     # Here we just set a handler for delete_event that immediately
     # exits GTK.
     # self.diag_window.connect('delete_event', self.delete_event)
     uber_box = gtk.VBox(NOT_HOMOGENEOUS, V_SPACE)
     self.diag_window.add(uber_box)
     uber_box.pack_start(analysis_frame, NOT_EXPAND, NOT_FILL, 0)
     # ==== Build the 'Specify Selection' section.
     tooltips = gtk.Tooltips()
     frame = gtk.Frame('Specify color range to select')
     # frame.set_label_align(0.0, 1.0)
     uber_box.pack_start(frame, NOT_EXPAND, NOT_FILL, 0)
     vbox = gtk.VBox(NOT_HOMOGENEOUS, V_SPACE)
     frame.add(vbox)
     # Build row of Selection Mode options
     hbox = gtk.HBox(NOT_HOMOGENEOUS, 0)
     vbox.pack_start(hbox, NOT_EXPAND, NOT_FILL, 0)
     lbl = gtk.Label('Selection Mode: ')
     hbox.pack_start(lbl, NOT_EXPAND, NOT_FILL, H_PAD)
     rbtn_lbl = ['Replace', 'Add', 'Subtract', 'Intersect']
     rbtn_data = [
         CHANNEL_OP_REPLACE, CHANNEL_OP_ADD, CHANNEL_OP_SUBTRACT,
         CHANNEL_OP_INTERSECT
     ]
     rbtn = None
     for c in range(4):
         rbtn = gtk.RadioButton(rbtn, rbtn_lbl[c])
         rbtn.connect('toggled', self.sel_mode_callback, rbtn_data[c])
         hbox.pack_start(rbtn, NOT_EXPAND, NOT_FILL, H_PAD)
         if c == 0:
             rbtn_actv = rbtn
     rbtn.set_active(True)  # get toggled msg sent out
     rbtn_actv.set_active(True)  # so callback() inits vars
     # Build row of Selection Context Options
     hbox = gtk.HBox(NOT_HOMOGENEOUS, 0)
     vbox.pack_start(hbox, NOT_EXPAND, NOT_FILL, 0)
     context_opt_lbl = self.context_opt_lbl
     for c in range(4):
         chk_btn = gtk.CheckButton(context_opt_lbl[c])
         chk_btn.connect("toggled", self.sel_ctxt_callback, c)
         hbox.pack_start(chk_btn, NOT_EXPAND, NOT_FILL, H_PAD)
     # Build 'Feather Radius' threshold widgets
     hbox = gtk.HBox(NOT_HOMOGENEOUS, 0)
     vbox.pack_start(hbox, NOT_EXPAND, NOT_FILL, 0)
     lbl = gtk.Label('Feather Radius')
     thresh_adj = gtk.Adjustment(pdb.gimp_context_get_feather_radius()[0],
                                 0, 100, .1, 1)
     spinner = gtk.SpinButton(thresh_adj, 1, 1)
     spinner.set_wrap(True)
     spinner.set_numeric(True)
     spinner.set_snap_to_ticks(True)
     self.f_radius_thresh_adj = thresh_adj
     self.f_radius_spinner = spinner
     hbox.pack_start(spinner, NOT_EXPAND, NOT_FILL, H_PAD)
     hbox.pack_start(lbl, NOT_EXPAND, NOT_FILL, 0)
     self.f_radius_box = hbox
     # Build Table for  Mid Pt. Color and Threshold widgets
     hbox = gtk.HBox(NOT_HOMOGENEOUS, TBL_BTN_SEC_H_SPACE)
     vbox.pack_start(hbox, NOT_EXPAND, NOT_FILL, V_SPACE)
     table = gtk.Table(len(row_labels), 1 + (len(spinner_labels[0]) * 2),
                       NOT_HOMOGENEOUS)
     table.set_row_spacings(TABLE_Y_SPACE)
     table.set_col_spacings(TABLE_X_SPACE)
     hbox.pack_start(table, NOT_EXPAND, NOT_FILL, H_PAD)
     row = 0
     # R, G & B threshold widgets
     for r_lbl in row_labels:
         col = 0
         lbl = gtk.Label(r_lbl)
         table.attach(lbl, col, col + 1, row, row + 1, gtk.FILL,
                      gtk.FILL)  # fill so justify method works
         lbl.set_alignment(0, .5)  #Left just. & Vert center
         col += 1
         for spin_lbl in spinner_labels[row]:
             if '' != spin_lbl:
                 lbl = gtk.Label()
                 lbl.set_markup('<tt>' + spin_lbl + '</tt>')
                 table.attach(lbl, col, col + 1, row, row + 1, 0, 0)
             col += 1
             thresh_adj = gtk.Adjustment(0, 0, 255, 0.5)
             spinner = gtk.SpinButton(thresh_adj, 0.5, 1)
             spinner.set_wrap(True)
             spinner.set_numeric(True)
             spinner.set_snap_to_ticks(True)
             thresh_adj_lst[row] += [thresh_adj]
             table.attach(spinner, col, col + 1, row, row + 1, 0, 0)
             col += 1
         row += 1
     # Add [Select] btn to lower right corner of Select Frame
     vbox = gtk.VBox(NOT_HOMOGENEOUS, 0)
     hbox.pack_end(vbox, NOT_EXPAND, NOT_FILL, H_PAD)
     bbox = gtk.HButtonBox()
     bbox.set_layout(gtk.BUTTONBOX_END)
     bbox.set_spacing(0)
     vbox.pack_end(bbox, NOT_EXPAND, NOT_FILL, 0)
     btn = gtk.Button('Select')
     btn.connect('clicked', self.select_callback)
     bbox.add(btn)
     # Add [Load Vals] btn above Select] btn
     bbox = gtk.HButtonBox()
     bbox.set_layout(gtk.BUTTONBOX_END)
     bbox.set_spacing(0)
     vbox.pack_end(bbox, NOT_EXPAND, NOT_FILL, 0)
     btn = gtk.Button('Load Vals')
     btn.connect('clicked', self.load_callback)
     bbox.add(btn)
     tooltips.set_tip(btn, 'Load Mid Vals & Thresholds\nfrom Analysis')
     # Build last section, [Close] btn
     bbox = gtk.HButtonBox()
     bbox.set_layout(gtk.BUTTONBOX_END)
     bbox.set_spacing(0)
     uber_box.pack_end(bbox, NOT_EXPAND, NOT_FILL, 0)
     btn = gtk.Button('Close')
     btn.connect('clicked', self.delete_event)
     bbox.add(btn)
     self.diag_window.show_all()
     self.f_radius_box.hide()
     return uber_box
    def __init__(self, img):
        #layout
        self.contenitore_gen = gtk.VBox()
        box_gen = gtk.VBox()
        box_tab = gtk.VBox()

        self.contenitore_gen.pack_start(box_gen, False, False, 0)

        #window
        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.win.connect("destroy", self.destroy)
        self.win.set_title("Win-Iconizer 1.0")
        self.win.set_position(gtk.WIN_POS_CENTER)
        self.win.set_default_size(400, 400)
        self.win.set_resizable(False)
        self.win.set_border_width(2)
        self.icon = self.win.render_icon(gtk.STOCK_NO, gtk.ICON_SIZE_BUTTON)
        self.win.set_icon(self.icon)
        self.label = gtk.Label(
            "Select the formats you would like to create:\n")
        self.win.add(self.contenitore_gen)

        box_gen.pack_start(box_tab, True, True, 1)

        box_tab.pack_start(self.label, True, True, 1)

        tooltips = gtk.Tooltips()
        table = gtk.Table(8, 5, False)
        table.set_col_spacings(5)

        table.attach(gtk.Label(""), 0, 1, 0, 1)
        table.attach(gtk.Label("16"), 1, 2, 0, 1)
        table.attach(gtk.Label("24"), 2, 3, 0, 1)
        table.attach(gtk.Label("32"), 3, 4, 0, 1)
        table.attach(gtk.Label("48"), 4, 5, 0, 1)
        table.attach(gtk.Label("64"), 5, 6, 0, 1)
        table.attach(gtk.Label("128"), 6, 7, 0, 1)
        table.attach(gtk.Label("256"), 7, 8, 0, 1)
        table.attach(gtk.Label("512"), 8, 9, 0, 1)

        #1-bit 2 colors
        self.c_1b_16p = gtk.CheckButton("")
        self.c_1b_16p.set_size_request(20, 20)

        self.c_1b_24p = gtk.CheckButton("")
        self.c_1b_24p.set_size_request(20, 20)

        self.c_1b_32p = gtk.CheckButton("")
        self.c_1b_32p.set_size_request(20, 20)

        self.c_1b_48p = gtk.CheckButton("")
        self.c_1b_48p.set_size_request(20, 20)

        self.c_1b_64p = gtk.CheckButton("")
        self.c_1b_64p.set_size_request(20, 20)

        self.c_1b_128p = gtk.CheckButton("")
        self.c_1b_128p.set_size_request(20, 20)

        self.c_1b_256p = gtk.CheckButton("")
        self.c_1b_256p.set_size_request(20, 20)

        self.c_1b_512p = gtk.CheckButton("")
        self.c_1b_512p.set_size_request(20, 20)

        l_mono = gtk.Label("Mono")
        table.attach(l_mono, 0, 1, 1, 2)
        tooltips.set_tip(l_mono, "Mono - 1-bit")
        table.attach(self.c_1b_16p, 1, 2, 1, 2, xoptions=gtk.EXPAND)
        table.attach(self.c_1b_24p, 2, 3, 1, 2, xoptions=gtk.EXPAND)
        table.attach(self.c_1b_32p, 3, 4, 1, 2, xoptions=gtk.EXPAND)
        table.attach(self.c_1b_48p, 4, 5, 1, 2, xoptions=gtk.EXPAND)
        table.attach(self.c_1b_64p, 5, 6, 1, 2, xoptions=gtk.EXPAND)
        table.attach(self.c_1b_128p, 6, 7, 1, 2, xoptions=gtk.EXPAND)
        table.attach(self.c_1b_256p, 7, 8, 1, 2, xoptions=gtk.EXPAND)
        table.attach(self.c_1b_512p, 8, 9, 1, 2, xoptions=gtk.EXPAND)

        #4-bit 16 colors
        self.c_16c_16p = gtk.CheckButton("")
        self.c_16c_16p.set_size_request(20, 20)

        self.c_16c_24p = gtk.CheckButton("")
        self.c_16c_24p.set_size_request(20, 20)

        self.c_16c_32p = gtk.CheckButton("")
        self.c_16c_32p.set_size_request(20, 20)

        self.c_16c_48p = gtk.CheckButton("")
        self.c_16c_48p.set_size_request(20, 20)

        self.c_16c_64p = gtk.CheckButton("")
        self.c_16c_64p.set_size_request(20, 20)

        self.c_16c_128p = gtk.CheckButton("")
        self.c_16c_128p.set_size_request(20, 20)

        self.c_16c_256p = gtk.CheckButton("")
        self.c_16c_256p.set_size_request(20, 20)

        self.c_16c_512p = gtk.CheckButton("")
        self.c_16c_512p.set_size_request(20, 20)

        l_16c = gtk.Label("16 Colors")
        table.attach(l_16c, 0, 1, 2, 3)
        tooltips.set_tip(l_16c, "16 Colors - 4-bits")
        table.attach(self.c_16c_16p, 1, 2, 2, 3, xoptions=gtk.EXPAND)
        table.attach(self.c_16c_24p, 2, 3, 2, 3, xoptions=gtk.EXPAND)
        table.attach(self.c_16c_32p, 3, 4, 2, 3, xoptions=gtk.EXPAND)
        table.attach(self.c_16c_48p, 4, 5, 2, 3, xoptions=gtk.EXPAND)
        table.attach(self.c_16c_64p, 5, 6, 2, 3, xoptions=gtk.EXPAND)
        table.attach(self.c_16c_128p, 6, 7, 2, 3, xoptions=gtk.EXPAND)
        table.attach(self.c_16c_256p, 7, 8, 2, 3, xoptions=gtk.EXPAND)
        table.attach(self.c_16c_512p, 8, 9, 2, 3, xoptions=gtk.EXPAND)

        #8-bit 256 colors
        self.c_256c_16p = gtk.CheckButton("")
        self.c_256c_16p.set_size_request(20, 20)

        self.c_256c_24p = gtk.CheckButton("")
        self.c_256c_24p.set_size_request(20, 20)

        self.c_256c_32p = gtk.CheckButton("")
        self.c_256c_32p.set_size_request(20, 20)

        self.c_256c_48p = gtk.CheckButton("")
        self.c_256c_48p.set_size_request(20, 20)

        self.c_256c_64p = gtk.CheckButton("")
        self.c_256c_64p.set_size_request(20, 20)

        self.c_256c_128p = gtk.CheckButton("")
        self.c_256c_128p.set_size_request(20, 20)

        self.c_256c_256p = gtk.CheckButton("")
        self.c_256c_256p.set_size_request(20, 20)

        self.c_256c_512p = gtk.CheckButton("")
        self.c_256c_512p.set_size_request(20, 20)

        l_256c = gtk.Label("256 Colors")
        table.attach(l_256c, 0, 1, 3, 4)
        tooltips.set_tip(l_256c, "256 Colors - 8-bits")
        table.attach(self.c_256c_16p, 1, 2, 3, 4, xoptions=gtk.EXPAND)
        table.attach(self.c_256c_24p, 2, 3, 3, 4, xoptions=gtk.EXPAND)
        table.attach(self.c_256c_32p, 3, 4, 3, 4, xoptions=gtk.EXPAND)
        table.attach(self.c_256c_48p, 4, 5, 3, 4, xoptions=gtk.EXPAND)
        table.attach(self.c_256c_64p, 5, 6, 3, 4, xoptions=gtk.EXPAND)
        table.attach(self.c_256c_128p, 6, 7, 3, 4, xoptions=gtk.EXPAND)
        table.attach(self.c_256c_256p, 7, 8, 3, 4, xoptions=gtk.EXPAND)
        table.attach(self.c_256c_512p, 8, 9, 3, 4, xoptions=gtk.EXPAND)

        #32-bit 4.2 billion colors RGBA
        self.c_32b_16p = gtk.CheckButton("")
        self.c_32b_16p.set_size_request(20, 20)

        self.c_32b_24p = gtk.CheckButton("")
        self.c_32b_24p.set_size_request(20, 20)

        self.c_32b_32p = gtk.CheckButton("")
        self.c_32b_32p.set_size_request(20, 20)

        self.c_32b_48p = gtk.CheckButton("")
        self.c_32b_48p.set_size_request(20, 20)

        self.c_32b_64p = gtk.CheckButton("")
        self.c_32b_64p.set_size_request(20, 20)

        self.c_32b_128p = gtk.CheckButton("")
        self.c_32b_128p.set_size_request(20, 20)

        self.c_32b_256p = gtk.CheckButton("")
        self.c_32b_256p.set_size_request(20, 20)

        self.c_32b_512p = gtk.CheckButton("")
        self.c_32b_512p.set_size_request(20, 20)

        l_rgba = gtk.Label("RGB/A")
        table.attach(l_rgba, 0, 1, 4, 5)
        tooltips.set_tip(l_rgba, "RGB/A - 32-bits")
        table.attach(self.c_32b_16p, 1, 2, 4, 5, xoptions=gtk.EXPAND)
        table.attach(self.c_32b_24p, 2, 3, 4, 5, xoptions=gtk.EXPAND)
        table.attach(self.c_32b_32p, 3, 4, 4, 5, xoptions=gtk.EXPAND)
        table.attach(self.c_32b_48p, 4, 5, 4, 5, xoptions=gtk.EXPAND)
        table.attach(self.c_32b_64p, 5, 6, 4, 5, xoptions=gtk.EXPAND)
        table.attach(self.c_32b_128p, 6, 7, 4, 5, xoptions=gtk.EXPAND)
        table.attach(self.c_32b_256p, 7, 8, 4, 5, xoptions=gtk.EXPAND)
        table.attach(self.c_32b_512p, 8, 9, 4, 5, xoptions=gtk.EXPAND)

        box_tab.pack_start(table, True, True, 1)

        #icon type
        box_type = gtk.VBox(True, 5)

        default = gtk.RadioButton(None, "Default")
        default.connect("toggled", self.Set_Icon_Type, "default")
        default.set_active(False)
        tooltips.set_tip(
            default,
            "48x48 (256 colors, 16 colors)\n32x32 (256 colors, 16 colors)\n16x16 (256 colors, 16 colors)"
        )
        box_type.pack_start(default, False, False, 0)

        win_vista = gtk.RadioButton(default, "Win Vista")
        win_vista.connect("toggled", self.Set_Icon_Type, "win_vista")
        tooltips.set_tip(
            win_vista,
            "Recommended:\n256x256 (RGB/A)\n64x64 (RGB/A)\n48x48 (RGB/A, 256 colors, 16 colors)\n32x32 (RGB/A, 256 colors, 16 colors)\n24x24 (RGB/A, 256 colors, 16 colors)\n16x16 (RGB/A, 256 colors, 16 colors)\nMinimum:\n256x256 (RGB/A)\n48x48 (RGB/A, 256 colors)\n32x32 (RGB/A, 256 colors)\n16x16 (RGB/A, 256 colors)\nOptional:\n256x256 (256 colors, 16 colors)\n64x64 (256 colors, 16 colors)"
        )
        box_type.pack_start(win_vista, False, False, 0)

        win_xp = gtk.RadioButton(default, "Win XP")
        win_xp.connect("toggled", self.Set_Icon_Type, "win_xp")
        tooltips.set_tip(
            win_xp,
            "Recommended:\n48x48 (RGB/A, 256 colors, 16 colors)\n32x32 (RGB/A, 256 colors, 16 colors)\n24x24 (RGB/A, 256 colors, 16 colors)\n16x16 (RGB/A, 256 colors, 16 colors)\nMinimum:\n32x32 (RGB/A, 256 colors, 16 colors),\n16x16 (RGB/A, 256 colors, 16 colors)\nOptional:\n128x128 (RGB/A)"
        )
        box_type.pack_start(win_xp, False, False, 0)

        win_95 = gtk.RadioButton(default,
                                 "Win 95 - Win 98 - Win ME - Win 2000")
        win_95.connect("toggled", self.Set_Icon_Type, "win_95")
        tooltips.set_tip(
            win_95,
            "Recommended:\n48x48 (256 colors, 16 colors)\n32x32 (256 colors, 16 colors)\n16x16 (256 colors, 16 colors)\nMinimum:\n32x32 (256 colors, 16 colors)\n16x16 (256 colors, 16 colors)"
        )
        box_type.pack_start(win_95, False, False, 0)

        favico = gtk.RadioButton(default, "Favico")
        favico.connect("toggled", self.Set_Icon_Type, "favico")
        tooltips.set_tip(
            favico, "Recommended:\n32x32 (256 colors)\n16x16 (256 colors)")
        box_type.pack_start(favico, False, False, 0)

        custom = gtk.RadioButton(default, "Custom")
        custom.connect("toggled", self.Set_Icon_Type, "custom")
        tooltips.set_tip(custom, "Create your own icon")
        box_type.pack_start(custom, False, False, 0)

        box_gen.pack_start(gtk.Label(""), True, True, 1)
        box_gen.pack_start(box_type, True, True, 1)
        box_gen.pack_start(gtk.Label(""), True, True, 1)

        b_exe = gtk.Button()
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON)
        b_exe.set_image(image)
        b_exe.set_label("Create")
        b_exe.set_size_request(80, 35)
        b_exe.connect("clicked", self.Create_Icon, img)

        #progress bar
        self.pbar = gtk.ProgressBar()
        self.pbar.set_text("0 %")
        box_gen.pack_start(self.pbar, True, True, 5)

        box_gen.pack_start(b_exe, False, False, 1)

        #set default
        self.Set_Icon_Type(self, "default")

        self.win.show_all()
Exemple #26
0
    def add_widget(self,widget):
    
        widget_type = type(widget) 
         
       # print widget_type     
        if(widget_type == Button or isinstance(widget,Button)):
            widget.instance = gtk.Button(widget.text)
            widget.instance.set_size_request(widget.width,widget.height)
            self.fixed.put(widget.instance, widget.position_X, widget.position_Y)            
            widget.instance.show()
            if(widget.callbackMethod != None ):
                widget.instance.connect('clicked',widget.callbackMethod)
                
        elif(widget_type==TextBox or isinstance(widget,TextBox) ):
            widget.instance = gtk.TextView(widget.buffer)
          
            widget.instance.set_size_request(widget.width,widget.height)
            self.fixed.put(widget.instance, widget.position_X, widget.position_Y)            
            widget.instance.show()
        
     
        elif(widget_type==CheckBox or isinstance(widget,CheckBox)):
            widget.instance = gtk.CheckButton(widget.title)
            widget.instance.set_size_request(widget.width,widget.height)
            self.fixed.put(widget.instance, widget.position_X, widget.position_Y)            
            widget.instance.show()
            widget.instance.set_active(widget.value)
            
        elif(widget_type==RadioButtons or isinstance(widget,RadioButtons)):
            widget.instance = []
            radio_instance = gtk.RadioButton(None, widget.labels[0])
            radio_instance.set_size_request(widget.width,widget.height)
            self.fixed.put(radio_instance,widget.position_X[0], widget.position_Y[0])
            radio_instance.show()
            widget.instance.append(radio_instance)
            for i in range(1,len(widget.labels)):
                radio_instance = gtk.RadioButton(widget.instance[0], widget.labels[i])
                radio_instance.set_size_request(widget.width,widget.height)
                self.fixed.put(radio_instance,widget.position_X[i], widget.position_Y[i])
                radio_instance.show()
                widget.instance.append(radio_instance)
            
            if(widget.selected_pos != None):
                widget.instance[widget.selected_pos].set_active(True)
       
        
        elif(widget_type==LabelText or isinstance(widget,LabelText)):
            widget.instance = gtk.Label(widget.text)
            widget.instance.set_size_request(widget.width,widget.height)
            self.fixed.put(widget.instance, widget.position_X, widget.position_Y)            
            widget.instance.show()
            
        elif(widget_type==TextField or isinstance(widget,TextField)):
            widget.instance = gtk.Entry()
            widget.instance.set_size_request(widget.width,widget.height)
            self.fixed.put(widget.instance, widget.position_X, widget.position_Y)
            widget.instance.set_text(widget.title)            
            widget.instance.show()
        elif(widget_type==TextFieldPass or isinstance(widget,TextField)):
            widget.instance = gtk.Entry()
            widget.instance.set_visibility(False)
            widget.instance.set_size_request(widget.width,widget.height)
            self.fixed.put(widget.instance, widget.position_X, widget.position_Y)
            widget.instance.set_text(widget.title)            
            widget.instance.show()
            
        elif(widget_type==ValueList or isinstance(widget,ValueList)):
            widget.instance = gtk.OptionMenu()
            widget.instance.set_size_request(widget.width,widget.height)
            menu = gtk.Menu()
            for name in widget.choices:
                item = gtk.MenuItem(name)
                item.show()
                menu.append(item)
                print "gis"
            widget.instance.set_menu(menu)
            widget.instance.show()
            self.fixed.put(widget.instance,widget.position_X, widget.position_Y)
        elif(widget_type == "Slider" or isinstance(widget,Slider) ):
        	'''
            	frame = self.abs_frame(widget)
        	widget.instance = gtk.HScale(frame, from_=widget.start, to=widget.end , orient=root.HORIZONTAL)
       	 	widget.instance.pack(fill=root.BOTH, expand=1)
        	'''	
		adj1 = gtk.Adjustment(0.0, widget.start, widget.end, 0.1, 1.0, 1.0)
		widget.instance = gtk.HScale(adj1)
   	        widget.instance.set_size_request(widget.width,widget.height)
   	        self.fixed.put(widget.instance, widget.position_X, widget.position_Y)
            	widget.instance.show()
            	
	elif(widget_type == "SpinBox" or isinstance(widget,SpinBox) ):
		'''
       	 	frame = self.abs_frame(widget)
        	widget.instance = root.Spinbox(frame, from_=widget.start, to=widget.end )
        	widget.instance.pack(fill=root.BOTH, expand=1)
        	'''
        	
        	#adj = gtk.Adjustment(0, widget.start, widget.end, 1.0, 1.0, 0.0)
        	adj = gtk.Adjustment(0.0, widget.start, widget.end, 0.1,0.1, 0.0)
        	widget.instance = gtk.SpinButton(adj , 0.1 , 1)
        	widget.instance.set_size_request(widget.width,widget.height)
   	        self.fixed.put(widget.instance, widget.position_X, widget.position_Y)
            	widget.instance.show()    
Exemple #27
0
 def slot_show(self, parent):
     self.parent = parent
     self.parent.entries.set_row_spacings(self.parent.rowSpace)
     for child in self.parent.entries.get_children():
         self.parent.entries.remove(child)
     cutLabel = gtk.Label('Cut Type')
     cutLabel.set_alignment(0.95, 0.5)
     cutLabel.set_width_chars(8)
     self.parent.entries.attach(cutLabel, 0, 1, 0, 1)
     self.outside = gtk.RadioButton(None, 'Outside')
     self.outside.connect('toggled', self.auto_preview)
     self.parent.entries.attach(self.outside, 1, 2, 0, 1)
     inside = gtk.RadioButton(self.outside, 'Inside')
     self.parent.entries.attach(inside, 2, 3, 0, 1)
     offsetLabel = gtk.Label('Offset')
     offsetLabel.set_alignment(0.95, 0.5)
     offsetLabel.set_width_chars(8)
     self.parent.entries.attach(offsetLabel, 3, 4, 0, 1)
     self.offset = gtk.CheckButton('Kerf')
     self.offset.connect('toggled', self.auto_preview)
     self.parent.entries.attach(self.offset, 4, 5, 0, 1)
     lLabel = gtk.Label('Lead In')
     lLabel.set_alignment(0.95, 0.5)
     lLabel.set_width_chars(8)
     self.parent.entries.attach(lLabel, 0, 1, 1, 2)
     self.liEntry = gtk.Entry()
     self.liEntry.set_width_chars(8)
     self.liEntry.connect('activate', self.auto_preview)
     self.liEntry.connect('changed', self.entry_changed)
     self.parent.entries.attach(self.liEntry, 1, 2, 1, 2)
     loLabel = gtk.Label('Lead Out')
     loLabel.set_alignment(0.95, 0.5)
     loLabel.set_width_chars(8)
     self.parent.entries.attach(loLabel, 0, 1, 2, 3)
     self.loEntry = gtk.Entry()
     self.loEntry.set_width_chars(8)
     self.loEntry.connect('activate', self.auto_preview)
     self.loEntry.connect('changed', self.parent.entry_changed)
     self.parent.entries.attach(self.loEntry, 1, 2, 2, 3)
     xSLabel = gtk.Label()
     xSLabel.set_markup('X <span foreground="red">origin</span>')
     xSLabel.set_alignment(0.95, 0.5)
     xSLabel.set_width_chars(8)
     self.parent.entries.attach(xSLabel, 0, 1, 3, 4)
     self.xSEntry = gtk.Entry()
     self.xSEntry.set_width_chars(8)
     self.xSEntry.connect('activate', self.auto_preview)
     self.xSEntry.connect('changed', self.parent.entry_changed)
     self.parent.entries.attach(self.xSEntry, 1, 2, 3, 4)
     ySLabel = gtk.Label()
     ySLabel.set_markup('Y <span foreground="red">origin</span>')
     ySLabel.set_alignment(0.95, 0.5)
     ySLabel.set_width_chars(8)
     self.parent.entries.attach(ySLabel, 0, 1, 4, 5)
     self.ySEntry = gtk.Entry()
     self.ySEntry.set_width_chars(8)
     self.ySEntry.connect('activate', self.auto_preview)
     self.ySEntry.connect('changed', self.parent.entry_changed)
     self.parent.entries.attach(self.ySEntry, 1, 2, 4, 5)
     self.centre = gtk.RadioButton(None, 'Centre')
     self.centre.connect('toggled', self.auto_preview)
     self.parent.entries.attach(self.centre, 1, 2, 5, 6)
     self.bLeft = gtk.RadioButton(self.centre, 'Btm Lft')
     self.parent.entries.attach(self.bLeft, 0, 1, 5, 6)
     lLabel = gtk.Label('Length')
     lLabel.set_alignment(0.95, 0.5)
     lLabel.set_width_chars(8)
     self.parent.entries.attach(lLabel, 0, 1, 6, 7)
     self.lEntry = gtk.Entry()
     self.lEntry.set_width_chars(8)
     self.lEntry.connect('activate', self.auto_preview)
     self.lEntry.connect('changed', self.parent.entry_changed)
     self.parent.entries.attach(self.lEntry, 1, 2, 6, 7)
     wLabel = gtk.Label('Width')
     wLabel.set_alignment(0.95, 0.5)
     wLabel.set_width_chars(8)
     self.parent.entries.attach(wLabel, 0, 1, 7, 8)
     self.wEntry = gtk.Entry()
     self.wEntry.set_width_chars(8)
     self.wEntry.connect('activate', self.auto_preview)
     self.wEntry.connect('changed', self.parent.entry_changed)
     self.parent.entries.attach(self.wEntry, 1, 2, 7, 8)
     angLabel = gtk.Label('Angle')
     angLabel.set_alignment(0.95, 0.5)
     angLabel.set_width_chars(8)
     self.parent.entries.attach(angLabel, 0, 1, 8, 9)
     self.angEntry = gtk.Entry()
     self.angEntry.set_width_chars(8)
     self.angEntry.set_text('0')
     self.angEntry.connect('activate', self.auto_preview)
     self.angEntry.connect('changed', self.parent.entry_changed)
     self.parent.entries.attach(self.angEntry, 1, 2, 8, 9)
     preview = gtk.Button('Preview')
     preview.connect('pressed', self.slot_preview)
     self.parent.entries.attach(preview, 0, 1, 12, 13)
     self.add = gtk.Button('Add')
     self.add.set_sensitive(False)
     self.add.connect('pressed', self.add_shape_to_file)
     self.parent.entries.attach(self.add, 2, 3, 12, 13)
     undo = gtk.Button('Undo')
     undo.connect('pressed', self.parent.undo_shape, self.add)
     self.parent.entries.attach(undo, 4, 5, 12, 13)
     pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
             filename='./wizards/images/slot.png', 
             width=240, 
             height=240)
     image = gtk.Image()
     image.set_from_pixbuf(pixbuf)
     self.parent.entries.attach(image, 2, 5, 1, 9)
     if self.parent.oSaved:
         self.centre.set_active(1)
     else:
         self.bLeft.set_active(1)
     self.liEntry.set_text(self.parent.leadIn)
     self.loEntry.set_text(self.parent.leadOut)
     self.xSEntry.set_text('{}'.format(self.parent.xSaved))
     self.ySEntry.set_text('{}'.format(self.parent.ySaved))
     if not self.liEntry.get_text() or float(self.liEntry.get_text()) == 0:
         self.offset.set_sensitive(False)
     self.parent.undo_shape(None, self.add)
     self.parent.W.show_all()
     self.lEntry.grab_focus()
Exemple #28
0
    def __init__(self, window):
        self._window = window
        gtk.Dialog.__init__(self, _('Preferences'), window, 0,
                            (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.connect('response', self._response)
        self.set_has_separator(False)
        self.set_resizable(True)
        self.set_default_response(gtk.RESPONSE_CLOSE)
        notebook = gtk.Notebook()
        self.vbox.pack_start(notebook)
        self.set_border_width(4)
        notebook.set_border_width(6)

        # ----------------------------------------------------------------
        # The "Appearance" tab.
        # ----------------------------------------------------------------
        page = _PreferencePage(80)
        page.new_section(_('Background'))
        fixed_bg_button = gtk.RadioButton(
            None, '{}:'.format(_('Use this colour as background')))
        fixed_bg_button.set_tooltip_text(
            _('Always use this selected colour as the background colour.'))
        color_button = gtk.ColorButton(gtk.gdk.Color(*prefs['bg colour']))
        color_button.connect('color_set', self._color_button_cb)
        page.add_row(fixed_bg_button, color_button)
        dynamic_bg_button = gtk.RadioButton(
            fixed_bg_button, _('Use dynamic background colour.'))
        dynamic_bg_button.set_active(prefs['smart bg'])
        dynamic_bg_button.connect('toggled', self._check_button_cb, 'smart bg')
        dynamic_bg_button.set_tooltip_text(
            _('Automatically pick a background colour that fits the viewed image.'
              ))
        page.add_row(dynamic_bg_button)

        page.new_section(_('Thumbnails'))
        label = gtk.Label('{}:'.format(_('Thumbnail size (in pixels)')))
        adjustment = gtk.Adjustment(prefs['thumbnail size'], 20, 128, 1, 10)
        thumb_size_spinner = gtk.SpinButton(adjustment)
        thumb_size_spinner.connect('value_changed', self._spinner_cb,
                                   'thumbnail size')
        page.add_row(label, thumb_size_spinner)
        thumb_number_button = gtk.CheckButton(
            _('Show page numbers on thumbnails.'))
        thumb_number_button.set_active(
            prefs['show page numbers on thumbnails'])
        thumb_number_button.connect('toggled', self._check_button_cb,
                                    'show page numbers on thumbnails')
        page.add_row(thumb_number_button)

        page.new_section(_('Magnifying Glass'))
        label = gtk.Label('{}:'.format(_('Magnifying glass size (in pixels)')))
        adjustment = gtk.Adjustment(prefs['lens size'], 50, 400, 1, 10)
        glass_size_spinner = gtk.SpinButton(adjustment)
        glass_size_spinner.connect('value_changed', self._spinner_cb,
                                   'lens size')
        glass_size_spinner.set_tooltip_text(
            _('Set the size of the magnifying glass. It is a square with a side of this many pixels.'
              ))
        page.add_row(label, glass_size_spinner)
        label = gtk.Label('{}:'.format(_('Magnification factor')))
        adjustment = gtk.Adjustment(prefs['lens magnification'], 1.1, 10.0,
                                    0.1, 1.0)
        glass_magnification_spinner = gtk.SpinButton(adjustment, digits=1)
        glass_magnification_spinner.connect('value_changed', self._spinner_cb,
                                            'lens magnification')
        glass_magnification_spinner.set_tooltip_text(
            _('Set the magnification factor of the magnifying glass.'))
        page.add_row(label, glass_magnification_spinner)

        page.new_section(_('Image scaling'))
        stretch_button = gtk.CheckButton(_('Stretch small images.'))
        stretch_button.set_active(prefs['stretch'])
        stretch_button.connect('toggled', self._check_button_cb, 'stretch')
        stretch_button.set_tooltip_text(
            _('Stretch images to a size that is larger than their original size if '
              'the current zoom mode requests it. If this preference is unset, images '
              'are never scaled to be larger than their original size.'))
        page.add_row(stretch_button)

        page.new_section(_('Transparency'))
        checkered_bg_button = gtk.CheckButton(
            _('Use checkered background for transparent images.'))
        checkered_bg_button.set_active(
            prefs['checkered bg for transparent images'])
        checkered_bg_button.connect('toggled', self._check_button_cb,
                                    'checkered bg for transparent images')
        checkered_bg_button.set_tooltip_text(
            _('Use a grey checkered background for transparent images. If this '
              'preference is unset, the background is plain white instead.'))
        page.add_row(checkered_bg_button)
        notebook.append_page(page, gtk.Label(_('Appearance')))

        # ----------------------------------------------------------------
        # The "Behaviour" tab.
        # ----------------------------------------------------------------
        page = _PreferencePage(150)
        page.new_section(_('Scroll'))
        smart_space_button = gtk.CheckButton(
            _('Use smart space key scrolling.'))
        smart_space_button.set_active(prefs['smart space scroll'])
        smart_space_button.connect('toggled', self._check_button_cb,
                                   'smart space scroll')
        smart_space_button.set_tooltip_text(
            _('Use smart scrolling with the space key. Normally '
              'the space key scrolls only right down (or up when '
              'shift is pressed), but with this preference set it '
              'also scrolls sideways and so tries to follow the '
              'natural reading order of the comic book.'))
        page.add_row(smart_space_button)

        flip_with_wheel_button = gtk.CheckButton(
            _('Flip pages when scrolling off the edges of the page.'))
        flip_with_wheel_button.set_active(prefs['flip with wheel'])
        flip_with_wheel_button.connect('toggled', self._check_button_cb,
                                       'flip with wheel')
        flip_with_wheel_button.set_tooltip_text(
            _('Flip pages when scrolling "off the page" '
              'with the scroll wheel or with the arrow keys.'
              ' It takes three consecutive "steps" with the '
              'scroll wheel or the arrow keys for the pages to '
              'be flipped.'))
        page.add_row(flip_with_wheel_button)

        page.new_section(_('Double page mode'))
        step_length_button = gtk.CheckButton(
            _('Flip two pages in double page mode.'))
        step_length_button.set_active(prefs['double step in double page mode'])
        step_length_button.connect('toggled', self._check_button_cb,
                                   'double step in double page mode')
        step_length_button.set_tooltip_text(
            _('Flip two pages, instead of one, each time we flip pages in double page mode.'
              ))
        page.add_row(step_length_button)
        virtual_double_button = gtk.CheckButton(
            _('Show only one wide image in double page mode.'))
        virtual_double_button.set_active(
            prefs['no double page for wide images'])
        virtual_double_button.connect('toggled', self._check_button_cb,
                                      'no double page for wide images')
        virtual_double_button.set_tooltip_text(
            _("Display only one image in double page mode, "
              "if the image's width exceeds its height. The "
              "result of this is that scans that span two "
              "pages are displayed properly (i.e. alone) also "
              "in double page mode."))
        page.add_row(virtual_double_button)

        page.new_section(_('Files'))
        auto_open_next_button = gtk.CheckButton(
            _('Automatically open the next archive.'))
        auto_open_next_button.set_active(prefs['auto open next archive'])
        auto_open_next_button.connect('toggled', self._check_button_cb,
                                      'auto open next archive')
        auto_open_next_button.set_tooltip_text(
            _('Automatically open the next archive '
              'in the directory when flipping past '
              'the last page, or the previous archive '
              'when flipping past the first page.'))
        page.add_row(auto_open_next_button)
        auto_open_last_button = gtk.CheckButton(
            _('Automatically open the last viewed file on startup.'))
        auto_open_last_button.set_active(prefs['auto load last file'])
        auto_open_last_button.connect('toggled', self._check_button_cb,
                                      'auto load last file')
        auto_open_last_button.set_tooltip_text(
            _('Automatically open, on startup, the file that was open when Comix was last closed.'
              ))
        page.add_row(auto_open_last_button)
        store_recent_button = gtk.CheckButton(
            _('Store information about recently opened files.'))
        store_recent_button.set_active(prefs['store recent file info'])
        store_recent_button.connect('toggled', self._check_button_cb,
                                    'store recent file info')
        store_recent_button.set_tooltip_text(
            _('Add information about all files opened from within Comix to the shared recent files list.'
              ))
        page.add_row(store_recent_button)
        create_thumbs_button = gtk.CheckButton(
            _('Store thumbnails for opened files.'))
        create_thumbs_button.set_active(prefs['create thumbnails'])
        create_thumbs_button.connect('toggled', self._check_button_cb,
                                     'create thumbnails')
        create_thumbs_button.set_tooltip_text(
            _('Store thumbnails for opened files according '
              'to the freedesktop.org specification. These '
              'thumbnails are shared by many other applications, '
              'such as most file managers.'))
        page.add_row(create_thumbs_button)

        page.new_section(_('Cache'))
        cache_button = gtk.CheckButton(_('Use a cache to speed up browsing.'))
        cache_button.set_active(prefs['cache'])
        cache_button.connect('toggled', self._check_button_cb, 'cache')
        cache_button.set_tooltip_text(
            _('Cache the images that are next to the currently '
              'viewed image in order to speed up browsing. Since '
              'the speed improvements are quite big, it is recommended '
              'that you have this preference set, unless you are '
              'running short on free RAM.'))
        page.add_row(cache_button)

        page.new_section(_('Image Animation'))
        gif_button = gtk.CheckButton(_('Play GIF image animations.'))
        gif_button.set_active(prefs['animate gifs'])
        gif_button.connect('toggled', self._check_button_cb, 'animate gifs')
        # TODO: Change if PixbufAnimation gets resizing
        gif_button.set_tooltip_text(
            _('Play animations for GIF files, if there is one. '
              'If this is set, animated GIF images will not be resized.'))
        page.add_row(gif_button)

        notebook.append_page(page, gtk.Label(_('Behaviour')))

        # ----------------------------------------------------------------
        # The "Display" tab.
        # ----------------------------------------------------------------
        page = _PreferencePage(180)
        page.new_section(_('Default modes'))
        double_page_button = gtk.CheckButton(
            _('Use double page mode by default.'))
        double_page_button.set_active(prefs['default double page'])
        double_page_button.connect('toggled', self._check_button_cb,
                                   'default double page')
        page.add_row(double_page_button)
        fullscreen_button = gtk.CheckButton(_('Use fullscreen by default.'))
        fullscreen_button.set_active(prefs['default fullscreen'])
        fullscreen_button.connect('toggled', self._check_button_cb,
                                  'default fullscreen')
        page.add_row(fullscreen_button)
        manga_button = gtk.CheckButton(_('Use manga mode by default.'))
        manga_button.set_active(prefs['default manga mode'])
        manga_button.connect('toggled', self._check_button_cb,
                             'default manga mode')
        page.add_row(manga_button)
        label = gtk.Label('{}:'.format(_('Default zoom mode')))
        zoom_combo = gtk.combo_box_new_text()
        zoom_combo.append_text(_('Best fit mode'))
        zoom_combo.append_text(_('Fit width mode'))
        zoom_combo.append_text(_('Fit height mode'))
        zoom_combo.append_text(_('Manual zoom mode'))
        # Change this if the combobox entries are reordered.
        zoom_combo.set_active(prefs['default zoom mode'])
        zoom_combo.connect('changed', self._combo_box_cb)
        page.add_row(label, zoom_combo)

        page.new_section(_('Fullscreen'))
        hide_in_fullscreen_button = gtk.CheckButton(
            _('Automatically hide all toolbars in fullscreen.'))
        hide_in_fullscreen_button.set_active(prefs['hide all in fullscreen'])
        hide_in_fullscreen_button.connect('toggled', self._check_button_cb,
                                          'hide all in fullscreen')
        page.add_row(hide_in_fullscreen_button)

        page.new_section(_('Slideshow'))
        label = gtk.Label('{}:'.format(_('Slideshow delay (in seconds)')))
        adjustment = gtk.Adjustment(prefs['slideshow delay'] / 1000.0, 0.5,
                                    3600.0, 0.1, 1)
        delay_spinner = gtk.SpinButton(adjustment, digits=1)
        delay_spinner.connect('value_changed', self._spinner_cb,
                              'slideshow delay')
        page.add_row(label, delay_spinner)

        page.new_section(_('Comments'))
        label = gtk.Label('{}:'.format(_('Comment extensions')))
        extensions_entry = gtk.Entry()
        extensions_entry.set_text(', '.join(prefs['comment extensions']))
        extensions_entry.connect('activate', self._entry_cb)
        extensions_entry.connect('focus_out_event', self._entry_cb)
        extensions_entry.set_tooltip_text(
            _('Treat all files found within archives, that have one of these file endings, as comments.'
              ))
        page.add_row(label, extensions_entry)

        page.new_section(_('Rotation'))
        auto_rotate_button = gtk.CheckButton(
            _('Automatically rotate images according to their metadata.'))
        auto_rotate_button.set_active(prefs['auto rotate from exif'])
        auto_rotate_button.connect('toggled', self._check_button_cb,
                                   'auto rotate from exif')
        auto_rotate_button.set_tooltip_text(
            _('Automatically rotate images when an '
              'orientation is specified in the image '
              'metadata, such as in an Exif tag.'))
        page.add_row(auto_rotate_button)
        notebook.append_page(page, gtk.Label(_('Display')))
        self.show_all()
    def DBQuery_show(self, item):
        """content view for specifically the DBQuery item"""

        vbox = gtk.VBox()
        vbox.show()

        box1 = gtk.HBox()
        box1.show()
        vbox.pack_start(box1)

        label2 = gtk.Label('Search Term')
        label2.show()
        box1.pack_start(label2)

        self.searchEntry = gtk.Entry()
        self.searchEntry.show()
        box1.pack_end(self.searchEntry, True, True, 10)
        self.searchEntry.set_text(item.searchTerm)

        box2 = gtk.HBox()
        box2.show()
        vbox.pack_start(box2)

        label3 = gtk.Label('Database')
        label3.show()
        box2.pack_start(label3)

        self.dbRadio1 = gtk.RadioButton(None, 'PubMed/GenBank')
        self.dbRadio1.show()
        box2.pack_start(self.dbRadio1)

        box3 = gtk.HBox()
        box3.show()
        vbox.pack_start(box3)

        label4 = gtk.Label('Search Type')
        label4.show()
        box3.pack_start(label4)

        box4 = gtk.VBox()
        box4.show()
        box3.pack_start(box4)

        self.typeRadio1 = gtk.RadioButton(None, 'nucleotide')
        self.typeRadio1.show()
        box4.pack_start(self.typeRadio1)
        self.typeRadio2 = gtk.RadioButton(self.typeRadio1, 'protein')
        self.typeRadio2.show()
        box4.pack_start(self.typeRadio2)
        self.typeRadio3 = gtk.RadioButton(self.typeRadio1, 'genome')
        self.typeRadio3.show()
        box4.pack_start(self.typeRadio3)

        if item.type == 'nucleotide':
            self.typeRadio1.set_active(True)
        elif item.type == 'protien':
            self.typeRadio2.set_active(True)
        elif item.type == 'genome':
            self.typeRadio3.set_active(True)

        box5 = gtk.HBox()
        box5.show()
        vbox.pack_start(box5)

        label5 = gtk.Label('Max Results')
        label5.show()
        box5.pack_start(label5)

        self.maxEntry = gtk.Entry()
        self.maxEntry.show()
        box5.pack_end(self.maxEntry, True, True, 10)
        self.maxEntry.set_text(str(item.maxResults))

        self.searchButton = gtk.Button('Search')
        self.searchButton.show()
        vbox.pack_start(self.searchButton, False, False)
        self.searchButton.set_border_width(20)
        self.searchButton.connect('clicked', self.search_action, item)

        return vbox
Exemple #30
0
    def add_tab(self, directory=None):
        """Adds a new tab to the terminal notebook.
        """
        box = GuakeTerminalBox()
        box.terminal.grab_focus()
        box.terminal.drag_dest_set(
            gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_DROP
            | gtk.DEST_DEFAULT_HIGHLIGHT,
            [('text/uri-list', gtk.TARGET_OTHER_APP, 0)], gtk.gdk.ACTION_COPY)
        box.terminal.connect('button-press-event', self.show_context_menu)
        box.terminal.connect('child-exited', self.on_terminal_exited, box)
        box.terminal.connect('window-title-changed',
                             self.on_terminal_title_changed, box)
        box.terminal.connect('drag-data-received', self.on_drag_data_received,
                             box)

        # -- Ubuntu has a patch to libvte which disables mouse scrolling in apps
        # -- like vim and less by default. If this is the case, enable it back.
        if hasattr(box.terminal, "set_alternate_screen_scroll"):
            box.terminal.set_alternate_screen_scroll(True)

        box.show()

        self.notebook.append_tab(box.terminal)

        # We can choose the directory to vte launch. It is important
        # to be used by dbus interface. I'm testing if directory is a
        # string because when binded to a signal, the first param can
        # be a button not a directory.
        default_params = {}
        if isinstance(directory, basestring):
            default_params['directory'] = directory

        final_params = self.get_fork_params(default_params)
        pid = box.terminal.fork_command(**final_params)
        if libutempter is not None:
            # After the fork_command we add this new tty to utmp !
            libutempter.utempter_add_record(box.terminal.get_pty(),
                                            os.uname()[1])
        box.terminal.pid = pid

        # Adding a new radio button to the tabbar
        label = box.terminal.get_window_title() or _("Terminal")
        tabs = self.tabs.get_children()
        parent = tabs and tabs[0] or None

        bnt = gtk.RadioButton(group=parent, label=label, use_underline=False)
        bnt.set_property('can-focus', False)
        bnt.set_property('draw-indicator', False)
        bnt.connect('button-press-event', self.show_tab_menu)
        bnt.connect('button-press-event', self.show_rename_current_tab_dialog)
        bnt.connect(
            'clicked', lambda *x: self.notebook.set_current_page(
                self.notebook.page_num(box)))
        if self.selected_color is not None:
            bnt.modify_bg(gtk.STATE_ACTIVE,
                          gtk.gdk.Color(str(self.selected_color)))
        drag_drop_type = ("text/plain", gtk.TARGET_SAME_APP, 80)
        bnt.drag_dest_set(gtk.DEST_DEFAULT_ALL, [drag_drop_type],
                          gtk.gdk.ACTION_MOVE)
        bnt.connect("drag_data_received", self.on_drop_tab)
        bnt.drag_source_set(gtk.gdk.BUTTON1_MASK, [drag_drop_type],
                            gtk.gdk.ACTION_MOVE)
        bnt.connect("drag_data_get", self.on_drag_tab)
        bnt.show()

        self.tabs.pack_start(bnt, expand=False, padding=1)

        self.notebook.append_page(box, None)
        self.notebook.set_current_page(self.notebook.page_num(box))
        box.terminal.grab_focus()
        self.load_config()

        if self.is_fullscreen:
            self.fullscreen()