Пример #1
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title("Nanoparticle")
        self.atoms = None
        import ase_ext.cluster.data
        self.data_module = ase_ext.cluster.data
        import ase_ext.cluster
        self.Cluster = ase_ext.cluster.Cluster
        self.wulffconstruction = ase_ext.cluster.wulff_construction
        self.no_update = True
        
        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)
           
        # Choose the element
        label = gtk.Label("Element: ")
        label.set_alignment(0.0, 0.2)
        element = gtk.Entry(max=3)
        self.element = element
        lattice_button = gtk.Button("Get structure")
        lattice_button.connect('clicked', self.get_structure)
        self.elementinfo = gtk.Label(" ")
        pack(vbox, [label, element, self.elementinfo, lattice_button], end=True)
        self.element.connect('activate', self.update)
        self.legal_element = False

        # The structure and lattice constant
        label = gtk.Label("Structure: ")
        self.structure = gtk.combo_box_new_text()
        self.allowed_structures = ('fcc',)
        for struct in self.allowed_structures:
            self.structure.append_text(struct)
        self.structure.set_active(0)
        self.structure.connect('changed', self.update)
        
        label2 = gtk.Label("   Lattice constant: ")
        self.lattice_const = gtk.Adjustment(3.0, 0.0, 1000.0, 0.01)
        lattice_box = gtk.SpinButton(self.lattice_const, 10.0, 3)
        lattice_box.numeric = True
        pack(vbox, [label, self.structure, label2, lattice_box])
        self.lattice_const.connect('value-changed', self.update)

        # Choose specification method
        label = gtk.Label("Method: ")
        self.method = gtk.combo_box_new_text()
        for meth in ("Layer specification", "Wulff construction"):
            self.method.append_text(meth)
        self.method.set_active(0)
        self.method.connect('changed', self.update_gui)
        pack(vbox, [label, self.method])
        pack(vbox, gtk.Label(""))
        
        # The number of layers
        self.layerbox = gtk.VBox()
        self.layerdata = attribute_collection()
        pack(vbox, self.layerbox)
        self.make_layer_gui(self.layerbox, self.layerdata, 0)

        # The Wulff construction
        self.wulffbox = gtk.VBox()
        self.wulffdata = attribute_collection()
        pack(vbox, self.wulffbox)
        self.make_layer_gui(self.wulffbox, self.wulffdata, 1)
        label = gtk.Label("Particle size: ")
        self.size_n_radio = gtk.RadioButton(None, "Number of atoms: ")
        self.size_n_radio.set_active(True)
        self.size_n_adj = gtk.Adjustment(100, 1, 100000, 1)
        self.size_n_spin = gtk.SpinButton(self.size_n_adj, 0, 0)
        self.size_dia_radio = gtk.RadioButton(self.size_n_radio,
                                              "Volume: ")
        self.size_dia_adj = gtk.Adjustment(1.0, 0, 100.0, 0.1)
        self.size_dia_spin = gtk.SpinButton(self.size_dia_adj, 10.0, 2)
        pack(self.wulffbox, [label, self.size_n_radio, self.size_n_spin,
                    gtk.Label("   "), self.size_dia_radio, self.size_dia_spin,
                    gtk.Label("ų")])
        self.size_n_radio.connect("toggled", self.update_gui)
        self.size_dia_radio.connect("toggled", self.update_gui)
        self.size_n_adj.connect("value-changed", self.update_size_n)
        self.size_dia_adj.connect("value-changed", self.update_size_dia)
        self.update_size_n()
        label = gtk.Label(
            "Rounding: If exact size is not possible, choose the size")
        pack(self.wulffbox, [label])
        self.round_above = gtk.RadioButton(None, "above  ")
        self.round_below = gtk.RadioButton(self.round_above, "below  ")
        self.round_closest = gtk.RadioButton(self.round_above, "closest  ")
        self.round_closest.set_active(True)
        buts = [self.round_above, self.round_below, self.round_closest]
        pack(self.wulffbox, buts)
        for b in buts:
            b.connect("toggled", self.update)
        
        # Information
        pack(vbox, gtk.Label(""))
        infobox = gtk.VBox()
        label1 = gtk.Label("Number of atoms: ")
        self.natoms_label = gtk.Label("-")
        label2 = gtk.Label("   Approx. diameter: ")
        self.dia1_label = gtk.Label("-")
        pack(infobox, [label1, self.natoms_label, label2, self.dia1_label])
        pack(infobox, gtk.Label(""))
        infoframe = gtk.Frame("Information about the created cluster:")
        infoframe.add(infobox)
        infobox.show()
        pack(vbox, infoframe)
        
        # Buttons
        self.pybut = PyButton("Creating a nanoparticle.")
        self.pybut.connect('clicked', self.makeatoms)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, buts], end=True, bottom=True)
        self.auto = gtk.CheckButton("Automatic Apply")
        fr = gtk.Frame()
        fr.add(self.auto)
        fr.show_all()
        pack(vbox, [fr], end=True, bottom=True)
        
        # Finalize setup
        self.update_gui()
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui
        self.no_update = False
Пример #2
0
    def create_build_gui(self):
        vbox = gtk.VBox(False, 12)
        vbox.set_border_width(6)
        vbox.show()

        hbox = gtk.HBox(False, 12)
        hbox.show()
        vbox.pack_start(hbox, expand=False, fill=False)

        label = gtk.Label("Machine:")
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.show()
        self.machine_combo.set_tooltip_text(
            "Selects the architecture of the target board for which you would like to build an image."
        )
        hbox.pack_start(self.machine_combo,
                        expand=False,
                        fill=False,
                        padding=6)
        label = gtk.Label("Base image:")
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        self.image_combo = gtk.ComboBox()
        self.image_combo.show()
        self.image_combo.set_tooltip_text(
            "Selects the image on which to base the created image")
        image_combo_cell = gtk.CellRendererText()
        self.image_combo.pack_start(image_combo_cell, True)
        self.image_combo.add_attribute(image_combo_cell, 'text',
                                       self.model.COL_NAME)
        hbox.pack_start(self.image_combo, expand=False, fill=False, padding=6)
        self.progress = gtk.ProgressBar()
        self.progress.set_size_request(250, -1)
        hbox.pack_end(self.progress, expand=False, fill=False, padding=6)

        ins = gtk.Notebook()
        vbox.pack_start(ins, expand=True, fill=True)
        ins.set_show_tabs(True)
        label = gtk.Label("Packages")
        label.show()
        ins.append_page(self.pkgsaz(), tab_label=label)
        label = gtk.Label("Package Collections")
        label.show()
        ins.append_page(self.tasks(), tab_label=label)
        ins.set_current_page(0)
        ins.show_all()

        hbox = gtk.HBox(False, 1)
        hbox.show()
        label = gtk.Label("Estimated image contents:")
        self.model.connect("contents-changed", self.update_package_count_cb,
                           label)
        label.set_property("xalign", 0.00)
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        info = gtk.Button("?")
        info.set_tooltip_text("What does this mean?")
        info.show()
        info.connect("clicked", self.info_button_clicked_cb)
        hbox.pack_start(info, expand=False, fill=False, padding=6)
        vbox.pack_start(hbox, expand=False, fill=False, padding=6)
        con = self.contents()
        con.show()
        vbox.pack_start(con, expand=True, fill=True)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(12)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False, fill=False)
        reset = gtk.Button("Reset")
        reset.connect("clicked", self.reset_clicked_cb)
        reset.show()
        bbox.add(reset)
        bake = gtk.Button("Bake")
        bake.connect("clicked", self.bake_clicked_cb)
        bake.show()
        bbox.add(bake)

        return vbox
Пример #3
0
    def __locations_page(self, page_type):
        """Return a widget containing a list of files and folders"""

        def add_whitelist_file_cb(button):
            """Callback for adding a file"""
            title = _("Choose a file")
            pathname = GuiBasic.browse_file(self.parent, title)
            if pathname:
                for this_pathname in pathnames:
                    if pathname == this_pathname[1]:
                        print "warning: '%s' already exists in whitelist" % pathname
                        return
                liststore.append([_('File'), pathname])
                pathnames.append(['file', pathname])
                options.set_whitelist_paths(pathnames)

        def add_whitelist_folder_cb(button):
            """Callback for adding a folder"""
            title = _("Choose a folder")
            pathname = GuiBasic.browse_folder(self.parent, title,
                                              multiple=False, stock_button=gtk.STOCK_ADD)
            if pathname:
                for this_pathname in pathnames:
                    if pathname == this_pathname[1]:
                        print "warning: '%s' already exists in whitelist" % pathname
                        return
                liststore.append([_('Folder'), pathname])
                pathnames.append(['folder', pathname])
                options.set_whitelist_paths(pathnames)

        def remove_whitelist_path_cb(button):
            """Callback for removing a path"""
            treeselection = treeview.get_selection()
            (model, _iter) = treeselection.get_selected()
            if None == _iter:
                # nothing selected
                return
            pathname = model[_iter][1]
            liststore.remove(_iter)
            for this_pathname in pathnames:
                if this_pathname[1] == pathname:
                    pathnames.remove(this_pathname)
                    options.set_whitelist_paths(pathnames)

        def add_custom_file_cb(button):
            """Callback for adding a file"""
            title = _("Choose a file")
            pathname = GuiBasic.browse_file(self.parent, title)
            if pathname:
                for this_pathname in pathnames:
                    if pathname == this_pathname[1]:
                        print "warning: '%s' already exists in whitelist" % pathname
                        return
                liststore.append([_('File'), pathname])
                pathnames.append(['file', pathname])
                options.set_custom_paths(pathnames)

        def add_custom_folder_cb(button):
            """Callback for adding a folder"""
            title = _("Choose a folder")
            pathname = GuiBasic.browse_folder(self.parent, title,
                                              multiple=False, stock_button=gtk.STOCK_ADD)
            if pathname:
                for this_pathname in pathnames:
                    if pathname == this_pathname[1]:
                        print "warning: '%s' already exists in whitelist" % pathname
                        return
                liststore.append([_('Folder'), pathname])
                pathnames.append(['folder', pathname])
                options.set_custom_paths(pathnames)

        def remove_custom_path_cb(button):
            """Callback for removing a path"""
            treeselection = treeview.get_selection()
            (model, _iter) = treeselection.get_selected()
            if None == _iter:
                # nothing selected
                return
            pathname = model[_iter][1]
            liststore.remove(_iter)
            for this_pathname in pathnames:
                if this_pathname[1] == pathname:
                    pathnames.remove(this_pathname)
                    options.set_custom_paths(pathnames)

        vbox = gtk.VBox()

        # load data
        if LOCATIONS_WHITELIST == page_type:
            pathnames = options.get_whitelist_paths()
        elif LOCATIONS_CUSTOM == page_type:
            pathnames = options.get_custom_paths()
        liststore = gtk.ListStore(str, str)
        for paths in pathnames:
            type_code = paths[0]
            type_str = None
            if type_code == 'file':
                type_str = _('File')
            elif type_code == 'folder':
                type_str = _('Folder')
            else:
                raise RuntimeError("Invalid type code: '%s'" % type_code)
            path = paths[1]
            liststore.append([type_str, path])

        if LOCATIONS_WHITELIST == page_type:
            # TRANSLATORS: "Paths" is used generically to refer to both files
            # and folders
            notice = gtk.Label(
                _("Theses paths will not be deleted or modified."))
        elif LOCATIONS_CUSTOM == page_type:
            notice = gtk.Label(
                _("These locations can be selected for deletion."))
        vbox.pack_start(notice)

        # create treeview
        treeview = gtk.TreeView(liststore)

        # create column views
        self.renderer0 = gtk.CellRendererText()
        self.column0 = gtk.TreeViewColumn(_("Type"), self.renderer0, text=0)
        treeview.append_column(self.column0)

        self.renderer1 = gtk.CellRendererText()
        # TRANSLATORS: In the tree view "Path" is used generically to refer to a
        # file, a folder, or a pattern describing either
        self.column1 = gtk.TreeViewColumn(_("Path"), self.renderer1, text=1)
        treeview.append_column(self.column1)
        treeview.set_search_column(1)

        # finish tree view
        swindow = gtk.ScrolledWindow()
        swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        swindow.set_size_request(300, 200)
        swindow.add(treeview)
        vbox.pack_start(swindow, False)

        # buttons that modify the list
        button_add_file = gtk.Button(_p('button', 'Add file'))
        if LOCATIONS_WHITELIST == page_type:
            button_add_file.connect("clicked", add_whitelist_file_cb)
        elif LOCATIONS_CUSTOM == page_type:
            button_add_file.connect("clicked", add_custom_file_cb)

        button_add_folder = gtk.Button(_p('button', 'Add folder'))
        if LOCATIONS_WHITELIST == page_type:
            button_add_folder.connect("clicked", add_whitelist_folder_cb)
        elif LOCATIONS_CUSTOM == page_type:
            button_add_folder.connect("clicked", add_custom_folder_cb)

        button_remove = gtk.Button(_p('button', 'Remove'))
        if LOCATIONS_WHITELIST == page_type:
            button_remove.connect("clicked", remove_whitelist_path_cb)
        elif LOCATIONS_CUSTOM == page_type:
            button_remove.connect("clicked", remove_custom_path_cb)

        button_box = gtk.HButtonBox()
        button_box.set_layout(gtk.BUTTONBOX_START)
        button_box.pack_start(button_add_file)
        button_box.pack_start(button_add_folder)
        button_box.pack_start(button_remove)
        vbox.pack_start(button_box, False)

        # return page
        return vbox
