def __init__(self, scan):
        HIGVBox.__init__(self)

        na = _('Not available')

        # Command info
        self.command_label = HIGEntryLabel(_('Command:'))
        self.info_command_label = HIGEntryLabel(na)

        self.nmap_version_label = HIGEntryLabel(_('Nmap Version:'))
        self.info_nmap_version_label = HIGEntryLabel(na)

        self.verbose_label = HIGEntryLabel(_('Verbosity level:'))
        self.info_verbose_label = HIGEntryLabel(na)

        self.debug_label = HIGEntryLabel(_('Debug level:'))
        self.info_debug_label = HIGEntryLabel(na)

        self.command_expander = gtk.Expander("<b>" + _("Command Info") +
                                             "</b>")
        self.command_expander.set_use_markup(True)

        self.command_table = HIGTable()
        self.command_table.set_border_width(5)
        self.command_table.set_row_spacings(6)
        self.command_table.set_col_spacings(6)

        self.command_hbox = HIGHBox()
        self.command_hbox._pack_noexpand_nofill(hig_box_space_holder())
        self.command_hbox._pack_noexpand_nofill(self.command_table)

        self.command_table.attach(self.command_label, 0, 1, 0, 1)
        self.command_table.attach(self.info_command_label, 1, 2, 0, 1)

        self.command_table.attach(self.nmap_version_label, 0, 1, 1, 2)
        self.command_table.attach(self.info_nmap_version_label, 1, 2, 1, 2)

        self.command_table.attach(self.verbose_label, 0, 1, 2, 3)
        self.command_table.attach(self.info_verbose_label, 1, 2, 2, 3)

        self.command_table.attach(self.debug_label, 0, 1, 3, 4)
        self.command_table.attach(self.info_debug_label, 1, 2, 3, 4)

        self.command_expander.add(self.command_hbox)
        self._pack_noexpand_nofill(self.command_expander)
        self.command_expander.set_expanded(True)

        # General info:
        self.start_label = HIGEntryLabel(_('Started on:'))
        self.info_start_label = HIGEntryLabel(na)

        self.finished_label = HIGEntryLabel(_('Finished on:'))
        self.info_finished_label = HIGEntryLabel(na)

        self.host_up_label = HIGEntryLabel(_('Hosts up:'))
        self.info_hosts_up_label = HIGEntryLabel(na)

        self.host_down_label = HIGEntryLabel(_('Hosts down:'))
        self.info_hosts_down_label = HIGEntryLabel(na)

        self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:'))
        self.info_hosts_scanned_label = HIGEntryLabel(na)

        self.open_label = HIGEntryLabel(_('Open ports:'))
        self.info_open_label = HIGEntryLabel(na)

        self.filtered_label = HIGEntryLabel(_('Filtered ports:'))
        self.info_filtered_label = HIGEntryLabel(na)

        self.closed_label = HIGEntryLabel(_('Closed ports:'))
        self.info_closed_label = HIGEntryLabel(na)

        self.general_expander = gtk.Expander("<b>" + _("General Info") +
                                             "</b>")
        self.general_expander.set_use_markup(True)

        self.general_table = HIGTable()
        self.general_table.set_border_width(5)
        self.general_table.set_row_spacings(6)
        self.general_table.set_col_spacings(6)

        self.general_hbox = HIGHBox()
        self.general_hbox._pack_noexpand_nofill(hig_box_space_holder())
        self.general_hbox._pack_noexpand_nofill(self.general_table)

        self.general_table.attach(self.start_label, 0, 1, 0, 1)
        self.general_table.attach(self.info_start_label, 1, 2, 0, 1)

        self.general_table.attach(self.finished_label, 0, 1, 1, 2)
        self.general_table.attach(self.info_finished_label, 1, 2, 1, 2)

        self.general_table.attach(self.host_up_label, 0, 1, 2, 3)
        self.general_table.attach(self.info_hosts_up_label, 1, 2, 2, 3)

        self.general_table.attach(self.host_down_label, 0, 1, 3, 4)
        self.general_table.attach(self.info_hosts_down_label, 1, 2, 3, 4)

        self.general_table.attach(self.host_scanned_label, 0, 1, 4, 5)
        self.general_table.attach(self.info_hosts_scanned_label, 1, 2, 4, 5)

        self.general_table.attach(self.open_label, 0, 1, 5, 6)
        self.general_table.attach(self.info_open_label, 1, 2, 5, 6)

        self.general_table.attach(self.filtered_label, 0, 1, 6, 7)
        self.general_table.attach(self.info_filtered_label, 1, 2, 6, 7)

        self.general_table.attach(self.closed_label, 0, 1, 7, 8)
        self.general_table.attach(self.info_closed_label, 1, 2, 7, 8)

        self.general_expander.add(self.general_hbox)
        self._pack_noexpand_nofill(self.general_expander)
        self.general_expander.set_expanded(True)

        self._set_from_scan(scan)
