Ejemplo n.º 1
0
    def __init__(self, parent=None, screenshot=None):
        '''
        init toolbar
        @param parent: the transient parent for this window
        @param screenshot: a Screenshot object
        '''
        self.screenshot = screenshot
        self.win = screenshot.window
        self.__config = OperateConfig()
        save_op = self.__config.get("save", "save_op")
        if save_op:
            self.screenshot.save_op_index = int(save_op)
        else:
            self.screenshot.save_op_index = SAVE_OP_AUTO

        #toolbar_padding_x = 15
        #toolbar_padding_y = 5
        #toolbar_icon_width = toolbar_icon_height = 28
        #toolbar_icon_num = 10
        #self.height = toolbar_icon_height + toolbar_padding_y * 2
        self.height = 30
        self.width = 279
        #self.width = 240

        self.window = Window(window_type=gtk.WINDOW_POPUP, shadow_visible=False)
        self.window.set_keep_above(True)
        self.window.set_decorated(False)
        self.window.set_transient_for(parent)

        self.toolbox = gtk.HBox(False, 6)
        toolbox_align = gtk.Alignment()
        toolbox_align.set(0, 0.5, 0, 0)
        toolbox_align.set_padding(2, 2, 11, 11)
        toolbox_align.add(self.toolbox)
        self.window.window_frame.pack_start(toolbox_align, True, True)
        #self.window.set_size_request(self.width, self.height)
        self.window.set_size_request(-1, self.height)

        self._toggle_button_list = []
        self.__button_accelerator_dict = {}
        self._toggle_button_group = ToggleButtonGroup([], 6)
        self.toolbox.pack_start(self._toggle_button_group)
        self.create_toggle_button("rect", ACTION_RECTANGLE, 0, _("Draw Rectangle"), "<Alt>1")
        self.create_toggle_button("ellipse", ACTION_ELLIPSE, 1, _("Draw Ellipse"), "<Alt>2")
        self.create_toggle_button("arrow",ACTION_ARROW, 2, _("Draw Arrow"), "<Alt>3")
        self.create_toggle_button("line",ACTION_LINE, 3, _("Draw Line"), "<Alt>4")
        self.create_toggle_button("text",ACTION_TEXT, 4, _("Draw Text"), "<Alt>5")

        self.create_button("undo", _("Undo"), "<Alt>6")

        if self.screenshot.is_subprocess:
            self.create_button("save", _("Save"), "<Alt>7")
        else:
            # pack save and list button
            save_combo_button = ComboButton(
                app_theme.get_pixbuf("action/save_normal.png"),
                app_theme.get_pixbuf("action/save_hover.png"),
                app_theme.get_pixbuf("action/save_press.png"),
                app_theme.get_pixbuf("action/save_normal.png"),
                app_theme.get_pixbuf("action/list_normal.png"),
                app_theme.get_pixbuf("action/list_hover.png"),
                app_theme.get_pixbuf("action/list_press.png"),
                app_theme.get_pixbuf("action/list_normal.png"),)
            save_combo_button.set_name("save")
            save_combo_button.connect("button-clicked", self._button_clicked, "save")
            save_combo_button.connect("arrow-clicked", self._list_menu_show)
            save_tip_text_list = ["Save automatically", "Save as", "Save to clipboard", "Save automatically to file and clipboard"]
            tip_text = save_tip_text_list[self.screenshot.save_op_index]
            save_combo_button.connect("enter-notify-event", self._show_tooltip, _(tip_text))
            self.toolbox.pack_start(save_combo_button)

        self.create_button("cancel", _("Cancel"), "<Alt>8")

        if not self.screenshot.is_subprocess:
            self.create_button("share", _("Share"), "<Alt>9")

        if self.screenshot:
            self._button_clicked_cb = {
                'undo': self.screenshot.undo,
                'save': self.save_operate,
                'cancel': self.win.quit,
                'share': self.share_picture}
Ejemplo n.º 2
0
      (None, "选项3", None),
      ],
     is_root_menu=True,
     )
 
 def click_combo_button(widget):
     print "click combo button"
     
 def show_combo_menu(widget, x, y, offset_x, offset_y):
     combo_menu.show((x, y), (offset_x, offset_y))
     
 combo_button = ComboButton(
     app_theme.get_pixbuf("button/button_normal.png"),
     app_theme.get_pixbuf("button/button_hover.png"),
     app_theme.get_pixbuf("button/button_press.png"),
     app_theme.get_pixbuf("button/button_normal.png"),
     app_theme.get_pixbuf("button/arrow_normal.png"),
     app_theme.get_pixbuf("button/arrow_hover.png"),
     app_theme.get_pixbuf("button/arrow_press.png"),
     app_theme.get_pixbuf("button/arrow_normal.png"),
     )
 combo_button.connect("button-clicked", click_combo_button)
 combo_button.connect("arrow-clicked", show_combo_menu)
 
 tab_1_box.pack_start(combo_button, False, False)
 
 # Add statusbar.
 statusbar = Statusbar(36)
 tab_1_box.pack_start(statusbar, False)
 application.window.add_move_event(statusbar)
 application.window.add_toggle_event(statusbar)
 
