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 }
def init_toolbar(self): self.toolbar = Window(window_type=gtk.WINDOW_POPUP) self.toolbar.set_size_request(-1, 41) padding_x, padding_y = 10, 5 play_box = gtk.HBox(spacing=2) play_box.connect("expose-event", self.expose_toolbar_mask) # swap played status handler Player.connect("played", self.__swap_play_status, True) Player.connect("paused", self.__swap_play_status, False) Player.connect("stopped", self.__swap_play_status, False) Player.connect("play-end", self.__swap_play_status, False) self.playpause_button = ToggleButton( app_theme.get_pixbuf("lyric/play_normal.png"), app_theme.get_pixbuf("lyric/pause_normal.png"), app_theme.get_pixbuf("lyric/play_hover.png"), app_theme.get_pixbuf("lyric/pause_hover.png"), app_theme.get_pixbuf("lyric/play_press.png"), app_theme.get_pixbuf("lyric/pause_press.png"), ) self.__id_signal_play = self.playpause_button.connect( "toggled", lambda w: Player.playpause()) prev = self.__create_button("previous") next = self.__create_button("next") prev_align = gtk.Alignment() prev_align.set(0.5, 0.5, 0, 0) prev_align.add(prev) next_align = gtk.Alignment() next_align.set(0.5, 0.5, 0, 0) next_align.add(next) play_align = gtk.Alignment() play_align.set_padding(2, 0, 0, 0) play_align.set(0.5, 0.5, 0, 0) play_align.add(self.playpause_button) # separte line separate_line = ImageBox(app_theme.get_pixbuf("lyric/separate.png")) sep_align = gtk.Alignment() sep_align.set(0.5, 0.5, 0, 0) sep_align.add(separate_line) zoom_in_align = self.__create_zoom_button( "zoom_in", _("Increase the lyrics size")) zoom_out_align = self.__create_zoom_button( "zoom_out", _("Decrease the lyrics size")) predefine_align = self.__create_simple_button( "predefine_color", self.popup_predefine_menu, _("Select color theme"), True) lock_align = self.__create_simple_button("lock", self.__lock_lyrics, _("Lock Lyrics")) karaoke_align, self.karaoke_button = self.__create_single_toggle_button( "karaoke", self.change_karaoke_status, _("Karaoke on/off")) line_align, self.line_button = self.__create_simple_toggle_button( "single_line", "double_line", None, _("Switch lines")) self.line_button_toggled_id = self.line_button.connect( "toggled", self.change_line_status) setting_align = self.__create_simple_button("setting", self.open_setting_window, _("Open settings panel")) search_align = self.__create_simple_button( "search", self.open_search_window, _("Search lrc file for current track")) close_align = self.__create_simple_button("close", self.close_lyric_window, _("Close lyrics")) before_align = self.__create_simple_button("before", self.before_offset, _("Lyrics rewind")) after_align = self.__create_simple_button("after", self.after_offset, _("Lyrics forward")) lrc_align = self.__create_simple_button("lrc", self.switch_to_scroll_lyrics, _("Switch to window mode")) play_box.pack_start(prev_align, False, False) play_box.pack_start(play_align, False, False) play_box.pack_start(next_align, False, False) play_box.pack_start(sep_align, False, False) play_box.pack_start(zoom_in_align, False, False) play_box.pack_start(zoom_out_align, False, False) play_box.pack_start(before_align, False, False) play_box.pack_start(after_align, False, False) play_box.pack_start(predefine_align, False, False) play_box.pack_start(karaoke_align, False, False) play_box.pack_start(line_align, False, False) play_box.pack_start(lock_align, False, False) play_box.pack_start(setting_align, False, False) play_box.pack_start(lrc_align, False, False) play_box.pack_start(search_align, False, False) play_box.pack_start(close_align, False, False) main_align = gtk.Alignment() main_align.set_padding(0, 0, padding_x, padding_x) main_align.set(0.5, 0.5, 0, 0) main_align.add(play_box) self.toolbar.window_frame.pack_start(main_align) self.load_button_status()
def __init__(self, parent=None, screenshot=None): ''' init colorbar @param parent: the transient parent for this window @param screenshot: a Screenshot object ''' self.screenshot = screenshot self.win = self.screenshot.window #padding_x = 5 #padding_y = 3 #icon_width = icon_height = 28 #self.width = 280 #color_num = 9 #self.height = icon_height + padding_y * 2 self.height = 36 self.width = 279 self.width_no_fill = 254 self.width_text = 259 self.window = Window(window_type=gtk.WINDOW_POPUP, shadow_visible=False) self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.window.set_keep_above(True) self.window.set_transient_for(parent) self.window.set_decorated(False) #vbox = gtk.VBox(False, 0) self.box = gtk.HBox(False, 5) self.size_box = gtk.HBox(False, 5) self.dynamic_box = gtk.HBox() colorbox_align = gtk.Alignment() #colorbox_align.set(0.5, 0.5, 0, 0) colorbox_align.set(0, 0.5, 1, 0) colorbox_align.set_padding(2, 2, 11, 11) colorbox_align.add(self.box) self.window.window_frame.pack_start(colorbox_align, True, True) self.window.set_size_request(self.width, self.height) #self.window.set_size_request(-1, self.height) self.__size_button_dict = {} self.create_size_button("small", ACTION_SIZE_SMALL) self.create_size_button("normal", ACTION_SIZE_NORMAL) self.create_size_button("big", ACTION_SIZE_BIG) self.create_size_button("ellipse_fill", ACTION_SIZE_RECTANGLE_ELLIPSE_FILL) self.create_size_button("rect_fill", ACTION_SIZE_RECTANGLE_ELLIPSE_FILL) self._set_size_button_state("small", True) self.size_align = gtk.Alignment() #self.size_align.set(0.5,0.5,0,0) self.size_align.set(0, 0.5, 1, 0) self.size_align.add(self.size_box) #self.dynamic_box.pack_start(self.size_align) self.box.pack_start(self.dynamic_box) # font select self.font_box = gtk.HBox(False, 5) font_img = gtk.image_new_from_pixbuf( app_theme.get_pixbuf("action/text_normal.png").get_pixbuf()) self.font_spin = SpinBox(self.screenshot.font_size, 8, 72, 1) self.font_spin.connect("value-changed", self._font_size_changed) self.font_spin.value_entry.set_can_focus(False) self.font_box.pack_start(font_img) self.font_box.pack_start(self.font_spin) self.font_align = gtk.Alignment() self.font_align.set(0.5, 0.5, 0, 0) self.font_align.add(self.font_box) # color select #self.color_select = gtk.EventBox() self.color_select = gtk.Image() pix = app_theme.get_pixbuf("color_big/red.png").get_pixbuf() self.color_select.set_from_pixbuf(pix) self.box.pack_start(self.color_select, False, False) # color button self.vbox = gtk.VBox(False, 2) self.above_hbox = gtk.HBox(False, 2) self.below_hbox = gtk.HBox(False, 2) self.color_map = { 'black': "#000000", # 1-1 'gray_dark': "#808080", # 1-2 'red': "#FF0000", # 1-3 'yellow_dark': "#FF9B00", # 1-4 'yellow': "#FFFF00", # 1-5 'green': "#B2E700", # 1-6 'green_dark': "#008000", # 1-7 'wathet_dark': "#008080", # 1-8 'white': "#FFFFFF", # 2-1 'gray': "#C0C0C0", # 2-2 'red_dark': "#E2004E", # 2-3 'pink': "#E2007A", # 2-4 'pink_dark': "#800080", # 2-5 'blue_dark': "#000080", # 2-6 'blue': "#0085E1", # 2-7 'wathet': "#009DE0" } # 2-8 self.create_color_button(self.above_hbox, "black") self.create_color_button(self.above_hbox, "gray_dark") self.create_color_button(self.above_hbox, "red") self.create_color_button(self.above_hbox, "yellow_dark") self.create_color_button(self.above_hbox, "yellow") self.create_color_button(self.above_hbox, "green") self.create_color_button(self.above_hbox, "green_dark") self.create_color_button(self.above_hbox, "wathet_dark") self.create_color_button(self.below_hbox, "white") self.create_color_button(self.below_hbox, "gray") self.create_color_button(self.below_hbox, "red_dark") self.create_color_button(self.below_hbox, "pink") self.create_color_button(self.below_hbox, "pink_dark") self.create_color_button(self.below_hbox, "blue_dark") self.create_color_button(self.below_hbox, "blue") self.create_color_button(self.below_hbox, "wathet") self.vbox.pack_start(self.above_hbox) self.vbox.pack_start(self.below_hbox) self.box.pack_start(self.vbox)