Exemple #2
0
    def __init__(self, word, theme_index, star_state=False):
        self.scroll = gtk.ScrolledWindow()
        self.scroll.set_size_request(500, 400)
        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        v_box = gtk.VBox()
        self.__block_list = []
        string = '<span font_desc="Sans Bold 17" font_family="Serif">%s</s\
pan>' % (word.query)
        (attr, default_text,
         unused_char) = pango.parse_markup(string, accel_marker=u'\x00')
        label = gtk.Label()
        alignment = gtk.Alignment(xalign=0.0,
                                  yalign=0.0,
                                  xscale=0.0,
                                  yscale=0.0)
        h_box = gtk.HBox(spacing=10)
        label.set_attributes(attr)
        label.set_text(default_text)
        unused = gtk.Label('')
        unused.set_selectable(True)
        label.set_selectable(True)
        height = width = not theme_index and 60 or 32
        speaker = Speaker(theme_index, width, height)
        speaker.set_tooltip('<span font_desc="Sans 10">spell</span>')
        if word.sound_url:
            speaker_id = speaker.connect("speaker_on", self.play_text, '',
                                         word.sound_url)
        else:
            speaker_id = speaker.connect("speaker_on", self.play_text,
                                         word.query)
        self.__block_list.append((speaker, speaker_id))
        star = Star(star_state)
        star.connect("starred", self.__update_database, word)
        h_box.pack_start(unused)
        h_box.pack_start(star())
        h_box.pack_start(label)
        h_box.pack_start(speaker())
        alignment.add(h_box)
        v_box.pack_start(alignment)
        string = ''
        for meaning in word.meaning:
            string += u'<span font_desc="Sans 12" font_family="Serif">\n\t'\
            + meaning + '</span>'
        if string:
            (attr, default_text,
             unused_char) = pango.parse_markup(string, accel_marker=u'\x00')
            label = gtk.Label()
            label.set_attributes(attr)
            label.set_text(default_text)
            label.set_selectable(True)
            alignment = gtk.Alignment(xalign=0.0,
                                      yalign=0.0,
                                      xscale=0.0,
                                      yscale=0.0)
            alignment.add(label)
            v_box.pack_start(alignment)
        if word.image or word.alt_image:
            fixed = gtk.Fixed()
            rms = 0.0
            if word.image and word.alt_image:
                path_1, path_2 = HOME_PATH + '/.plexicon/data/image1.gif', \
                                 HOME_PATH + '/.plexicon/data/image2.gif'
                file_1, file_2 = open(path_1, 'wb'), \
                                 open(path_2, 'wb')
                file_1.write(word.image)
                file_2.write(word.alt_image)
                file_1.close()
                file_2.close()
                import Image, math, operator
                hist1 = Image.open(path_1).histogram()
                hist2 = Image.open(path_2).histogram()
                rms = math.sqrt(
                    reduce(operator.add,
                           map(lambda a, b:
                               (a - b)**2, hist1, hist2)) / len(hist1))
                if not rms:
                    word.alt_image = ''
            if rms != 0.0:
                image_1, image_2 = gtk.image_new_from_pixbuf(gtk.gdk. \
                                       pixbuf_new_from_file(path_1)), \
                                   gtk.image_new_from_pixbuf(gtk.gdk. \
                                       pixbuf_new_from_file(path_2))
                fixed.put(image_1, 20, 0)
                fixed.put(image_2, 40 + image_1.requisition.width, 0)
            else:
                cur = word.image == '' and [word.alt_image] or [word.image]
                path = HOME_PATH + '/.plexicon/data/image.gif'
                image_file = open(path, 'wb')
                image_file.write(cur[0])
                image_file.close()
                image = gtk.image_new_from_pixbuf(
                    gtk.gdk.pixbuf_new_from_file(path))
                x_coordinate = 500 >= image.requisition.width and (500 - \
                                              image.requisition.width) / 2 or 0
                fixed.put(image, x_coordinate, 0)
            v_box.pack_start(gtk.Label(''), True, True)
            expander = gtk.Expander()
            expander.set_use_markup(True)
            expander.set_use_underline(True)
            expander.set_tooltip_markup('<span font_desc="Sans 10"><sub>click \
to expand</sub></span>')
            expander.set_label(
                '<span font_desc="Sans 10" foreground="#ff0000">\
' + u'\u2605' * 12 +
                '  <span font_desc="Sans 10" foreground="#0000ff">_More De\
finitions</span>  ' + u'\u2605' * 14 + '</span>')
            expander.set_spacing(10)
            expander.add(fixed)
            v_box.pack_start(expander)
        alignment = gtk.Alignment(xalign=0.0,
                                  yalign=0.0,
                                  xscale=0.0,
                                  yscale=0.0)
        alignment.add(v_box)
        self.scroll.add_with_viewport(alignment)
        self.scroll.get_child().modify_bg(gtk.STATE_NORMAL,
                                          gtk.gdk.color_parse('#ffffff'))
