Example #1
0
 def __init__(self, controls): 
     gtk.Frame.__init__(self)
     FControl.__init__(self, controls)
     
     self.album_label = gtk.Label()
     self.album_label.set_line_wrap(True)
     self.album_label.set_markup("<b></b>")
     self.set_label_widget(self.album_label)                                
     
     self.empty = TextArea()
     
     self.best_songs = SimpleTreeControl(_("Best Songs"), controls)
     self.best_songs.line_title = EventLabel(self.best_songs.get_title(), func=self.show_current, arg=self.best_songs, func1=self.show_best_songs)
     
     self.artists = SimpleTreeControl(_("Similar Artists"), controls)
     self.artists.line_title = EventLabel(self.artists.get_title(), func=self.show_current, arg=self.artists, func1=self.show_similar_artists)
     
     self.tracks = SimpleTreeControl(_("Similar Songs"), controls)
     self.tracks.line_title = EventLabel(self.tracks.get_title(), func=self.show_current, arg=self.tracks, func1=self.show_similar_tracks)
             
     self.tags = SimpleTreeControl(_("Similar Tags"), controls)
     self.tags.line_title = EventLabel(self.tags.get_title(), func=self.show_current, arg=self.tags, func1=self.show_similar_tags)
     
     
     self.lyrics = TextArea()
     lyric_title = _("Lyrics")
     self.lyrics.set_text("", lyric_title)
     self.lyrics.line_title = EventLabel(lyric_title, func=self.show_current, arg=self.lyrics, func1=self.show_similar_lyrics)
     
     
     """wiki"""
     wBox = gtk.VBox()
     wiki_title = _("About Artist")
     self.wiki = TextArea()
     
     wBox.line_title = EventLabel(wiki_title, func=self.show_current, arg=wBox, func1=self.show_wiki_info)
     
     self.last_fm_label = gtk.LinkButton("http://www.last.fm", "last.fm")
     self.wiki_label = gtk.LinkButton("http://www.wikipedia.org", "wikipedia")
     
     self.wiki = TextArea()
     self.wiki.set_text("", wiki_title)
     
     wBox.pack_start(HBoxDecorator(self.last_fm_label, self.wiki_label), False, False)
     wBox.pack_start(self.wiki, True, True)
     
     wBox.scroll = wBox
     
     self.vpaned_small = gtk.VBox(False, 0)
     
     """image and similar artists"""
     ibox = gtk.HBox(False, 0)
     self.image = ImageBase(ICON_BLANK_DISK, FC().info_panel_image_size)
     
     
     lbox = gtk.VBox(False, 0)
     
     
     self.left_widget = [wBox, self.artists, self.tracks, self.tags, self.lyrics, self.best_songs]
     
     for l_widget in self.left_widget:        
         lbox.pack_start(l_widget.line_title)
             
     ibox.pack_start(self.image, False, False)
     ibox.pack_start(lbox, True, True)
             
     """image and similar artists"""
     sbox = gtk.VBox(False, 0)
     
     for l_widget in self.left_widget:        
         sbox.pack_start(l_widget.scroll, True, True)
     
     sbox.pack_end(self.empty.scroll, True, True)
     
     self.vpaned_small.pack_start(ibox, False, False)
     self.vpaned_small.pack_start(sbox, True, True)
             
     self.add(self.vpaned_small)
     
     self.hide_all()
     
     self.bean = None
     self.info_cache = InfoCache()
Example #2
0
File: dialog.py Project: kaday/rose
def run_hyperlink_dialog(stock_id=None,
                         text="",
                         title=None,
                         search_func=lambda i: False):
    """Run a dialog with inserted hyperlinks."""
    parent_window = get_dialog_parent()
    dialog = gtk.Window()
    dialog.set_transient_for(parent_window)
    dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
    dialog.set_title(title)
    dialog.set_modal(False)
    top_vbox = gtk.VBox()
    top_vbox.show()
    main_hbox = gtk.HBox(spacing=DIALOG_PADDING)
    main_hbox.show()
    # Insert the image
    image_vbox = gtk.VBox()
    image_vbox.show()
    image = gtk.image_new_from_stock(stock_id, size=gtk.ICON_SIZE_DIALOG)
    image.show()
    image_vbox.pack_start(image,
                          expand=False,
                          fill=False,
                          padding=DIALOG_PADDING)
    main_hbox.pack_start(image_vbox,
                         expand=False,
                         fill=False,
                         padding=DIALOG_PADDING)
    # Apply the text
    message_vbox = gtk.VBox()
    message_vbox.show()
    label = rose.gtk.util.get_hyperlink_label(text, search_func)
    message_vbox.pack_start(label,
                            expand=True,
                            fill=True,
                            padding=DIALOG_PADDING)
    scrolled_window = gtk.ScrolledWindow()
    scrolled_window.set_border_width(DIALOG_PADDING)
    scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
    scrolled_window.add_with_viewport(message_vbox)
    scrolled_window.child.set_shadow_type(gtk.SHADOW_NONE)
    scrolled_window.show()
    vbox = gtk.VBox()
    vbox.pack_start(scrolled_window, expand=True, fill=True)
    vbox.show()
    main_hbox.pack_start(vbox, expand=True, fill=True)
    top_vbox.pack_start(main_hbox, expand=True, fill=True)
    # Insert the button
    button_box = gtk.HBox(spacing=DIALOG_PADDING)
    button_box.show()
    button = rose.gtk.util.CustomButton(label=DIALOG_BUTTON_CLOSE,
                                        size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                                        stock_id=gtk.STOCK_CLOSE)
    button.connect("clicked", lambda b: dialog.destroy())
    button_box.pack_end(button,
                        expand=False,
                        fill=False,
                        padding=DIALOG_PADDING)
    top_vbox.pack_end(button_box,
                      expand=False,
                      fill=False,
                      padding=DIALOG_PADDING)
    dialog.add(top_vbox)
    if "\n" in text:
        label.set_line_wrap(False)
    dialog.set_resizable(True)
    # make sure the dialog size doesn't exceed the maximum - if so change it
    max_size = rose.config_editor.SIZE_MACRO_DIALOG_MAX
    my_size = dialog.size_request()
    new_size = [-1, -1]
    for i in [0, 1]:
        new_size[i] = min([my_size[i], max_size[i]])
    scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    dialog.set_default_size(*new_size)
    dialog.show()
    label.set_selectable(True)
    button.grab_focus()
Example #3
0
    def __init__(self):
        debug.mainthreadTest()
        self.menu_name = "MessageWindow_%d" % MessageWindow.count
        self.title = "%s Messages %d" % (subWindow.oofname(),
                                         MessageWindow.count)
        self.windows_menu_name = "Message_%d" % MessageWindow.count

        subWindow.SubWindow.__init__(self,
                                     title=self.title,
                                     menu=self.menu_name)

        # We are locally responsible for the windows submenu items.
        self.gtk.connect("destroy", self.destroy)

        # raise_window function is provided by the SubWindow class.
        OOF.Windows.Messages.addItem(
            oofmenu.OOFMenuItem(self.windows_menu_name,
                                help="Raise Message window %d." %
                                MessageWindow.count,
                                cli_only=0,
                                no_log=1,
                                gui_callback=self.raise_window))

        MessageWindow.count += 1

        allMessageWindows.add(self)

        # Control box, with buttons.  These could be menu items.
        controlbox = gtk.Frame()
        controlbox.set_shadow_type(gtk.SHADOW_OUT)
        self.mainbox.pack_start(controlbox, expand=0, fill=0)
        controlinnards = gtk.VBox()
        controlbox.add(controlinnards)
        buttonbox = gtk.HBox()
        controlinnards.pack_start(buttonbox, expand=0, padding=2)
        savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...")
        tooltips.set_tooltip_text(
            savebutton, "Save the contents of this window to a file.")
        buttonbox.pack_start(savebutton, expand=0, fill=0, padding=2)
        gtklogger.setWidgetName(savebutton, "Save")
        gtklogger.connect(savebutton, 'clicked', self.saveButtonCB)

        self.button_dict = {}
        self.signal_dict = {}
        for m in reporter.messageclasses:
            button = gtk.CheckButton(m)
            gtklogger.setWidgetName(button, m)
            buttonbox.pack_end(button, fill=0, expand=0, padding=2)
            self.signal_dict[m] = gtklogger.connect(button, "clicked",
                                                    self.button_click)
            self.button_dict[m] = button
            tooltips.set_tooltip_text(
                button, "Show or hide " + reporter.messagedescriptions[m])

        messagepane = gtk.ScrolledWindow()
        ## The ScrolledWindow's scrollbars are *not* logged in the
        ## gui, because blocking the adjustment "changed" signals in
        ## the write_message function, below, doesn't work to suppress
        ## logging.  This means that programmatic changes to the
        ## scrollbars are logged along with user changes, which fills
        ## up the log file with extraneous lines.
        messagepane.set_border_width(4)
        messagepane.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.mainbox.add(messagepane)

        self.messages = gtk.TextView()
        gtklogger.setWidgetName(self.messages, "Text")
        self.messages.set_editable(False)
        self.messages.set_cursor_visible(False)
        self.messages.set_wrap_mode(gtk.WRAP_WORD)
        self.changeFont(mainmenuGUI.getFixedFont())

        self.gtk.set_default_size(90 * gtkutils.widgetCharSize(self.messages),
                                  200)

        # Get two marks to be used for automatic scrolling
        bfr = self.messages.get_buffer()
        enditer = bfr.get_end_iter()
        self.endmark = bfr.create_mark(None, enditer, False)
        self.midmark = bfr.create_mark(None, enditer, False)

        messagepane.add(self.messages)

        self.state_dict = {}
        for m in reporter.messageclasses:
            self.state_dict[m] = 1

        self.sbcbs = [
            switchboard.requestCallbackMain("write message",
                                            self.write_message),
            switchboard.requestCallbackMain("change fixed font",
                                            self.changeFont)
        ]

        self.draw()
Example #4
0
 def hBoxIt3(self, homogeneous, spacing, whatToBox, pad):
     new_hbox = gtk.HBox(homogeneous, spacing)
     new_hbox.pack_start(whatToBox, expand=False, fill=False, padding=pad)
     return new_hbox
Example #5
0
 def labelIt(self, label, object):
     new_label = gtk.Label(label)
     new_box = gtk.HBox(True, 10)
     new_box.pack_start(new_label, expand=False, fill=False, padding=0)
     new_box.pack_start(object, expand=False, fill=False, padding=0)
     return new_box
Example #6
0
    def __init__(self, config, parent=None):

        self.cnt = 1
        self.conf = config
        self.lastsel = ""
        self.oldfind = ""
        self.full = False
        self.stopspeak = True
        self.stopload = False
        self.olditer = None
        self.move = None
        self.mark = None
        self.deftitle = "ePub Viewer: "
        self.speech_pid = None
        self.iterlist = []
        self.iterlist2 = []
        self.stags = []
        self.xtags = []

        gtk.Window.__init__(self)

        self.connect("unmap", self.OnExit)

        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect('destroy', self.destroyme)

        try:
            self.set_icon_from_file("epub.png")
        except:
            try:
                self.set_icon_from_file("/usr/share/pyepub/epub.png")
            except:
                print "Cannot load app icon."

        www = gtk.gdk.screen_width()
        hhh = gtk.gdk.screen_height()
        self.set_default_size(3 * www / 4, 3 * hhh / 4)

        self.set_position(gtk.WIN_POS_CENTER)
        self.set_title(self.deftitle)

        hpaned = gtk.HPaned()
        hpaned.set_border_width(2)

        vpaned = gtk.VPaned()
        vpaned.set_border_width(2)

        self.add(hpaned)

        view1 = gtk.TextView()
        view1.set_border_width(0)
        view1.set_left_margin(8)
        view1.set_right_margin(8)
        view1.set_editable(False)

        view1.connect("key-press-event", self.key_press_event)
        view1.connect("key-release-event", self.key_rel_event)
        view1.connect("event-after", self.event_after)
        view1.connect("expose-event", self.expose_event)
        view1.connect("motion-notify-event", self.motion_notify_event)
        view1.connect("visibility-notify-event", self.visibility_notify_event)

        self.view = view1

        self.buffer_1 = view1.get_buffer()
        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(view1)

        view2 = gtk.TextView()
        #view2.set_border_width(8)
        view2.set_editable(False)
        view2.set_wrap_mode(gtk.WRAP_WORD)
        view2.unset_flags(gtk.CAN_FOCUS)

        self.buffer_2 = view2.get_buffer()
        sw2 = gtk.ScrolledWindow()
        sw2.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw2.add(view2)

        view2.connect("key-press-event", self.key_press_event2)
        view2.connect("event-after", self.event_after2)
        view2.connect("motion-notify-event", self.motion_notify_event2)
        view2.connect("visibility-notify-event", self.visibility_notify_event2)

        vbox = gtk.VBox()
        vbox.set_spacing(5)
        vbox.add(sw)

        lab1 = gtk.Label("Idle")
        lab1.set_justify(gtk.JUSTIFY_RIGHT)
        lab2 = gtk.Label(" ")
        lab3 = gtk.Label("     ")
        lab4 = gtk.Label("     ")
        lab5 = gtk.Label(" ")

        #butt1 =      gtk.Button(" Show TOC File ");
        butt2 = gtk.Button(" Pre_v ")
        butt2.connect("clicked", self.prev)
        butt3 = gtk.Button(" N_ext ")
        butt3.connect("clicked", self.next)
        butt2a = gtk.Button(" PgUp ")
        butt3a = gtk.Button(" PgDn ")
        self.butt4 = gtk.Button(" _Read ")
        self.butt4.connect("clicked", self.read_tts)
        butt5 = gtk.Button(" _Home ")
        butt5.connect("clicked", self.home)
        butt5a = gtk.Button(" En_d ")
        butt5a.connect("clicked", self.end)
        butt6 = gtk.Button("  E_xit ")
        butt6.connect("clicked", self.exit)
        butt7 = gtk.Button(" _Find ")
        butt7.connect("clicked", self.find)

        hbox = gtk.HBox()
        #hbox.pack_start(butt1, False)
        hbox.pack_start(butt2, False)
        hbox.pack_start(butt3, False)

        hbox.pack_start(butt2a, False)
        hbox.pack_start(butt3a, False)

        hbox.pack_start(butt5, False)
        hbox.pack_start(butt5a, False)

        hbox.pack_start(butt7, False)
        hbox.pack_start(lab3, False)
        hbox.pack_start(self.butt4, False)
        hbox.pack_start(lab4, False)
        hbox.pack_start(butt6, False)
        hbox.pack_start(lab1)
        hbox.pack_start(lab2, False)
        self.hbox = hbox

        vbox.pack_end(hbox, False)
        self.prog = lab1

        vpaned.add(sw2)
        vpaned.add2(vbox)
        hpaned.add2(vpaned)

        treeview = self.create_tree()
        treeview.connect("row-activated", self.tree_sel)
        treeview.connect("cursor-changed", self.tree_sel_row)
        treeview.connect("key-press-event", self.key_press_event3)
        self.treeview = treeview

        sw3 = gtk.ScrolledWindow()
        sw3.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw3.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw3.add(treeview)
        frame2 = gtk.Frame()
        frame2.add(sw3)
        hpaned.add(frame2)
        self.hpaned = hpaned
        hpaned.set_position(200)
        vpaned.set_position(1)
        self.iter = self.buffer_1.get_iter_at_offset(0)
        self.iter2 = self.buffer_2.get_iter_at_offset(0)
        self.set_focus(view1)
        self.show_all()

        if self.conf.fullscreen:
            #self.set_default_size(www, hhh)
            self.window.fullscreen()
            self.full = True
            self.hpaned.set_position(0)