Ejemplo n.º 3
0
            (None, "选项3", None),
        ],
        is_root_menu=True,
    )

    def click_combo_button(widget):
        print "click combo button"

    def show_combo_menu(widget, x, y, offset_x, offset_y):
        combo_menu.show((x, y), (offset_x, offset_y))

    combo_button = ComboButton(
        app_theme.get_pixbuf("button/button_normal.png"),
        app_theme.get_pixbuf("button/button_hover.png"),
        app_theme.get_pixbuf("button/button_press.png"),
        app_theme.get_pixbuf("button/button_normal.png"),
        app_theme.get_pixbuf("button/arrow_normal.png"),
        app_theme.get_pixbuf("button/arrow_hover.png"),
        app_theme.get_pixbuf("button/arrow_press.png"),
        app_theme.get_pixbuf("button/arrow_normal.png"),
    )
    combo_button.connect("button-clicked", click_combo_button)
    combo_button.connect("arrow-clicked", show_combo_menu)

    temp_hbox = gtk.HBox()
    tab_1_box.pack_start(temp_hbox, False, False)

    temp_hbox.pack_start(combo_button, False, False)

    star_view = StarView()
    temp_hbox.pack_start(star_view, False, False)
Ejemplo n.º 4
0
    def __init__(self, parent=None, screenshot=None):
        '''
        init toolbar
        @param parent: the transient parent for this window
        @param screenshot: a Screenshot object
        '''
        self.screenshot = screenshot
        self.win = screenshot.window
        self.__config = OperateConfig()
        save_op = self.__config.get("save", "save_op")
        if save_op:
            self.screenshot.save_op_index = int(save_op)
        else:
            self.screenshot.save_op_index = SAVE_OP_AUTO

        #toolbar_padding_x = 15
        #toolbar_padding_y = 5
        #toolbar_icon_width = toolbar_icon_height = 28
        #toolbar_icon_num = 10
        #self.height = toolbar_icon_height + toolbar_padding_y * 2
        self.height = 30
        self.width = 279
        #self.width = 240

        self.window = Window(window_type=gtk.WINDOW_POPUP,
                             shadow_visible=False)
        self.window.set_keep_above(True)
        self.window.set_decorated(False)
        self.window.set_transient_for(parent)

        self.toolbox = gtk.HBox(False, 6)
        toolbox_align = gtk.Alignment()
        toolbox_align.set(0, 0.5, 0, 0)
        toolbox_align.set_padding(2, 2, 11, 11)
        toolbox_align.add(self.toolbox)
        self.window.window_frame.pack_start(toolbox_align, True, True)
        #self.window.set_size_request(self.width, self.height)
        self.window.set_size_request(-1, self.height)

        self._toggle_button_list = []
        self._toggle_button_group = ToggleButtonGroup([], 6)
        self.toolbox.pack_start(self._toggle_button_group)
        self.create_toggle_button("rect", ACTION_RECTANGLE, 0,
                                  _("draw rectangle"))
        self.create_toggle_button("ellipse", ACTION_ELLIPSE, 1,
                                  _("draw ellipse"))
        self.create_toggle_button("arrow", ACTION_ARROW, 2, _("draw arrow"))
        self.create_toggle_button("line", ACTION_LINE, 3, _("draw line"))
        self.create_toggle_button("text", ACTION_TEXT, 4, _("draw Text"))

        self.create_button("undo", _("undo"))
        # pack save and list button
        save_combo_button = ComboButton(
            app_theme.get_pixbuf("action/save_normal.png"),
            app_theme.get_pixbuf("action/save_hover.png"),
            app_theme.get_pixbuf("action/save_press.png"),
            app_theme.get_pixbuf("action/save_normal.png"),
            app_theme.get_pixbuf("action/list_normal.png"),
            app_theme.get_pixbuf("action/list_hover.png"),
            app_theme.get_pixbuf("action/list_press.png"),
            app_theme.get_pixbuf("action/list_normal.png"),
        )
        save_combo_button.set_name("save")
        save_combo_button.connect("button-clicked", self._button_clicked,
                                  "save")
        save_combo_button.connect("arrow-clicked", self._list_menu_show)
        save_tip_text_list = [
            "save automatically", "save as", "save to clipboard",
            "save automatically to file and clipboard"
        ]
        tip_text = save_tip_text_list[self.screenshot.save_op_index]
        save_combo_button.connect("enter-notify-event", self._show_tooltip,
                                  _(tip_text))
        self.toolbox.pack_start(save_combo_button)

        self.create_button("cancel", _("cancel"))
        self.create_button("share", _("share"))

        if self.screenshot:
            self._button_clicked_cb = {
                'undo': self.screenshot.undo,
                'save': self.save_operate,
                'cancel': self.win.quit,
                'share': self.share_picture
            }