Exemple #3
0
    def __init__(self):
        gtk.VBox.__init__(self)
        from application import get_app
        app = get_app()
        self.app = app
        self.ani = app.doc.ani.model
        self.is_playing = False

        self.set_size_request(200, 150)
        self.app.doc.model.doc_observers.append(self.doc_structure_modified_cb)

        # create list:
        self.listmodel = self.create_list()

        # create tree view:
        self.treeview = gtk.TreeView(self.listmodel)
        self.treeview.set_rules_hint(True)
        self.treeview.set_headers_visible(False)
        treesel = self.treeview.get_selection()
        treesel.set_mode(gtk.SELECTION_SINGLE)
        self.changed_handler = treesel.connect('changed', self.on_row_changed)

        self.add_columns()

        layers_scroll = gtk.ScrolledWindow()
        layers_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        layers_scroll.set_placement(gtk.CORNER_TOP_RIGHT)
        layers_scroll.add(self.treeview)

        # xsheet controls:

        def pixbuf_button(pixbuf):
            b = gtk.Button()
            img = gtk.Image()
            img.set_from_pixbuf(pixbuf)
            b.add(img)
            return b

        pixbuf_key = self.app.pixmaps.keyframe_add
        self.key_button = pixbuf_button(pixbuf_key)
        self.key_button.connect('clicked', self.on_toggle_key)
        self.key_button.set_tooltip_text(_('Toggle Keyframe'))

        pixbuf_skip = self.app.pixmaps.cel_skip
        self.skip_button = pixbuf_button(pixbuf_skip)
        self.skip_button.connect('clicked', self.on_toggle_skip)
        self.skip_button.set_tooltip_text(_('Set/Unset onion skin'))

        self.chdesc_button = stock_button(gtk.STOCK_ITALIC)
        self.chdesc_button.connect('clicked', self.on_change_description)
        self.chdesc_button.set_tooltip_text(_('Change Cel Description'))

        pixbuf_add = self.app.pixmaps.cel_add
        self.add_cel_button = pixbuf_button(pixbuf_add)
        self.add_cel_button.connect('clicked', self.on_add_cel)
        self.add_cel_button.set_tooltip_text(_('Add cel to this frame'))

        pixbuf_remove = self.app.pixmaps.cel_remove
        self.remove_cel_button = pixbuf_button(pixbuf_remove)
        self.remove_cel_button.connect('clicked', self.on_remove_cel)
        self.remove_cel_button.set_tooltip_text(_('Remove cel of this frame'))

        buttons_hbox = gtk.HBox()
        buttons_hbox.pack_start(self.key_button)
        buttons_hbox.pack_start(self.skip_button)
        buttons_hbox.pack_start(self.chdesc_button)
        buttons_hbox.pack_start(self.add_cel_button)
        buttons_hbox.pack_start(self.remove_cel_button)

        # player controls:

        self.previous_button = stock_button(gtk.STOCK_GO_UP)
        self.previous_button.connect('clicked', self.on_previous_frame)
        self.previous_button.set_tooltip_text(_('Previous Frame'))

        self.next_button = stock_button(gtk.STOCK_GO_DOWN)
        self.next_button.connect('clicked', self.on_next_frame)
        self.next_button.set_tooltip_text(_('Next Frame'))

        self.play_button = stock_button(gtk.STOCK_MEDIA_PLAY)
        self.play_button.connect('clicked', self.on_animation_play)
        self.play_button.set_tooltip_text(_('Play animation'))

        self.pause_button = stock_button(gtk.STOCK_MEDIA_PAUSE)
        self.pause_button.connect('clicked', self.on_animation_pause)
        self.pause_button.set_tooltip_text(_('Pause animation'))

        self.stop_button = stock_button(gtk.STOCK_MEDIA_STOP)
        self.stop_button.connect('clicked', self.on_animation_stop)
        self.stop_button.set_tooltip_text(_('Stop animation'))

        anibuttons_hbox = gtk.HBox()
        anibuttons_hbox.pack_start(self.previous_button)
        anibuttons_hbox.pack_start(self.next_button)
        anibuttons_hbox.pack_start(self.play_button)
        anibuttons_hbox.pack_start(self.pause_button)
        anibuttons_hbox.pack_start(self.stop_button)

        # frames edit controls:

        insert_frame_button = stock_button(gtk.STOCK_ADD)
        insert_frame_button.connect('clicked', self.on_insert_frames)
        insert_frame_button.set_tooltip_text(_('Insert frames'))
        self.insert_frame_button = insert_frame_button

        remove_frame_button = stock_button(gtk.STOCK_REMOVE)
        remove_frame_button.connect('clicked', self.on_remove_frames)
        remove_frame_button.set_tooltip_text(_('Remove frames'))
        self.remove_frame_button = remove_frame_button

        cut_button = stock_button(gtk.STOCK_CUT)
        cut_button.connect('clicked', self.on_cut)
        cut_button.set_tooltip_text(_('Cut cel'))
        self.cut_button = cut_button

        copy_button = stock_button(gtk.STOCK_COPY)
        copy_button.connect('clicked', self.on_copy)
        copy_button.set_tooltip_text(_('Copy cel'))
        self.copy_button = copy_button

        paste_button = stock_button(gtk.STOCK_PASTE)
        paste_button.connect('clicked', self.on_paste)
        paste_button.set_tooltip_text(_('Paste cel'))
        self.paste_button = paste_button

        editbuttons_hbox = gtk.HBox()
        editbuttons_hbox.pack_start(insert_frame_button)
        editbuttons_hbox.pack_start(remove_frame_button)
        editbuttons_hbox.pack_start(cut_button)
        editbuttons_hbox.pack_start(copy_button)
        editbuttons_hbox.pack_start(paste_button)

        # lightbox controls:

        adj = gtk.Adjustment(lower=0, upper=100, step_incr=1, page_incr=10)
        self.opacity_scale = gtk.HScale(adj)
        opa = self.app.preferences.get('lightbox.factor', 100)
        self.opacity_scale.set_value(opa)
        self.opacity_scale.set_value_pos(gtk.POS_LEFT)
        opacity_lbl = gtk.Label(_('Opacity:'))
        opacity_hbox = gtk.HBox()
        opacity_hbox.pack_start(opacity_lbl, expand=False)
        opacity_hbox.pack_start(self.opacity_scale, expand=True)
        self.opacity_scale.connect('value-changed',
                                   self.on_opacityfactor_changed)

        self.expander_prefs_loaded = False
        self.connect("show", self.show_cb)

        def opacity_checkbox(attr, label, tooltip=None):
            cb = gtk.CheckButton(label)
            pref = "lightbox.%s" % (attr, )
            default = DEFAULT_ACTIVE_CELS[attr]
            cb.set_active(self.app.preferences.get(pref, default))
            cb.connect('toggled', self.on_opacity_toggled, attr)
            if tooltip is not None:
                cb.set_tooltip_text(tooltip)
            opacityopts_vbox.pack_start(cb, expand=False)

        opacityopts_vbox = gtk.VBox()
        opacity_checkbox('cel', _('Inmediate'),
                         _("Show the inmediate next and previous cels."))
        opacity_checkbox(
            'key', _('Inmediate keys'),
            _("Show the cel keys that are after and before the current cel."))
        opacity_checkbox(
            'inbetweens', _('Inbetweens'),
            _("Show the cels that are between the inmediate key cels."))
        opacity_checkbox('other keys', _('Other keys'),
                         _("Show the other keys cels."))
        opacity_checkbox('other', _('Other'), _("Show the rest of the cels."))

        self.framerate_adjustment = gtk.Adjustment(value=self.ani.framerate,
                                                   lower=1,
                                                   upper=120,
                                                   step_incr=0.01)
        self.framerate_adjustment.connect("value-changed",
                                          self.on_framerate_changed)
        self.framerate_entry = gtk.SpinButton(
            adjustment=self.framerate_adjustment, digits=2, climb_rate=1.5)
        framerate_lbl = gtk.Label(_('Frame rate:'))
        framerate_hbox = gtk.HBox()
        framerate_hbox.pack_start(framerate_lbl, False, False)
        framerate_hbox.pack_start(self.framerate_entry, False, False)

        icons_cb = gtk.CheckButton(_("Small icons"))
        icons_cb.set_active(
            self.app.preferences.get("xsheet.small_icons", False))
        icons_cb.connect('toggled', self.on_smallicons_toggled)
        icons_cb.set_tooltip_text(
            _("Use smaller icons, better to see more rows."))

        play_lightbox_cb = gtk.CheckButton(_("Play with lightbox on"))
        play_lightbox_cb.set_active(
            self.app.preferences.get("xsheet.play_lightbox", False))
        play_lightbox_cb.connect('toggled', self.on_playlightbox_toggled)
        play_lightbox_cb.set_tooltip_text(
            _("Show other frames while playing, this is slower."))

        showprev_cb = gtk.CheckButton(_("Lightbox show previous"))
        showprev_cb.set_active(
            self.app.preferences.get("xsheet.lightbox_show_previous", True))
        showprev_cb.connect('toggled', self.on_shownextprev_toggled,
                            'previous')
        showprev_cb.set_tooltip_text(_("Show previous cels in the lightbox."))

        shownext_cb = gtk.CheckButton(_("Lightbox show next"))
        shownext_cb.set_active(
            self.app.preferences.get("xsheet.lightbox_show_next", False))
        shownext_cb.connect('toggled', self.on_shownextprev_toggled, 'next')
        shownext_cb.set_tooltip_text(_("Show next cels in the lightbox."))

        controls_vbox = gtk.VBox()
        controls_vbox.pack_start(buttons_hbox, expand=False)
        controls_vbox.pack_start(anibuttons_hbox, expand=False)
        controls_vbox.pack_start(editbuttons_hbox, expand=False)

        preferences_vbox = gtk.VBox()
        preferences_vbox.pack_start(framerate_hbox, expand=False)
        preferences_vbox.pack_start(icons_cb, expand=False)
        preferences_vbox.pack_start(play_lightbox_cb, expand=False)
        preferences_vbox.pack_start(showprev_cb, expand=False)
        preferences_vbox.pack_start(shownext_cb, expand=False)
        preferences_vbox.pack_start(opacity_hbox, expand=False)
        preferences_vbox.pack_start(opacityopts_vbox, expand=False)

        self.controls_expander = gtk.Expander(label=_('Controls'))
        self.controls_expander.add(controls_vbox)
        self.controls_expander.connect("notify::expanded", self.expanded_cb,
                                       'controls')

        self.prefs_expander = gtk.Expander(label=_('Preferences'))
        self.prefs_expander.add(preferences_vbox)
        self.prefs_expander.connect("notify::expanded", self.expanded_cb,
                                    'preferences')

        self.pack_start(layers_scroll)
        self.pack_start(self.controls_expander, expand=False)
        self.pack_start(self.prefs_expander, expand=False)

        self.show_all()
        self._change_player_buttons()
        self.app.doc.model.doc_observers.append(self.update)