Example #7
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self,
            name="Boundary Conditions",
            ordering=230,
            tip=
            "Set field and flux boundary conditions on the mesh's boundaries.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              callback=self.meshCB,
                                              scope=self)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)
        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)
        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)
        switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB)

        bcbuildframe = gtk.Frame()
        gtklogger.setWidgetName(bcbuildframe, 'Condition')
        bcbuildframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(bcbuildframe, expand=1, fill=1)
        bcbuildbox = gtk.VBox(spacing=2)
        bcbuildframe.add(bcbuildbox)

        # Buttons for creating, editing and removing boundary conditions

        align = gtk.Alignment(xalign=0.5)
        bcbuildbox.pack_start(align, expand=0, fill=0, padding=3)
        bcbuttons = gtk.HBox(homogeneous=1, spacing=3)
        align.add(bcbuttons)

        self.bcNew = gtk.Button("New...")
        gtklogger.setWidgetName(self.bcNew, 'New')
        gtklogger.connect(self.bcNew, "clicked", self.bcNew_CB)
        tooltips.set_tooltip_text(
            self.bcNew, "Create a new boundary condition in the current mesh.")
        bcbuttons.pack_start(self.bcNew, expand=1, fill=1)

        self.bcRename = gtk.Button("Rename...")
        gtklogger.setWidgetName(self.bcRename, 'Rename')
        gtklogger.connect(self.bcRename, 'clicked', self.bcRename_CB)
        tooltips.set_tooltip_text(self.bcRename,
                                  "Rename the selected boundary condition.")
        bcbuttons.pack_start(self.bcRename, expand=1, fill=1)

        self.bcEdit = gtk.Button("Edit...")
        gtklogger.setWidgetName(self.bcEdit, 'Edit')
        gtklogger.connect(self.bcEdit, 'clicked', self.bcEdit_CB)
        tooltips.set_tooltip_text(self.bcEdit,
                                  "Edit the selected boundary condition.")
        bcbuttons.pack_start(self.bcEdit, expand=1, fill=1)

        self.bcCopy = gtk.Button("Copy...")
        gtklogger.setWidgetName(self.bcCopy, 'Copy')
        gtklogger.connect(self.bcCopy, 'clicked', self.bcCopy_CB)
        tooltips.set_tooltip_text(
            self.bcCopy,
            "Copy the selected boundary condition to another mesh.")
        bcbuttons.pack_start(self.bcCopy, expand=1, fill=1)

        self.bcCopyAll = gtk.Button("Copy All...")
        gtklogger.setWidgetName(self.bcCopyAll, 'CopyAll')
        gtklogger.connect(self.bcCopyAll, 'clicked', self.bcCopyAll_CB)
        tooltips.set_tooltip_text(
            self.bcCopyAll,
            "Copy all the boundary conditions to another mesh.")
        bcbuttons.pack_start(self.bcCopyAll, expand=1, fill=1)

        self.bcDel = gtk.Button("Delete")
        gtklogger.setWidgetName(self.bcDel, 'Delete')
        gtklogger.connect(self.bcDel, "clicked", self.bcDel_CB)
        tooltips.set_tooltip_text(self.bcDel,
                                  "Remove the selected boundary condition.")
        bcbuttons.pack_start(self.bcDel, expand=1, fill=1)

        # List of boundary conditions
        bcscroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(bcscroll, "BCScroll")
        bcbuildbox.pack_start(bcscroll, expand=1, fill=1)
        bcscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.bclist = BCList(self)
        bcscroll.add(self.bclist.gtk)

        self.bclist.update(None)

        switchboard.requestCallbackMain(("new who", "Microstructure"),
                                        self.newMSorSkeleton)
        switchboard.requestCallbackMain(("new who", "Skeleton"),
                                        self.newMSorSkeleton)

        # Callbacks for when the mesh changes state internally.
        switchboard.requestCallbackMain("boundary conditions changed",
                                        self.newBCs)
        switchboard.requestCallbackMain("boundary conditions toggled",
                                        self.toggleBCs)
        switchboard.requestCallbackMain("field defined", self.fieldDefined)
        switchboard.requestCallbackMain("equation activated",
                                        self.eqnActivated)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("mesh boundaries changed",
                                        self.newMeshBoundaries)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.statusChanged)
Example #8
0
    def __init_window(self):
        # Start pyGTK setup
        self.window = gtk.Window()
        self.window.set_title(_("Openbox Logout"))

        self.window.connect("destroy", self.quit)
        self.window.connect("key-press-event", self.on_keypress)
        self.window.connect("window-state-event", self.on_window_state_change)

        if not self.window.is_composited():
            self.logger.debug("No compositing, enabling rendered effects")
            # Window isn't composited, enable rendered effects
            self.rendered_effects = True
        else:
            # Link in Cairo rendering events
            self.window.connect('expose-event', self.on_expose)
            self.window.connect('screen-changed', self.on_screen_changed)
            self.on_screen_changed(self.window)
            self.rendered_effects = False

        self.window.set_size_request(620, 200)
        self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black"))

        self.window.set_decorated(False)
        self.window.set_position(gtk.WIN_POS_CENTER)

        # Check monitor
        screen = gtk.gdk.screen_get_default()
        if screen.get_n_monitors() < self.monitor:
            self.monitor = screen.get_n_monitors()

        geometry = screen.get_monitor_geometry(self.monitor)
        width = geometry.width
        height = geometry.height
        x = geometry.x
        y = geometry.y

        # Create the main panel box
        self.mainpanel = gtk.HBox()

        # Create the button box
        self.buttonpanel = gtk.HButtonBox()
        self.buttonpanel.set_spacing(10)

        # Pack in the button box into the panel box, with two padder boxes
        self.mainpanel.pack_start(gtk.VBox())
        self.mainpanel.pack_start(self.buttonpanel, False, False)
        self.mainpanel.pack_start(gtk.VBox())

        # Add the main panel to the window
        self.window.add(self.mainpanel)

        for button in self.button_list:
            self.__add_button(button, self.buttonpanel)

        if self.rendered_effects == True:
            self.logger.debug("Stepping though render path")
            w = gtk.gdk.get_default_root_window()
            pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width,
                                height)
            pb = pb.get_from_drawable(w, w.get_colormap(), x, y, 0, 0, width,
                                      height)

            self.logger.debug("Rendering Fade")
            # Convert Pixbuf to PIL Image
            wh = (pb.get_width(), pb.get_height())
            pilimg = Image.fromstring("RGB", wh, pb.get_pixels())

            pilimg = pilimg.point(lambda p: (p * self.opacity) / 255)

            # "Convert" the PIL to Pixbuf via PixbufLoader
            buf = StringIO.StringIO()
            pilimg.save(buf, "ppm")
            del pilimg
            loader = gtk.gdk.PixbufLoader("pnm")
            loader.write(buf.getvalue())
            pixbuf = loader.get_pixbuf()

            # Cleanup IO
            buf.close()
            loader.close()

            pixmap, mask = pixbuf.render_pixmap_and_mask()
            # width, height = pixmap.get_size()
        else:
            pixmap = None

        self.window.set_app_paintable(True)
        self.window.resize(width, height)
        self.window.realize()

        if pixmap:
            self.window.window.set_back_pixmap(pixmap, False)
        self.window.move(x, y)