Пример #4
0
    def __init__(self, maitansetup, *args, **kwargs):
        gtk.Window.__init__(self, *args, **kwargs)

        if (maitansetup):
            self.setup = maitansetup
        else:
            self.setup = MaitanSetup()

        accelgroup = gtk.AccelGroup()
        self.add_accel_group(accelgroup)
        item_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT, accelgroup)
        menu_file = gtk.Menu()
        menu_file.add(item_quit)
        self.item_file = gtk.MenuItem('_File')
        self.item_file.props.submenu = menu_file
        menubar = gtk.MenuBar()
        menubar.append(self.item_file)

        self.textbuf = gtk.TextBuffer()
        self.textbuf.set_text(self.setup.get_default_document())
        self.textview = gtk.TextView(self.textbuf)
        self.textview.set_wrap_mode(gtk.WRAP_CHAR)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.add(self.textview)

        self.button_cut = gtk.Button(stock=gtk.STOCK_EXECUTE)
        self.button_paste = gtk.Button(stock=gtk.STOCK_PREFERENCES)
        self.button_clear = gtk.Button(stock=gtk.STOCK_CLEAR)

        notebook = gtk.Notebook()
        notebook.set_tab_pos(gtk.POS_BOTTOM)

        vbox_img = gtk.VBox()
        notebook.append_page(vbox_img, gtk.Label("Image"))

        hbox_imgctl = gtk.HBox()
        self.zoom_ratio = gtk.Adjustment(value=30,
                                         lower=5,
                                         upper=200,
                                         step_incr=5)
        self.zoom_ratio.connect('value-changed', self.draw_image)
        sb = gtk.SpinButton(self.zoom_ratio)
        hbox_imgctl.pack_end(sb, expand=False, fill=False)
        hbox_imgctl.pack_end(gtk.Label("Zoom for preview (%): "),
                             expand=False,
                             fill=False)

        self.image = gtk.Image()
        self.image_exists = False
        self.image.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG)

        self.imagebuf = None

        sw_img = gtk.ScrolledWindow()
        sw_img.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw_img.add_with_viewport(self.image)

        vbox_img.pack_start(sw_img, expand=True, fill=True)
        vbox_img.pack_start(hbox_imgctl, expand=False, fill=False)

        self.textbuf_log = gtk.TextBuffer()
        self.textview_log = gtk.TextView(self.textbuf_log)
        self.textview_log.set_wrap_mode = gtk.WRAP_CHAR
        self.textview_log.set_editable(False)

        sw_log = gtk.ScrolledWindow()
        sw_log.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw_log.add(self.textview_log)
        notebook.append_page(sw_log, gtk.Label("Log"))

        hbox_btn = gtk.HButtonBox()
        hbox_btn.pack_start(self.button_cut, expand=False, fill=False)
        hbox_btn.pack_start(self.button_clear, expand=False, fill=False)
        hbox_btn.pack_start(self.button_paste, expand=False, fill=False)

        box = gtk.VBox(spacing=3)

        box.pack_start(sw)
        box.pack_start(hbox_btn, expand=False, fill=False)

        paned = gtk.VPaned()
        paned.add1(box)
        paned.add2(notebook)

        vbox = gtk.VBox()
        vbox.pack_start(menubar, expand=False, fill=False)
        vbox.pack_start(paned)

        self.clipboard = gtk.Clipboard()
        self.clipboard_primary = gtk.Clipboard(selection='PRIMARY')
        self.connect('delete_event', gtk.main_quit)
        item_quit.connect('activate', gtk.main_quit)
        self.button_cut.connect('clicked', self.on_button_cut_clicked)
        self.button_paste.connect('clicked', self.on_button_paste_clicked)
        self.button_clear.connect('clicked', self.on_button_clear_clicked)
        #    self.clipboard.connect('owner-change', self.on_clipboard_owner_change)
        self.add(vbox)
        self.set_size_request(350, 300)
    def create_visual_elements(self):
        self.set_size_request(600, 400)
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
        label.set_markup(markup)
        self.vbox.pack_start(label, expand=False, fill=False, padding=2)

        table = gtk.Table(2, 10, False)
        table.set_col_spacings(5)
        table.set_row_spacings(5)
        self.vbox.pack_start(table, expand=True, fill=True)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        tv = gtk.TextView()
        tv.set_editable(False)
        tv.set_wrap_mode(gtk.WRAP_WORD)
        tv.set_cursor_visible(False)
        self.buf = gtk.TextBuffer()
        self.buf.set_text(self.image_path)
        tv.set_buffer(self.buf)
        scroll.add(tv)
        table.attach(scroll, 0, 10, 0, 1)

        # There are 2 ways to use DeployImageDialog
        # One way is that called by HOB when the 'Deploy Image' button is clicked
        # The other way is that called by a standalone script.
        # Following block of codes handles the latter way. It adds a 'Select Image' button and
        # emit a signal when the button is clicked.
        if self.standalone:
            gobject.signal_new("select_image_clicked", self,
                               gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
            icon = gtk.Image()
            pix_buffer = gtk.gdk.pixbuf_new_from_file(
                hic.ICON_IMAGES_DISPLAY_FILE)
            icon.set_from_pixbuf(pix_buffer)
            button = gtk.Button("Select Image")
            button.set_image(icon)
            #button.set_size_request(140, 50)
            table.attach(button, 9, 10, 1, 2, gtk.FILL, 0, 0, 0)
            button.connect("clicked", self.select_image_button_clicked_cb)

        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=False, padding=10)

        self.usb_desc = gtk.Label()
        self.usb_desc.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
        self.usb_desc.set_markup(markup)

        self.usb_combo = gtk.combo_box_new_text()
        self.usb_combo.connect("changed", self.usb_combo_changed_cb)
        model = self.usb_combo.get_model()
        model.clear()
        self.usb_combo.append_text(self.__dummy_usb__)
        for usb in self.find_all_usb_devices():
            self.usb_combo.append_text("/dev/" + usb)
        self.usb_combo.set_active(0)
        self.vbox.pack_start(self.usb_combo, expand=False, fill=False)
        self.vbox.pack_start(self.usb_desc,
                             expand=False,
                             fill=False,
                             padding=2)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=True, padding=10)

        self.vbox.show_all()
        self.progress_bar.hide()
Пример #6
0
    def _create_toolitems_2_4(self):
        # use the GTK+ 2.4 GtkToolbar API
        iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR
        if not _new_tooltip_api:
            self.tooltips = gtk.Tooltips()

        for text, tooltip_text, image_num, callback, callback_arg, scroll \
                in self.toolitems:
            if text is None:
                self.insert(gtk.SeparatorToolItem(), -1)
                continue
            image = gtk.Image()
            image.set_from_stock(image_num, iconSize)
            tbutton = gtk.ToolButton(image, text)
            self.insert(tbutton, -1)
            if callback_arg:
                tbutton.connect('clicked', getattr(self, callback),
                                callback_arg)
            else:
                tbutton.connect('clicked', getattr(self, callback))
            if scroll:
                tbutton.connect('scroll_event', getattr(self, callback))
            if _new_tooltip_api:
                tbutton.set_tooltip_text(tooltip_text)
            else:
                tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')

        # Axes toolitem, is empty at start, update() adds a menu if >=2 axes
        self.axes_toolitem = gtk.ToolItem()
        self.insert(self.axes_toolitem, 0)
        if _new_tooltip_api:
            self.axes_toolitem.set_tooltip_text(
                'Select axes that controls affect')
        else:
            self.axes_toolitem.set_tooltip(
                self.tooltips,
                tip_text='Select axes that controls affect',
                tip_private='Private')

        align = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0)
        self.axes_toolitem.add(align)

        self.menubutton = gtk.Button("Axes")
        align.add(self.menubutton)

        def position_menu(menu):
            """Function for positioning a popup menu.
            Place menu below the menu button, but ensure it does not go off
            the bottom of the screen.
            The default is to popup menu at current mouse position
            """
            x0, y0 = self.window.get_origin()
            x1, y1, m = self.window.get_pointer()
            x2, y2 = self.menubutton.get_pointer()
            sc_h = self.get_screen().get_height()  # requires GTK+ 2.2 +
            w, h = menu.size_request()

            x = x0 + x1 - x2
            y = y0 + y1 - y2 + self.menubutton.allocation.height
            y = min(y, sc_h - h)
            return x, y, True

        def button_clicked(button, data=None):
            self.axismenu.popup(None, None, position_menu, 0,
                                gtk.get_current_event_time())

        self.menubutton.connect("clicked", button_clicked)
Пример #7
0
    def __init__(self, session):
        '''Constructor, response_cb receive the response number, the new file
        selected and a list of the paths on the icon view.
        picture_path is the path of the current display picture,
        '''
        gtk.Window.__init__(self)
        self.set_modal(True)

        self.config = session.config

        self.avatar_manager = gui.base.AvatarManager(session)

        self.set_title(_("Avatar chooser"))
        self.set_default_size(620, 400)
        self.set_border_width(4)
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)

        cache_path = self.avatar_manager.get_avatars_dir()
        faces_paths = self.avatar_manager.get_system_avatars_dirs()
        contact_cache_path = self.avatar_manager.get_cached_avatars_dir()
        self.views = []
        self.views.append(
            IconView(_('Used'), [cache_path], self.on_remove, self.on_accept,
                     IconView.TYPE_SELF_PICS, self._on_image_area_selector))
        self.views.append(
            IconView(_('System pictures'), faces_paths, self.on_remove,
                     self.on_accept, IconView.TYPE_SYSTEM_PICS, None))
        self.views.append(
            IconView(_('Contact pictures'), contact_cache_path, self.on_remove,
                     self.on_accept, IconView.TYPE_CONTACTS_PICS, None))

        vbox = gtk.VBox(spacing=4)
        side_vbox = gtk.VBox(spacing=4)
        hbox = gtk.HBox(spacing=4)

        hbbox = gtk.HButtonBox()
        hbbox.set_spacing(4)
        hbbox.set_layout(gtk.BUTTONBOX_END)

        vbbox = gtk.VButtonBox()
        vbbox.set_spacing(4)
        vbbox.set_layout(gtk.BUTTONBOX_START)

        b_clear = gtk.Button(_("No picture"))
        self.b_add = gtk.Button(stock=gtk.STOCK_ADD)
        self.b_remove = gtk.Button(stock=gtk.STOCK_REMOVE)
        self.b_remove_all = gtk.Button(_("Remove all"))
        b_accept = gtk.Button(stock=gtk.STOCK_OK)
        b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)

        b_clear.connect('clicked', self._on_clear)
        self.b_add.connect('clicked', self._on_add)
        self.b_remove.connect('clicked', self.on_remove)
        self.b_remove_all.connect('clicked', self._on_remove_all)
        b_accept.connect('clicked', self.on_accept)
        b_cancel.connect('clicked', self._on_cancel)
        self.connect('delete-event', self._on_close)
        self.connect("key-press-event", self.on_key_press)

        Avatar = extension.get_default('avatar')
        self.img_current = Avatar()
        self.img_current.set_size_request(96, 96)
        frame_current = gtk.Frame(_("Current"))
        frame_current.add(self.img_current)

        hbbox.pack_start(b_clear, False)
        hbbox.pack_start(b_cancel, False)
        hbbox.pack_start(b_accept, False)

        vbbox.pack_start(self.b_add, False)
        vbbox.pack_start(self.b_remove, False)
        vbbox.pack_start(self.b_remove_all, False)

        side_vbox.pack_start(frame_current, False)
        side_vbox.pack_start(vbbox)

        self.notebook = gtk.Notebook()
        self.notebook.set_show_tabs(True)

        for view in self.views:
            self.notebook.append_page(view, view.label)
        self.notebook.connect("switch-page", self._on_tab_changed)

        hbox.pack_start(self.notebook, True, True)
        hbox.pack_start(side_vbox, False, False)

        vbox.pack_start(hbox, True, True)
        vbox.pack_start(hbbox, False)

        vbox.show_all()
        self.add(vbox)

        current_avatar = session.config.last_avatar
        self.img_current.set_from_file(current_avatar)