Exemple #4
0
    def __init__(self, *args, **kwargs):
        super(WinCSV, self).__init__(*args, **kwargs)

        self.dialog = gtk.Dialog(parent=self.parent,
                                 flags=gtk.DIALOG_DESTROY_WITH_PARENT)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.connect('response', self.response)

        dialog_vbox = gtk.VBox()

        self.add_header(dialog_vbox)

        hbox_mapping = gtk.HBox(True)
        dialog_vbox.pack_start(hbox_mapping, True, True, 0)

        frame_fields = gtk.Frame()
        frame_fields.set_shadow_type(gtk.SHADOW_NONE)
        viewport_fields = gtk.Viewport()
        scrolledwindow_fields = gtk.ScrolledWindow()
        scrolledwindow_fields.set_policy(gtk.POLICY_AUTOMATIC,
                                         gtk.POLICY_AUTOMATIC)
        viewport_fields.add(scrolledwindow_fields)
        frame_fields.add(viewport_fields)
        label_all_fields = gtk.Label(_('<b>All fields</b>'))
        label_all_fields.set_use_markup(True)
        frame_fields.set_label_widget(label_all_fields)
        hbox_mapping.pack_start(frame_fields, True, True, 0)

        vbox_buttons = gtk.VBox(False, 10)
        vbox_buttons.set_border_width(5)
        hbox_mapping.pack_start(vbox_buttons, False, True, 0)

        button_add = gtk.Button(_('_Add'), stock=None, use_underline=True)
        button_add.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-list-add', gtk.ICON_SIZE_BUTTON)
        button_add.set_image(img_button)
        button_add.connect_after('clicked', self.sig_sel)
        vbox_buttons.pack_start(button_add, False, False, 0)

        button_remove = gtk.Button(_('_Remove'),
                                   stock=None,
                                   use_underline=True)
        button_remove.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_BUTTON)
        button_remove.set_image(img_button)
        button_remove.connect_after('clicked', self.sig_unsel)
        vbox_buttons.pack_start(button_remove, False, False, 0)

        button_remove_all = gtk.Button(_('_Clear'),
                                       stock=None,
                                       use_underline=True)
        button_remove_all.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-clear', gtk.ICON_SIZE_BUTTON)
        button_remove_all.set_image(img_button)
        button_remove_all.connect_after('clicked', self.sig_unsel_all)
        vbox_buttons.pack_start(button_remove_all, False, False, 0)

        hseparator_buttons = gtk.HSeparator()
        vbox_buttons.pack_start(hseparator_buttons, False, False, 3)

        self.add_buttons(vbox_buttons)

        frame_fields_selected = gtk.Frame()
        frame_fields_selected.set_shadow_type(gtk.SHADOW_NONE)
        viewport_fields_selected = gtk.Viewport()
        scrolledwindow_fields_selected = gtk.ScrolledWindow()
        scrolledwindow_fields_selected.set_policy(gtk.POLICY_AUTOMATIC,
                                                  gtk.POLICY_AUTOMATIC)
        viewport_fields_selected.add(scrolledwindow_fields_selected)
        frame_fields_selected.add(viewport_fields_selected)
        label_fields_selected = gtk.Label(_('<b>Fields selected</b>'))
        label_fields_selected.set_use_markup(True)
        frame_fields_selected.set_label_widget(label_fields_selected)
        hbox_mapping.pack_start(frame_fields_selected, True, True, 0)

        frame_csv_param = gtk.Frame()
        frame_csv_param.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        dialog_vbox.pack_start(frame_csv_param, False, True, 0)
        alignment_csv_param = gtk.Alignment(0.5, 0.5, 1, 1)
        alignment_csv_param.set_padding(7, 7, 7, 7)
        frame_csv_param.add(alignment_csv_param)

        vbox_csv_param = gtk.VBox()
        alignment_csv_param.add(vbox_csv_param)

        self.add_chooser(vbox_csv_param)

        expander_csv = gtk.Expander()
        vbox_csv_param.pack_start(expander_csv, False, True, 0)
        label_csv_param = gtk.Label(_('CSV Parameters'))
        expander_csv.set_label_widget(label_csv_param)
        table = gtk.Table(2, 4, False)
        table.set_border_width(8)
        table.set_row_spacings(9)
        table.set_col_spacings(8)
        expander_csv.add(table)

        label_csv_delimiter = gtk.Label(_('Delimiter:'))
        label_csv_delimiter.set_alignment(1, 0.5)
        table.attach(label_csv_delimiter, 0, 1, 0, 1)
        self.csv_delimiter = gtk.Entry()
        self.csv_delimiter.set_max_length(1)
        if os.name == 'nt' and ',' == locale.localeconv()['decimal_point']:
            delimiter = ';'
        else:
            delimiter = ','
        self.csv_delimiter.set_text(delimiter)
        self.csv_delimiter.set_width_chars(1)
        label_csv_delimiter.set_mnemonic_widget(self.csv_delimiter)
        table.attach(self.csv_delimiter, 1, 2, 0, 1)

        label_csv_quotechar = gtk.Label(_("Quote char:"))
        label_csv_quotechar.set_alignment(1, 0.5)
        table.attach(label_csv_quotechar, 2, 3, 0, 1)
        self.csv_quotechar = gtk.Entry()
        self.csv_quotechar.set_text("\"")
        self.csv_quotechar.set_width_chars(1)
        label_csv_quotechar.set_mnemonic_widget(self.csv_quotechar)
        table.attach(self.csv_quotechar, 3, 4, 0, 1)

        label_csv_enc = gtk.Label(_("Encoding:"))
        label_csv_enc.set_alignment(1, 0.5)
        table.attach(label_csv_enc, 0, 1, 1, 2)
        if hasattr(gtk, 'ComboBoxText'):
            self.csv_enc = gtk.ComboBoxText()
        else:
            self.csv_enc = gtk.combo_box_new_text()
        for i, encoding in enumerate(encodings):
            self.csv_enc.append_text(encoding)
            if ((os.name == 'nt' and encoding == 'cp1252')
                    or (os.name != 'nt' and encoding == 'utf_8')):
                self.csv_enc.set_active(i)
        label_csv_enc.set_mnemonic_widget(self.csv_enc)
        table.attach(self.csv_enc, 1, 2, 1, 2)

        self.add_csv_header_param(table)

        button_cancel = gtk.Button("gtk-cancel", stock="gtk-cancel")
        self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL)

        button_ok = gtk.Button("gtk-ok", stock="gtk-ok")
        self.dialog.add_action_widget(button_ok, gtk.RESPONSE_OK)

        self.dialog.vbox.pack_start(dialog_vbox)

        self.view1 = gtk.TreeView()
        self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.view1.connect('row-expanded', self.on_row_expanded)
        scrolledwindow_fields.add(self.view1)
        self.view2 = gtk.TreeView()
        self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        scrolledwindow_fields_selected.add(self.view2)
        self.view1.set_headers_visible(False)
        self.view2.set_headers_visible(False)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Field name'), cell, text=0)
        self.view1.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Field name'), cell, text=0)
        self.view2.append_column(column)

        self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)

        self.model_populate(self._get_fields(self.model))

        self.view1.set_model(self.model1)
        self.view1.connect('row-activated', self.sig_sel)
        self.view2.set_model(self.model2)
        self.view2.connect('row-activated', self.sig_unsel)

        sensible_allocation = self.sensible_widget.get_allocation()
        self.dialog.set_default_size(int(sensible_allocation.width * 0.9),
                                     int(sensible_allocation.height * 0.9))
        self.dialog.show_all()
        center_window(self.dialog, self.parent, self.sensible_widget)

        self.register()

        if sys.platform != 'darwin':
            self.view2.drag_source_set(
                gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK, [
                    gtk.TargetEntry.new('EXPORT_TREE', gtk.TARGET_SAME_WIDGET,
                                        0)
                ], gtk.gdk.ACTION_MOVE)
            self.view2.drag_dest_set(gtk.DEST_DEFAULT_ALL, [
                gtk.TargetEntry.new('EXPORT_TREE', gtk.TARGET_SAME_WIDGET, 0)
            ], gtk.gdk.ACTION_MOVE)
            self.view2.connect('drag-begin', self.drag_begin)
            self.view2.connect('drag-motion', self.drag_motion)
            self.view2.connect('drag-drop', self.drag_drop)
            self.view2.connect("drag-data-get", self.drag_data_get)
            self.view2.connect('drag-data-received', self.drag_data_received)
            self.view2.connect('drag-data-delete', self.drag_data_delete)