Example #9
0
    buttons['MachUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
    buttons['ReDown'] = gtk.ToolButton(gtk.STOCK_GO_BACK)
    buttons['ReDisp'] = gtk.Button("")
    buttons['ReUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
    buttons['NEDown'] = gtk.ToolButton(gtk.STOCK_GO_BACK)
    buttons['NEDisp'] = gtk.Button("")
    buttons['NEUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)

    fig = Figure()
    canvas = FigureCanvas(fig)  # a gtk.DrawingArea
    nav = NavigationToolbar(canvas, win)
    nav.set_size_request(250, 35)

    sep = [gtk.SeparatorToolItem() for i in range(10)]

    toolbar = gtk.HBox(False, 2)
    toolbar.pack_start(buttons['New'], False, False, 0)
    toolbar.pack_start(buttons['Open'], False, False, 0)
    toolbar.pack_start(buttons['Save'], False, False, 0)
    toolbar.pack_start(sep[0], False, False, 0)
    toolbar.pack_start(nav, False, False, 0)
    toolbar.pack_start(sep[1], False, False, 0)
    toolbar.pack_start(combobox, False, False, 0)
    toolbar.pack_start(sep[2], False, False, 0)
    toolbar.pack_start(buttons['ReMesh'], False, False, 0)
    toolbar.pack_start(sep[3], False, False, 0)
    toolbar.pack_start(buttons['MachDown'], False, False, 0)
    toolbar.pack_start(buttons['MachDisp'], False, False, 0)
    toolbar.pack_start(buttons['MachUp'], False, False, 0)
    toolbar.pack_start(sep[4], False, False, 0)
    toolbar.pack_start(buttons['ReDown'], False, False, 0)
Example #10
0
    def setup_ui(self):
        """Creates the actual UI."""

        # create a floating toplevel window and set some title and border
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.window.set_title(self.app_name)
        self.window.set_border_width(8)

        # connect delete and destroy events
        self.window.connect("destroy", self.destroy)
        self.window.connect("delete-event", self.destroy)

        # This is our main container, vertically ordered.
        self.box_container = gtk.VBox(False, 5)
        self.box_container.show()

        self.notebook = gtk.Notebook()
        self.page_latex = gtk.HBox(False, 5)
        self.page_latex.set_border_width(8)
        self.page_latex.show()
        self.page_log = gtk.HBox(False, 5)
        self.page_log.set_border_width(8)
        self.page_log.show()
        self.page_settings = gtk.HBox(False, 5)
        self.page_settings.set_border_width(8)
        self.page_settings.show()
        self.page_help = gtk.VBox(False, 5)
        self.page_help.set_border_width(8)
        self.page_help.show()
        self.notebook.append_page(self.page_latex, gtk.Label("LaTeX"))
        self.notebook.append_page(self.page_log, gtk.Label("Log"))
        self.notebook.append_page(self.page_settings, gtk.Label("Settings"))
        self.notebook.append_page(self.page_help, gtk.Label("Help"))
        self.notebook.show()

        # First component: The input text view for the LaTeX code.
        # It lives in a ScrolledWindow so we can get some scrollbars when the
        # text is too long.
        self.text = gtk.TextView(self.syntax_buffer)
        self.text.get_buffer().set_text(self.src)
        self.text.show()
        self.text_container = gtk.ScrolledWindow()
        self.text_container.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
        self.text_container.set_shadow_type(gtk.SHADOW_IN)
        self.text_container.add(self.text)
        self.text_container.set_size_request(400, 200)
        self.text_container.show()

        self.page_latex.pack_start(self.text_container)


        # Second component: The log view
        self.log_view = gtk.TextView()
        self.log_view.show()
        self.log_container = gtk.ScrolledWindow()
        self.log_container.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
        self.log_container.set_shadow_type(gtk.SHADOW_IN)
        self.log_container.add(self.log_view)
        self.log_container.set_size_request(400, 200)
        self.log_container.show()

        self.page_log.pack_start(self.log_container)


        # third component: settings
        self.settings_container = gtk.Table(2,2)
        self.settings_container.set_row_spacings(8)
        self.settings_container.show()

        self.label_preamble = gtk.Label("Preamble")
        self.label_preamble.set_alignment(0, 0.5)
        self.label_preamble.show()
        self.preamble = gtk.FileChooserButton("...")
        if 'preamble' in self.settings and os.path.exists(self.settings['preamble']):
            self.preamble.set_filename(self.settings['preamble'])
        self.preamble.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
        self.preamble.show()
        self.settings_container.attach(self.label_preamble, yoptions=gtk.SHRINK,
            left_attach=0, right_attach=1, top_attach=0, bottom_attach=1)
        self.settings_container.attach(self.preamble, yoptions=gtk.SHRINK,
            left_attach=1, right_attach=2, top_attach=0, bottom_attach=1)

        self.label_scale = gtk.Label("Scale")
        self.label_scale.set_alignment(0, 0.5)
        self.label_scale.show()
        self.scale_adjustment = gtk.Adjustment(value=1.0, lower=0, upper=100,
                                               step_incr=0.1)
        self.scale = gtk.SpinButton(adjustment=self.scale_adjustment, digits=1)
        if 'scale' in self.settings:
            self.scale.set_value(float(self.settings['scale']))
        self.scale.show()
        self.settings_container.attach(self.label_scale, yoptions=gtk.SHRINK,
            left_attach=0, right_attach=1, top_attach=1, bottom_attach=2)
        self.settings_container.attach(self.scale, yoptions=gtk.SHRINK,
            left_attach=1, right_attach=2, top_attach=1, bottom_attach=2)

        self.page_settings.pack_start(self.settings_container)


        # help tab
        self.help_label = gtk.Label()
        self.help_label.set_markup(Ui.help_text)
        self.help_label.set_line_wrap(True)
        self.help_label.show()

        self.about_label = gtk.Label()
        self.about_label.set_markup(Ui.about_text)
        self.about_label.set_line_wrap(True)
        self.about_label.show()

        self.separator_help = gtk.HSeparator()
        self.separator_help.show()

        self.page_help.pack_start(self.help_label)
        self.page_help.pack_start(self.separator_help)
        self.page_help.pack_start(self.about_label)


        self.box_container.pack_start(self.notebook, True, True)

        # separator between buttonbar and notebook
        self.separator_buttons = gtk.HSeparator()
        self.separator_buttons.show()

        self.box_container.pack_start(self.separator_buttons, False, False)

        # the button bar
        self.box_buttons = gtk.HButtonBox()
        self.box_buttons.set_layout(gtk.BUTTONBOX_END)
        self.box_buttons.show()

        self.button_render = gtk.Button(stock=gtk.STOCK_APPLY)
        self.button_cancel = gtk.Button(stock=gtk.STOCK_CLOSE)
        self.button_render.set_flags(gtk.CAN_DEFAULT)
        self.button_render.connect("clicked", self.render, None)
        self.button_cancel.connect("clicked", self.cancel, None)
        self.button_render.show()
        self.button_cancel.show()

        self.box_buttons.pack_end(self.button_cancel)
        self.box_buttons.pack_end(self.button_render)

        self.box_container.pack_start(self.box_buttons, False, False)

        self.window.add(self.box_container)
        self.window.set_default(self.button_render)
        self.window.show()
Example #11
0
    def ui_init(self):
        self._fullscreen = False
        self._showing_info = False

        # FIXME: if _thumb_tray becomes some kind of button group, we wouldn't
        # have to track which recd is active
        self._active_recd = None

        self.connect_after('key-press-event', self._key_pressed)

        self._active_toolbar_idx = 0

        self._toolbar_box = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        self._toolbar_box.toolbar.insert(activity_button, 0)
        self.set_toolbar_box(self._toolbar_box)
        self._toolbar = self.get_toolbar_box().toolbar

        tool_group = None
        if self.model.get_has_camera():
            self._photo_button = RadioToolButton()
            self._photo_button.props.group = tool_group
            tool_group = self._photo_button
            self._photo_button.props.icon_name = 'camera-external'
            self._photo_button.props.label = _('Photo')
            self._photo_button.mode = constants.MODE_PHOTO
            self._photo_button.connect('clicked', self._mode_button_clicked)
            self._toolbar.insert(self._photo_button, -1)

            self._video_button = RadioToolButton()
            self._video_button.props.group = tool_group
            self._video_button.props.icon_name = 'media-video'
            self._video_button.props.label = _('Video')
            self._video_button.mode = constants.MODE_VIDEO
            self._video_button.connect('clicked', self._mode_button_clicked)
            self._toolbar.insert(self._video_button, -1)
        else:
            self._photo_button = None
            self._video_button = None

        self._audio_button = RadioToolButton()
        self._audio_button.props.group = tool_group
        self._audio_button.props.icon_name = 'media-audio'
        self._audio_button.props.label = _('Audio')
        self._audio_button.mode = constants.MODE_AUDIO
        self._audio_button.connect('clicked', self._mode_button_clicked)
        self._toolbar.insert(self._audio_button, -1)

        self._toolbar.insert(gtk.SeparatorToolItem(), -1)

        self._toolbar_controls = RecordControl(self._toolbar)

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self._toolbar.insert(separator, -1)
        self._toolbar.insert(StopButton(self), -1)
        self.get_toolbar_box().show_all()

        main_box = gtk.VBox()
        self.set_canvas(main_box)
        main_box.get_parent().modify_bg(gtk.STATE_NORMAL, COLOR_BLACK)
        main_box.show()

        self._media_view = MediaView()
        self._media_view.connect('media-clicked', self._media_view_media_clicked)
        self._media_view.connect('pip-clicked', self._media_view_pip_clicked)
        self._media_view.connect('info-clicked', self._media_view_info_clicked)
        self._media_view.connect('full-clicked', self._media_view_full_clicked)
        self._media_view.connect('tags-changed', self._media_view_tags_changed)
        self._media_view.show()

        self._controls_hbox = gtk.HBox()
        self._controls_hbox.show()

        self._shutter_button = ShutterButton()
        self._shutter_button.connect("clicked", self._shutter_clicked)
        self._controls_hbox.pack_start(self._shutter_button, expand=True, fill=False)

        self._countdown_image = CountdownImage()
        self._controls_hbox.pack_start(self._countdown_image, expand=True, fill=False)

        self._play_button = PlayButton()
        self._play_button.connect('clicked', self._play_pause_clicked)
        self._controls_hbox.pack_start(self._play_button, expand=False)

        self._playback_scale = PlaybackScale(self.model)
        self._controls_hbox.pack_start(self._playback_scale, expand=True, fill=True)

        self._progress = ProgressInfo()
        self._controls_hbox.pack_start(self._progress, expand=True, fill=True)

        self._title_label = gtk.Label()
        self._title_label.set_markup("<b><span foreground='white'>"+_('Title:')+'</span></b>')
        self._controls_hbox.pack_start(self._title_label, expand=False)

        self._title_entry = gtk.Entry()
        self._title_entry.modify_bg(gtk.STATE_INSENSITIVE, COLOR_BLACK)
        self._title_entry.connect('changed', self._title_changed)
        self._controls_hbox.pack_start(self._title_entry, expand=True, fill=True, padding=10)

        self._record_container = RecordContainer(self._media_view, self._controls_hbox)
        main_box.pack_start(self._record_container, expand=True, fill=True,
                padding=6)
        self._record_container.show()

        self._thumb_tray = HTray()
        self._thumb_tray.set_size_request(-1, 150)
        main_box.pack_end(self._thumb_tray, expand=False)
        self._thumb_tray.show_all()
Example #12
0
    def create_window(self):
        self.window = gtk.Window()
        title = "Log out " + getpass.getuser() + "? Choose an option:"
        self.window.set_title(title)
        self.window.set_border_width(5)
        self.window.set_size_request(500, 80)
        self.window.set_resizable(False)
        self.window.set_keep_above(True)
        self.window.stick
        self.window.set_position(1)
        self.window.connect("delete_event", gtk.main_quit)
        windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
        self.window.set_icon(windowicon)

        
        #Create HBox for buttons
        self.button_box = gtk.HBox()
        self.button_box.show()
        
        #Cancel button
        self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL)
        self.cancel.set_border_width(4)
        self.cancel.connect("clicked", self.cancel_action)
        self.button_box.pack_start(self.cancel)
        self.cancel.show()
        
        #Logout button
        self.logout = gtk.Button("_Log out")
        self.logout.set_border_width(4)
        self.logout.connect("clicked", self.logout_action)
        self.button_box.pack_start(self.logout)
        self.logout.show()
        
        #Suspend button
        self.suspend = gtk.Button("_Suspend")
        self.suspend.set_border_width(4)
        self.suspend.connect("clicked", self.suspend_action)
        self.button_box.pack_start(self.suspend)
        self.suspend.show()
        
        #Reboot button
        self.reboot = gtk.Button("_Reboot")
        self.reboot.set_border_width(4)
        self.reboot.connect("clicked", self.reboot_action)
        self.button_box.pack_start(self.reboot)
        self.reboot.show()
        
        #Shutdown button
        self.shutdown = gtk.Button("_Power off")
        self.shutdown.set_border_width(4)
        self.shutdown.connect("clicked", self.shutdown_action)
        self.button_box.pack_start(self.shutdown)
        self.shutdown.show()
        
        #Create HBox for status label
        self.label_box = gtk.HBox()
        self.label_box.show()
        self.status = gtk.Label()
        self.status.show()
        self.label_box.pack_start(self.status)
        
        #Create VBox and pack the above HBox's
        self.vbox = gtk.VBox()
        self.vbox.pack_start(self.button_box)
        self.vbox.pack_start(self.label_box)
        self.vbox.show()
        
        self.window.add(self.vbox)
        self.window.show()
Example #13
0
    def __init__(self):
        self.root = os.getcwd()
        self.filemodel = gtk.TreeStore(str, str, bool)
        self.fileview = self.get_view('Files', self.filemodel, 'fileview')
        self.colmodel = gtk.TreeStore(str, str, str)
        self.colview = self.get_view('Collections', self.colmodel, 'colview')

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Kindelabra v%s" % VERSION)
        self.window.set_default_size(1000, 700)
        self.window.connect("destroy", gtk.main_quit)
        self.accel_group = gtk.AccelGroup()
        self.window.add_accel_group(self.accel_group)
        vbox_main = gtk.VBox()
        filechooserdiag = gtk.FileChooserDialog(
            "Select your Kindle folder", self.window,
            gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
             gtk.RESPONSE_ACCEPT))
        filechooserdiag.set_current_folder(os.path.join(self.root, 'system'))
        self.filechooser = gtk.FileChooserButton(filechooserdiag)
        self.filechooser.connect("current-folder-changed", self.load)

        file_toolbar = gtk.HBox()
        file_toolbar.pack_start(self.filechooser, True, True, 2)
        file_toolbar.pack_start(
            self.get_button('gtk-refresh', 'Refresh files', self.refresh),
            False, True, 2)
        file_toolbar.pack_start(
            self.get_button('gtk-open', 'Open collection file',
                            self.open_collection, "O"), False, True, 2)
        file_toolbar.pack_start(gtk.VSeparator(), False, True, 2)
        file_toolbar.pack_start(
            self.get_button('gtk-save', 'Save collection file', self.save,
                            "S"), False, True, 2)

        hbox_main = gtk.HBox()
        filescroll = gtk.ScrolledWindow()
        filescroll.add(self.fileview)
        colscroll = gtk.ScrolledWindow()
        colscroll.add(self.colview)
        col_toolbar = gtk.VBox()
        col_toolbar.pack_start(
            self.get_button('gtk-new', 'Create new collection',
                            self.add_collection, "N"), False, True, 2)
        col_toolbar.pack_start(
            self.get_button('gtk-edit', 'Rename collection',
                            self.rename_collection, "E"), False, True, 2)
        col_toolbar.pack_start(
            self.get_button('gtk-remove', 'Delete collection',
                            self.del_collection), False, True, 2)
        col_toolbar.pack_start(gtk.HSeparator(), False, True, 7)
        col_toolbar.pack_start(
            self.get_button('gtk-go-forward', 'Add book to collection',
                            self.add_file), False, True, 2)
        col_toolbar.pack_start(
            self.get_button('gtk-go-back', 'Remove book from collection',
                            self.del_file), False, True, 2)
        col_toolbar.pack_start(gtk.HSeparator(), False, True, 7)
        col_toolbar.pack_start(
            self.get_button('gtk-revert-to-saved', 'Revert collections',
                            self.revert), False, True, 2)

        hbox_main.add(filescroll)
        hbox_main.pack_start(col_toolbar, False, False, 2)
        hbox_main.add(colscroll)

        self.statusbar = gtk.Statusbar()

        vbox_main.pack_start(file_toolbar, False)
        vbox_main.add(hbox_main)
        vbox_main.pack_start(self.statusbar, False)

        self.window.add(vbox_main)
        self.window.show_all()
        self.status("Select your Kindle's home folder")
        gtk.main()
Example #14
0
	def __init__(self, notebookinfo=None, port=8080, public=True, **opts):
		'''Constructor
		@param notebookinfo: the notebook location
		@param port: the http port to serve on
		@param public: allow connections to the server from other
		computers - if C{False} can only connect from localhost
		@param opts: options for L{WWWInterface.__init__()}
		'''
		gtk.Window.__init__(self)
		self.set_title('Zim - ' + _('Web Server')) # T: Window title
		self.set_border_width(10)
		self.interface_opts = opts
		self.httpd = None
		self._source_id = None

		# Widgets
		self.status_label = gtk.Label()
		self.status_label.set_markup('<i>'+_('Server not started')+'</i>')
			# T: Status in web server gui
		self.start_button = IconButton('gtk-media-play')
		self.start_button.connect('clicked', lambda o: self.start())
		self.stop_button = IconButton('gtk-media-stop')
		self.stop_button.connect('clicked', lambda o: self.stop())
		self.stop_button.set_sensitive(False)

		if gtk.gtk_version >= (2, 10) \
		and gtk.pygtk_version >= (2, 10):
			self.link_button = gtk.LinkButton('')
			self.link_button.set_sensitive(False)
		else:
			self.link_button = None

		self.notebookcombobox = NotebookComboBox(current=notebookinfo)
		self.open_button = IconButton('gtk-index')
		self.open_button.connect('clicked', lambda *a: NotebookDialog(self).run())

		self.portentry = gtk.SpinButton()
		self.portentry.set_numeric(True)
		self.portentry.set_range(80, 10000)
		self.portentry.set_increments(1, 80)
		self.portentry.set_value(port)

		self.public_checkbox = gtk.CheckButton(label=_('Allow public access'))
			# T: Checkbox in web server gui
		self.public_checkbox.set_active(public)


		# Build the interface
		vbox = gtk.VBox()
		self.add(vbox)

		hbox = gtk.HBox(spacing=12)
		hbox.pack_start(self.start_button, False)
		hbox.pack_start(self.stop_button, False)
		hbox.pack_start(self.status_label, False)
		vbox.add(hbox)

		table = input_table_factory((
			(_('Notebook'), self.notebookcombobox, self.open_button),
				# T: Field in web server gui
			(_('Port'), self.portentry),
				# T: Field in web server gui for HTTP port (e.g. port 80)
			self.public_checkbox
		))
		vbox.add(table)

		if self.link_button:
			hbox = gtk.HBox()
			hbox.pack_end(self.link_button, False)
			vbox.add(hbox)
Example #15
0
def ofd(fname=None):

    dialog = gtk.Dialog("pyedit: Open File", None,
                        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
                         gtk.RESPONSE_ACCEPT))

    dialog.set_default_response(gtk.RESPONSE_ACCEPT)

    dialog.connect("key-press-event", area_key, dialog)
    dialog.connect("key-release-event", area_key, dialog)

    dialog.set_default_size(800, 600)

    # Spacers
    label1 = gtk.Label("   ")
    label2 = gtk.Label("   ")
    label3 = gtk.Label("   ")
    label4 = gtk.Label("   ")
    label5 = gtk.Label("   ")
    label6 = gtk.Label("   ")
    label7 = gtk.Label("   ")
    label8 = gtk.Label("   ")
    label10 = gtk.Label("   ")

    dialog.label11 = gtk.Label("   ")
    dialog.label12 = gtk.Label("   ")

    dialog.pbox = gtk.HBox()
    fill_path(dialog)

    dialog.vbox.pack_start(label4, False)
    dialog.vbox.pack_start(dialog.pbox, False)
    dialog.vbox.pack_start(label10, False)

    warnings.simplefilter("ignore")
    dialog.entry = gtk.Entry()
    warnings.simplefilter("default")

    dialog.entry.set_activates_default(True)
    dialog.entry.set_text(fname)

    hbox2 = gtk.HBox()
    hbox2.pack_start(label6, False)
    hbox2.pack_start(dialog.entry)
    hbox2.pack_start(label7, False)

    dialog.vbox.pack_start(hbox2, False)
    dialog.vbox.pack_start(label8, False)

    dialog.ts = gtk.ListStore(str, str, str, str)
    tview = create_ftree(dialog.ts)

    scroll = gtk.ScrolledWindow()

    tview.connect("row-activated", tree_sel, dialog)
    tview.connect("cursor-changed", tree_sel_row, dialog)
    dialog.tview = tview

    scroll.add(tview)

    frame2 = gtk.Frame()
    frame2.add(scroll)

    hbox3 = gtk.HBox()
    hbox3.pack_start(label1, False)
    hbox3.pack_start(frame2)
    hbox3.pack_start(label2, False)

    dialog.vbox.pack_start(hbox3)
    dialog.vbox.pack_start(label3, False)

    dialog.show_all()
    populate(dialog)
    dialog.set_focus(tview)
    #dialog.set_focus(dialog.entry)

    response = dialog.run()

    if response == gtk.RESPONSE_ACCEPT:
        res = os.path.realpath(dialog.entry.get_text())
    else:
        res = ""
    #print "response", response, "res", res
    dialog.destroy()

    return res