Пример #8
0
 def __init__(self, plugin, gui, userfacade, logger):
     object.__init__(self)
     self.plugin = gtk.VBox(False)
     self.logger = logger
     self.options = None
     self.userfacade = userfacade
     # 1st line
     hbox = gtk.HBox(False)
     label_name = gtk.Label()
     align = gtk.Alignment(0.01, 0.5, 0, 0)
     label_name.set_markup(_("CSV file:"))
     align.add(label_name)
     hbox.pack_start(align, False, False, 5)
     self.button_addfile = gtk.Button()
     image = gtk.Image()
     image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
     self.button_addfile.set_image(image)
     self.button_addfile.set_tooltip_text(_("Select a CSV file to load photo's variables"))
     self.button_addfile.set_label(_("Select file"))
     self.button_addfile.connect('clicked', self._load_csv)
     align = gtk.Alignment(0.01, 0.5, 0, 0)
     align.add(self.button_addfile)
     hbox.pack_start(align, False, False, 5)
     self.plugin.pack_start(hbox, False, False, 5)
     # 3rd line
     hbox_headers = gtk.HBox(False)
     label_headers = gtk.Label()
     label_headers.set_markup(_("Headers:"))
     hbox_headers.pack_start(label_headers, False, False, 5)
     self.entry_headers = gtk.Entry(max=256)
     self.entry_headers.connect('focus-out-event', self._out_entry)
     self.entry_headers.connect('activate', self._set_entry)
     self.entry_headers.set_tooltip_text(_("List of column headers of the CSV file. Each header will be a variable for each photo"))
     self.entry_headers.set_sensitive(False)
     hbox_headers.pack_start(self.entry_headers, True, True, 2)
     label_headerid = gtk.Label()
     label_headerid.set_markup(_("where photo name is:"))
     hbox_headers.pack_start(label_headerid, False, False, 0)
     self.cb_headerid = gtk.combo_box_new_text()
     self.cb_headerid.connect("changed", self._combo_id)
     self.cb_headerid.set_tooltip_text(_("Name of the column to match with each photo file name. It must be one of the Headers"))
     self.cb_headerid.set_sensitive(False)
     self.cb_headerid.append_text('          ')
     hbox_headers.pack_start(self.cb_headerid, False, False, 5)
     self.plugin.pack_start(hbox_headers, False, False, 5)
     # 4st line
     self.checkbutton_geolocate = gtk.CheckButton(_("Geolocate photos using CSV headers"))
     self.checkbutton_geolocate.set_tooltip_text(_("It is active, it will assign the following headers to each photo. It will geotag the photos by using those headers, but, warning: GPX data will take precedence!"))
     self.checkbutton_geolocate.connect('toggled', self._geolocate)
     self.checkbutton_geolocate.set_sensitive(False)
     # Headers Variables
     self.frame = gtk.Frame()
     self.frame.set_label_widget(self.checkbutton_geolocate)
     table = gtk.Table(2, 4, True)
     label_lat = gtk.Label()
     label_lat.set_markup(_("Latitude:"))
     align = gtk.Alignment(1.00, 0.5, 0, 0)
     align.add(label_lat)
     table.attach(align, 0, 1, 0, 1, gtk.FILL)
     self.cb_lat = gtk.combo_box_new_text()
     self.cb_lat.connect("changed", self._combo_geolocate, CSVImport_CONFKEY_HEADER_LAT)
     self.cb_lat.set_tooltip_text(_("Latitude header name"))
     table.attach(self.cb_lat, 1, 2, 0, 1)
     label_lon = gtk.Label()
     label_lon.set_markup(_("Longitude:"))
     align = gtk.Alignment(1.00, 0.5, 0, 0)
     align.add(label_lon)
     table.attach(align, 2, 3, 0, 1, gtk.FILL)
     self.cb_lon = gtk.combo_box_new_text()
     self.cb_lon.connect("changed", self._combo_geolocate, CSVImport_CONFKEY_HEADER_LON)
     self.cb_lon.set_tooltip_text(_("Longitude header name"))
     table.attach(self.cb_lon, 3, 4, 0, 1)
     label_date = gtk.Label()
     label_date.set_markup(_("Time-Date:"))
     align = gtk.Alignment(1.00, 0.5, 0, 0)
     align.add(label_date)
     table.attach(align, 0, 1, 1, 2)
     self.cb_date = gtk.combo_box_new_text()
     self.cb_date.connect("changed", self._combo_geolocate, CSVImport_CONFKEY_HEADER_DATE)
     table.attach(self.cb_date, 1, 2, 1, 2)
     label_ele = gtk.Label()
     label_ele.set_markup(_("Elevation:"))
     align = gtk.Alignment(1.00, 0.5, 0, 0)
     align.add(label_ele)
     table.attach(align, 2, 3, 1, 2)
     self.cb_ele = gtk.combo_box_new_text()
     self.cb_ele.connect("changed", self._combo_geolocate, CSVImport_CONFKEY_HEADER_ELE)
     self.cb_ele.set_tooltip_text(_("Elevation header name"))
     table.attach(self.cb_ele, 3, 4, 1, 2)
     table.set_border_width(20)
     table.set_row_spacings(5)
     self.frame.add(table)
     self.frame.set_border_width(5)
     self.frame.set_sensitive(False)
     self.plugin.pack_start(self.frame, False, False, 5)
     # Button
     self.button_process = gtk.Button()
     self.button_process.set_label(_("Process"))
     image = gtk.Image()
     image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON)
     self.button_process.set_image(image)
     self.button_process.connect('clicked', self.process)
     align = gtk.Alignment(0.50, 0.5, 0.1, 0)
     align.add(self.button_process)
     self.plugin.pack_start(align, False, False, 0)
     self.button_process.set_sensitive(False)
     # Attributes
     self.rootplugin = plugin
     self.rootgui = gui
     self.window = gui.builder.get_object("window")
     self.events = True
Пример #9
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)
Пример #10
0
class CheckWidget:
    def __init__(self,master,check=None):
        self.widget = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.make_widgets()

        if check:
            self.load_check(check)
            self.check = check
        else:
            self.check = Check()
            
        self.widget.show_all()
        gtk.mainloop()
        return

    def load_check(self,check):
        self.dateentry.set_text(check.date.formatUS())
        if check.number: self.number.set_text(str(check.number))
        if check.payee: self.payee.set_text(check.payee)
        if check.memo: self.memo.set_text(check.memo)
        if check.amount: self.amount.set_text("%.2f" % check.amount)
        if check.cleared: self.cleared.set_active(1)
        return

    def get_check_from_form(self):
        str = self.dateentry.get_text()
        self.check.date.parse_datestring(str)

        str = get_string_from_entry(self.number)
        self.check.amount = get_float_from_entry(self.amount)
        self.check.payee = get_string_from_entry(self.payee)
        self.check.memo = get_string_from_entry(self.memo)
        self.check.cleared = self.cleared.get_active()
        return

    def make_widgets(self):
        self.widget.set_title("Check Edit")
        self.widget.connect("destroy",gtk.mainquit)

        self.vbox = gtk.VBox()
        self.widget.add(self.vbox)


        #Number/Date Row
        self.numberrow = gtk.HBox()
        self.vbox.pack_start(self.numberrow)
        self.numberrow.pack_start(gtk.Label("Number"))
        self.number = gtk.Entry()
        self.numberrow.pack_start(self.number)
        self.numberrow.pack_start(gtk.Label("Date"))
        self.dateentry = gtk.Entry()
        self.numberrow.pack_start(self.dateentry)

        #Transaction Row
        self.transactionrow = gtk.HBox()
        self.vbox.pack_start(self.transactionrow)
        self.transactionrow.pack_start(gtk.Label("Transaction"))
        self.payee = gtk.Entry()
        self.transactionrow.pack_start(self.payee)

        #Amount/Cleared Row
        self.amountrow = gtk.HBox()
        self.vbox.pack_start(self.amountrow)
        self.amountrow.pack_start(gtk.Label("Amount"))
        self.amount = gtk.Entry()
        self.amountrow.pack_start(self.amount)
         self.cleared = gtk.CheckButton("Cleared")
        self.amountrow.pack_start(self.cleared)

        #Memo/Button Row
        self.buttonrow = gtk.HBox()
        self.vbox.pack_start(self.buttonrow)
        self.buttonrow.pack_start(gtk.Label("Memo"))
        self.memo = gtk.Entry()
        self.buttonrow.pack_start(self.memo)
        self.okbutton = gtk.Button("Ok")
        self.buttonrow.pack_start(self.okbutton)
        self.okbutton.connect("clicked",self.save)
        self.cancelbutton = gtk.Button("Cancel")
        self.buttonrow.pack_start(self.cancelbutton)
        self.cancelbutton.connect("clicked",self.cancel)

        return
Пример #11
0
    def __init__(self, mainWindow):
        self.runcmd = mainWindow.runcmd
        # Create a new window

        self.window = gtk.Window()  #hadjustment=None, vadjustment=None)
        self.swindow = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
        self.swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
        self.window.set_title("AGOOEY Process Selector")

        self.window.set_size_request(600, 240)

        self.window.connect("delete_event", self.delete_event)
        self.vbox = gtk.VBox(homogeneous=False, spacing=0)
        self.hbox = gtk.HBox(homogeneous=False, spacing=0)
        rows = 6
        cols = 6
        self.table = gtk.Table(rows, cols, False)

        button_strings = [
            'm__readfiles', 's__readfiles', 'coarseorb', 'demassist',
            'subtrrefpha', 'dinsar', 'm__porbits', 's__porbits', 'coarsecorr',
            'coregpm', 'comprefdem', 'slant2h', 'm__crop', 's__crop',
            'm__filtazi', 'resample', 'subtrrefdem', 'geocode', 'm__simamp',
            '', 's__filtazi', 'filtrange', 'coherence', '', 'm__timing', '',
            'fine', 'interfero', 'filtphase', '', 'm__ovs', 's__ovs',
            'reltiming', 'comprefpha', 'unwrap'
        ]
        button = map(lambda i: gtk.Button(button_strings[i]),
                     range(len(button_strings)))

        ##### SET THE HBOX #####
        self.processEntry = gtk.Entry()
        self.processEntry.set_editable(False)
        self.processEntry.show()

        self.applyButton = gtk.Button(label='Apply',
                                      stock=None,
                                      use_underline=True)
        self.applyButton.connect("clicked", self.applyButtonClicked)
        self.applyButton.set_flags(gtk.CAN_DEFAULT)
        self.applyButton.show()

        self.refreshButton = gtk.Button(label='Clear',
                                        stock=None,
                                        use_underline=True)
        self.refreshButton.connect("clicked", self.refreshButtonClicked)
        self.refreshButton.set_flags(gtk.CAN_DEFAULT)
        self.refreshButton.show()

        self.advancedChkBtn = gtk.CheckButton("Advanced")
        self.advancedChkBtn.connect("toggled", self.advancedChkBtnToggled)
        self.advancedChkBtn.show()

        self.hbox.pack_start(self.refreshButton,
                             expand=False,
                             fill=False,
                             padding=10)
        self.hbox.pack_start(self.applyButton,
                             expand=False,
                             fill=False,
                             padding=10)
        self.hbox.pack_end(self.advancedChkBtn,
                           expand=False,
                           fill=False,
                           padding=20)

        #### SET THE TABLE ####
        for i in range(len(button_strings)):
            y, x = divmod(i, cols)
            if not button_strings[i]:
                continue
            button[i].connect("clicked", self.processButtonClicked)
            self.table.attach(button[i], x, x + 1, y, y + 1)
            button[i].show()

        ### SET THE VBOX ####
        self.vbox.pack_start(
            self.processEntry,
            expand=False,
            fill=False,
        )
        self.vbox.pack_start(
            self.hbox,
            expand=False,
            fill=False,
        )
        self.vbox.pack_start(
            self.table,
            expand=False,
            fill=False,
        )
        self.window.set_default(self.applyButton)

        self.swindow.add_with_viewport(self.vbox)
        self.window.add(self.swindow)
        #self.vbox.show()
        self.window.show_all()