Exemple #5
0
    def __init__(self, value_dict=None):
        gtk.VBox.__init__(self)
        box, self.name_entry = dialogs.box_add(self,
                                               [(gtk.Entry(), True, None)],
                                               'Collection Name: ')
        self.path_entry = dialogs.PathnameEntry('',
                                                'Path to Images: ',
                                                'Choose a Directory',
                                                directory=True)
        self.pack_start(self.path_entry, False)
        self.name_entry.connect("changed", self.name_changed)
        self.path_entry.path_entry.connect("changed", self.path_changed)

        self.a_frame = gtk.Expander("Advanced Options")
        self.a_box = gtk.VBox()
        self.a_frame.add(self.a_box)
        self.recursive_button = gtk.CheckButton("Include sub-directories")
        self.recursive_button.set_active(True)
        self.rescan_check = gtk.CheckButton("Rescan for changes after opening")
        self.rescan_check.set_active(True)
        self.load_meta_check = gtk.CheckButton("Load metadata")
        self.load_meta_check.set_active(True)
        self.monitor_images_check = gtk.CheckButton(
            "Monitor image folders for changes")
        self.monitor_images_check.set_active(True)
        self.use_internal_thumbnails_check = gtk.CheckButton(
            "Use embedded thumbnails if available")
        self.use_internal_thumbnails_check.set_active(False)
        self.store_thumbs_combo = wb.LabeledComboBox("Thumbnail storage", [
            "Gnome Desktop Thumbnail Cache (User's Home)",
            "Hidden Folder in Collection Folder"
        ])
        if settings.is_windows:
            self.store_thumbs_combo.set_sensitive(False)
            self.store_thumbs_combo.set_form_data(1)
        else:
            self.store_thumbs_combo.set_form_data(0)
        self.trash_location_combo = wb.LabeledComboBox("Trash Location", [
            "User's Trash Folder", "Hidden .trash Folder in Collection Folder"
        ])
        self.trash_location_combo.set_form_data(0)
        self.store_thumbnails_check = gtk.CheckButton(
            "Store thumbnails in cache")
        self.store_thumbnails_check.set_active(True)
        self.store_thumbnails_check.connect("clicked",
                                            self.store_thumbnails_clicked)
        self.sidecar_check = gtk.CheckButton(
            "Use metadata sidecars for unsupported formats")
        self.sidecar_check.set_active(False)
        self.a_box.pack_start(self.recursive_button, False)
        self.a_box.pack_start(self.rescan_check, False)
        self.a_box.pack_start(self.monitor_images_check, False)
        self.a_box.pack_start(self.load_meta_check, False)
        self.a_box.pack_start(self.sidecar_check, False)
        self.a_box.pack_start(self.use_internal_thumbnails_check, False)
        self.a_box.pack_start(self.store_thumbnails_check, False)
        self.a_box.pack_start(self.store_thumbs_combo, False)
        self.a_box.pack_start(self.trash_location_combo, False)
        self.pack_start(self.a_frame, False)
        self.show_all()
        if value_dict:
            self.set_values(value_dict)