Example #16
0
    def __init__(self, filename=None):
        # initialise some variables:
        self.ncfn = filename
        self.pc = None
        self.cfacs = None
        self.proj = None
        self.src_proj = None

        self.lon1 = None
        self.lon2 = None
        self.lat1 = None
        self.lat2 = None

        ###############
        ## GTK setup ##
        ###############

        # create new window
        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)

        ######################
        # setup window
        ######################
        self.win.set_border_width(10)
        self.win.set_default_size(600, 400)
        self.win.set_title('SMC Gridded Data Plotter')

        ######################
        # add the GTK canvas:
        ######################
        self.fig = plt.Figure(figsize=(5, 4), dpi=100)
        self.canvas = FigureCanvas(self.fig)

        ################
        # Add menu bar #
        ################
        menu_bar = gtk.MenuBar()
        file_menu = gtk.Menu()
        open_item = gtk.MenuItem("Open")
        exit_item = gtk.MenuItem("Exit")
        file_menu.append(open_item)
        file_menu.append(exit_item)

        open_item.connect("activate", self.load_event)

        root_menu = gtk.MenuItem("File")
        root_menu.set_submenu(file_menu)
        menu_bar.append(root_menu)

        ###########
        # Controls
        ##########

        # buttons:
        btnPlot = gtk.Button('Update Plot')
        btnPrev = gtk.Button('Prev Time')
        btnNext = gtk.Button('Next Time')

        # Field combo box:
        store = gtk.ListStore(str, str)
        self.cbox_field = gtk.ComboBox(store)
        cell = gtk.CellRendererText()
        self.cbox_field.pack_start(cell, True)
        self.cbox_field.add_attribute(cell, 'text', 1)
        store.append(['hs', 'sig wave heihgt'])

        # Times combo box:
        store = gtk.ListStore(int, str)
        self.cbox_times = gtk.ComboBox(store)
        cell = gtk.CellRendererText()
        self.cbox_times.pack_start(cell, True)
        self.cbox_times.add_attribute(cell, 'text', 1)
        #for i in range(1,61):
        #    store.append([i-1, 'T+%03d' % i])

        # Domain combo box:
        store = gtk.ListStore(str, float, float, float, float)
        self.cbox_domains = gtk.ComboBox(store)
        cell = gtk.CellRendererText()
        self.cbox_domains.pack_start(cell, True)
        self.cbox_domains.add_attribute(cell, 'text', 0)
        store.append(
            ['Full Domain (could be slow)', -999.9, -999.9, -999.9, -999.9])
        store.append(['UK', 35.0, 70.0, -15.0, 10.0])
        store.append(['South West UK', 49.4, 51.5, -6.7, -1.6])
        store.append(['Mediterranean', 29.5, 46.5, -6.0, 36.5])
        store.append(['North Atlantic', 20.0, 70.0, -90, 30])
        store.append(['West Pacific', -70.0, 70.0, 120, 200])
        store.append(['East Pacific', -70.0, 70.0, -160, -68])
        store.append(['Arabian Gulf', 23.0, 30.5, 47.5, 59.5])
        store.append(['Caspian Sea', 36.0, 47.5, 46.0, 55.5])
        store.append(['Black Sea', 40.5, 47.1, 27.0, 42.0])
        store.append(['Caribbean', 10.0, 27.5, -86.5, -58.5])
        store.append(['South China Sea', -9.5, 24.0, 98.0, 128.0])
        store.append(['Australasia', -48, 0.0, 105.0, 179.0])
        self.cbox_domains.set_active(1)

        # Projections:
        store = gtk.ListStore(object, str)
        self.cbox_proj = gtk.ComboBox(store)
        cell = gtk.CellRendererText()
        self.cbox_proj.pack_start(cell, True)
        self.cbox_proj.add_attribute(cell, 'text', 1)
        store.append([ccrs.PlateCarree(), 'Plate Carree'])
        store.append([
            ccrs.RotatedPole(pole_latitude=37.5, pole_longitude=177.5),
            'Euro Rotated Pole'
        ])
        store.append([ccrs.Robinson(), 'Robinson'])
        store.append([ccrs.Mercator(), 'Mercator'])
        store.append([ccrs.Geostationary(), 'Geostationary'])

        self.cbox_proj.set_active(0)

        # coastlines:
        store = gtk.ListStore(object, str)
        self.cbox_coast = gtk.ComboBox(store)
        cell = gtk.CellRendererText()
        self.cbox_coast.pack_start(cell, True)
        self.cbox_coast.add_attribute(cell, 'text', 1)
        store.append([None, 'None'])
        store.append(['10m', 'High res (10m)'])
        store.append(['50m', 'Medium res (50m)'])
        store.append(['110m', 'Low res (110m)'])

        self.cbox_coast.set_active(3)
        self.coast = '110m'

        # lat/lon ranges:
        self.inLat1 = gtk.Entry()
        self.inLat2 = gtk.Entry()
        self.inLon1 = gtk.Entry()
        self.inLon2 = gtk.Entry()
        self.domain_changed_event(
            self.cbox_domains)  # update with default domain

        # Cell size selection
        cellsbox = gtk.HBox(homogeneous=False, spacing=5)
        self.chkf1 = gtk.CheckButton("3km")
        self.chkf2 = gtk.CheckButton("6km")
        self.chkf3 = gtk.CheckButton("12km")
        self.chkf4 = gtk.CheckButton("25km")
        cellsbox.pack_end(self.chkf1)
        cellsbox.pack_end(self.chkf2)
        cellsbox.pack_end(self.chkf3)
        cellsbox.pack_end(self.chkf4)

        # Colour range box:
        crangebox = gtk.HBox(homogeneous=False, spacing=5)
        self.cmin = gtk.Entry()
        self.cmax = gtk.Entry()
        self.cauto = gtk.CheckButton('Auto')
        crangebox.pack_start(self.cmin)
        crangebox.pack_start(self.cmax)
        crangebox.pack_start(self.cauto)
        self.cauto.set_active(True)
        self.cmin.set_sensitive(False)
        self.cmax.set_sensitive(False)

        self.cauto.connect('toggled', self.cauto_changed_event)

        ## controls layout
        grid = gtk.Table(rows=8, columns=3)
        grid.attach(gtk.Label('Field'), 0, 1, 0, 1, yoptions=gtk.SHRINK)
        grid.attach(gtk.Label('Time'), 0, 1, 1, 2, yoptions=gtk.SHRINK)
        grid.attach(gtk.Label('Projection'), 0, 1, 2, 3, yoptions=gtk.SHRINK)
        grid.attach(gtk.Label('Coastline'), 0, 1, 3, 4, yoptions=gtk.SHRINK)
        grid.attach(gtk.Label('Domain '), 0, 1, 4, 5, yoptions=gtk.SHRINK)
        grid.attach(gtk.Label('Lat Range'), 0, 1, 5, 6, yoptions=gtk.SHRINK)
        grid.attach(gtk.Label('Lon Range'), 0, 1, 6, 7, yoptions=gtk.SHRINK)
        grid.attach(gtk.Label('Cells'), 0, 1, 7, 8, yoptions=gtk.SHRINK)
        grid.attach(gtk.Label('Colour range'), 0, 1, 8, 9, yoptions=gtk.SHRINK)

        grid.attach(self.cbox_field, 1, 3, 0, 1, yoptions=gtk.SHRINK)
        grid.attach(self.cbox_times, 1, 3, 1, 2, yoptions=gtk.SHRINK)
        grid.attach(self.cbox_proj, 1, 3, 2, 3, yoptions=gtk.SHRINK)
        grid.attach(self.cbox_coast, 1, 3, 3, 4, yoptions=gtk.SHRINK)
        grid.attach(self.cbox_domains, 1, 3, 4, 5, yoptions=gtk.SHRINK)
        grid.attach(self.inLat1, 1, 2, 5, 6, yoptions=gtk.SHRINK)
        grid.attach(self.inLat2, 2, 3, 5, 6, yoptions=gtk.SHRINK)
        grid.attach(self.inLon1, 1, 2, 6, 7, yoptions=gtk.SHRINK)
        grid.attach(self.inLon2, 2, 3, 6, 7, yoptions=gtk.SHRINK)
        grid.attach(cellsbox, 1, 3, 7, 8, yoptions=gtk.SHRINK)
        grid.attach(crangebox, 1, 3, 8, 9, yoptions=gtk.SHRINK)

        #grid.attach(btnPlot,                0, 1, 8, 9, yoptions=gtk.SHRINK, xoptions=gtk.SHRINK)
        # Hbox for plot buttons
        btn_hbox = gtk.HBox(homogeneous=False, spacing=5)
        btn_hbox.pack_start(btnPrev, True, False, 0)
        btn_hbox.pack_start(btnPlot, True, False, 0)
        btn_hbox.pack_start(btnNext, True, False, 0)

        ## File details text view
        txt = gtk.TextBuffer()
        txt.set_text('Please load a file')
        self.tv_file_details = gtk.TextView(txt)

        vbox = gtk.VBox(spacing=15)
        vbox.pack_start(grid, False)
        vbox.pack_start(btn_hbox, False)
        vbox.pack_end(self.tv_file_details, True)

        # plot controls
        from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
        toolbar = NavigationToolbar(self.canvas, self.win)
        #vbox.pack_end(toolbar, False, False)

        # Top level layout box:
        topbox = gtk.VBox()
        topbox.pack_start(menu_bar, expand=False, fill=True)

        box = gtk.HBox(homogeneous=False, spacing=5)
        topbox.pack_end(box)

        # canvas/toolbar layout
        plotbox = gtk.VBox(homogeneous=False, spacing=0)
        plotbox.pack_start(self.canvas, expand=True, fill=True)
        plotbox.pack_end(toolbar, False, False)

        box.pack_start(plotbox, expand=True, fill=True)
        box.pack_end(vbox, expand=False, fill=False)
        self.win.add(topbox)

        ###################
        # connect signals:
        ###################
        # destroy/delete:
        self.win.connect("delete_event", self.delete_event)
        self.win.connect("destroy", self.destroy)

        btnPlot.connect("clicked", self.plot_event)
        btnNext.connect("clicked", self.next_time_event)
        btnPrev.connect("clicked", self.prev_time_event)

        self.cbox_domains.connect('changed', self.domain_changed_event)

        # show window
        self.win.show_all()

        #### Load file, if passed in:
        if self.ncfn is not None:
            self.loadfile(self.ncfn)