Пример #12
0
    def _init_ui(self):
        # Dialog for editing dimensions (width, height, DPI)
        app = self.app
        buttons = (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)
        self._size_dialog = windowing.Dialog(app,
                                             _("Frame Size"),
                                             app.drawWindow,
                                             buttons=buttons)
        unit = _('px')

        height_label = gtk.Label(_('Height:'))
        height_label.set_alignment(0.0, 0.5)
        width_label = gtk.Label(_('Width:'))
        width_label.set_alignment(0.0, 0.5)
        dpi_label = gtk.Label(_('Resolution:'))
        dpi_label.set_alignment(0.0, 0.5)
        color_label = gtk.Label(_('Color:'))
        color_label.set_alignment(0.0, 0.5)

        height_entry = gtk.SpinButton(adjustment=self.height_adj,
                                      climb_rate=0.25,
                                      digits=0)
        self.height_adj.set_spin_button(height_entry)

        width_entry = gtk.SpinButton(adjustment=self.width_adj,
                                     climb_rate=0.25,
                                     digits=0)
        self.width_adj.set_spin_button(width_entry)
        dpi_entry = gtk.SpinButton(adjustment=self.dpi_adj,
                                   climb_rate=0.0,
                                   digits=0)

        color_button = gtk.ColorButton()
        color_rgba = self.app.preferences.get("frame.color_rgba")
        color_rgba = [min(max(c, 0), 1) for c in color_rgba]
        color_gdk = RGBColor(*color_rgba[0:3]).to_gdk_color()
        color_alpha = int(65535 * color_rgba[3])
        color_button.set_color(color_gdk)
        color_button.set_use_alpha(True)
        color_button.set_alpha(color_alpha)
        color_button.set_title(_("Frame Color"))
        color_button.connect("color-set", self._color_set_cb)
        color_align = gtk.Alignment(0, 0.5, 0, 0)
        color_align.add(color_button)

        size_table = gtk.Table(6, 3)
        size_table.set_border_width(3)
        xopts = gtk.FILL | gtk.EXPAND
        yopts = gtk.FILL
        xpad = ypad = 3

        unit_combobox = gtk.ComboBoxText()
        for unit in UnitAdjustment.CONVERT_UNITS.keys():
            unit_combobox.append_text(unit)
        for i, key in enumerate(UnitAdjustment.CONVERT_UNITS):
            if key == _('px'):
                unit_combobox.set_active(i)
        unit_combobox.connect('changed', self.on_unit_changed)
        self._unit_combobox = unit_combobox

        row = 0
        size_table.attach(width_label, 0, 1, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(width_entry, 1, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(self.unit_label, 2, 3, row, row + 1, xopts, yopts,
                          xpad + 4, ypad)

        row += 1
        size_table.attach(height_label, 0, 1, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(height_entry, 1, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(unit_combobox, 2, 3, row, row + 1, xopts, yopts,
                          xpad, ypad)

        row += 1
        size_table.attach(dpi_label, 0, 1, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(dpi_entry, 1, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)

        # Options panel UI
        opts_table = gtk.Table(3, 3)
        opts_table.set_border_width(3)

        row = 0
        size_button = gtk.Button("<size-summary>")
        self._size_button = size_button
        size_button.connect("clicked", self._size_button_clicked_cb)
        opts_table.attach(size_button, 0, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)

        row += 1
        opts_table.attach(color_label, 0, 1, row, row + 1, xopts, yopts, xpad,
                          ypad)
        opts_table.attach(color_align, 1, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)

        crop_layer_button = gtk.Button(_('Set Frame to Layer'))
        crop_layer_button.set_tooltip_text(
            _("Set frame to the extents of "
              "the current layer"))
        crop_document_button = gtk.Button(_('Set Frame to Document'))
        crop_document_button.set_tooltip_text(
            _("Set frame to the combination "
              "of all layers"))
        crop_layer_button.connect('clicked', self.crop_frame_cb,
                                  'CropFrameToLayer')
        crop_document_button.connect('clicked', self.crop_frame_cb,
                                     'CropFrameToDocument')

        trim_button = gtk.Button()
        trim_action = self.app.find_action("TrimLayer")
        trim_button.set_related_action(trim_action)
        trim_button.set_label(_('Trim Layer to Frame'))
        trim_button.set_tooltip_text(
            _("Trim parts of the current layer "
              "which lie outside the frame"))

        self.enable_button = gtk.CheckButton()
        frame_toggle_action = self.app.find_action("FrameToggle")
        self.enable_button.set_related_action(frame_toggle_action)
        self.enable_button.set_label(_('Enabled'))

        row += 1
        opts_table.attach(self.enable_button, 1, 2, row, row + 1, xopts, yopts,
                          xpad, ypad)

        row += 1
        opts_table.attach(crop_layer_button, 0, 2, row, row + 1, xopts, yopts,
                          xpad, ypad)

        row += 1
        opts_table.attach(crop_document_button, 0, 2, row, row + 1, xopts,
                          yopts, xpad, ypad)

        row += 1
        opts_table.attach(trim_button, 0, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)

        content_area = self._size_dialog.get_content_area()
        content_area.pack_start(size_table, True, True)

        self._size_dialog.connect('response', self._size_dialog_response_cb)

        self.add(opts_table)
    def gen_editable_settings(self, setting, tooltip=""):
        setting_hbox = gtk.HBox(False, 12)

        vbox = gtk.VBox(False, 12)
        setting_hbox.pack_start(vbox, expand=True, fill=True)

        setting_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        for key in setting.keys():
            setting_store.set(setting_store.append(), 0, key, 1, setting[key])

        setting_tree = gtk.TreeView(setting_store)
        setting_tree.set_headers_visible(True)
        setting_tree.set_size_request(300, 100)

        col = gtk.TreeViewColumn('Key')
        col.set_min_width(100)
        col.set_max_width(150)
        col.set_resizable(True)
        col1 = gtk.TreeViewColumn('Value')
        col1.set_min_width(100)
        col1.set_max_width(150)
        col1.set_resizable(True)
        setting_tree.append_column(col)
        setting_tree.append_column(col1)
        cell = gtk.CellRendererText()
        cell.set_property('width-chars', 10)
        cell.set_property('editable', True)
        cell.set_data("column", 0)
        cell.connect("edited", self.editable_settings_cell_edited,
                     setting_store)
        cell1 = gtk.CellRendererText()
        cell1.set_property('width-chars', 10)
        cell1.set_property('editable', True)
        cell1.set_data("column", 1)
        cell1.connect("edited", self.editable_settings_cell_edited,
                      setting_store)
        col.pack_start(cell, True)
        col1.pack_end(cell1, True)
        col.set_attributes(cell, text=0)
        col1.set_attributes(cell1, text=1)

        scroll = gtk.ScrolledWindow()
        scroll.set_shadow_type(gtk.SHADOW_IN)
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.add(setting_tree)
        vbox.pack_start(scroll, expand=True, fill=True)

        # some buttons
        hbox = gtk.HBox(True, 6)
        vbox.pack_start(hbox, False, False)

        button = gtk.Button(stock=gtk.STOCK_ADD)
        button.connect("clicked", self.editable_settings_add_item_clicked,
                       setting_store)
        hbox.pack_start(button)

        button = gtk.Button(stock=gtk.STOCK_REMOVE)
        button.connect("clicked", self.editable_settings_remove_item_clicked,
                       setting_tree)
        hbox.pack_start(button)

        info = HobInfoButton(tooltip, self)
        setting_hbox.pack_start(info, expand=False, fill=False)

        return setting_hbox, setting_store
Пример #14
0
import gtk


def hello_world(widget, data=None):
    print("Hello World")


def delete_event(widget, event, data=None):
    return False


def destroy(widget, data=None):
    gtk.main_quit()


window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("delete_event", delete_event)
window.connect("destroy", destroy)
button = gtk.Button("Hello World")
button.connect("clicked", hello_world, None)

window.add(button)
button.show()
window.show()

try:
    from IPython.lib.inputhook import enable_gui
    enable_gui('gtk')
except ImportError:
    gtk.main()
Пример #15
0
import gtk
import webkit
window = gtk.Window()
window.show()

window.resize(200,200)
window.set_title("Bibud")

go = gtk.Button("Go!")

hbox = gtk.HBox()

text = gtk.Entry()

hbox.pack_start(text)

hbox.pack_start(go)

window.add(hbox)

browser = webkit.WebView()
window.add(browser)
browser.show()
browser.open("http://www.example.com")

scroller = gtk.ScrolledWindow()
scroller.add(browser)
window.add(scroller)
scroller.show()

window.show_all()
Пример #16
0
    def __init__(self, fb):
        self.needsReboot = []
        self.xserver_pid = fb.xserver_pid
        self.wm_pid = fb.wm_pid
        self.doReconfig = fb.doReconfig
        self.doDebug = fb.doDebug
        self.lowRes = fb.lowRes
        self.autoscreenshot = fb.autoscreenshot

        self.moduleList = []
        self.moduleDict = {}
        self.pageHistory = []
        self.nextPage = None

        # Create the initial window and a vbox to fill it with.
        self.win = gtk.Window()
        self.win.set_position(gtk.WIN_POS_CENTER)
        self.win.set_decorated(False)

        if not self.doReconfig:
            self.win.set_keep_below(True)

        self.x_screen = gtk.gdk.screen_width()
        self.y_screen = gtk.gdk.screen_height()

        # Create a box that will hold all other widgets.
        self.mainHBox = gtk.HBox(False, 10)

        # leftVBox holds the labels for the various modules.
        self.leftVBox = gtk.VBox()
        self.leftVBox.set_border_width(5)

        # leftEventBox exists only so we have somewhere to paint an image.
        self.leftEventBox = gtk.EventBox()
        self.leftEventBox.add(self.leftVBox)
        self.leftEventBox.connect("realize", self.leb_realized)

        # rightVBox holds the notebook and the button box.
        self.rightVBox = gtk.VBox()
        self.rightVBox.set_border_width(5)

        # If we're in low res mode, grow the right hand box to take up the
        # entire window.
        if self.x_screen >= 800:
            self.leftEventBox.set_size_request(int(0.2 * self.x_screen),
                                               self.y_screen)
            self.rightVBox.set_size_request(int(0.8 * self.x_screen),
                                            self.y_screen)
            self.win.fullscreen()
        else:
            self.rightVBox.set_size_request(self.x_screen, self.y_screen)
            self.win.set_size_request(self.x_screen, self.y_screen)
            self.lowRes = 1

        # Create a button box to handle navigation.
        self.buttonBox = gtk.HButtonBox()
        self.buttonBox.set_layout(gtk.BUTTONBOX_END)
        self.buttonBox.set_spacing(10)

        # Create the "go back" button, marking it insensitive by default.
        self.backButton = gtk.Button(use_underline=True,
                                     stock='gtk-go-back',
                                     label=_("_Back"))
        self.backButton.set_sensitive(False)
        self.backButton.connect('clicked', self.backClicked)

        self.buttonBox.set_border_width(10)
        self.buttonBox.pack_start(self.backButton)

        # Create the "go forward" button.
        self.nextButton = gtk.Button(use_underline=True,
                                     stock='gtk-go-forward',
                                     label=_("_Forward"))
        self.nextHandler = self.nextButton.connect('clicked', self.nextClicked)
        self.buttonBox.pack_start(self.nextButton)

        # Create the notebook.  We use a ListView to control which page in the
        # notebook is displayed.
        self.notebook = gtk.Notebook()
        if self.doDebug:
            #self.modulePath = ('/usr/src/rhn/up2date/firstboot')
            self.modulePath = ('/usr/share/firstboot/modules')
            self.notebook.set_show_tabs(False)
            self.notebook.set_scrollable(True)
            self.notebook.set_show_border(False)
        else:
            self.modulePath = ('/usr/share/firstboot/modules')
            self.notebook.set_show_tabs(False)
            self.notebook.set_show_border(False)

        self.notebook.connect("switch-page", self.switchPage)

        sys.path.append(self.modulePath)

        self.loadModules()

        self.notebook.set_current_page(0)
        self.setPointer(0)

        # Add the widgets into the right side.
        self.rightVBox.pack_start(self.notebook)
        self.rightVBox.pack_start(self.buttonBox, expand=False)

        # Add the widgets into the main widget.
        if not self.lowRes:
            self.mainHBox.pack_start(self.leftEventBox)

        self.mainHBox.pack_start(self.rightVBox)
        self.win.add(self.mainHBox)

        self.win.connect("destroy", self.destroy)
        self.winHandler = self.win.connect("key-release-event",
                                           self.keyRelease)

        # This should really be in firstboot.py, but something about
        # importing all the modules screws the keyboard up only when we
        # start from rhgb.  So here it is.
        if not fb.doDebug:
            from rhpl.keyboard import Keyboard
            kbd = Keyboard()
            kbd.read()
            kbd.activate()

        self.win.show_all()
        self.win.present()
        self.nextButton.grab_focus()
        gtk.main()
Пример #17
0
    def __init__(self,
                 partitions,
                 diskset,
                 intf,
                 parent,
                 origvgrequest,
                 isNew=0):
        self.partitions = partitions
        self.diskset = diskset
        self.origvgrequest = origvgrequest
        self.isNew = isNew
        self.intf = intf
        self.parent = parent

        self.availlvmparts = self.partitions.getAvailLVMPartitions(
            self.origvgrequest, self.diskset)
        self.logvolreqs = self.partitions.getLVMLVForVG(self.origvgrequest)
        self.origvolreqs = copy.copy(self.logvolreqs)

        # if no PV exist, raise an error message and return
        if len(self.availlvmparts) < 1:
            self.intf.messageWindow(
                _("Not enough physical volumes"),
                _("At least one unused physical "
                  "volume partition is "
                  "needed to create an LVM Volume Group.\n\n"
                  "Create a partition or RAID array "
                  "of type \"physical volume (LVM)\" and then "
                  "select the \"LVM\" option again."),
                custom_icon="error")
            self.dialog = None
            return

        if isNew:
            tstr = _("Make LVM Volume Group")
        else:
            try:
                tstr = _("Edit LVM Volume Group: %s") % (
                    origvgrequest.volumeGroupName, )
            except:
                tstr = _("Edit LVM Volume Group")

        dialog = gtk.Dialog(tstr, self.parent)
        gui.addFrame(dialog)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)

        dialog.set_position(gtk.WIN_POS_CENTER)

        maintable = gtk.Table()
        maintable.set_row_spacings(5)
        maintable.set_col_spacings(5)
        row = 0

        # volume group name
        if not origvgrequest.getPreExisting():
            lbl = createAlignedLabel(_("_Volume Group Name:"))
            self.volnameEntry = gtk.Entry(16)
            lbl.set_mnemonic_widget(self.volnameEntry)
            if not self.isNew:
                self.volnameEntry.set_text(self.origvgrequest.volumeGroupName)
            else:
                self.volnameEntry.set_text(
                    lvm.createSuggestedVGName(self.partitions))
        else:
            lbl = createAlignedLabel(_("Volume Group Name:"))
            self.volnameEntry = gtk.Label(self.origvgrequest.volumeGroupName)

        maintable.attach(lbl, 0, 1, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.attach(self.volnameEntry, 1, 2, row, row + 1,
                         gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        row = row + 1

        if not origvgrequest.getPreExisting():
            lbl = createAlignedLabel(_("_Physical Extent:"))
            (self.peOption, self.peOptionMenu) = self.createPEOptionMenu(
                self.origvgrequest.pesize)
            lbl.set_mnemonic_widget(self.peOption)
        else:
            # FIXME: this is a nice hack -- if we create the option menu, but
            # don't display it, getting the value always returns what we init'd
            # it to
            lbl = createAlignedLabel(_("Physical Extent:"))
            (self.peOption, self.peOptionMenu) = self.createPEOptionMenu(
                self.origvgrequest.pesize)
            self.peOption = gtk.Label(
                self.prettyFormatPESize(origvgrequest.pesize))

        maintable.attach(lbl, 0, 1, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.attach(self.peOption, 1, 2, row, row + 1,
                         gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        row = row + 1

        (self.lvmlist, sw) = self.createAllowedLvmPartitionsList(
            self.availlvmparts, self.origvgrequest.physicalVolumes,
            self.partitions, origvgrequest.getPreExisting())
        if origvgrequest.getPreExisting():
            self.lvmlist.set_sensitive(gtk.FALSE)
        self.lvmlist.set_size_request(275, 80)
        lbl = createAlignedLabel(_("Physical Volumes to _Use:"))
        lbl.set_mnemonic_widget(self.lvmlist)
        maintable.attach(lbl, 0, 1, row, row + 1)
        maintable.attach(sw, 1, 2, row, row + 1)
        row = row + 1

        maintable.attach(createAlignedLabel(_("Used Space:")), 0, 1, row,
                         row + 1, gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        lbox = gtk.HBox()
        self.usedSpaceLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(1.0, 0.5, 0.0, 0.0)
        labelalign.add(self.usedSpaceLabel)
        lbox.pack_start(labelalign, gtk.FALSE, gtk.FALSE)
        self.usedPercentLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(1.0, 0.5, 0.0, 0.0)
        labelalign.add(self.usedPercentLabel)
        lbox.pack_start(labelalign, gtk.FALSE, gtk.FALSE, padding=10)
        maintable.attach(lbox, 1, 2, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.set_row_spacing(row, 0)
        row = row + 1

        maintable.attach(createAlignedLabel(_("Free Space:")), 0, 1, row,
                         row + 1, gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        lbox = gtk.HBox()
        self.freeSpaceLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(1.0, 0.5, 0.0, 0.0)
        labelalign.add(self.freeSpaceLabel)
        lbox.pack_start(labelalign, gtk.FALSE, gtk.FALSE)
        self.freePercentLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(1.0, 0.5, 0.0, 0.0)
        labelalign.add(self.freePercentLabel)
        lbox.pack_start(labelalign, gtk.FALSE, gtk.FALSE, padding=10)

        maintable.attach(lbox, 1, 2, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.set_row_spacing(row, 0)
        row = row + 1

        maintable.attach(createAlignedLabel(_("Total Space:")), 0, 1, row,
                         row + 1, gtk.EXPAND | gtk.FILL, gtk.SHRINK)
        self.totalSpaceLabel = gtk.Label("")
        labelalign = gtk.Alignment()
        labelalign.set(0.0, 0.5, 0.0, 0.0)
        labelalign.add(self.totalSpaceLabel)
        maintable.attach(labelalign, 1, 2, row, row + 1, gtk.EXPAND | gtk.FILL,
                         gtk.SHRINK)
        maintable.set_row_spacing(row, 5)
        row = row + 1

        # populate list of logical volumes
        lvtable = gtk.Table()
        lvtable.set_row_spacings(5)
        lvtable.set_col_spacings(5)
        self.logvolstore = gtk.ListStore(gobject.TYPE_STRING,
                                         gobject.TYPE_STRING,
                                         gobject.TYPE_STRING)

        if self.logvolreqs:
            for lvrequest in self.logvolreqs:
                iter = self.logvolstore.append()
                self.logvolstore.set_value(iter, 0,
                                           lvrequest.logicalVolumeName)
                if lvrequest.mountpoint is not None:
                    self.logvolstore.set_value(iter, 1, lvrequest.mountpoint)
                else:
                    self.logvolstore.set_value(iter, 1, "")
                self.logvolstore.set_value(
                    iter, 2, "%g" %
                    (lvrequest.getActualSize(self.partitions, self.diskset)))

        self.logvollist = gtk.TreeView(self.logvolstore)
        col = gtk.TreeViewColumn(_("Logical Volume Name"),
                                 gtk.CellRendererText(),
                                 text=0)
        self.logvollist.append_column(col)
        col = gtk.TreeViewColumn(_("Mount Point"),
                                 gtk.CellRendererText(),
                                 text=1)
        self.logvollist.append_column(col)
        col = gtk.TreeViewColumn(_("Size (MB)"),
                                 gtk.CellRendererText(),
                                 text=2)
        self.logvollist.append_column(col)
        self.logvollist.connect('row-activated', self.logvolActivateCb)

        sw = gtk.ScrolledWindow()
        sw.add(self.logvollist)
        sw.set_size_request(100, 100)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        lvtable.attach(sw, 0, 1, 0, 1)

        # button box of options
        lvbbox = gtk.VBox()
        add = gtk.Button(_("_Add"))
        add.connect("clicked", self.addLogicalVolumeCB)
        lvbbox.pack_start(add)
        edit = gtk.Button(_("_Edit"))
        edit.connect("clicked", self.editLogicalVolumeCB)
        lvbbox.pack_start(edit)
        delete = gtk.Button(_("_Delete"))
        delete.connect("clicked", self.delLogicalVolumeCB)
        lvbbox.pack_start(delete)

        lvalign = gtk.Alignment()
        lvalign.set(0.5, 0.0, 0.0, 0.0)
        lvalign.add(lvbbox)
        lvtable.attach(lvalign, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK)

        # pack all logical volumne stuff in a frame
        lvtable.set_border_width(12)
        l = gtk.Label()
        l.set_markup("<b>%s</b>" % (_("Logical Volumes"), ))
        frame = gtk.Frame()
        frame.set_label_widget(l)
        frame.add(lvtable)
        frame.set_shadow_type(gtk.SHADOW_NONE)

        #	dialog.vbox.pack_start(frame)
        maintable.attach(frame, 0, 2, row, row + 1)
        row = row + 1

        dialog.vbox.pack_start(maintable)
        dialog.set_size_request(500, 450)
        dialog.show_all()

        # set space labels to correct values
        self.updateVGSpaceLabels()

        self.dialog = dialog
Пример #18
0
import gtk
import random


def callback(widget, data):
    print "Callback", data


def delete_event(widget, event, data=None):
    gtk.main_quit()
    return False


h = gtk.HBox()

b1 = gtk.Button("Button 1")
b1.connect("clicked", callback, "1")

h.add(b1)

for padding in [0, 10]:
    for fill in [True, False]:
        for expand in [True, False]:
            name = "expand %s\nfill %s\npadding %s" % (expand, fill, padding)
            ab = gtk.Button(name)
            ab.connect("clicked", callback, name)
            h.pack_start(ab, expand, fill, padding)

w = gtk.Window()
w.connect("delete_event", delete_event)
w.add(h)
Пример #19
0
    def __init__(self):
        super(MainFrame, self).__init__()  # 初始化

        self.set_title("BitLog")  # 标题
        self.set_size_request(250, 150)  # 窗口大小
        self.set_position(gtk.WIN_POS_CENTER)  # 窗口位置
        self.connect("destroy", gtk.main_quit)
        self.set_icon_from_file("icon.png")

        #LOGO "BitLog"
        logo = gtk.Label()
        logo.set_use_markup(gtk.TRUE)
        logo.set_markup('<span size="38000"><b>BitLog</b></span>')

        # 图标
        login_img = gtk.Image()
        login_img.set_from_file("login.png")
        logout_img = gtk.Image()
        logout_img.set_from_file("logout.png")
        setting_img = gtk.Image()
        setting_img.set_from_file("setting.png")
        about_img = gtk.Image()
        about_img.set_from_file("about.png")

        login_btn = gtk.Button()  # 登录按钮
        login_btn.set_image(login_img)
        login_btn.connect("clicked", self.login)
        login_btn.set_tooltip_text(u"登录")
        login_btn.set_size_request(100, 40)

        logout_btn = gtk.Button()  # 注销按钮
        logout_btn.set_image(logout_img)
        logout_btn.connect("clicked", self.logout)
        logout_btn.set_tooltip_text(u"注销")
        logout_btn.set_size_request(100, 40)

        setting_btn = gtk.Button()  # 设置按钮
        setting_btn.set_image(setting_img)
        setting_btn.connect("clicked", self.Se)
        setting_btn.set_tooltip_text(u"设置")

        about_btn = gtk.Button()  # 关于按钮
        about_btn.set_image(about_img)
        about_btn.connect("clicked", self.Ab)
        about_btn.set_tooltip_text("关于")

        # 控件布局
        fixed = gtk.Fixed()
        fixed.put(logo, 20, 20)
        fixed.put(setting_btn, 200, 20)
        fixed.put(about_btn, 200, 50)
        fixed.put(login_btn, 20, 85)
        fixed.put(logout_btn, 130, 85)

        self.add(fixed)
        self.show_all()

        # 检查本地是否存有账号和密码
        global user, pswd, sta
        try:
            fuser = file('user.pkl', 'rb+')
            fpswd = file('pswd.pkl', 'rb+')
            fsta = file('sta.pkl', 'rb+')
            user = pickle.load(fuser)
            pswd = pickle.load(fpswd)
            sta = pickle.load(fsta)
        except:
            fuser = file('user.pkl', 'wb+')
            fpswd = file('pswd.pkl', 'wb+')
            fsta = file('sta.pkl', 'wb+')
            user = ''
            pswd = ''
            sta = 0
Пример #20
0
    logo.set_from_pixbuf(pixbuf)

fixed = gtk.Fixed()

#button_close = gtk.Button(label=" Cerrar ")
#button_close.connect("clicked", on_close_clicked)
#button_close.connect_object("clicked", gtk.Widget.destroy, window)
#button_close.set_tooltip_text("Cerrar acerca de Huayra")

menu = gtk.Menu()
menu_item_copy = gtk.MenuItem("Copiar al portapapeles")
menu_item_copy.set_tooltip_text("Copiar al portapapeles")
menu.append(menu_item_copy)
menu_item_copy.connect("activate", menu_item_copy_response, " Texto")
menu_item_copy.show()
button_menu = gtk.Button()

image = gtk.Image()
image.set_from_file(os.path.join(APP_PATH, 'media', 'compartir.svg'))
button_menu.set_image(image)
button_menu.props.relief = gtk.RELIEF_NONE

button_menu.connect_object("event", button_press, menu)


def draw_background(widget, event):
    try:
        background = gtk.gdk.pixbuf_new_from_file(
            os.path.join(APP_PATH, 'media',
                         'huayra-about-background.svg'))  # ret pixbuf
        background = background.scale_simple(width, height, 1)
Пример #21
0
    def __init__thread(self, gfxwindow, time, position, output):
        debug.mainthreadTest()
        allMeshDataWindows.append(self)
        widgetscope.WidgetScope.__init__(self, None)

        current_count = MeshDataGUI.count
        MeshDataGUI.count += 1
        self._name = "Mesh_Data_%d" % current_count
        self.output = output
        self.time = time
        self.position = position
        self.sbcallbacks = []
        self.gsbcallbacks = []  # callbacks from a specific gfx window
        self.updateLock = lock.Lock()

        self.outputparam = \
                     ooflib.engine.IO.output.ValueOutputParameter('output')

        # Although it's not displayed, we need a mesh widget in the
        # widgetscope, or the OutputParameterWidget won't work.
        # TODO 3.1: Is this ugly, or what?
        self.meshWidget = whowidget.WhoWidget(mesh.meshes,
                                              scope=self,
                                              name="Godot")

        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        title = utils.underscore2space(self._name)
        self.gtk.set_title(title)
        gtklogger.newTopLevelWidget(self.gtk, title)
        gtklogger.connect_passive(self.gtk, 'delete-event')
        gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Put this window into the Windows menu.  The menu item can't
        # be logged, since the creation and operation of the window
        # aren't logged, so scripts shouldn't refer to it at all.
        mainmenu.OOF.Windows.Mesh_Data.addItem(
            oofmenu.OOFMenuItem(self._name,
                                no_log=1,
                                help="Raise Mesh Data window %d." %
                                current_count,
                                threadable=oofmenu.UNTHREADABLE,
                                callback=self.raiseWindow))

        expander = gtk.Expander("Source")
        gtklogger.setWidgetName(expander, 'ViewSource')
        gtklogger.connect_passive_after(expander, 'activate')
        self.mainbox.pack_start(expander, expand=0, fill=0)
        expander.set_expanded(1)

        self.table = gtk.Table(rows=config.dimension() + 4, columns=2)
        expander.add(self.table)

        label = gtk.Label("Source Window:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0, 1, 0, 1, xpadding=3, xoptions=gtk.FILL)
        tooltips.set_tooltip_text(
            label, "Display data for mouse clicks in this Graphics window.")

        self.gfxWindowChooser = chooser.ChooserWidget([],
                                                      callback=self.chooserCB,
                                                      name='GfxWindow')
        self.table.attach(self.gfxWindowChooser.gtk,
                          1,
                          2,
                          0,
                          1,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)

        label = gtk.Label("Mesh:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          1,
                          2,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        tooltips.set_tooltip_text(
            label, "Data is displayed for values on this mesh.")

        self.meshText = gtk.Entry()
        gtklogger.setWidgetName(self.meshText, "meshname")
        self.meshText.set_editable(False)
        self.meshText.set_size_request(12 * guitop.top().charsize, -1)
        self.table.attach(self.meshText,
                          1,
                          2,
                          1,
                          2,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)

        # Position controls
        label = gtk.Label("position x:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          2,
                          3,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        self.xText = gtk.Entry()
        gtklogger.setWidgetName(self.xText, 'x')
        self.xText.set_size_request(12 * guitop.top().digitsize, -1)
        self.table.attach(self.xText,
                          1,
                          2,
                          2,
                          3,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        self.xsignal = gtklogger.connect(self.xText, 'changed',
                                         self.posChangedCB)

        label = gtk.Label("position y:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          3,
                          4,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        self.yText = gtk.Entry()
        gtklogger.setWidgetName(self.yText, 'y')
        self.yText.set_size_request(12 * guitop.top().digitsize, -1)
        self.table.attach(self.yText,
                          1,
                          2,
                          3,
                          4,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        self.ysignal = gtklogger.connect(self.yText, 'changed',
                                         self.posChangedCB)

        if config.dimension() == 3:
            label = gtk.Label("position z:")
            label.set_alignment(1.0, 0.5)
            self.table.attach(label,
                              0,
                              1,
                              4,
                              5,
                              xpadding=3,
                              xoptions=gtk.FILL,
                              yoptions=0)
            self.zText = gtk.Entry()
            gtklogger.setWidgetName(self.zText, 'z')
            self.zText.set_size_request(12 * guitop.top().digitsize, -1)
            self.table.attach(self.zText,
                              1,
                              2,
                              4,
                              5,
                              xpadding=3,
                              xoptions=gtk.EXPAND | gtk.FILL,
                              yoptions=0)
            self.zsignal = gtklogger.connect(self.zText, 'changed',
                                             self.posChangedCB)
            timerow = 5
        else:
            timerow = 6

        # Time controls.  Typing in the time widget does not
        # immediately update the displayed data, because interpolating
        # to a new time is an expensive computation, and shouldn't be
        # done while the user is in the middle of typing.  Instead,
        # the time widget is normally desensitized and uneditable.
        # When the user clicks the "Edit" button, the widget becomes
        # editable, the rest of the window is desensitized, and the
        # "Edit" button changes do a "Done" button.  When the user
        # clicks "Done" the data is updated and the time widget
        # becomes uneditable again.
        label = gtk.Label("time:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          timerow,
                          timerow + 1,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        tBox = gtk.HBox(spacing=3)
        self.table.attach(tBox,
                          1,
                          2,
                          timerow,
                          timerow + 1,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        self.tText = gtk.Entry()
        self.tText.set_editable(False)
        self.tText.set_sensitive(False)
        tBox.pack_start(self.tText, expand=1, fill=1)
        gtklogger.setWidgetName(self.tText, 't')
        self.tText.set_size_request(12 * guitop.top().digitsize, -1)
        self.tEditButton = gtk.Button("Edit")
        tBox.pack_start(self.tEditButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.tEditButton, "tEdit")
        gtklogger.connect(self.tEditButton, 'clicked', self.tEditCB)
        self.tEditMode = False

        # Output selection
        label = gtk.Label("Output:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          timerow + 2,
                          timerow + 3,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        tooltips.set_tooltip_text(label, "Choose which data is displayed.")

        self.outputwidget = self.outputparam.makeWidget(scope=self)
        self.table.attach(self.outputwidget.gtk,
                          1,
                          2,
                          timerow + 2,
                          timerow + 3,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        switchboard.requestCallback(self.outputwidget, self.outputwidgetCB)

        # Data display panel
        hbox = gtk.HBox()
        self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5)
        frame = gtk.Frame("Data")
        gtklogger.setWidgetName(frame, 'Data')
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, expand=1, fill=1, padding=5)
        # valign keeps the data widget at the top of the frame
        valign = gtk.Alignment(yalign=0.0)
        frame.add(valign)
        # dhbox just provides space between the data widget and the frame
        dhbox = gtk.HBox(spacing=5)
        valign.add(dhbox)
        # databox is where the data widget goes
        self.databox = gtk.VBox()
        dhbox.pack_start(self.databox, expand=1, fill=1, padding=5)
        self.datawidget = None  # set by updateData

        # Buttons at the bottom of the window
        buttonbox = gtk.HBox()
        self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=3)
        # Freeze buttons
        freezeframe = gtk.Frame("Freeze")
        gtklogger.setWidgetName(freezeframe, "Freeze")
        buttonbox.pack_start(freezeframe, expand=1, fill=1, padding=3)
        hbox = gtk.HBox()
        freezeframe.add(hbox)
        # Freeze Space button
        self.freezeSpaceFlag = False
        self.freezeSpaceButton = gtk.CheckButton('Space')
        gtklogger.setWidgetName(self.freezeSpaceButton, 'Space')
        hbox.pack_start(self.freezeSpaceButton, expand=1, fill=0, padding=0)
        self.freezeSpaceButton.set_active(self.freezeSpaceFlag)
        gtklogger.connect(self.freezeSpaceButton, 'clicked',
                          self.freezeSpaceButtonCB)
        tooltips.set_tooltip_text(
            self.freezeSpaceButton,
            "Prevent the data in this window from being updated when the sample position changes."
        )
        # Freeze Time button
        self.freezeTimeFlag = False
        self.freezeTimeButton = gtk.CheckButton('Time')
        gtklogger.setWidgetName(self.freezeTimeButton, "Time")
        hbox.pack_start(self.freezeTimeButton, expand=1, fill=0, padding=0)
        self.freezeTimeButton.set_active(self.freezeTimeFlag)
        gtklogger.connect(self.freezeTimeButton, 'clicked',
                          self.freezeTimeButtonCB)
        tooltips.set_tooltip_text(
            self.freezeTimeButton,
            "Prevent the data in this window from being updated when the Mesh's time changes."
        )

        # Clone button
        self.cloneButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Clone')
        gtklogger.setWidgetName(self.cloneButton, 'Clone')
        gtklogger.connect(self.cloneButton, 'clicked', self.cloneButtonCB)
        buttonbox.pack_start(self.cloneButton, expand=0, fill=0, padding=3)
        tooltips.set_tooltip_text(
            self.cloneButton,
            "Make a copy of this window with its current settings.")

        # Close button
        self.closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
        gtklogger.setWidgetName(self.closeButton, 'Close')
        gtklogger.connect(self.closeButton, 'clicked', self.closeButtonCB)
        buttonbox.pack_end(self.closeButton, expand=0, fill=0, padding=3)

        self.gtk.connect('destroy', self.destroyCB)

        self.updateGfxWindowChooser()
        if gfxwindow:
            self.gfxWindowChooser.set_state(gfxwindow.name)
        if position is not None:
            self.updatePosition(position)
        self.currentMesh = None
        self.updateMesh()

        self.setupSwitchboard()  # gfx window dependent callbacks
        self.sbcallbacks += [
            switchboard.requestCallbackMain('open graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('close graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('mesh data changed',
                                            self.meshDataChanged),
            switchboard.requestCallbackMain((gfxwindow, "time changed"),
                                            self.timeChanged)
        ]

        self.gtk.show_all()
Пример #22
0
 def addButton(self):
     self.button = gtk.Button("Enter BlueJeans")
     self.button.connect("clicked", self.continued, None)
     self.window.add(self.button)
     self.button.show()
Пример #23
0
    def __init__(self):
        # Read configuration
        self.readConfig()

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title(self.lang.get_string(1))
        self.window.set_border_width(5)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.set_modal(gtk.TRUE)
        self.window.set_resizable(gtk.FALSE)
        icon = gtk.gdk.pixbuf_new_from_file(ICON_PATH)
        gtk.window_set_default_icon_list((icon))

        # Register events
        self.window.connect("delete_event", self.onDelete)

        # configElements = [ [Option Name, String ID, Entry, Label ], ...  ]
        self.configElements = [["gmailusername", 2, None, None],
                               ["gmailpassword", 22, None, None],
                               ["browserpath", 3, None, None],
                               ["proxy", 36, None, None],
                               ["voffset", 28, None, None],
                               ["hoffset", 27, None, None],
                               ["checkinterval", 31, None, None],
                               ["animationdelay", 29, None, None],
                               ["popuptimespan", 30, None, None]]

        # Create table and attach to window
        table = gtk.Table(rows=12, columns=2, homogeneous=gtk.FALSE)

        self.window.add(table)

        # Create and attach widgets
        for i in range(len(self.configElements)):
            curVar = self.configElements[i][0]
            curLabel = self.configElements[i][1]

            label = gtk.Label(self.lang.get_string(curLabel))
            label.set_alignment(0, 0.5)
            textbox = gtk.Entry(max=0)

            if (self.options[curVar] != None):
                textbox.set_text(str(self.options[curVar]))

            if (curVar == "gmailpassword"):
                textbox.set_visibility(gtk.FALSE)
                textbox.set_invisible_char('*')

            # Store widget in element array
            self.configElements[i][2] = textbox
            self.configElements[i][3] = label
            table.attach(label, 0, 1, i, i + 1, xpadding=2, ypadding=1)

            table.attach(textbox, 1, 2, i, i + 1, xpadding=2, ypadding=1)

            label.show()
            textbox.show()

        # Add checkbox to save username/pass to file
        alignment = gtk.Alignment(0.5, 0.5, 0.0, 0.0)
        self.savePassword = gtk.CheckButton(label=self.lang.get_string(34))
        alignment.add(self.savePassword)

        if (self.readLoginFromFile == None
                and (self.options["gmailusername"] != None
                     and self.options["gmailpassword"] != None)):
            self.readLoginFromFile = True
        else:
            self.readLoginFromFile = False

        if (self.readLoginFromFile):
            self.savePassword.set_active(gtk.TRUE)
        else:
            self.savePassword.set_active(gtk.FALSE)

        self.savePassword.show()
        table.attach(alignment, 0, 2, 10, 11)
        alignment.show()

        # Add combobox to select language
        self.lbl_langs = gtk.Label(self.lang.get_string(4))
        self.lbl_langs.set_alignment(0, 0.5)
        self.cbo_langs = gtk.combo_box_new_text()
        self.cbo_langs.connect('changed', self.update_labels)
        for one_lang in self.langs:
            if one_lang == self.lang:
                self.cbo_langs.prepend_text(one_lang.get_name())
            else:
                self.cbo_langs.append_text(one_lang.get_name())
        self.cbo_langs.set_active(0)
        # Attach combobox and label
        table.attach(self.lbl_langs, 0, 1, 9, 10)
        self.lbl_langs.show()
        table.attach(self.cbo_langs, 1, 2, 9, 10, xpadding=5, ypadding=5)
        self.cbo_langs.show()

        # Add 'Close' button
        button = gtk.Button(stock=gtk.STOCK_OK)
        table.attach(button, 0, 2, 11, 12, xpadding=2, ypadding=2)
        button.connect("clicked", self.onOkay)
        button.show()

        table.show()
Пример #24
0
	def runTest(self):
		'''There is one long test.'''

		ui = MockUI()
		ui.notebook = self.notebook
		ui.page = Path('Test:foo')
		uistate = ConfigDict()
		self.assertTrue(self.notebook.get_page(ui.page).exists())

		PATHS = ('Parent:Daughter:Granddaughter',
				 'Test:tags', 'Test:foo', 'Books')
		LEN_PATHS = len(PATHS)
		PATHS_NAMES = {PATHS[0]:'name 1', PATHS[1]:'name 2', PATHS[2]:'name 3'}

		# Check correctness of reading uistate.
		uistate.setdefault('bookmarks', [])
		uistate.setdefault('bookmarks_names', {})

		uistate['bookmarks'] = list(PATHS)
		uistate['bookmarks_names'] = dict(PATHS_NAMES)
		Bar = BookmarkBar(ui, uistate, get_page_func = lambda: '')
		self.assertTrue(Bar.paths == list(PATHS))
		self.assertTrue(Bar.paths_names == PATHS_NAMES)

		uistate['bookmarks'] = []
		uistate['bookmarks_names'] = {}
		Bar = BookmarkBar(ui, uistate, get_page_func = lambda: '')
		self.assertTrue(Bar.paths == [])
		self.assertTrue(Bar.paths_names == {})

		# Add paths to the beginning of the bar.
		for i, path in enumerate(PATHS):
			Bar._add_new(path, add_bookmarks_to_beginning = True)
			self.assertTrue(len(Bar.paths) == i + 1)
		self.assertTrue(Bar.paths == list(reversed(PATHS)))

		# Add paths to the end of the bar.
		Bar.paths = []
		for i, path in enumerate(PATHS):
			Bar._add_new(path, add_bookmarks_to_beginning = False)
			self.assertTrue(len(Bar.paths) == i + 1)
		self.assertTrue(Bar.paths == list(PATHS))

		# Check that the same path can't be added to the bar.
		Bar._add_new(PATHS[0])
		Bar._add_new(PATHS[1])
		self.assertTrue(Bar.paths == list(PATHS))

		# Delete paths from the bar.
		for i, button in enumerate(Bar.container.get_children()[2:]):
			path = button.zim_path
			self.assertTrue(path in Bar.paths)
			Bar.delete(button.zim_path)
			self.assertTrue(len(Bar.paths) == LEN_PATHS - i - 1)
			self.assertTrue(path not in Bar.paths)
		self.assertTrue(Bar.paths == [])

		# Check short page names.
		uistate['show_full_page_name'] = False
		for path in PATHS:
			Bar._add_new(path)
		self.assertTrue(Bar.paths == list(PATHS))
		for i, button in enumerate(Bar.container.get_children()[2:]):
			self.assertTrue(PATHS[i] == button.zim_path)
			self.assertTrue(Path(PATHS[i]).basename == button.get_label())
		uistate['show_full_page_name'] = True

		# Delete all bookmarks from the bar.
		Bar.delete_all()
		self.assertTrue(Bar.paths == [])

		# Check restriction of max bookmarks in the bar.
		pagelist = set(self.index.list_pages(None))
		_enhanced_pagelist = set()
		for page in pagelist:
			_enhanced_pagelist.update( set(self.index.list_pages(page)) )
			if len(_enhanced_pagelist) > MAX_BOOKMARKS:
				break
		pagelist.update(_enhanced_pagelist)
		self.assertTrue(len(pagelist) > MAX_BOOKMARKS)
		pagelist = list(pagelist)
		for page in pagelist:
			Bar._add_new(page.name)
		self.assertTrue(len(Bar.paths) == MAX_BOOKMARKS)
		self.assertTrue(Bar.paths == [a.name for a in pagelist[:MAX_BOOKMARKS]])
		Bar.delete_all()

		# Check 'save' option in preferences.
		for i, path in enumerate(PATHS):
			Bar.on_preferences_changed({'save':False, 'add_bookmarks_to_beginning':False})
			Bar._add_new(path)
			self.assertTrue(uistate['bookmarks'] == [])
			Bar.on_preferences_changed({'save':True, 'add_bookmarks_to_beginning':False})
			self.assertTrue(uistate['bookmarks'] == list(PATHS[:i+1]))
		self.assertTrue(uistate['bookmarks'] == list(PATHS))

		# Check changing a bookmark.
		self.assertTrue('Test' not in Bar.paths)
		self.assertTrue('Books' in Bar.paths)
		Bar.change_bookmark('Books', 'Books')
		self.assertTrue(Bar.paths == list(PATHS))
		_b_paths = [a for a in Bar.paths if a != 'Books']
		Bar.change_bookmark('Books', 'Test')
		self.assertTrue('Test' in Bar.paths)
		self.assertTrue('Books' not in Bar.paths)
		_e_paths = [a for a in Bar.paths if a != 'Test']
		self.assertTrue(_b_paths == _e_paths)

		Bar.change_bookmark('Test', 'Books')
		self.assertTrue(Bar.paths == list(PATHS))

		# Check deleting a bookmark after deleting a page in the notebook.
		self.assertTrue(len(Bar.paths) == LEN_PATHS)
		for i, path in enumerate(PATHS):
			self.assertTrue(path in Bar.paths)
			self.notebook.delete_page(Path(path))
			self.assertTrue(path not in Bar.paths)
			self.assertTrue(len(Bar.paths) == LEN_PATHS - i - 1)
		self.assertTrue(Bar.paths == [])

		# Check reordering bookmarks.
		PATHS_2 = ('1','2','3','4','5')
		PATHS_NAMES_2 = {PATHS_2[0]:'11', PATHS_2[1]:'22', PATHS_2[2]:'33'}

		Bar.paths = list(PATHS_2)
		Bar.move_bookmark(PATHS_2[2], PATHS_2[2], 'left')
		self.assertTrue(Bar.paths == list(PATHS_2))
		Bar.move_bookmark(PATHS_2[3], PATHS_2[3], 'right')
		self.assertTrue(Bar.paths == list(PATHS_2))
		Bar.move_bookmark('3', '1', 'left')
		self.assertTrue(Bar.paths == ['3','1','2','4','5'])
		Bar.move_bookmark('5', '1', 'left')
		self.assertTrue(Bar.paths == ['3','5','1','2','4'])
		Bar.move_bookmark('5', '1', 'right')
		self.assertTrue(Bar.paths == ['3','1','5','2','4'])
		Bar.move_bookmark('3', '4', 'right')
		self.assertTrue(Bar.paths == ['1','5','2','4','3'])
		Bar.move_bookmark('5', '4', '-')
		self.assertTrue(Bar.paths == ['1','5','2','4','3'])

		# CHECK RENAMING
		# Check rename_bookmark and save options.
		Bar.paths = list(PATHS_2)
		button = gtk.Button(label = PATHS_2[0], use_underline = False)
		button.zim_path = PATHS_2[0]
		Bar.on_preferences_changed({'save':True, 'add_bookmarks_to_beginning':False})
		Bar._reload_bar()

		def rename_check(label, path, paths_names, path_names_uistate):
			self.assertTrue(button.get_label() == label)
			self.assertTrue(button.zim_path == path)
			self.assertTrue(Bar.paths_names == paths_names)
			self.assertTrue(uistate['bookmarks_names'] == path_names_uistate)

		rename_check(PATHS_2[0], PATHS_2[0], {}, {})
		Clipboard.set_text('new name')
		Bar.rename_bookmark(button)
		rename_check('new name', PATHS_2[0], {PATHS_2[0]:'new name'}, {PATHS_2[0]:'new name'})
		Bar.on_preferences_changed({'save':False, 'add_bookmarks_to_beginning':False})
		rename_check('new name', PATHS_2[0], {PATHS_2[0]:'new name'}, {})
		Bar.on_preferences_changed({'save':True, 'add_bookmarks_to_beginning':False})
		rename_check('new name', PATHS_2[0], {PATHS_2[0]:'new name'}, {PATHS_2[0]:'new name'})
		Bar.rename_bookmark(button)
		rename_check(PATHS_2[0], PATHS_2[0], {}, {})

		# Check delete with renaming.
		Bar.on_preferences_changed({'save':True, 'add_bookmarks_to_beginning':False})
		paths_names_copy = dict(PATHS_NAMES_2)
		Bar.paths_names = dict(PATHS_NAMES_2)
		for key in PATHS_NAMES_2:
			Bar.delete(key)
			del paths_names_copy[key]
			self.assertTrue(Bar.paths_names == paths_names_copy)
			self.assertTrue(uistate['bookmarks_names'] == Bar.paths_names)

		# Check delete all with renaming.
		Bar.paths_names = dict(PATHS_NAMES_2)
		Bar.delete_all()
		self.assertTrue(Bar.paths_names == {})
		self.assertTrue(uistate['bookmarks_names'] == {})

		# Check change bookmark with renaming.
		Bar.paths = list(PATHS_2)
		Bar.paths_names = dict(PATHS_NAMES_2)
		paths_names_copy = dict(PATHS_NAMES_2)
		paths_names_copy.pop(PATHS_2[0], None)
		Bar.change_bookmark(PATHS_2[0], 'new path')
		self.assertTrue(Bar.paths_names == paths_names_copy)
		self.assertTrue(Bar.paths == ['new path'] + list(PATHS_2[1:]))

		# Check that paths and paths_names didn't change in the process.
		self.assertTrue(PATHS_2 == ('1','2','3','4','5'))
		self.assertTrue(PATHS_NAMES_2 == {PATHS_2[0]:'11', PATHS_2[1]:'22', PATHS_2[2]:'33'})
Пример #25
0
    def __init__(self, aSession, aLoggingPolicy, aTitle):
        """Constructor
		aLoggingPolicy tuple containing logging policy
		"""

        Window.__init__(self,
                        os.path.join(GLADEFILE_PATH, "LoggingPolicy.glade"),
                        "top_frame")
        self.theSession = aSession
        # Sets the return number
        self.___num = None

        # Create the Dialog
        self.win = gtk.Dialog("Logging Policy", None, gtk.DIALOG_MODAL)
        self.win.connect("destroy", self.destroy)
        self.win.set_title(aTitle)
        # Sets size and position
        self.win.set_border_width(2)
        self.win.set_default_size(300, 75)
        self.win.set_position(gtk.WIN_POS_MOUSE)

        aPixbuf16 = gtk.gdk.pixbuf_new_from_file(
            os.path.join(config.GLADEFILE_PATH, 'ecell.png'))
        aPixbuf32 = gtk.gdk.pixbuf_new_from_file(
            os.path.join(config.GLADEFILE_PATH, 'ecell32.png'))
        self.win.set_icon_list(aPixbuf16, aPixbuf32)

        # Sets title
        # self.win.set_title(aTitle)
        Window.openWindow(self)
        # Sets messagd
        self.win.vbox.pack_start(self['top_frame'])
        self.win.show()

        # appends ok button
        ok_button = gtk.Button("  OK  ")
        self.win.action_area.pack_start(
            ok_button,
            False,
            False,
        )
        ok_button.set_flags(gtk.CAN_DEFAULT)
        ok_button.grab_default()
        ok_button.show()
        ok_button.connect("clicked", self.oKButtonClicked)

        # appends cancel button
        cancel_button = gtk.Button(" Cancel ")
        self.win.action_area.pack_start(cancel_button, False, False)
        cancel_button.show()
        cancel_button.connect("clicked", self.cancelButtonClicked)

        self.__populateDialog(aLoggingPolicy)

        # add handlers
        self.addHandlers({
            "on_space_max_toggled": self.__spaceLimitButtonChosen,
            "on_space_no_limit_toggled": self.__spaceNoLimitButtonChosen,
            "on_log_by_secs_toggled": self.__logBySecsButtonChosen,
            "on_log_by_step_toggled": self.__logByStepButtonChosen
        })
Пример #26
0
    def __init__(self, dbstate, uistate, track=[]):
        self.dbstate = dbstate
        self.__uistate = uistate
        self.title = _("Plugin Manager")
        ManagedWindow.ManagedWindow.__init__(self, uistate, track,
                                             self.__class__)

        self.__pmgr = GuiPluginManager.get_instance()
        self.__preg = PluginRegister.get_instance()
        self.set_window(
            gtk.Dialog("", uistate.window, gtk.DIALOG_DESTROY_WITH_PARENT,
                       (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)), None,
            self.title)
        self.window.set_size_request(750, 400)
        self.window.connect('response', self.close)

        notebook = gtk.Notebook()

        #first page with all registered plugins
        vbox_reg = gtk.VBox()
        scrolled_window_reg = gtk.ScrolledWindow()
        self.list_reg = gtk.TreeView()
        #  model: plugintype, hidden, pluginname, plugindescr, pluginid
        self.model_reg = gtk.ListStore(gobject.TYPE_STRING,
                                       gobject.TYPE_STRING,
                                       gobject.TYPE_STRING,
                                       gobject.TYPE_STRING,
                                       gobject.TYPE_STRING)
        self.selection_reg = self.list_reg.get_selection()
        self.list_reg.set_model(self.model_reg)
        self.list_reg.set_rules_hint(True)
        self.list_reg.connect('button-press-event', self.button_press_reg)
        col0_reg = gtk.TreeViewColumn(_('Type'),
                                      gtk.CellRendererText(),
                                      text=0)
        col0_reg.set_sort_column_id(0)
        col0_reg.set_resizable(True)
        self.list_reg.append_column(col0_reg)
        col = gtk.TreeViewColumn(_('Status'), gtk.CellRendererText(), markup=1)
        col.set_sort_column_id(1)
        self.list_reg.append_column(col)
        col2_reg = gtk.TreeViewColumn(_('Name'),
                                      gtk.CellRendererText(),
                                      text=2)
        col2_reg.set_sort_column_id(2)
        col2_reg.set_resizable(True)
        self.list_reg.append_column(col2_reg)
        col = gtk.TreeViewColumn(_('Description'),
                                 gtk.CellRendererText(),
                                 text=3)
        col.set_sort_column_id(3)
        col.set_resizable(True)
        self.list_reg.append_column(col)
        self.list_reg.set_search_column(2)

        scrolled_window_reg.add(self.list_reg)
        vbox_reg.pack_start(scrolled_window_reg)
        hbutbox = gtk.HButtonBox()
        hbutbox.set_layout(gtk.BUTTONBOX_SPREAD)
        self.__info_btn = gtk.Button(_("Info"))
        hbutbox.add(self.__info_btn)
        self.__info_btn.connect('clicked', self.__info, self.list_reg,
                                4)  # id_col
        self.__hide_btn = gtk.Button(_("Hide/Unhide"))
        hbutbox.add(self.__hide_btn)
        self.__hide_btn.connect('clicked', self.__hide, self.list_reg, 4,
                                1)  # list, id_col, hide_col
        if __debug__:
            self.__edit_btn = gtk.Button(_("Edit"))
            hbutbox.add(self.__edit_btn)
            self.__edit_btn.connect('clicked', self.__edit, self.list_reg,
                                    4)  # id_col
            self.__load_btn = gtk.Button(_("Load"))
            hbutbox.add(self.__load_btn)
            self.__load_btn.connect('clicked', self.__load, self.list_reg,
                                    4)  # id_col
        vbox_reg.pack_start(hbutbox, expand=False, padding=5)

        notebook.append_page(vbox_reg,
                             tab_label=gtk.Label(_('Registered Plugins')))

        #second page with loaded plugins
        vbox_loaded = gtk.VBox()
        scrolled_window = gtk.ScrolledWindow()
        self.list = gtk.TreeView()
        self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                                   gobject.TYPE_STRING, object,
                                   gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.selection = self.list.get_selection()
        self.list.set_model(self.model)
        self.list.set_rules_hint(True)
        self.list.connect('button-press-event', self.button_press)
        self.list.connect('cursor-changed', self.cursor_changed)
        col = gtk.TreeViewColumn(_('Loaded'), gtk.CellRendererText(), markup=0)
        col.set_sort_column_id(0)
        col.set_resizable(True)
        self.list.append_column(col)
        col1 = gtk.TreeViewColumn(_('File'), gtk.CellRendererText(), text=1)
        col1.set_sort_column_id(1)
        col1.set_resizable(True)
        self.list.append_column(col1)
        col = gtk.TreeViewColumn(_('Status'), gtk.CellRendererText(), markup=5)
        col.set_sort_column_id(5)
        self.list.append_column(col)
        col2 = gtk.TreeViewColumn(_('Message'), gtk.CellRendererText(), text=2)
        col2.set_sort_column_id(2)
        col2.set_resizable(True)
        self.list.append_column(col2)
        self.list.set_search_column(1)

        scrolled_window.add(self.list)
        vbox_loaded.pack_start(scrolled_window)
        hbutbox = gtk.HButtonBox()
        hbutbox.set_layout(gtk.BUTTONBOX_SPREAD)
        self.__info_btn = gtk.Button(_("Info"))
        hbutbox.add(self.__info_btn)
        self.__info_btn.connect('clicked', self.__info, self.list, 4)  # id_col
        self.__hide_btn = gtk.Button(_("Hide/Unhide"))
        hbutbox.add(self.__hide_btn)
        self.__hide_btn.connect('clicked', self.__hide, self.list, 4,
                                5)  # list, id_col, hide_col

        if __debug__:
            self.__edit_btn = gtk.Button(_("Edit"))
            hbutbox.add(self.__edit_btn)
            self.__edit_btn.connect('clicked', self.__edit, self.list,
                                    4)  # id_col
            self.__load_btn = gtk.Button(_("Load"))
            self.__load_btn.set_sensitive(False)
            hbutbox.add(self.__load_btn)
            self.__load_btn.connect('clicked', self.__load, self.list,
                                    4)  # id_col
        vbox_loaded.pack_start(hbutbox, expand=False, padding=5)
        notebook.append_page(vbox_loaded,
                             tab_label=gtk.Label(_('Loaded Plugins')))

        #third page with method to install plugin
        install_page = gtk.VBox()
        scrolled_window = gtk.ScrolledWindow()
        self.addon_list = gtk.TreeView()
        # model: help_name, name, ptype, image, desc, use, rating, contact, download, url
        self.addon_model = gtk.ListStore(
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING)
        self.addon_list.set_model(self.addon_model)
        self.addon_list.set_rules_hint(True)
        #self.addon_list.connect('button-press-event', self.button_press)
        col = gtk.TreeViewColumn(_('Addon Name'),
                                 gtk.CellRendererText(),
                                 text=1)
        col.set_sort_column_id(1)
        self.addon_list.append_column(col)
        col = gtk.TreeViewColumn(_('Type'), gtk.CellRendererText(), text=2)
        col.set_sort_column_id(2)
        self.addon_list.append_column(col)
        col = gtk.TreeViewColumn(_('Description'),
                                 gtk.CellRendererText(),
                                 text=4)
        col.set_sort_column_id(4)
        self.addon_list.append_column(col)
        self.addon_list.connect('cursor-changed', self.button_press_addon)

        install_row = gtk.HBox()
        install_row.pack_start(gtk.Label(_("Path to Addon:")), expand=False)
        self.install_addon_path = gtk.Entry()

        button = gtk.Button()
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
        button.add(img)
        button.connect('clicked', self.__select_file)
        install_row.pack_start(self.install_addon_path, expand=True)
        install_row.pack_start(button, expand=False, fill=False)

        scrolled_window.add(self.addon_list)
        install_page.pack_start(scrolled_window)
        #add some spce under the scrollbar
        install_page.pack_start(gtk.Label(''), expand=False, fill=False)
        #path to addon path line
        install_page.pack_start(install_row, expand=False, fill=False)

        hbutbox = gtk.HButtonBox()
        hbutbox.set_layout(gtk.BUTTONBOX_SPREAD)
        self.__add_btn = gtk.Button(_("Install Addon"))
        hbutbox.add(self.__add_btn)
        self.__add_btn.connect('clicked', self.__get_addon_top)
        self.__add_all_btn = gtk.Button(_("Install All Addons"))
        hbutbox.add(self.__add_all_btn)
        self.__add_all_btn.connect('clicked', self.__get_all_addons)
        self.__refresh_btn = gtk.Button(_("Refresh Addon List"))
        hbutbox.add(self.__refresh_btn)
        self.__refresh_btn.connect('clicked', self.__refresh_addon_list)
        install_page.pack_start(hbutbox, expand=False, padding=5)
        # notebook.append_page(install_page,
        #                      tab_label=gtk.Label(_('Install Addons')))

        #add the notebook to the window
        self.window.vbox.add(notebook)

        if __debug__:
            # Only show the "Reload" button when in debug mode
            # (without -O on the command line)
            self.__reload_btn = gtk.Button(_("Reload"))
            self.window.action_area.add(self.__reload_btn)
            self.__reload_btn.connect('clicked', self.__reload)

        #obtain hidden plugins from the pluginmanager
        self.hidden = self.__pmgr.get_hidden_plugin_ids()

        self.window.show_all()
        self.__populate_lists()
        self.list_reg.columns_autosize()
Пример #27
0
    def __drives_page(self):
        """Return widget containing the drives page"""

        def add_drive_cb(button):
            """Callback for adding a drive"""
            title = _("Choose a folder")
            pathname = GuiBasic.browse_folder(self.parent, title,
                                              multiple=False, stock_button=gtk.STOCK_ADD)
            if pathname:
                liststore.append([pathname])
                pathnames.append(pathname)
                options.set_list('shred_drives', pathnames)

        def remove_drive_cb(button):
            """Callback for removing a drive"""
            treeselection = treeview.get_selection()
            (model, _iter) = treeselection.get_selected()
            if None == _iter:
                # nothing selected
                return
            pathname = model[_iter][0]
            liststore.remove(_iter)
            pathnames.remove(pathname)
            options.set_list('shred_drives', pathnames)

        vbox = gtk.VBox()

        # TRANSLATORS: 'free' means 'unallocated'
        notice = gtk.Label(
            _("Choose a writable folder for each drive for which to overwrite free space."))
        notice.set_line_wrap(True)
        vbox.pack_start(notice, False)

        liststore = gtk.ListStore(str)

        pathnames = options.get_list('shred_drives')
        if pathnames:
            pathnames = sorted(pathnames)
        if not pathnames:
            pathnames = []
        for pathname in pathnames:
            liststore.append([pathname])
        treeview = gtk.TreeView(model=liststore)
        crt = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn(None, crt, text=0)
        treeview.append_column(tvc)

        vbox.pack_start(treeview)

        # TRANSLATORS: In the preferences dialog, this button adds a path to
        # the list of paths
        button_add = gtk.Button(_p('button', 'Add'))
        button_add.connect("clicked", add_drive_cb)
        # TRANSLATORS: In the preferences dialog, this button removes a path
        # from the list of paths
        button_remove = gtk.Button(_p('button', 'Remove'))
        button_remove.connect("clicked", remove_drive_cb)

        button_box = gtk.HButtonBox()
        button_box.set_layout(gtk.BUTTONBOX_START)
        button_box.pack_start(button_add)
        button_box.pack_start(button_remove)
        vbox.pack_start(button_box, False)

        return vbox
Пример #28
0
    def __init__(self):
        gtk.VBox.__init__(self, False, 2)

        self.set_border_width(4)

        self.store = gtk.ListStore(str, int, str)
        self.view = gtk.TreeView(self.store)
        self.view.set_rules_hint(True)
        self.view.set_reorderable(True)

        idx = 0
        lbls = (_('Column title'), _('Column size'), _('Function/cfield'))

        for lbl in lbls[:-1]:
            rend = gtk.CellRendererText()
            rend.set_property('editable', True)
            rend.connect('edited', self.__on_rend_edited, idx)

            col = gtk.TreeViewColumn(lbl, rend, text=idx)
            self.view.append_column(col)
            idx += 1

        # Last column
        model = gtk.ListStore(str)
        cfields = AuditManager().get_configuration('global.cfields').keys()
        cfields.sort()

        for field in cfields:
            model.append(['%' + field + '%'])

        rend = gtk.CellRendererCombo()
        rend.set_property('model', model)
        rend.set_property('text-column', 0)
        rend.set_property('editable', True)
        rend.connect('edited', self.__on_rend_edited, idx)

        self.view.props.has_tooltip = True
        self.view.connect('query-tooltip', self.__on_query_tooltip)

        col = gtk.TreeViewColumn(lbls[-1], rend, text=idx)
        self.view.append_column(col)

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

        sw.add(self.view)

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

        btn = gtk.Button(stock=gtk.STOCK_ADD)
        btn.connect('clicked', self.__on_add_row)
        bb.pack_start(btn)

        btn = gtk.Button(stock=gtk.STOCK_REMOVE)
        btn.connect('clicked', self.__on_remove_row)
        bb.pack_start(btn)

        self.pack_start(sw)
        self.pack_end(bb, False, False)

        # Let's populate
        columns_str = Prefs()['gui.maintab.sniffview.columns'].value

        for column_str in columns_str.split(','):
            try:
                label, pixel_size, eval_str = column_str.split('|', 2)
                pixel_size = int(pixel_size)

                self.store.append([label, pixel_size, eval_str])
            except:
                pass

        self.widgets = []
    def initGUI(self):
        # the widget tree:
        #
        # Window self
        #   VBox vbox
        #     ScrolledWindow scr
        #       Table table
        #     HBox hbox
        #       Label label_columns
        #       SpinButton columns
        #       Button ok
        #       Button cancel
        #       Button reload
        #     Progressbar progressbar
        #
        self.set_title(_("Please select an icon."))
        self.set_modal(gtk.TRUE)
        self.set_size_request(400, 390)
        #self.connect("delete_event", self.on_delete)  # disabled, 4/25/2003 - Erica Andrews
        self.connect("key-press-event", self.on_key)

        self.table=gtk.Table(1,1, gtk.FALSE)
        self.table.set_row_spacings(5)
        self.table.set_col_spacings(5)
        self.table.show()

        self.scr = gtk.ScrolledWindow()
        self.scr.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scr.set_border_width(10)
        self.scr.add_with_viewport(self.table)
        self.scr.show()

        self.label_columns = gtk.Label(_("Columns:"))
        self.label_columns.show()

        adj = gtk.Adjustment(self.num_columns, 1, 30, 1, 10, 10)
        self.columns = gtk.SpinButton(adj, 1, 0)
        self.columns.set_numeric(gtk.TRUE)
        self.columns.set_editable(gtk.FALSE)
        self.columns.set_update_policy(gtk.UPDATE_IF_VALID)
        adj.connect("value_changed", self.on_columns_changed)
        self.columns.show()

        self.ok = gtk.Button(_("Ok"))
        self.ok.set_flags(gtk.CAN_DEFAULT | gtk.CAN_FOCUS | 
                          gtk.HAS_FOCUS | gtk.HAS_DEFAULT)
        self.ok.connect("clicked", self.do_ok)
        self.ok.show()

        self.cancel = gtk.Button(_("Cancel"))
        self.cancel.set_flags(gtk.CAN_DEFAULT|gtk.CAN_FOCUS)
        self.cancel.connect("clicked", self.do_close)
        self.cancel.show()

        self.reload = gtk.Button(_("Reload"))
        self.reload.set_flags(gtk.CAN_DEFAULT|gtk.CAN_FOCUS)
        self.reload.connect("clicked", self.do_reload)
        self.reload.show()

        self.hbox = gtk.HBox(gtk.FALSE, 10)
        self.hbox.set_border_width(10)
        self.hbox.pack_start(self.label_columns, gtk.FALSE, gtk.FALSE, 0)
        self.hbox.pack_start(self.columns,       gtk.FALSE, gtk.FALSE, 0)
        self.hbox.pack_start(self.ok,            gtk.TRUE,  gtk.TRUE,  0)
        self.hbox.pack_start(self.cancel,        gtk.TRUE,  gtk.TRUE,  0)
        self.hbox.pack_start(self.reload,        gtk.TRUE,  gtk.TRUE,  0)
        self.hbox.show()

        self.progressbar = gtk.ProgressBar()
        self.progressbar.set_text("")
#DJM        self.progressbar.set_show_text(gtk.TRUE)
        self.progressbar.show()

        self.vbox = gtk.VBox(gtk.FALSE, 0)
        self.vbox.pack_start(self.scr,         gtk.TRUE,  gtk.TRUE,  0)
        self.vbox.pack_start(self.hbox,        gtk.FALSE, gtk.FALSE, 0)
        self.vbox.pack_start(self.progressbar, gtk.FALSE, gtk.FALSE, 0)
        self.vbox.show()

        self.add(self.vbox)
Пример #30
0
    def __init__(self, line, fig):
        gtk.Dialog.__init__(self, 'Line Properties')

        self.fig = fig
        self.line = line

        table = gtk.Table(3, 2)
        table.show()
        table.set_row_spacings(4)
        table.set_col_spacings(4)
        table.set_homogeneous(True)
        self.vbox.pack_start(table, True, True)

        row = 0

        label = gtk.Label('linewidth')
        label.show()
        entry = gtk.Entry()
        entry.show()
        entry.set_text(str(line.get_linewidth()))
        self.entryLineWidth = entry
        table.attach(label, 0, 1, row, row + 1, xoptions=False, yoptions=False)
        table.attach(entry, 1, 2, row, row + 1, xoptions=True, yoptions=False)
        row += 1

        self.rgbLine = colorConverter.to_rgb(self.line.get_color())

        def set_color(button):
            rgb = get_color(self.rgbLine)
            if rgb is not None:
                self.rgbLine = rgb

        label = gtk.Label('color')
        label.show()
        button = gtk.Button(stock=gtk.STOCK_SELECT_COLOR)
        button.show()
        button.connect('clicked', set_color)
        table.attach(label, 0, 1, row, row + 1, xoptions=False, yoptions=False)
        table.attach(button, 1, 2, row, row + 1, xoptions=True, yoptions=False)
        row += 1

        ## line styles
        label = gtk.Label('linestyle')
        label.show()
        thisStyle = line.get_linestyle()
        styles = [thisStyle]
        for key in lineStyles.keys():
            if key == thisStyle: continue
            styles.append(key)

        self.menuLineStyle, self.menuLineStyleItemd = make_option_menu(styles)
        table.attach(label, 0, 1, row, row + 1, xoptions=False, yoptions=False)
        table.attach(self.menuLineStyle,
                     1,
                     2,
                     row,
                     row + 1,
                     xoptions=True,
                     yoptions=False)
        row += 1

        ## marker
        label = gtk.Label('marker')
        label.show()

        keys = lineMarkers.keys()
        keys.append('None')
        marker = line.get_marker()
        if marker is None: marker = 'None'
        styles = [marker]
        for key in keys:
            if key == marker: continue
            styles.append(key)

        self.menuMarker, self.menuMarkerItemd = make_option_menu(styles)
        table.attach(label, 0, 1, row, row + 1, xoptions=False, yoptions=False)
        table.attach(self.menuMarker,
                     1,
                     2,
                     row,
                     row + 1,
                     xoptions=True,
                     yoptions=False)
        row += 1

        self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY)
        self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)