Exemple #6
0
    def __init__(self, context, pipeline, odisp, overview_mode=True, **args):
        super(CommandExecutionHeader, self).__init__(**args)
        self.__context = context
        self.__pipeline = pipeline
        self.__overview_mode = overview_mode
        self.__primary_complete = False
        self.__complete_unseen = False
        self.__last_view_time = None
        self.__visible = True
        self.__prev_pipeline_state = None
        self.__cancelled = False
        self.__undone = False
        self.__exception = False
        self.__mouse_hovering = False
        
        self.__throbber_pixbuf_done = PixbufCache.getInstance().get('throbber-done.gif', size=None)
        self.__throbber_pixbuf_ani = PixbufCache.getInstance().get('throbber.gif', size=None, animation=True)
        
        self.__tooltips = gtk.Tooltips()

        self.__pipeline.connect("state-changed", self.__on_pipeline_state_change)   
        self.__pipeline.connect("metadata", self.__on_pipeline_metadata)
        
        self.__main_hbox = gtk.HBox()
        self.pack_start(self.__main_hbox, expand=True)
        self.__cmdstatus_vbox = gtk.VBox()
        self.__main_hbox.pack_start(self.__cmdstatus_vbox, expand=True)
        
        self.__titlebox_ebox = gtk.EventBox()
        self.__titlebox_ebox.set_visible_window(False)
        if overview_mode:
            self.__titlebox_ebox.add_events(gtk.gdk.BUTTON_PRESS_MASK
                                            & gtk.gdk.ENTER_NOTIFY_MASK
                                            & gtk.gdk.LEAVE_NOTIFY_MASK)
            self.__titlebox_ebox.connect("enter_notify_event", self.__on_enter) 
            self.__titlebox_ebox.connect("leave_notify_event", self.__on_leave) 
        self.__titlebox_ebox.connect("button-press-event", lambda eb, e: self.__on_button_press(e))

        self.__titlebox = gtk.HBox()
        self.__titlebox_ebox.add(self.__titlebox)
        self.__cmdstatus_vbox.pack_start(hotwidgets.Align(self.__titlebox_ebox), expand=False)
        self.__pipeline_str = self.__pipeline.__str__()
        self.__title = gtk.Label()
        self.__title.set_alignment(0, 0.5)
        #self.__title.set_selectable(True)        
        self.__title.set_ellipsize(True)
        self.__state_image = gtk.Image()
        self.__titlebox.pack_start(self.__state_image, expand=False)
        self.__titlebox.pack_start(hotwidgets.Align(self.__title, padding_left=4), expand=True)
        self.__statusbox = gtk.HBox()
        self.__cmdstatus_vbox.pack_start(self.__statusbox, expand=False)
        self.__status_left = gtk.Label()
        self.__status_right = gtk.Label()
        self.__statusbox.pack_start(hotwidgets.Align(self.__status_left, padding_left=4), expand=False)
        self.__action = hotwidgets.Link()
        self.__action.connect("clicked", self.__on_action)
        self.__statusbox.pack_start(hotwidgets.Align(self.__action), expand=False)          
        self.__statusbox.pack_start(hotwidgets.Align(self.__status_right), expand=False)        
        
        self.__undoable = self.__pipeline.get_undoable() and (not self.__pipeline.get_idempotent())

        status_cmds = list(pipeline.get_status_commands())
        self.__pipeline_status_visible = False
        if status_cmds:
            self.__cmd_statuses = gtk.HBox(spacing=8)
            show_cmd_name = len(status_cmds) > 1
            for cmdname in status_cmds:
                self.__cmd_statuses.pack_start(CommandStatusDisplay(show_cmd_name and cmdname or None), expand=True)
            self.__statusbox.pack_start(hotwidgets.Align(self.__cmd_statuses), expand=False)
        else:
            self.__cmd_statuses = None
            self.__cmd_status_show_cmd = False

        self.__objects = odisp
        self.__objects.connect("primary-complete", self.__on_primary_complete)        
        self.__objects.connect("changed", lambda o: self.__update_titlebox())

        self.__exception_box = gtk.HBox()
        self.__exception_link = hotwidgets.Link()
        self.__exception_link.set_alignment(0.0, 0.5)
        self.__exception_link.set_ellipsize(True)
        self.__exception_link.connect('clicked', self.__on_exception_clicked)
        self.__exception_box.pack_start(self.__exception_link, expand=True)        
        self.__cmdstatus_vbox.pack_start(hotwidgets.Align(self.__exception_box, padding_left=4), expand=False)
        if overview_mode:
            self.__cmdstatus_vbox.pack_start(gtk.HSeparator(), expand=False)
            self.__otype_expander = None
        else:
            self.__otype_expander = gtk.Expander('')
            self.__otype_expander.unset_flags(gtk.CAN_FOCUS);
            self.__otype_expander.set_use_markup(True)
            self.__otype_expander.connect('notify::expanded', self.__on_otype_expander_toggled)
            self.__main_hbox.pack_start(self.__otype_expander, expand=False)