Example #17
0
    def __init__(self, coord, kmx, kmy, layer, conf, force_update):
        self.layers = []

        def _zoom(zoom0, zoom1):
            out_hbox = gtk.HBox(False, 50)
            out_hbox.set_border_width(10)
            in_hbox = gtk.HBox(False, 20)
            in_hbox.pack_start(lbl("min:"), False)
            self.s_zoom0 = SpinBtn(zoom0)
            self.s_zoom0.set_digits(0)
            in_hbox.pack_start(self.s_zoom0)
            out_hbox.pack_start(in_hbox)

            in_hbox = gtk.HBox(False, 20)
            in_hbox.pack_start(lbl("max:"), False)
            self.s_zoom1 = SpinBtn(zoom1)
            self.s_zoom1.set_digits(0)
            in_hbox.pack_start(self.s_zoom1)
            out_hbox.pack_start(in_hbox)
            hbox = gtk.HBox()
            hbox.set_border_width(10)
            hbox.pack_start(myFrame(" Zoom ", out_hbox, 0))
            return hbox

        def _center(lat0, lon0):
            vbox = gtk.VBox(False, 5)
            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("latitude:"))
            self.e_lat0 = myEntry("%.6f" % lat0, 15, False)
            hbox.pack_start(self.e_lat0, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("longitude:"))
            self.e_lon0 = myEntry("%.6f" % lon0, 15, False)
            hbox.pack_start(self.e_lon0, False)
            vbox.pack_start(hbox)
            return myFrame(" Center ", vbox)

        def _area(kmx, kmy):
            vbox = gtk.VBox(False, 5)
            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("width:"))
            self.e_kmx = myEntry("%.6g" % kmx, 10, False)
            hbox.pack_start(self.e_kmx, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("height:"))
            self.e_kmy = myEntry("%.6g" % kmy, 10, False)
            hbox.pack_start(self.e_kmy, False)
            vbox.pack_start(hbox)
            return myFrame(" Area (km) ", vbox)

        def download_rclick(self, event, menu):
            if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
                menu.popup(None, None, None, event.button, event.time)

        def rclick_menu(active_layer, map_serv):
            menu = gtk.Menu()
            for layer in range(len(LAYER_NAMES)):
                self.layers.append(gtk.CheckMenuItem(LAYER_NAMES[layer]))
                if layer == active_layer:
                    self.layers[-1].set_active(True)
                else:
                    self.layers[-1].set_sensitive(layer in MAP_SERVICES[map_serv]['layers'])
                menu.append(self.layers[-1])
            menu.show_all()
            return menu

        def _buttons(strFolder, layer, conf):
            hbbox = gtk.HButtonBox()
            hbbox.set_border_width(10)
            hbbox.set_layout(gtk.BUTTONBOX_SPREAD)
            menu = rclick_menu(layer, MAP_SERVERS.index(conf.map_service))
            gtk.stock_add([(gtk.STOCK_HARDDISK, "_Download", 0, 0, "")])
            self.b_download = gtk.Button(stock=gtk.STOCK_HARDDISK)
            self.b_download.connect('clicked', self.start_download, strFolder)
            self.b_download.connect('event', download_rclick, menu)
            hbbox.pack_start(self.b_download)

            hbox = gtk.HBox()
            gtk.stock_add([(gtk.STOCK_UNDELETE, "", 0, 0, "")])
            self.b_open = gtk.Button(stock=gtk.STOCK_UNDELETE)
            self.b_open.connect('clicked', self.do_open, strFolder)
            hbox.pack_start(self.b_open, padding=25)
            if isdir(fldDown):
                hbbox.pack_start(hbox)

            self.b_pause = gtk.Button(stock='gtk-media-pause')
            self.b_pause.connect('clicked', self.do_pause)
            self.b_pause.set_sensitive(False)

            hbbox.pack_start(self.b_pause)
            return hbbox

        fldDown = join(conf.init_path, 'download')
        print "DLWindow(", coord, kmx, kmy, layer, ')'
        self.conf = conf
        self.force_update = force_update
        kmx = mapUtils.nice_round(kmx)
        kmy = mapUtils.nice_round(kmy)
        gtk.Window.__init__(self)
        lat0 = coord[0]
        lon0 = coord[1]
        zoom0 = max(MAP_MIN_ZOOM_LEVEL, coord[2] - 3)
        zoom1 = min(MAP_MAX_ZOOM_LEVEL, coord[2] + 1)

        vbox = gtk.VBox(False)
        hbox = gtk.HBox(False, 10)
        hbox.pack_start(_center(lat0, lon0))
        hbox.pack_start(_area(kmx, kmy))
        vbox.pack_start(hbox)
        vbox.pack_start(_zoom(zoom0, zoom1))
        vbox.pack_start(_buttons(fldDown, layer, conf))

        self.pbar = gtk.ProgressBar()
        self.pbar.set_text(" ")
        vbox.pack_start(self.pbar)
        self.add(vbox)

        self.set_title("GMapCatcher download")
        self.set_border_width(10)
        ico = mapPixbuf.ico()
        if ico:
            self.set_icon(ico)

        self.complete = []
        self.processing = False
        self.gmap = None
        self.downloader = None
        self.connect('delete-event', self.on_delete)
        self.connect('key-press-event', self.key_press)
        self.show_all()
Example #18
0
    def __init__(self,
                 categories,
                 category_message_time_tuples,
                 category_stock_ids,
                 default_size=None,
                 parent=None,
                 destroy_hook=None):
        super(ConsoleWindow, self).__init__()
        if parent is not None:
            self.set_transient_for(parent)
        if default_size is None:
            default_size = self.DEFAULT_SIZE
        self.set_default_size(*default_size)
        self.set_title(self.TITLE)
        self._filter_category = self.CATEGORY_ALL
        self.categories = categories
        self.category_icons = []
        for id_ in category_stock_ids:
            self.category_icons.append(
                self.render_icon(id_, gtk.ICON_SIZE_MENU))
        self._destroy_hook = destroy_hook
        top_vbox = gtk.VBox()
        top_vbox.show()
        self.add(top_vbox)

        message_scrolled_window = gtk.ScrolledWindow()
        message_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
                                           gtk.POLICY_AUTOMATIC)
        message_scrolled_window.show()
        self._message_treeview = gtk.TreeView()
        self._message_treeview.show()
        self._message_treeview.set_rules_hint(True)

        # Set up the category column (icons).
        category_column = gtk.TreeViewColumn()
        category_column.set_title(self.COLUMN_TITLE_CATEGORY)
        cell_category = gtk.CellRendererPixbuf()
        category_column.pack_start(cell_category, expand=False)
        category_column.set_cell_data_func(cell_category,
                                           self._set_category_cell, 0)
        category_column.set_clickable(True)
        category_column.connect("clicked", self._sort_column, 0)
        self._message_treeview.append_column(category_column)

        # Set up the message column (info text).
        message_column = gtk.TreeViewColumn()
        message_column.set_title(self.COLUMN_TITLE_MESSAGE)
        cell_message = gtk.CellRendererText()
        message_column.pack_start(cell_message, expand=False)
        message_column.add_attribute(cell_message, attribute="text", column=1)
        message_column.set_clickable(True)
        message_column.connect("clicked", self._sort_column, 1)
        self._message_treeview.append_column(message_column)

        # Set up the time column (text).
        time_column = gtk.TreeViewColumn()
        time_column.set_title(self.COLUMN_TITLE_TIME)
        cell_time = gtk.CellRendererText()
        time_column.pack_start(cell_time, expand=False)
        time_column.set_cell_data_func(cell_time, self._set_time_cell, 2)
        time_column.set_clickable(True)
        time_column.set_sort_indicator(True)
        time_column.connect("clicked", self._sort_column, 2)
        self._message_treeview.append_column(time_column)

        self._message_store = gtk.TreeStore(str, str, int)
        for category, message, time in category_message_time_tuples:
            self._message_store.append(None, [category, message, time])
        filter_model = self._message_store.filter_new()
        filter_model.set_visible_func(self._get_should_show)
        self._message_treeview.set_model(filter_model)

        message_scrolled_window.add(self._message_treeview)
        top_vbox.pack_start(message_scrolled_window, expand=True, fill=True)

        category_hbox = gtk.HBox()
        category_hbox.show()
        top_vbox.pack_end(category_hbox, expand=False, fill=False)
        for i, category in enumerate(categories + [self.CATEGORY_ALL]):
            togglebutton = gtk.ToggleButton(label=category,
                                            use_underline=False)
            togglebutton.connect(
                "toggled", lambda b: self._set_new_filter(
                    b, category_hbox.get_children()))
            togglebutton.show()
            category_hbox.pack_start(togglebutton, expand=True, fill=True)
        togglebutton.set_active(True)
        self.show()
        self._scroll_to_end()
        self.connect("destroy", self._handle_destroy)
Example #19
0
        self.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_DROP,
                           targets_accept,
                           gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)

        targets_send = [("text/x-jabber-roster-item", 0, TARGET_ROSTER_ITEM),
                        ("text/x-jabber-id", 0, TARGET_JID)]
        self.drag_source_set(gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK,
                             targets_send,
                             gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)

        self.connect("drag-data-received", self.__on_drag_data_received)
        self.connect("drag-data-get", self.__on_drag_data_get)
        self.connect("drag-begin", self.__on_drag_begin)

        ## Create the widgets we'll always have
        self.__hboxPJ = gtk.HBox(0, 4)
        self.add(self.__hboxPJ)
        self.__hboxPJ.show()

        self.__lblPJ = gtk.Label("")
        self.__lblPJ.set_alignment(0.0, 0.5)
        self.__hboxPJ.pack_end(self.__lblPJ, 1, 1, 0)
        self.__lblPJ.show()

        self.__pixPJ = gtk.Image()
        rm = self.__app.resources
        self.__pixPJ.set_from_pixbuf(rm.get(rm.rtPIXBUF, "online"))
        self.__hboxPJ.pack_end(self.__pixPJ, 0, 0, 0)
        self.__pixPJ.show()

        ## Get presence updates for the current default jid
Example #20
0
    def __init__(self):
        self.dialog = gtk.Dialog(title='Nutrient Goal',
                                 flags=gtk.DIALOG_MODAL,
                                 buttons=(gtk.STOCK_HELP, gtk.RESPONSE_HELP,
                                          'gtk-save', 1, gtk.STOCK_CANCEL,
                                          gtk.RESPONSE_CANCEL))
        self.dialog.set_resizable(False)

        hbox1 = gtk.HBox(False, 0)
        self.dialog.vbox.pack_start(hbox1, True, True, 0)

        notebook1 = gtk.Notebook()
        notebook1.set_border_width(5)
        hbox1.pack_start(notebook1, True, True, 0)

        self.table_list = []
        self.table_list.append(gtk.Table(4, 6, False))
        self.table_list.append(gtk.Table(4, 11, False))
        self.table_list.append(gtk.Table(4, 10, False))
        self.table_list.append(gtk.Table(4, 14, False))
        self.table_list.append(gtk.Table(4, 5, False))

        for i in range(5):
            self.table_list[i].set_border_width(5)
            self.table_list[i].set_row_spacings(5)
            self.table_list[i].set_col_spacings(5)
            self.table_list[i].attach(gtk.Label('Daily Goal'), 1, 2, 0, 1,
                                      gtk.FILL | gtk.EXPAND, 0, 0, 0)
            self.table_list[i].attach(gtk.Label('Daily Goal'), 3, 4, 0, 1,
                                      gtk.FILL | gtk.EXPAND, 0, 0, 0)
            notebook1.add(self.table_list[i])

        label_list = []
        label0 = gtk.Label('')
        label0.set_text_with_mnemonic('M_acro-Nutrients')
        label_list.append(label0)
        label1 = gtk.Label('')
        label1.set_text_with_mnemonic('M_icro-Nutrients')
        label_list.append(label1)
        label2 = gtk.Label('')
        label2.set_text_with_mnemonic('Ami_no Acids')
        label_list.append(label2)
        label3 = gtk.Label('')
        label3.set_text_with_mnemonic('Fa_ts')
        label_list.append(label3)
        label4 = gtk.Label('')
        label4.set_text_with_mnemonic('Misce_llaneous')
        label_list.append(label4)

        for i in range(5):
            notebook1.set_tab_label(notebook1.get_nth_page(i), label_list[i])

        self.nutr_list = []
        for num, label_text, table_num, l, r, t, b in nutr_data_list:
            nutr = Nutrient()
            nutr.num = num
            nutr.table_num = table_num
            nutr.left = l
            nutr.right = r
            nutr.top = t
            nutr.bottom = b
            nutr.label = gtk.Label(label_text)
            nutr.label.set_alignment(1.0, 0.5)
            nutr.entry = gtk.Entry()
            self.nutr_list.append(nutr)

        for nutr in self.nutr_list:
            self.table_list[nutr.table_num].attach(nutr.label, nutr.left,
                                                   nutr.right, nutr.top,
                                                   nutr.bottom, gtk.FILL, 0, 0,
                                                   0)
            self.table_list[nutr.table_num].attach(nutr.entry, nutr.left + 1,
                                                   nutr.right + 1, nutr.top,
                                                   nutr.bottom,
                                                   gtk.FILL | gtk.EXPAND, 0, 0,
                                                   0)