Exemple #7
0
    def __init__(self, parent):
        gtk.Window.__init__(self)

        self.what = _('What is happening?')
        self.blocked = False
        self.mainwin = parent
        #self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.set_title(_('Update status'))
        self.set_resizable(False)
        #self.set_default_size(500, 120)
        self.set_size_request(500, 150)
        self.set_transient_for(parent)
        #self.set_modal(True)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self.label = gtk.Label()
        self.label.set_use_markup(True)
        self.label.set_alignment(0, 0.5)
        self.label.set_markup('<span size="medium"><b>%s</b></span>' %
                              self.what)
        self.label.set_justify(gtk.JUSTIFY_LEFT)

        self.num_chars = gtk.Label()
        self.num_chars.set_use_markup(True)
        self.num_chars.set_markup(
            '<span size="14000" foreground="#999"><b>140</b></span>')

        self.update_text = MessageTextView()
        self.update_text.set_border_width(2)
        self.update_text.set_left_margin(2)
        self.update_text.set_right_margin(2)
        self.update_text.set_wrap_mode(gtk.WRAP_WORD)
        buffer = self.update_text.get_buffer()

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        scroll.add(self.update_text)

        updatebox = gtk.HBox(False)
        updatebox.pack_start(scroll, True, True, 3)

        self.url = gtk.Entry()
        self.url.connect('changed', self.__on_url_changed)
        self.btn_url = gtk.Button(_('Shorten URL'))
        self.btn_url.set_tooltip_text(_('Shorten URL'))

        tools = gtk.HBox(False)
        tools.pack_start(self.url, True, True, 3)
        tools.pack_start(self.btn_url, False, False)

        self.toolbox = gtk.Expander()
        self.toolbox.set_label(_('Options'))
        self.toolbox.set_expanded(False)
        self.toolbox.add(tools)

        self.btn_clr = gtk.Button()
        self.btn_clr.set_image(self.mainwin.load_image('action-clear.png'))
        self.btn_clr.set_tooltip_text(_('Clear all') + ' (Ctrl+L)')
        self.btn_clr.set_relief(gtk.RELIEF_NONE)

        self.btn_frn = gtk.Button()
        self.btn_frn.set_image(
            self.mainwin.load_image('action-add-friends.png'))
        self.btn_frn.set_tooltip_text(_('Add friends') + ' (Ctrl+F)')
        self.btn_frn.set_relief(gtk.RELIEF_NONE)

        self.btn_upd = gtk.Button(_('Tweet'))
        self.btn_upd.set_tooltip_text(_('Update your status') + ' (Ctrl+T)')
        chk_short = gtk.CheckButton(_('Autoshort URLs'))
        chk_short.set_sensitive(False)

        top = gtk.HBox(False)
        top.pack_start(self.label, True, True, 5)
        top.pack_start(self.num_chars, False, False, 5)

        self.waiting = CairoWaiting(parent)
        self.lblerror = gtk.Label()
        self.lblerror.set_use_markup(True)
        error_align = gtk.Alignment(xalign=0.0)
        error_align.add(self.lblerror)

        buttonbox = gtk.HBox(False)
        #buttonbox.pack_start(chk_short, False, False, 0)
        buttonbox.pack_start(self.btn_frn, False, False, 0)
        buttonbox.pack_start(self.btn_clr, False, False, 0)
        buttonbox.pack_start(gtk.HSeparator(), False, False, 2)
        buttonbox.pack_start(self.btn_upd, False, False, 0)
        abuttonbox = gtk.Alignment(1, 0.5)
        abuttonbox.add(buttonbox)

        bottom = gtk.HBox(False)
        bottom.pack_start(self.waiting, False, False, 5)
        bottom.pack_start(error_align, True, True, 4)
        bottom.pack_start(abuttonbox, True, True, 5)

        vbox = gtk.VBox(False)
        vbox.pack_start(top, False, False, 2)
        vbox.pack_start(updatebox, True, True, 2)
        vbox.pack_start(bottom, False, False, 2)
        vbox.pack_start(self.toolbox, False, False, 2)

        self.add(vbox)

        self.connect('key-press-event', self.__detect_shortcut)
        self.connect('delete-event', self.__unclose)
        buffer.connect('changed', self.count_chars)
        self.btn_frn.connect('clicked', self.show_friend_dialog)
        self.btn_clr.connect('clicked', self.clear)
        self.btn_upd.connect('clicked', self.update)
        self.btn_url.connect('clicked', self.short_url)
        self.btn_url.set_sensitive(False)
        self.toolbox.connect('activate', self.show_options)
        self.update_text.connect('mykeypress', self.__on_key_pressed)

        if SPELLING:
            try:
                self.spell = gtkspell.Spell(self.update_text)
            except Exception, e_msg:
                # FIXME: Usar el log
                print 'DEBUG:UI:Can\'t load gtkspell -> %s' % e_msg