Example #21
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self,
                                 name="Active %s" % Spacestring,
                                 ordering=71.1,
                                 tip="Modify active %s." % spacestring)

        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        # Microstructure widget, centered at the top of the page.
        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        label = gtk.Label('Microstructure=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        self.mswidget = whowidget.WhoWidget(microstructure.microStructures,
                                            scope=self)
        centerbox.pack_start(self.mswidget.gtk[0], expand=0, fill=0)

        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)
        gtklogger.connect_passive(mainpane, 'notify::position')

        # Active area status in the left half of the main pane.
        vbox = gtk.VBox()
        mainpane.pack1(vbox, resize=1, shrink=0)
        aasframe = gtk.Frame("Active %s Status" % Spacestring)
        aasframe.set_shadow_type(gtk.SHADOW_IN)
        vbox.pack_start(aasframe, expand=0, fill=0, padding=2)
        self.aainfo = gtk.Label()
        gtklogger.setWidgetName(self.aainfo, "Status")
        ##        self.aainfo.set_alignment(0.0, 0.5)
        aasframe.add(self.aainfo)

        naaframe = gtk.Frame("Named Active %ss" % Spacestring)
        naaframe.set_shadow_type(gtk.SHADOW_IN)
        vbox.pack_start(naaframe, expand=1, fill=1)
        naabox = gtk.VBox()
        naaframe.add(naabox)
        self.aalist = chooser.ScrolledChooserListWidget(
            callback=self.aalistCB,
            dbcallback=self.aalistCB2,
            name="NamedAreas")
        naabox.pack_start(self.aalist.gtk, expand=1, fill=1, padding=2)
        bbox = gtk.HBox()
        naabox.pack_start(bbox, expand=0, fill=0, padding=2)
        self.storebutton = gtk.Button("Store...")
        bbox.pack_start(self.storebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.storebutton, "Store")
        gtklogger.connect(self.storebutton, 'clicked', self.storeCB)
        tooltips.set_tooltip_text(
            self.storebutton,
            "Save the current active %s for future use." % spacestring)
        self.renamebutton = gtk.Button("Rename...")
        bbox.pack_start(self.renamebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.renamebutton, "Rename")
        gtklogger.connect(self.renamebutton, 'clicked', self.renameCB)
        tooltips.set_tooltip_text(
            self.renamebutton,
            "Rename the selected saved active %s." % spacestring)
        self.deletebutton = gtk.Button("Delete")
        bbox.pack_start(self.deletebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.deletebutton, "Delete")
        gtklogger.connect(self.deletebutton, 'clicked', self.deleteCB)
        tooltips.set_tooltip_text(
            self.deletebutton,
            "Delete the selected saved active %s." % spacestring)
        self.restorebutton = gtk.Button("Restore")
        bbox.pack_start(self.restorebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.restorebutton, "Restore")
        gtklogger.connect(self.restorebutton, 'clicked', self.restoreCB)
        tooltips.set_tooltip_text(
            self.restorebutton,
            "Use the selected saved active %s." % spacestring)

        # Active area modification methods in the right half of the main pane
        modframe = gtk.Frame("Active %s Modification" % Spacestring)
        gtklogger.setWidgetName(modframe, "Modify")
        modframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(modframe, resize=0, shrink=0)
        modbox = gtk.VBox()
        modframe.add(modbox)
        ##        scroll = gtk.ScrolledWindow()
        ##        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        ##        modbox.pack_start(scroll, expand=1, fill=1)
        self.activeareaModFactory = regclassfactory.RegisteredClassFactory(
            activeareamod.ActiveAreaModifier.registry,
            title="Method:",
            scope=self,
            name="Method")
        ##        scroll.add_with_viewport(self.activeareaModFactory.gtk)
        modbox.pack_start(self.activeareaModFactory.gtk, expand=1, fill=1)
        self.historian = historian.Historian(self.activeareaModFactory.set,
                                             self.sensitizeHistory,
                                             setCBkwargs={'interactive': 1})
        self.activeareaModFactory.set_callback(self.historian.stateChangeCB)

        # Prev, OK, and Next buttons
        hbox = gtk.HBox()
        modbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.prevbutton = gtkutils.prevButton()
        hbox.pack_start(self.prevbutton, expand=0, fill=0, padding=2)
        gtklogger.connect(self.prevbutton, 'clicked', self.historian.prevCB)
        tooltips.set_tooltip_text(
            self.prevbutton,
            'Recall the previous active %s modification operation.' %
            spacestring)
        self.okbutton = gtk.Button(stock=gtk.STOCK_OK)
        hbox.pack_start(self.okbutton, expand=1, fill=1, padding=2)
        gtklogger.setWidgetName(self.okbutton, "OK")
        gtklogger.connect(self.okbutton, 'clicked', self.okbuttonCB)
        tooltips.set_tooltip_text(
            self.okbutton,
            'Perform the active %s modification operation defined above.' %
            spacestring)
        self.nextbutton = gtkutils.nextButton()
        hbox.pack_start(self.nextbutton, expand=0, fill=0, padding=2)
        gtklogger.connect(self.nextbutton, 'clicked', self.historian.nextCB)
        tooltips.set_tooltip_text(
            self.nextbutton,
            "Recall the next active %s modification operation." % spacestring)

        # Undo, Redo, Override
        hbox = gtk.HBox()
        modbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        hbox.pack_start(self.undobutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.undobutton, "Undo")
        gtklogger.connect(self.undobutton, 'clicked', self.undoCB)
        tooltips.set_tooltip_text(self.undobutton,
                                  "Undo the previous operation.")

        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        hbox.pack_start(self.redobutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.redobutton, "Redo")
        gtklogger.connect(self.redobutton, 'clicked', self.redoCB)
        tooltips.set_tooltip_text(self.redobutton, "Redo an undone operation.")

        self.overridebutton = gtk.ToggleButton('Override')
        hbox.pack_start(self.overridebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.overridebutton, "Override")
        self.overridesignal = gtklogger.connect(self.overridebutton, 'clicked',
                                                self.overrideCB)
        tooltips.set_tooltip_text(
            self.overridebutton,
            "Temporarily activate the entire microstructure.")

        # Switchboard signals
        self.sbcallbacks = [
            switchboard.requestCallback(self.mswidget, self.mswidgetCB),
            switchboard.requestCallback("active area modified",
                                        self.aamodified),
            switchboard.requestCallbackMain("stored active areas changed",
                                            self.storedAAChanged),
            switchboard.requestCallbackMain(
                ('validity', self.activeareaModFactory), self.validityChangeCB)
        ]

        self.built = True
Example #22
0
    def _main_window_default_style(self):
        wcfg = self.config['main_window']

        button_style = self.config.get('font_styles', {}).get('buttons', {})
        border_padding = int(2 * button_style.get('points', 10) / 3)

        vbox = gtk.VBox(False, 0)
        vbox.set_border_width(border_padding)

        # Enforce that the window always has at least one status section,
        # even if the configuration doesn't specify one.
        sd_defs = wcfg.get("status_displays") or [{
            "id":
            "notification",
            "details":
            wcfg.get('initial_notification', '')
        }]

        # Scale the status icons relative to a) how tall the window is,
        # and b) how many status lines we are showing.
        icon_size = int(0.66 * wcfg.get('height', 360) / len(sd_defs))

        status_displays = []
        for st in sd_defs:
            ss = {
                'id': st['id'],
                'hbox': gtk.HBox(False, border_padding),
                'vbox': gtk.VBox(False, border_padding),
                'title': gtk.Label(),
                'details': gtk.Label()
            }

            for which in ('title', 'details'):
                ss[which].set_markup(st.get(which, ''))
                exact = '%s_%s' % (ss['id'], which)
                if exact in self.font_styles:
                    ss[which].modify_font(self.font_styles[exact])
                elif which in self.font_styles:
                    ss[which].modify_font(self.font_styles[which])

            if 'icon' in st:
                ss['icon'] = gtk.Image()
                ss['hbox'].pack_start(ss['icon'], False, True)
                self._set_status_display_icon(ss, st['icon'], icon_size)
                text_x = 0.0
            else:
                # If there is no icon, center our title and details
                text_x = 0.5

            ss['title'].set_alignment(text_x, 1.0)
            ss['details'].set_alignment(text_x, 0.0)
            ss['vbox'].pack_start(ss['title'], True, True)
            ss['vbox'].pack_end(ss['details'], True, True)
            ss['vbox'].set_spacing(1)
            ss['hbox'].pack_start(ss['vbox'], True, True)
            ss['hbox'].set_spacing(7)
            status_displays.append(ss)
        self.status_display = dict((ss['id'], ss) for ss in status_displays)

        notify = None
        if 'notification' not in self.status_display:
            notify = gtk.Label()
            notify.set_markup(wcfg.get('initial_notification', ''))
            notify.set_alignment(0, 0.5)
            if 'notification' in self.font_styles:
                notify.modify_font(self.font_styles['notification'])

        if wcfg.get('background'):
            self._set_background_image(vbox, wcfg.get('background'))

        button_box = gtk.HBox(False, border_padding)

        self._main_window_indicator(vbox, button_box)
        self._main_window_add_action_items(button_box)
        if notify:
            button_box.pack_start(notify, True, True)
        for ss in status_displays:
            vbox.pack_start(ss['hbox'], True, True)
        vbox.pack_end(button_box, False, True)

        self.main_window['window'].add(vbox)
        self.main_window.update({
            'vbox':
            vbox,
            'notification': (notify if notify else
                             self.status_display['notification']['details']),
            'status_displays':
            status_displays,
            'buttons':
            button_box
        })
Example #23
0
 def hBoxThese(self, homogenous, spacing, list, pad=0):
     new_box = gtk.HBox(homogenous, spacing)
     for item in list:
         new_box.pack_start(item, expand=False, fill=False, padding=pad)
     return new_box
Example #24
0
    def __init__(self,
                 controller,
                 device,
                 minor,
                 cur_size,
                 min_size,
                 max_size,
                 fstype,
                 bytes_in_sector=512,
                 format=True):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        self.controller = controller
        self.device = device
        self.minor = minor
        self.min_size = min_size
        self.max_size = max_size
        self.cur_size = cur_size
        self.fstype = fstype
        self.bytes_in_sector = bytes_in_sector
        self.format = format
        if self.min_size == -1 or self.max_size == -1:
            self.min_size = self.cur_size
            self.max_size = self.cur_size
        self.sync_slider_to_text = True

        self.connect("delete_event", self.delete_event)
        self.connect("destroy", self.destroy_event)
        self.set_default_size(400, 300)
        if self.fstype == "free":
            self.set_title(_("New partition on ") + device)
        else:
            self.set_title(
                _("Properties for ") +
                self.controller.devices[self.device][minor]['devnode'])

        self.globalbox = gtk.VBox(False, 0)
        self.globalbox.set_border_width(10)

        self.resize_box = gtk.VBox(False, 0)
        self.resize_hpaned = gtk.HPaned()
        #		self.resize_hpaned.set_size_request(400, -1)
        self.resize_hpaned.connect("size-allocate", self.part_resized)
        self.resize_part_space_frame = gtk.Frame()
        self.resize_part_space_frame.set_shadow_type(gtk.SHADOW_IN)
        self.resize_part_space = PartitionButton.Partition(
            color1=self.controller.colors['linux-swap'],
            color2=self.controller.colors['free'],
            division=0,
            label="")
        self.resize_part_space.set_sensitive(False)
        self.resize_part_space_frame.add(self.resize_part_space)
        if self.type == "free" or self.min_size <= 1:
            self.resize_hpaned.pack1(self.resize_part_space_frame,
                                     resize=True,
                                     shrink=True)
        else:
            self.resize_hpaned.pack1(self.resize_part_space_frame,
                                     resize=True,
                                     shrink=False)
        self.resize_unalloc_space_frame = gtk.Frame()
        self.resize_unalloc_space_frame.set_shadow_type(gtk.SHADOW_IN)
        self.resize_unalloc_space = PartitionButton.Partition(
            color1=self.controller.colors['unalloc'],
            color2=self.controller.colors['unalloc'],
            label="")
        self.resize_unalloc_space.set_sensitive(False)
        self.resize_unalloc_space_frame.add(self.resize_unalloc_space)
        self.resize_hpaned.add2(self.resize_unalloc_space_frame)
        self.resize_hpaned.set_position(0)
        self.resize_box.pack_start(self.resize_hpaned,
                                   expand=False,
                                   fill=False,
                                   padding=0)
        self.resize_box.pack_start(gtk.Label(
            _("You can slide above or enter values below")),
                                   expand=False,
                                   padding=2)
        resize_text_box = gtk.HBox(False, 0)
        resize_text_box.pack_start(gtk.Label(_("New size:")),
                                   expand=False,
                                   fill=False,
                                   padding=0)
        self.resize_info_part_size = gtk.Entry(max=9)
        self.resize_info_part_size.set_width_chars(7)
        self.resize_info_part_size.connect("insert-text",
                                           self.validate_keypress)
        self.resize_info_part_size.connect("focus-out-event",
                                           self.update_slider_and_entries,
                                           "part-size")
        resize_text_box.pack_start(self.resize_info_part_size,
                                   expand=False,
                                   fill=False,
                                   padding=6)
        resize_text_box.pack_start(gtk.Label(_("MB")),
                                   expand=False,
                                   fill=False,
                                   padding=0)
        resize_text_box.pack_start(gtk.Label("  "),
                                   expand=False,
                                   fill=False,
                                   padding=20)
        resize_text_box.pack_start(gtk.Label(_("Unalloc. size:")),
                                   expand=False,
                                   fill=False,
                                   padding=6)
        self.resize_info_unalloc_size = gtk.Entry(max=9)
        self.resize_info_unalloc_size.set_width_chars(7)
        self.resize_info_unalloc_size.connect("insert-text",
                                              self.validate_keypress)
        self.resize_info_unalloc_size.connect("focus-out-event",
                                              self.update_slider_and_entries,
                                              "unalloc-size")
        resize_text_box.pack_start(self.resize_info_unalloc_size,
                                   expand=False,
                                   fill=False,
                                   padding=0)
        resize_text_box.pack_start(gtk.Label("MB"),
                                   expand=False,
                                   fill=False,
                                   padding=3)
        self.resize_box.pack_start(resize_text_box,
                                   expand=False,
                                   fill=False,
                                   padding=10)
        self.globalbox.pack_start(self.resize_box,
                                  expand=False,
                                  fill=False,
                                  padding=0)

        self.part_info_box = gtk.HBox(False, 0)
        part_info_table = gtk.Table(6, 2, False)
        part_info_table.set_col_spacings(10)
        part_info_table.set_row_spacings(5)
        info_partition_label = gtk.Label(_("Partition:"))
        info_partition_label.set_alignment(0.0, 0.5)
        part_info_table.attach(info_partition_label, 0, 1, 0, 1)
        self.info_partition = gtk.Label()
        self.info_partition.set_alignment(0.0, 0.5)
        part_info_table.attach(self.info_partition, 1, 2, 0, 1)

        info_partition_format = gtk.Label(_("Format:"))
        info_partition_format.set_alignment(0.0, 0.5)
        part_info_table.attach(info_partition_format, 0, 1, 1, 2)
        resize_info_part_format_box = gtk.HBox(False, 0)
        self.resize_info_part_format_yes = gtk.RadioButton(label=_("Yes"))
        self.resize_info_part_format_no = gtk.RadioButton(
            label=_("No"), group=self.resize_info_part_format_yes)
        if self.fstype == "free":
            self.resize_info_part_format_yes.set_sensitive(False)
            self.resize_info_part_format_no.set_sensitive(False)
        else:
            if self.format:
                self.resize_info_part_format_yes.set_active(True)
            else:
                self.resize_info_part_format_no.set_active(True)
        resize_info_part_format_box.pack_start(
            self.resize_info_part_format_yes, expand=False, fill=False)
        resize_info_part_format_box.pack_start(self.resize_info_part_format_no,
                                               expand=False,
                                               fill=False,
                                               padding=10)
        part_info_table.attach(resize_info_part_format_box, 1, 2, 1, 2)

        info_partition_type = gtk.Label(_("Type:"))
        info_partition_type.set_alignment(0.0, 0.5)
        part_info_table.attach(info_partition_type, 0, 1, 2, 3)
        self.resize_info_part_type = gtk.combo_box_new_text()
        self.resize_info_part_type.append_text(_("Primary"))
        self.resize_info_part_type.append_text(_("Logical"))
        self.resize_info_part_type.set_active(0)
        part_info_table.attach(self.resize_info_part_type, 1, 2, 2, 3)

        info_partition_fs = gtk.Label(_("Filesystem:"))
        info_partition_fs.set_alignment(0.0, 0.5)
        part_info_table.attach(info_partition_fs, 0, 1, 3, 4)
        self.resize_info_part_filesystem = gtk.combo_box_new_text()
        for fs in self.controller.supported_filesystems:
            self.resize_info_part_filesystem.append_text(fs)
        self.resize_info_part_filesystem.set_active(0)
        self.resize_info_part_filesystem.connect("changed",
                                                 self.filesystem_changed)
        part_info_table.attach(self.resize_info_part_filesystem, 1, 2, 3, 4)

        info_partition_mountpoint = gtk.Label(_("Mount point:"))
        info_partition_mountpoint.set_alignment(0.0, 0.5)
        part_info_table.attach(info_partition_mountpoint, 0, 1, 4, 5)
        self.part_mount_point_entry = gtk.Entry()
        part_info_table.attach(self.part_mount_point_entry, 1, 2, 4, 5)

        info_partition_mountopts = gtk.Label(_("Mount options:"))
        info_partition_mountopts.set_alignment(0.0, 0.5)
        part_info_table.attach(info_partition_mountopts, 0, 1, 5, 6)
        self.part_mount_opts_entry = gtk.Entry()
        part_info_table.attach(self.part_mount_opts_entry, 1, 2, 5, 6)

        self.part_info_box.pack_start(part_info_table,
                                      expand=False,
                                      fill=False,
                                      padding=0)
        self.globalbox.pack_start(self.part_info_box,
                                  expand=False,
                                  fill=False,
                                  padding=10)

        bottom_box = gtk.HBox(True, 0)
        ok_button = gtk.Button(_(" OK "))
        ok_button.set_flags(gtk.CAN_DEFAULT)
        ok_button.set_size_request(60, -1)
        ok_button.connect("clicked", self.ok_clicked)
        bottom_box.pack_start(ok_button, expand=False, fill=False, padding=0)
        cancel_button = gtk.Button(_(" Cancel "))
        cancel_button.set_size_request(60, -1)
        cancel_button.connect("clicked", self.cancel_clicked)
        bottom_box.pack_start(cancel_button,
                              expand=False,
                              fill=False,
                              padding=0)
        self.globalbox.pack_end(bottom_box,
                                expand=False,
                                fill=False,
                                padding=0)

        self.add(self.globalbox)
        ok_button.grab_default()
        self.set_modal(True)
        self.set_transient_for(self.controller.controller.window)
        self.make_visible()
Example #25
0
File: dialog.py Project: kaday/rose
def run_dialog(dialog_type,
               text,
               title=None,
               modal=True,
               cancel=False,
               extra_text=None):
    """Run a simple dialog with an 'OK' button and some text."""
    parent_window = get_dialog_parent()
    dialog = gtk.Dialog(parent=parent_window)
    if parent_window is None:
        dialog.set_icon(rose.gtk.util.get_icon())
    if cancel:
        cancel_button = dialog.add_button(gtk.STOCK_CANCEL,
                                          gtk.RESPONSE_CANCEL)
    if extra_text:
        info_button = gtk.Button(stock=gtk.STOCK_INFO)
        info_button.show()
        info_title = DIALOG_TITLE_EXTRA_INFO
        info_button.connect(
            "clicked",
            lambda b: run_scrolled_dialog(extra_text, title=info_title))
        dialog.action_area.pack_start(info_button, expand=False, fill=False)
    ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
    if dialog_type == gtk.MESSAGE_INFO:
        stock_id = gtk.STOCK_DIALOG_INFO
    elif dialog_type == gtk.MESSAGE_WARNING:
        stock_id = gtk.STOCK_DIALOG_WARNING
    elif dialog_type == gtk.MESSAGE_QUESTION:
        stock_id = gtk.STOCK_DIALOG_QUESTION
    elif dialog_type == gtk.MESSAGE_ERROR:
        stock_id = gtk.STOCK_DIALOG_ERROR
    else:
        stock_id = None

    if stock_id is not None:
        dialog.image = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_DIALOG)
        dialog.image.show()

    dialog.label = gtk.Label(text)
    try:
        pango.parse_markup(text)
    except glib.GError:
        try:
            dialog.label.set_markup(rose.gtk.util.safe_str(text))
        except:
            dialog.label.set_text(text)
    else:
        dialog.label.set_markup(text)
    dialog.label.show()
    hbox = gtk.HBox()

    if stock_id is not None:
        image_vbox = gtk.VBox()
        image_vbox.pack_start(dialog.image,
                              expand=False,
                              fill=False,
                              padding=DIALOG_PADDING)
        image_vbox.show()
        hbox.pack_start(image_vbox,
                        expand=False,
                        fill=False,
                        padding=rose.config_editor.SPACING_PAGE)

    scrolled_window = gtk.ScrolledWindow()
    scrolled_window.set_border_width(0)
    scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
    vbox = gtk.VBox()
    vbox.pack_start(dialog.label, expand=True, fill=True)
    vbox.show()
    scrolled_window.add_with_viewport(vbox)
    scrolled_window.child.set_shadow_type(gtk.SHADOW_NONE)
    scrolled_window.show()
    hbox.pack_start(scrolled_window,
                    expand=True,
                    fill=True,
                    padding=rose.config_editor.SPACING_PAGE)
    hbox.show()
    dialog.vbox.pack_end(hbox, expand=True, fill=True)

    if "\n" in text:
        dialog.label.set_line_wrap(False)
    dialog.set_resizable(True)
    dialog.set_modal(modal)
    if title is not None:
        dialog.set_title(title)

    # ensure the dialog size does not exceed the maximum allowed
    max_size = rose.config_editor.SIZE_MACRO_DIALOG_MAX
    my_size = dialog.size_request()
    new_size = [-1, -1]
    for i in [0, 1]:
        new_size[i] = min([my_size[i], max_size[i]])
    scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    dialog.set_default_size(*new_size)
    ok_button.grab_focus()
    if modal or cancel:
        dialog.show()
        response = dialog.run()
        dialog.destroy()
        return (response == gtk.RESPONSE_OK)
    else:
        ok_button.connect("clicked", lambda b: dialog.destroy())
        dialog.show()
Example #26
0
	def __init__(self, parent):
		FindExtension.__init__(self, parent)

		self._pattern = '*'
		self._compare_method = fnmatch.fnmatch

		# prepare options
		plugin_options = parent._application.plugin_options
		self._options = plugin_options.create_section(self.__class__.__name__)

		# connect notify signal
		parent.connect('notify-start', self.__handle_notify_start)

		# enabled by default
		self._checkbox_active.set_active(True)

		# create label showing pattern help
		label_help = gtk.Label()
		label_help.set_alignment(0, 0)
		label_help.set_use_markup(True)

		label_help.set_markup(_(
							'<b>Pattern matching</b>\n'
							'*\t\tEverything\n'
							'?\t\tAny single character\n'
							'[seq]\tAny character in <i>seq</i>\n'
							'[!seq]\tAny character <u>not</u> in <i>seq</i>'
						))

		# create containers
		hbox = gtk.HBox(True, 15)
		vbox_left = gtk.VBox(False, 5)
		vbox_right = gtk.VBox(False, 0)

		# create interface
		vbox_pattern = gtk.VBox(False, 0)

		label_pattern = gtk.Label(_('Search for:'))
		label_pattern.set_alignment(0, 0.5)

		self._entries = gtk.ListStore(str)
		self._entry_pattern = gtk.ComboBoxEntry(model=self._entries)
		self._entry_pattern.connect('changed', self.__handle_pattern_change)

		self._checkbox_case_sensitive = gtk.CheckButton(_('Case sensitive'))
		self._checkbox_case_sensitive.connect('toggled', self.__handle_case_sensitive_toggle)

		# pack interface
		self.vbox.remove(self._checkbox_active)

		vbox_pattern.pack_start(label_pattern, False, False, 0)
		vbox_pattern.pack_start(self._entry_pattern, False, False, 0)

		vbox_left.pack_start(self._checkbox_active, False, False, 0)
		vbox_left.pack_start(vbox_pattern, False, False, 0)
		vbox_left.pack_start(self._checkbox_case_sensitive, False, False, 0)

		vbox_right.pack_start(label_help, True, True, 0)

		hbox.pack_start(vbox_left, True, True, 0)
		hbox.pack_start(vbox_right, True, True, 0)

		self.vbox.pack_start(hbox, True, True, 0)

		# load saved values
		self._load_history()
Example #27
0
File: dialog.py Project: kaday/rose
    def __init__(self,
                 cmd_args,
                 description=None,
                 title=None,
                 stock_id=gtk.STOCK_EXECUTE,
                 hide_progress=False,
                 modal=True,
                 event_queue=None):
        window = get_dialog_parent()
        self.dialog = gtk.Dialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT),
                                 parent=window)
        self.dialog.set_modal(modal)
        self.dialog.set_default_size(*DIALOG_SIZE_PROCESS)
        self._is_destroyed = False
        self.dialog.set_icon(
            self.dialog.render_icon(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU))
        self.cmd_args = cmd_args
        self.event_queue = event_queue
        str_cmd_args = [rose.gtk.util.safe_str(a) for a in cmd_args]
        if description is not None:
            str_cmd_args = [description]
        if title is None:
            self.dialog.set_title(" ".join(str_cmd_args[0:2]))
        else:
            self.dialog.set_title(title)
        if callable(cmd_args[0]):
            self.label = gtk.Label(self.DIALOG_FUNCTION_LABEL)
        else:
            self.label = gtk.Label(self.DIALOG_PROCESS_LABEL)
        self.label.set_use_markup(True)
        self.label.show()
        self.image = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_DIALOG)
        self.image.show()
        image_vbox = gtk.VBox()
        image_vbox.pack_start(self.image, expand=False, fill=False)
        image_vbox.show()
        top_hbox = gtk.HBox()
        top_hbox.pack_start(image_vbox,
                            expand=False,
                            fill=False,
                            padding=DIALOG_PADDING)
        top_hbox.show()
        hbox = gtk.HBox()
        hbox.pack_start(self.label,
                        expand=False,
                        fill=False,
                        padding=DIALOG_PADDING)
        hbox.show()
        main_vbox = gtk.VBox()
        main_vbox.show()
        main_vbox.pack_start(hbox,
                             expand=False,
                             fill=False,
                             padding=DIALOG_SUB_PADDING)

        cmd_string = str_cmd_args[0]
        if str_cmd_args[1:]:
            if callable(cmd_args[0]):
                cmd_string += "(" + " ".join(str_cmd_args[1:]) + ")"
            else:
                cmd_string += " " + " ".join(str_cmd_args[1:])
        self.cmd_label = gtk.Label()
        self.cmd_label.set_markup("<b>" + cmd_string + "</b>")
        self.cmd_label.show()
        cmd_hbox = gtk.HBox()
        cmd_hbox.pack_start(self.cmd_label,
                            expand=False,
                            fill=False,
                            padding=DIALOG_PADDING)
        cmd_hbox.show()
        main_vbox.pack_start(cmd_hbox,
                             expand=False,
                             fill=True,
                             padding=DIALOG_SUB_PADDING)
        # self.dialog.set_modal(True)
        self.progress_bar = gtk.ProgressBar()
        self.progress_bar.set_pulse_step(0.1)
        self.progress_bar.show()
        hbox = gtk.HBox()
        hbox.pack_start(self.progress_bar,
                        expand=True,
                        fill=True,
                        padding=DIALOG_PADDING)
        hbox.show()
        main_vbox.pack_start(hbox,
                             expand=False,
                             fill=False,
                             padding=DIALOG_SUB_PADDING)
        top_hbox.pack_start(main_vbox,
                            expand=True,
                            fill=True,
                            padding=DIALOG_PADDING)
        if self.event_queue is None:
            self.dialog.vbox.pack_start(top_hbox, expand=True, fill=True)
        else:
            text_view_scroll = gtk.ScrolledWindow()
            text_view_scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
            text_view_scroll.show()
            text_view = gtk.TextView()
            text_view.show()
            self.text_buffer = text_view.get_buffer()
            self.text_tag = self.text_buffer.create_tag()
            self.text_tag.set_property("scale", pango.SCALE_SMALL)
            text_view.connect('size-allocate', self._handle_scroll_text_view)
            text_view_scroll.add(text_view)
            text_expander = gtk.Expander(self.DIALOG_LOG_LABEL)
            text_expander.set_spacing(DIALOG_SUB_PADDING)
            text_expander.add(text_view_scroll)
            text_expander.show()
            top_pane = gtk.VPaned()
            top_pane.pack1(top_hbox, resize=False, shrink=False)
            top_pane.show()
            self.dialog.vbox.pack_start(top_pane,
                                        expand=True,
                                        fill=True,
                                        padding=DIALOG_SUB_PADDING)
            top_pane.pack2(text_expander, resize=True, shrink=True)
        if hide_progress:
            progress_bar.hide()
        self.ok_button = self.dialog.get_action_area().get_children()[0]
        self.ok_button.hide()
        for child in self.dialog.vbox.get_children():
            if isinstance(child, gtk.HSeparator):
                child.hide()
        self.dialog.show()