Exemple #8
0
    def create_ui(self):
        self.set_border_width(5)
        app_vbox = gtk.VBox(spacing=5)

        self.module_hbox = gtk.HBox(spacing=5)
        app_vbox.pack_start(self.module_hbox, fill=False, expand=False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _('Choose Module:'))
        self.module_hbox.pack_start(label, fill=False, expand=False)

        self.module_combo = gtk.ComboBox(self.modules_list_model)
        cell = gtk.CellRendererText()
        self.module_combo.pack_start(cell, True)
        self.module_combo.add_attribute(cell, 'text', 0)
        self.module_combo.changed_signal_id = self.module_combo.connect(
            'changed', self.on_module_selection_changed_cb)

        self.module_combo.set_row_separator_func(lambda x, y: x.get(y, 1)[0])
        self.module_hbox.pack_start(self.module_combo, fill=True)

        separator = gtk.VSeparator()
        self.module_hbox.pack_start(separator, fill=False, expand=False)
        preferences = gtk.Button(stock=gtk.STOCK_PREFERENCES)
        preferences.connect('clicked', self.on_preferences_cb)
        self.module_hbox.pack_start(preferences, fill=False, expand=False)

        self.progressbar = gtk.ProgressBar()
        self.progressbar.set_text(_('Build Progress'))
        app_vbox.pack_start(self.progressbar, fill=False, expand=False)

        expander = gtk.Expander(_('Terminal'))
        expander.set_expanded(False)
        app_vbox.pack_start(expander, fill=False, expand=False)
        sclwin = gtk.ScrolledWindow()
        sclwin.set_size_request(-1, 300)
        sclwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
        expander.add(sclwin)
        if vte:
            self.terminal = vte.Terminal()
            self.terminal.connect('child-exited', self.on_vte_child_exit_cb)
        else:
            os.environ['TERM'] = 'dumb'  # avoid commands printing vt sequences
            self.terminal = gtk.TextView()
            self.terminal.set_size_request(800, -1)
            textbuffer = self.terminal.get_buffer()
            terminal_bold_tag = textbuffer.create_tag('bold')
            terminal_bold_tag.set_property('weight', pango.WEIGHT_BOLD)
            terminal_mono_tag = textbuffer.create_tag('mono')
            terminal_mono_tag.set_property('family', 'Monospace')
            terminal_stdout_tag = textbuffer.create_tag('stdout')
            terminal_stdout_tag.set_property('family', 'Monospace')
            terminal_stderr_tag = textbuffer.create_tag('stderr')
            terminal_stderr_tag.set_property('family', 'Monospace')
            terminal_stderr_tag.set_property('foreground', 'red')
            terminal_stdin_tag = textbuffer.create_tag('stdin')
            terminal_stdin_tag.set_property('family', 'Monospace')
            terminal_stdin_tag.set_property('style', pango.STYLE_ITALIC)
            self.terminal.set_editable(False)
            self.terminal.set_wrap_mode(gtk.WRAP_CHAR)
        sclwin.add(self.terminal)
        self.terminal_sclwin = sclwin

        self.error_hbox = self.create_error_hbox()
        app_vbox.pack_start(self.error_hbox, fill=False, expand=False)

        buttonbox = gtk.HButtonBox()
        buttonbox.set_layout(gtk.BUTTONBOX_END)
        app_vbox.pack_start(buttonbox, fill=False, expand=False)

        # Translators: This is a button label (to start build)
        self.build_button = gtk.Button(_('Start'))
        self.build_button.connect('clicked', self.on_build_cb)
        buttonbox.add(self.build_button)

        button = gtk.Button(stock=gtk.STOCK_HELP)
        button.connect('clicked', self.on_help_cb)
        buttonbox.add(button)
        buttonbox.set_child_secondary(button, True)

        app_vbox.show_all()
        self.error_hbox.hide()
        self.add(app_vbox)