Example #28
0
    def __init__(self, model, ids, context=None):
        super(WinExport, self).__init__()

        self.dialog = gtk.Dialog(title=_("Export to CSV"),
                                 parent=self.parent,
                                 flags=gtk.DIALOG_DESTROY_WITH_PARENT)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.connect('response', self.response)

        vbox = gtk.VBox()
        frame_predef_exports = gtk.Frame()
        frame_predef_exports.set_border_width(2)
        frame_predef_exports.set_shadow_type(gtk.SHADOW_NONE)
        vbox.pack_start(frame_predef_exports, True, True, 0)
        viewport_exports = gtk.Viewport()
        scrolledwindow_exports = gtk.ScrolledWindow()
        scrolledwindow_exports.set_policy(gtk.POLICY_AUTOMATIC,
                                          gtk.POLICY_AUTOMATIC)
        label_predef_exports = gtk.Label(_("<b>Predefined exports</b>"))
        label_predef_exports.set_use_markup(True)
        frame_predef_exports.set_label_widget(label_predef_exports)
        viewport_exports.add(scrolledwindow_exports)
        frame_predef_exports.add(viewport_exports)

        hbox = gtk.HBox(True)
        vbox.pack_start(hbox, True, True, 0)

        frame_all_fields = gtk.Frame()
        frame_all_fields.set_shadow_type(gtk.SHADOW_NONE)
        hbox.pack_start(frame_all_fields, True, True, 0)
        label_all_fields = gtk.Label(_("<b>All fields</b>"))
        label_all_fields.set_use_markup(True)
        frame_all_fields.set_label_widget(label_all_fields)
        viewport_all_fields = gtk.Viewport()
        scrolledwindow_all_fields = gtk.ScrolledWindow()
        scrolledwindow_all_fields.set_policy(gtk.POLICY_AUTOMATIC,
                                             gtk.POLICY_AUTOMATIC)
        viewport_all_fields.add(scrolledwindow_all_fields)
        frame_all_fields.add(viewport_all_fields)

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

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

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

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

        hseparator_buttons = gtk.HSeparator()
        vbox_buttons.pack_start(hseparator_buttons, False, True, 0)

        button_save_export = gtk.Button(_("Save Export"),
                                        stock=None,
                                        use_underline=True)
        button_save_export.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-save', gtk.ICON_SIZE_BUTTON)
        button_save_export.set_image(img_button)
        button_save_export.connect_after('clicked', self.addreplace_predef)
        vbox_buttons.pack_start(button_save_export, False, False, 0)

        button_del_export = gtk.Button(_("Delete Export"),
                                       stock=None,
                                       use_underline=True)
        button_del_export.set_alignment(0.0, 0.0)
        img_button = gtk.Image()
        img_button.set_from_stock('tryton-delete', gtk.ICON_SIZE_BUTTON)
        button_del_export.set_image(img_button)
        button_del_export.connect_after('clicked', self.remove_predef)
        vbox_buttons.pack_start(button_del_export, False, False, 0)

        frame_export = gtk.Frame()
        frame_export.set_shadow_type(gtk.SHADOW_NONE)
        label_export = gtk.Label(_("<b>Fields to export</b>"))
        label_export.set_use_markup(True)
        frame_export.set_label_widget(label_export)

        alignment_export = gtk.Alignment(0.5, 0.5, 1, 1)
        alignment_export.set_padding(0, 0, 12, 0)
        frame_export.add(alignment_export)
        viewport_fields_to_export = gtk.Viewport()
        scrolledwindow_export = gtk.ScrolledWindow()
        scrolledwindow_export.set_policy(gtk.POLICY_AUTOMATIC,
                                         gtk.POLICY_AUTOMATIC)
        viewport_fields_to_export.add(scrolledwindow_export)
        alignment_export.add(viewport_fields_to_export)
        hbox.pack_start(frame_export, True, True, 0)

        frame_options = gtk.Frame()
        frame_options.set_border_width(2)
        label_options = gtk.Label(_("<b>Options</b>"))
        label_options.set_use_markup(True)
        frame_options.set_label_widget(label_options)
        vbox.pack_start(frame_options, False, True, 5)
        hbox_options = gtk.HBox(False, 2)
        frame_options.add(hbox_options)
        hbox_options.set_border_width(2)

        combo_saveas = gtk.combo_box_new_text()
        hbox_options.pack_start(combo_saveas, True, True, 0)
        combo_saveas.append_text(_("Open"))
        combo_saveas.append_text(_("Save"))
        vseparator_options = gtk.VSeparator()
        hbox_options.pack_start(vseparator_options, False, False, 10)

        checkbox_add_field_names = gtk.CheckButton(_("Add _field names"))
        checkbox_add_field_names.set_active(True)
        hbox_options.pack_start(checkbox_add_field_names, False, False, 0)

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

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

        self.dialog.vbox.pack_start(vbox)

        self.ids = ids
        self.model = model
        self.context = context

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

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

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

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

        self.fields = {}

        self.model_populate(self._get_fields(model))

        self.view1.set_model(self.model1)
        self.view1.connect('row-activated', self.sig_sel)
        self.view2.set_model(self.model2)
        self.view2.connect('row-activated', self.sig_unsel)
        if sys.platform != 'darwin':
            self.view2.drag_source_set(
                gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK,
                [('EXPORT_TREE', gtk.TARGET_SAME_WIDGET, 0)],
                gtk.gdk.ACTION_MOVE)
            self.view2.drag_dest_set(
                gtk.DEST_DEFAULT_ALL,
                [('EXPORT_TREE', gtk.TARGET_SAME_WIDGET, 0)],
                gtk.gdk.ACTION_MOVE)
            self.view2.connect('drag-begin', self.drag_begin)
            self.view2.connect('drag-motion', self.drag_motion)
            self.view2.connect('drag-drop', self.drag_drop)
            self.view2.connect("drag-data-get", self.drag_data_get)
            self.view2.connect('drag-data-received', self.drag_data_received)
            self.view2.connect('drag-data-delete', self.drag_data_delete)

        self.wid_action = combo_saveas
        self.wid_write_field_names = checkbox_add_field_names
        self.wid_action.set_active(0)

        # Creating the predefined export view
        self.pref_export = gtk.TreeView()
        self.pref_export.append_column(
            gtk.TreeViewColumn(_('Name'), gtk.CellRendererText(), text=2))
        scrolledwindow_exports.add(self.pref_export)

        self.pref_export.connect("button-press-event", self.export_click)
        self.pref_export.connect("key-press-event", self.export_keypress)

        # Fill the predefined export tree view
        self.predef_model = gtk.ListStore(gobject.TYPE_INT,
                                          gobject.TYPE_PYOBJECT,
                                          gobject.TYPE_STRING)
        self.fill_predefwin()

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

        self.register()
Example #29
0
    def __init__(self, parent=None):
        hildon.Window.__init__(self)
        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect('destroy', lambda *w: gtk.main_quit())

        self.set_title(self.__class__.__name__)

        hbox = gtk.HBox(False, 8)

        self.add(hbox)

        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        hbox.pack_start(sw, True, True, 0)

        model = self.__create_model()
        treeview = gtk.TreeView(model)
        treeview.set_headers_visible(True)
        sw.add(treeview)

        column = gtk.TreeViewColumn()
        column.set_title("Macro")

        cell_renderer = gtk.CellRendererPixbuf()
        column.pack_start(cell_renderer, False)
        column.set_attributes(cell_renderer, stock_id=1)

        cell_renderer = gtk.CellRendererText()
        column.pack_start(cell_renderer, True)
        column.set_cell_data_func(cell_renderer, macro_set_func_text)

        treeview.append_column(column)

        cell_renderer = gtk.CellRendererText()
        treeview.insert_column_with_data_func(-1, "Label", cell_renderer,
                                              label_set_func)

        cell_renderer = gtk.CellRendererText()
        treeview.insert_column_with_data_func(-1, "Accel", cell_renderer,
                                              accel_set_func)

        cell_renderer = gtk.CellRendererText()
        treeview.insert_column_with_data_func(-1, "ID", cell_renderer,
                                              id_set_func)

        align = gtk.Alignment(0.5, 0.0, 0.0, 0.0)
        hbox.pack_end(align, False, False, 0)

        frame = gtk.Frame("Selected Item")
        align.add(frame)

        vbox = gtk.VBox(False, 8)
        vbox.set_border_width(4)
        frame.add(vbox)

        display = StockItemDisplay()
        treeview.set_data("stock-display", display)

        display.type_label = gtk.Label()
        display.macro_label = gtk.Label()
        display.id_label = gtk.Label()
        display.label_accel_label = gtk.Label()
        display.icon_image = gtk.Image()
        # empty image

        vbox.pack_start(display.type_label, False, False, 0)
        vbox.pack_start(display.icon_image, False, False, 0)
        vbox.pack_start(display.label_accel_label, False, False, 0)
        vbox.pack_start(display.macro_label, False, False, 0)
        vbox.pack_start(display.id_label, False, False, 0)

        selection = treeview.get_selection()
        selection.set_mode(gtk.SELECTION_SINGLE)

        selection.connect("changed", self.on_selection_changed)

        self.show_all()
Example #30
0
    def __init__(self):
        gtk.ToolItem.__init__(self)
        preview = ColorPreview()
        self.dropdown_button = dropdownpanel.DropdownPanelButton(preview)
        self.preview_size = _get_icon_size()
        self.connect("toolbar-reconfigured", self._toolbar_reconf_cb)
        self.connect("create-menu-proxy", lambda *a: True)
        self.set_tooltip_text(_("Color History and other tools"))
        self.add(self.dropdown_button)

        from application import get_app
        app = get_app()
        app.brush.observers.append(self._brush_settings_changed_cb)
        preview.color = app.brush_color_manager.get_color()

        self._app = app
        self._main_preview = preview

        panel_frame = gtk.Frame()
        panel_frame.set_shadow_type(gtk.SHADOW_OUT)
        self.dropdown_button.set_property("panel-widget", panel_frame)
        panel_vbox = gtk.VBox()
        panel_vbox.set_spacing(widgets.SPACING_TIGHT)
        panel_vbox.set_border_width(widgets.SPACING)
        panel_frame.add(panel_vbox)

        def hide_panel_cb(*a):
            self.dropdown_button.panel_hide()

        def hide_panel_idle_cb(*a):
            gobject.idle_add(self.dropdown_button.panel_hide)

        # Colour changing
        section_frame = widgets.section_frame(_("Change Color"))
        panel_vbox.pack_start(section_frame, True, True)

        section_table = gtk.Table()
        section_table.set_col_spacings(widgets.SPACING)
        section_table.set_border_width(widgets.SPACING)
        section_frame.add(section_table)

        hsv_widget = HSVTriangle()
        hsv_widget.set_size_request(175, 175)
        hsv_widget.set_color_manager(app.brush_color_manager)
        section_table.attach(hsv_widget, 0, 1, 0, 1)

        preview_hbox = gtk.HBox()
        color_picker = ColorPickerButton()
        preview_adj = PreviousCurrentColorAdjuster()
        preview_adj.set_color_manager(app.brush_color_manager)
        color_picker.set_color_manager(app.brush_color_manager)
        preview_hbox.pack_start(color_picker, False, False)
        preview_hbox.pack_start(preview_adj, True, True)

        side_vbox = gtk.VBox()
        side_vbox.set_spacing(widgets.SPACING_TIGHT)
        section_table.attach(side_vbox, 1, 2, 0, 1)

        def init_proxy(widget, action_name):
            action = app.find_action(action_name)
            assert action is not None, \
                    "Must be able to find action %s" % (action_name,)
            widget.set_related_action(action)
            widget.connect("clicked", hide_panel_cb)
            return widget

        button = init_proxy(gtk.Button(), "ColorDetailsDialog")
        side_vbox.pack_end(button, False, False)
        side_vbox.pack_end(preview_hbox, False, False)

        side_vbox.pack_end(gtk.Alignment(), True, True)
        button = init_proxy(gtk.ToggleButton(), "HCYWheelTool")
        button.set_label(_("HCY Wheel"))
        side_vbox.pack_end(button, False, False)
        button = init_proxy(gtk.ToggleButton(), "PaletteTool")
        button.set_label(_("Color Palette"))
        side_vbox.pack_end(button, False, False)

        # History
        section_frame = widgets.section_frame(_("Recently Used"))
        panel_vbox.pack_start(section_frame, True, True)

        history = ColorHistoryView(app)
        history.button_clicked += self._history_button_clicked
        section_frame.add(history)