def _create_view_toolbar(self): # Color changer and Zoom toolbar view_toolbar = Gtk.Toolbar() self._theme_toggler = ToolButton('dark-theme') self._theme_toggler.set_tooltip('Switch to Dark Theme') self._theme_toggler.props.accelerator = '<Ctrl><Shift>I' self._theme_toggler.connect('clicked', self._toggled_theme) view_toolbar.insert(self._theme_toggler, -1) self._theme_toggler.show() self.fg_color_palette = ColorToolButton('color-preview') self.fg_color_palette._tooltip = "Set Foreground Text color" self.fg_color_palette.set_title('Foreground Color') self.fg_color_palette.connect('notify::color', self.__fg_color_notify_cb) view_toolbar.insert(self.fg_color_palette, -1) self.fg_color_palette.show() self.bg_color_palette = ColorToolButton('color-preview') self.bg_color_palette._tooltip = "Set Background color" self.bg_color_palette.set_title('Background Color') self.bg_color_palette.connect('notify::color', self.__bg_color_notify_cb) self.bg_color_palette.set_color(Gdk.Color.parse('#FFFFFF')[1]) view_toolbar.insert(self.bg_color_palette, -1) self.bg_color_palette.show() sep = Gtk.SeparatorToolItem() view_toolbar.insert(sep, -1) sep.show() zoom_out_button = ToolButton('zoom-out') zoom_out_button.set_tooltip(_('Zoom out')) zoom_out_button.props.accelerator = '<Ctrl>minus' zoom_out_button.connect('clicked', self.__zoom_out_cb) view_toolbar.insert(zoom_out_button, -1) zoom_out_button.show() zoom_in_button = ToolButton('zoom-in') zoom_in_button.set_tooltip(_('Zoom in')) zoom_in_button.props.accelerator = '<Ctrl>plus' zoom_in_button.connect('clicked', self.__zoom_in_cb) view_toolbar.insert(zoom_in_button, -1) zoom_in_button.show() fullscreen_button = ToolButton('view-fullscreen') fullscreen_button.set_tooltip(_("Fullscreen")) fullscreen_button.props.accelerator = '<Alt>Return' fullscreen_button.connect('clicked', self.__fullscreen_cb) view_toolbar.insert(fullscreen_button, -1) fullscreen_button.show() return view_toolbar
test = common.Test() test.show() box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) test.pack_start(box, True, True, 0) box.show() toolbar_box = ToolbarBox() box.pack_start(toolbar_box, False, False, 0) toolbar_box.show() separator = Gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() def color_changed_cb(button, pspec): print button.get_color() color_button = ColorToolButton() color_button.connect("notify::color", color_changed_cb) toolbar_box.toolbar.insert(color_button, -1) color_button.show() if __name__ == '__main__': common.main(test)
def __init__(self, handle): activity.Activity.__init__(self, handle, True) self.max_participants = 1 # CHART_OPTIONS self._font_option = TITLE_FONT self.x_label = '' self.y_label = '' self.chart_color = utils.get_user_fill_color('str') self.chart_line_color = utils.get_user_stroke_color('str') self.current_chart = None self.charts_area = None self.chart_data = [] self.chart_type_buttons = [] self._font_options = { 'titleColor': '#000000', 'titleFont': 'Sans', 'titleFontSize': 12, 'axis': { 'tickFont': 'Sans', 'tickFontSize': 12, 'tickColor': '#000000', 'labelFontSize': 14, 'labelColor': '#666666', 'labelFont': 'Sans', 'lineColor': '#b3b3b3'}} # TOOLBARS self._labels_font = RadioToolButton() self._title_font = RadioToolButton() toolbarbox = ToolbarBox() activity_button = ActivityToolbarButton(self) activity_btn_toolbar = activity_button.page activity_btn_toolbar.title.connect('changed', self._set_chart_title) save_as_image = ToolButton('save-as-image') save_as_image.connect('clicked', self._save_as_image) save_as_image.set_tooltip(_('Save as image')) activity_btn_toolbar.insert(save_as_image, -1) save_as_image.show() import_stopwatch = ToolButton('import-stopwatch') import_stopwatch.connect('clicked', self.__import_stopwatch_cb) import_stopwatch.set_tooltip(_('Read StopWatch data')) activity_btn_toolbar.insert(import_stopwatch, -1) import_stopwatch.show() import_measure = ToolButton('import-measure') import_measure.set_tooltip(_('Read Measure data')) if utils.get_channels() == 1: import_measure.connect('clicked', self.__import_measure_cb, 1) else: import_measure.connect('clicked', self._measure_btn_clicked) self._create_measure_palette(import_measure) activity_btn_toolbar.insert(import_measure, -1) import_measure.show() toolbarbox.toolbar.insert(activity_button, 0) add_v = ToolButton('gtk-add') add_v.connect('clicked', self._add_value) add_v.set_tooltip(_('Add a value')) toolbarbox.toolbar.insert(add_v, -1) remove_v = ToolButton('gtk-remove') remove_v.connect('clicked', self._remove_value) remove_v.set_tooltip(_('Remove the selected value')) toolbarbox.toolbar.insert(remove_v, -1) self._remove_v = remove_v separator = Gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) toolbarbox.toolbar.insert(separator, -1) # We create two sets: one for the main toolbar and one for the # chart toolbar. We choose which set to use based on the # screen width. self._create_chart_buttons(toolbarbox.toolbar) self._chart_button = ToolbarButton(icon_name='vbar') chart_toolbar = Gtk.Toolbar() self._create_chart_buttons(chart_toolbar) self._chart_button.props.page = chart_toolbar chart_toolbar.show_all() toolbarbox.toolbar.insert(self._chart_button, -1) separator = Gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) toolbarbox.toolbar.insert(separator, -1) self._options_button = ToolbarButton(icon_name='preferences-system') options_toolbar = Gtk.Toolbar() self.chart_color_btn = ColorToolButton() self.chart_color_btn.set_color(_COLOR1) self.chart_color_btn.set_title(_('Chart Color')) options_toolbar.insert(self.chart_color_btn, -1) GObject.timeout_add(1000, self._connect_color_btn, self.chart_color_btn, self._set_chart_color) self.line_color_btn = ColorToolButton() self.line_color_btn.set_color(_COLOR2) self.line_color_btn.set_title(_('Line Color')) options_toolbar.insert(self.line_color_btn, -1) GObject.timeout_add(1000, self._connect_color_btn, self.line_color_btn, self._set_chart_line_color) separator = Gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) options_toolbar.insert(separator, -1) h_label_icon = Icon(icon_name='hlabel') h_label_tool_item = Gtk.ToolItem() h_label_tool_item.add(h_label_icon) options_toolbar.insert(h_label_tool_item, -1) self.h_label = Entry(_('Horizontal label...')) self.h_label.entry.connect('changed', self._set_h_label) options_toolbar.insert(self.h_label, -1) separator = Gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(False) options_toolbar.insert(separator, -1) v_label_icon = Icon(icon_name='vlabel') v_label_tool_item = Gtk.ToolItem() v_label_tool_item.add(v_label_icon) options_toolbar.insert(v_label_tool_item, -1) self.v_label = Entry(_('Vertical label...')) self.v_label.entry.connect('changed', self._set_v_label) options_toolbar.insert(self.v_label, -1) self._options_button.props.page = options_toolbar options_toolbar.show_all() toolbarbox.toolbar.insert(self._options_button, -1) text_toolbar_btn = ToolbarButton() text_toolbar_btn.props.icon_name = 'format-text' text_toolbar_btn.props.label = _('Text') toolbarbox.toolbar.insert(text_toolbar_btn, -1) self._text_options_btn = text_toolbar_btn texttoolbar = Gtk.Toolbar() self.font_name_combo = FontComboBox() self.font_name_combo.set_font_name('Sans') def set_font_name(w): self._set_chart_font_options(font=w.get_font_name()) self.font_name_combo.connect("changed", set_font_name) texttoolbar.insert(ToolComboBox(self.font_name_combo), -1) self.font_size = FontSize() def set_font_size(w): self._set_chart_font_options(size=w.get_font_size()) self.font_size.connect("changed", set_font_size) texttoolbar.insert(self.font_size, -1) self.text_color_btn = ColorToolButton() self.text_color_btn.set_color(style.COLOR_BLACK.get_gdk_color()) self.text_color_btn.set_title(_('Font Color')) texttoolbar.insert(self.text_color_btn, -1) GObject.timeout_add(1000, self._connect_color_btn, self.text_color_btn, self._set_text_color) # self._title_font created in the top of the file self._title_font.connect('clicked', self._set_font_option, TITLE_FONT) self._title_font.set_tooltip(_('Title font')) self._title_font.props.icon_name = 'title-font' op_group = self._title_font texttoolbar.insert(self._title_font, 0) # self._labels_font created in the top of the file self._labels_font.connect('clicked', self._set_font_option, LABELS_FONT) self._labels_font.set_tooltip(_('Labels font')) self._labels_font.props.icon_name = 'labels-font' self._labels_font.props.group = op_group texttoolbar.insert(self._labels_font, 1) tick_font = RadioToolButton() tick_font.connect('clicked', self._set_font_option, TICK_FONT) tick_font.set_tooltip(_('Tick font')) tick_font.props.icon_name = 'tick-font' tick_font.props.group = op_group texttoolbar.insert(tick_font, 2) separator = Gtk.SeparatorToolItem() texttoolbar.insert(separator, 3) text_toolbar_btn.props.page = texttoolbar texttoolbar.show_all() separator = Gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) toolbarbox.toolbar.insert(separator, -1) self._fullscreen_button = ToolButton('view-fullscreen') self._fullscreen_button.set_tooltip(_("Fullscreen")) self._fullscreen_button.props.accelerator = '<Alt>Return' self._fullscreen_button.connect('clicked', self.__fullscreen_cb) toolbarbox.toolbar.insert(self._fullscreen_button, -1) charthelp.create_help(toolbarbox.toolbar) separator = Gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) toolbarbox.toolbar.insert(separator, -1) stopbtn = StopButton(self) toolbarbox.toolbar.insert(stopbtn, -1) self.set_toolbar_box(toolbarbox) # CANVAS paned = Gtk.HPaned() box = Gtk.VBox() self.box = box # Set the info box width to 1/3 of the screen: def size_allocate_cb(widget, allocation): paned.disconnect(self._setup_handle) box_width = allocation.width / 3 box.set_size_request(box_width, -1) self._setup_handle = paned.connect('size_allocate', size_allocate_cb) scroll = Gtk.ScrolledWindow() scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.labels_and_values = ChartData(self) scroll.add(self.labels_and_values) self.labels_and_values.connect('label-changed', self._label_changed) self.labels_and_values.connect('value-changed', self._value_changed) box.pack_start(scroll, True, True, 0) liststore_toolbar = Gtk.Toolbar() move_up = ToolButton('go-up') move_up.set_tooltip(_('Move up')) move_up.connect('clicked', self._move_up) move_down = ToolButton('go-down') move_down.set_tooltip(_('Move down')) move_down.connect('clicked', self._move_down) liststore_toolbar.insert(move_up, 0) liststore_toolbar.insert(move_down, 1) box.pack_end(liststore_toolbar, False, False, 0) paned.add1(box) # CHARTS AREA eventbox = Gtk.EventBox() self.charts_area = ChartArea(self) eventbox.modify_bg(Gtk.StateType.NORMAL, _WHITE) eventbox.add(self.charts_area) self._notebook = Gtk.Notebook() self._notebook.set_property('show-tabs', False) self._notebook.append_page(eventbox, Gtk.Label()) # EMPTY WIDGETS empty_widgets = Gtk.EventBox() empty_widgets.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color()) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) mvbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox.pack_start(mvbox, True, False, 0) image_icon = Icon(pixel_size=style.LARGE_ICON_SIZE, icon_name='chart', stroke_color=style.COLOR_BUTTON_GREY.get_svg(), fill_color=style.COLOR_TRANSPARENT.get_svg()) mvbox.pack_start(image_icon, False, False, style.DEFAULT_PADDING) label = Gtk.Label('<span foreground="%s"><b>%s</b></span>' % (style.COLOR_BUTTON_GREY.get_html(), _('No data'))) label.set_use_markup(True) mvbox.pack_start(label, False, False, style.DEFAULT_PADDING) hbox = Gtk.Box() open_image_btn = Gtk.Button() open_image_btn.connect('clicked', self._add_value) add_image = Gtk.Image.new_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON) buttonbox = Gtk.Box() buttonbox.pack_start(add_image, False, True, 0) buttonbox.pack_end(Gtk.Label(_('Add a value')), True, True, 5) open_image_btn.add(buttonbox) hbox.pack_start(open_image_btn, True, False, 0) mvbox.pack_start(hbox, False, False, style.DEFAULT_PADDING) empty_widgets.add(vbox) empty_widgets.show_all() self._notebook.append_page(empty_widgets, Gtk.Label()) paned.add2(self._notebook) self.set_canvas(paned) self.charts_area.connect('size_allocate', self._chart_size_allocate) self.show_all() Gdk.Screen.get_default().connect('size-changed', self._configure_cb) self._configure_cb()
def build_toolbar(self): self.max_participants = 4 toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() create_toolbar = ToolbarButton() create_toolbar.props.page = Gtk.Toolbar() create_toolbar.props.icon_name = 'magicpen' create_toolbar.props.label = _('Create') toolbar_box.toolbar.insert(create_toolbar, -1) self._insert_create_tools(create_toolbar) color = ColorToolButton('color') color.connect('notify::color', self.__color_notify_cb) toolbar_box.toolbar.insert(color, -1) color.show() random = ToggleToolButton('colorRandom') random.set_tooltip(_('Toggle random color')) toolbar_box.toolbar.insert(random, -1) random.set_active(True) random.connect('toggled', self.__random_toggled_cb) random.show() color.random = random random.color = color random.timeout_id = GLib.timeout_add(100, self.__timeout_cb, random) self._insert_stop_play_button(toolbar_box.toolbar) clear_trace = ToolButton('clear-trace') clear_trace.set_tooltip(_('Clear Trace Marks')) clear_trace.set_accelerator(_('<ctrl>x')) clear_trace.connect('clicked', self.clear_trace_cb) clear_trace.set_sensitive(False) toolbar_box.toolbar.insert(clear_trace, -1) clear_trace.show() self.clear_trace = clear_trace self._insert_clear_all_button(toolbar_box.toolbar) load_example = ToolButton('load-sample') load_example.set_tooltip(_('Show sample projects')) load_example.connect('clicked', self._create_store) toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1) toolbar_box.toolbar.insert(load_example, -1) load_example.show() separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_size_request(0, -1) separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop = StopButton(self) toolbar_box.toolbar.insert(stop, -1) stop.show() separator = Gtk.SeparatorToolItem() activity_button.props.page.insert(separator, -1) separator.show() export_json = ToolButton('save-as-json') export_json.set_tooltip(_('Export tracked objects to journal')) export_json.connect('clicked', self._export_json_cb) activity_button.props.page.insert(export_json, -1) export_json.show() load_project = ToolButton('load-project') load_project.set_tooltip(_('Load project from journal')) load_project.connect('clicked', self._load_project) activity_button.props.page.insert(load_project, -1) load_project.show() self.set_toolbar_box(toolbar_box) toolbar_box.show_all() create_toolbar.set_expanded(True) return toolbar_box
def __init__(self, abiword_canvas): GObject.GObject.__init__(self) self.font_name_combo = FontComboBox() self.font_name_combo.set_font_name('Sans') self._fonts_changed_id = self.font_name_combo.connect( 'changed', self._font_changed_cb, abiword_canvas) self._abi_handler = abiword_canvas.connect('font-family', self._font_family_cb) self.insert(ToolComboBox(self.font_name_combo), -1) self.font_size = FontSize() self._abi_handler = abiword_canvas.connect('font-size', self._font_size_cb) self._changed_id = self.font_size.connect( 'changed', self._font_size_changed_cb, abiword_canvas) self.insert(self.font_size, -1) bold = ToggleToolButton('format-text-bold') bold.set_tooltip(_('Bold')) bold.props.accelerator = '<Ctrl>B' bold_id = bold.connect('clicked', lambda sender: abiword_canvas.toggle_bold()) abiword_canvas.connect('bold', lambda abi, b: self._setToggleButtonState(bold, b, bold_id)) self.insert(bold, -1) italic = ToggleToolButton('format-text-italic') italic.set_tooltip(_('Italic')) italic.props.accelerator = '<Ctrl>I' italic_id = italic.connect('clicked', lambda sender: abiword_canvas.toggle_italic()) abiword_canvas.connect('italic', lambda abi, b: self._setToggleButtonState(italic, b, italic_id)) self.insert(italic, -1) underline = ToggleToolButton('format-text-underline') underline.set_tooltip(_('Underline')) underline.props.accelerator = '<Ctrl>U' underline_id = underline.connect('clicked', lambda sender: abiword_canvas.toggle_underline()) abiword_canvas.connect('underline', lambda abi, b: self._setToggleButtonState(underline, b, underline_id)) self.insert(underline, -1) color = ColorToolButton() color.connect('notify::color', self._text_color_cb, abiword_canvas) tool_item = Gtk.ToolItem() tool_item.add(color) self.insert(tool_item, -1) abiword_canvas.connect( 'color', lambda abi, r, g, b: color.set_color(Gdk.Color(r * 256, g * 256, b * 256))) # MAGIC NUMBER WARNING: Secondary toolbars are not a standard height? self.set_size_request(-1, style.GRID_CELL_SIZE) def append_align(icon_name, tooltip, do_abi_cb, style_name, button, menu_box): menu_item = AbiMenuItem(abiword_canvas, style_name, do_abi_cb, icon_name, tooltip, button) menu_box.append_item(menu_item) menu_item.show() self._aligment_btn = ToolButton(icon_name='format-justify-left') self._aligment_btn.props.tooltip = _('Choose alignment') self._aligment_btn.props.hide_tooltip_on_click = False self._aligment_btn.palette_invoker.props.toggle_palette = True menu_box = PaletteMenuBox() self._aligment_btn.props.palette.set_content(menu_box) menu_box.show() append_align('format-justify-left', _('Left justify'), abiword_canvas.align_left, 'left-align', self._aligment_btn, menu_box) append_align('format-justify-center', _('Center justify'), abiword_canvas.align_center, 'center-align', self._aligment_btn, menu_box) append_align('format-justify-right', _('Right justify'), abiword_canvas.align_right, 'right-align', self._aligment_btn, menu_box) append_align('format-justify-fill', _('Fill justify'), abiword_canvas.align_justify, 'justify-align', self._aligment_btn, menu_box) self.insert(self._aligment_btn, -1) self.show_all()
def __init__(self, main_area): Gtk.Toolbar.__init__(self) self._main_area = main_area self._font_list = ['ABC123', 'Sans', 'Serif', 'Monospace', 'Symbol'] self._font_sizes = [ '8', '9', '10', '11', '12', '14', '16', '20', '22', '24', '26', '28', '36', '48', '72' ] self.font_button = ToolButton('font-text') self.font_button.set_tooltip(_('Select font')) self.font_button.connect('clicked', self.__font_selection_cb) self.insert(self.font_button, -1) self._setup_font_palette() self.insert(Gtk.SeparatorToolItem(), -1) self.font_size_up = ToolButton('resize+') self.font_size_up.set_tooltip(_('Bigger')) self.font_size_up.connect('clicked', self.__font_sizes_cb, True) self.insert(self.font_size_up, -1) if len(self._main_area.selected) > 0: font_size = self._main_area.font_size else: font_size = utils.default_font_size self.size_label = Gtk.Label(str(font_size)) self.size_label.show() toolitem = Gtk.ToolItem() toolitem.add(self.size_label) toolitem.show() self.insert(toolitem, -1) self.font_size_down = ToolButton('resize-') self.font_size_down.set_tooltip(_('Smaller')) self.font_size_down.connect('clicked', self.__font_sizes_cb, False) self.insert(self.font_size_down, -1) self.insert(Gtk.SeparatorToolItem(), -1) self.bold = ToolButton('bold-text') self.bold.set_tooltip(_('Bold')) self.bold.connect('clicked', self.__bold_cb) self.insert(self.bold, -1) self.italics = ToolButton('italics-text') self.italics.set_tooltip(_('Italics')) self.italics.connect('clicked', self.__italics_cb) self.insert(self.italics, -1) self.underline = ToolButton('underline-text') self.underline.set_tooltip(_('Underline')) self.underline.connect('clicked', self.__underline_cb) self.insert(self.underline, -1) foreground_color = ColorToolButton() foreground_color.set_title(_('Set font color')) foreground_color.connect('color-set', self.__foreground_color_cb) self.insert(foreground_color, -1) bakground_color = ColorToolButton() bakground_color.set_title(_('Set background color')) bakground_color.connect('color-set', self.__background_color_cb) bakground_color.set_color(Gdk.Color(65535, 65535, 65535)) self.insert(bakground_color, -1) self.show_all()
def make_toolbar(self): def make_separator(expand=False, size=0): separator = Gtk.SeparatorToolItem() separator.set_size_request(size, -1) if expand: separator.set_expand(True) if expand or size: separator.props.draw = False return separator self.color_palettes = [] toolbar_box = ToolbarBox() toolbar = toolbar_box.toolbar activity_button = ToolButton() activity_button.set_icon_widget(ActivityIcon(None)) toolbar.insert(activity_button, -1) toolbar.insert(make_separator(size=30), -1) button_copy = ToolButton(Gtk.STOCK_COPY) button_copy.set_tooltip('Copy the text.') button_copy.connect('clicked', self.copy_text) toolbar.insert(button_copy, -1) button_cut = ToolButton('cut') button_cut.set_tooltip('Cut the text.') button_cut.connect('clicked', self.cut_text) toolbar.insert(button_cut, -1) button_remove = ToolButton(Gtk.STOCK_REMOVE) button_remove.set_tooltip('Remove all the text.') button_remove.connect('clicked', self.remove_text) toolbar.insert(button_remove, -1) toolbar.insert(make_separator(size=30), -1) button_normal = ColorToolButton() button_normal.set_color(G.cairo_to_gdk(self.area.normal_color)) button_normal.set_title('Choose a color for the buttons.') button_normal.connect('color-set', self._normal_color_changed) toolbar.insert(button_normal, -1) self.color_palettes.append(button_normal) button_selected = ColorToolButton() button = button_selected.get_child() button_selected.set_color(G.cairo_to_gdk(self.area.selected_color)) button_selected.set_title('Choose a color for the selected buttons.') button_selected.connect('color-set', self._selected_color_changed) toolbar.insert(button_selected, -1) self.color_palettes.append(button_selected) button_labels = ColorToolButton() button_labels.set_color(G.cairo_to_gdk(self.area.label_color)) button_labels.set_title('Choose a color for the labels buttons.') button_labels.connect('color-set', self._label_color_changed) toolbar.insert(button_labels, -1) self.color_palettes.append(button_labels) button_background = ColorToolButton() button_background.set_color(G.cairo_to_gdk(self.area.background_color)) button_background.set_title('Choose a color for the background.') button_background.connect('color-set', self._background_color_changed) toolbar.insert(button_background, -1) self.color_palettes.append(button_background) toolbar.insert(make_separator(expand=True), -1) stop_button = ToolButton('activity-stop') stop_button.connect('clicked', lambda w: self.close()) stop_button.props.accelerator = '<Ctrl>Q' toolbar.insert(stop_button, -1) self.set_toolbar_box(toolbar_box)
def build_colors_toolbar(self, toolbox): colors_bar = Gtk.Toolbar() ######################################################################## # Point color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Points')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() fill_color = ColorToolButton() fill_color.connect('notify::color', self.color_point_change) item.add(fill_color) colors_bar.insert(item, -1) # Separator separator = Gtk.SeparatorToolItem() colors_bar.insert(separator, -1) separator.show() ######################################################################## # Back color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Background')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() _fill_color = ColorToolButton() c = Gdk.RGBA() c.red = 21588 c.green = 47546 c.blue = 18504 _fill_color.set_color(c) _fill_color.connect('notify::color', self.color_back_change) item.add(_fill_color) colors_bar.insert(item, -1) # Separator separator = Gtk.SeparatorToolItem() colors_bar.insert(separator, -1) separator.show() ######################################################################## # Line color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Lines')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() _fill_color = ColorToolButton() _fill_color.connect('notify::color', self.color_line_change) item.add(_fill_color) colors_bar.insert(item, -1) # Separator separator = Gtk.SeparatorToolItem() colors_bar.insert(separator, -1) separator.show() ######################################################################## # Owner color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Owner')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() _fill_color = ColorToolButton() c = Gdk.RGBA() c.red = 65535 _fill_color.set_color(c) _fill_color.connect('notify::color', self.color_owner_change) item.add(_fill_color) colors_bar.insert(item, -1) colors_bar.show_all() colors_button = ToolbarButton(label=_('Colors'), page=colors_bar, icon_name='toolbar-colors') toolbox.toolbar.insert(colors_button, -1) colors_button.show()
def __init__(self): super(PyApp, self).__init__() self.set_title('Palettes') self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) vbox = Gtk.VBox() toolbarbox = ToolbarBox() vbox.add(toolbarbox) toolbar = toolbarbox.toolbar color_button = ColorToolButton() toolbar.insert(color_button, -1) button = ToolButton('list-add') button.set_tooltip('Palette with widgets') toolbar.insert(button, -1) palette = button.get_palette() palette_box = Gtk.VBox() palette.set_content(palette_box) checkbutton1 = Gtk.CheckButton(label='Option 1') palette_box.pack_start(checkbutton1, False, False, 0) checkbutton2 = Gtk.CheckButton(label='Option 2') palette_box.pack_start(checkbutton2, False, False, 0) checkbutton3 = Gtk.CheckButton(label='Option 3') palette_box.pack_start(checkbutton3, False, False, 0) separator = Gtk.VSeparator() palette_box.pack_start(separator, False, False, 0) radio_button1 = Gtk.RadioButton(label='Option 1') palette_box.pack_start(radio_button1, False, False, 0) radio_button2 = Gtk.RadioButton(label='Option 2', group=radio_button1) palette_box.pack_start(radio_button2, False, False, 0) radio_button3 = Gtk.RadioButton(label='Option 3', group=radio_button1) palette_box.pack_start(radio_button3, False, False, 0) palette_box.show_all() button = ToolButton(icon_name='format-justify-fill') button.props.tooltip = 'Select list' button.props.hide_tooltip_on_click = False button.palette_invoker.props.toggle_palette = True toolbar.insert(button, -1) menu_box = PaletteMenuBox() button.props.palette.set_content(menu_box) menu_box.show() menu_item = PaletteMenuItem('Item 1', icon_name='format-justify-fill') menu_box.append_item(menu_item) menu_item = PaletteMenuItem('Item 1', icon_name='format-justify-center') menu_box.append_item(menu_item) menu_item = PaletteMenuItem('Item 1', icon_name='format-justify-left') menu_box.append_item(menu_item) menu_item = PaletteMenuItem('Item 1', icon_name='format-justify-right') menu_box.append_item(menu_item) self.add(vbox) self.show_all() self.connect('destroy', Gtk.main_quit)
def build_colors_toolbar(self, toolbox): colors_bar = Gtk.Toolbar() ###################################################################### # Point color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Player 1')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() _fill_color = ColorToolButton() color = Gdk.Color(red=65535, green=65535, blue=65535) _fill_color.set_color(color) _fill_color.connect('notify::color', self.color_player1_change) item.add(_fill_color) colors_bar.insert(item, -1) # Separator separator = Gtk.SeparatorToolItem() colors_bar.insert(separator, -1) separator.show() ###################################################################### # Back color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Player 2')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() _fill_color = ColorToolButton() color = Gdk.Color(red=0, green=0, blue=0) _fill_color.set_color(color) _fill_color.connect('notify::color', self.color_player2_change) item.add(_fill_color) colors_bar.insert(item, -1) # Separator separator = Gtk.SeparatorToolItem() colors_bar.insert(separator, -1) separator.show() ###################################################################### # Line color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Lines')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() _fill_color = ColorToolButton() _fill_color.connect('notify::color', self.color_line_change) item.add(_fill_color) colors_bar.insert(item, -1) # Separator separator = Gtk.SeparatorToolItem() colors_bar.insert(separator, -1) separator.show() ###################################################################### # Line color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Background')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() _fill_color = ColorToolButton() color = Gdk.Color(red=0, green=25700, blue=0) _fill_color.set_color(color) _fill_color.connect('notify::color', self.color_back_change) item.add(_fill_color) colors_bar.insert(item, -1) # Separator separator = Gtk.SeparatorToolItem() colors_bar.insert(separator, -1) separator.show() ###################################################################### # Line color item = Gtk.ToolItem() label = Gtk.Label() label.set_text('%s ' % _('Board')) item.add(label) colors_bar.insert(item, -1) # select color item = Gtk.ToolItem() _fill_color = ColorToolButton() color = Gdk.Color(red=0, green=0, blue=65535) _fill_color.set_color(color) _fill_color.connect('notify::color', self.color_board_change) item.add(_fill_color) colors_bar.insert(item, -1) ###################################################################### colors_bar.show_all() colors_button = ToolbarButton(label=_('Colors'), page=colors_bar, icon_name='toolbar-colors') toolbox.toolbar.insert(colors_button, -1) colors_button.show()
def __init__ (self, handle): if os.path.exists('/tmp/1'): os.remove('/tmp/1') activity.Activity.__init__ (self, handle) # abiword uses the current directory for all its file dialogs os.chdir(os.path.expanduser('~')) # create our main abiword canvas self.abiword_canvas = Abi.Widget() self.set_canvas(self.abiword_canvas) self.abiword_canvas.connect_after('map-event', self.__map_event_cb) self.abiword_canvas.show() if os.path.exists('/tmp/2'): os.remove('/tmp/2') toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) separator = Gtk.SeparatorToolItem() separator.show() activity_button.props.page.insert(separator, 2) export_button = ExportButton(self, self.abiword_canvas) export_button.show() activity_button.props.page.insert(export_button, 2) toolbar_box.toolbar.insert(activity_button, 0) edit_toolbar = ToolbarButton() edit_toolbar.props.page = EditToolbar(self, toolbar_box) edit_toolbar.props.icon_name = 'toolbar-edit' edit_toolbar.props.label = _('Edit') toolbar_box.toolbar.insert(edit_toolbar, -1) view_toolbar = ToolbarButton() view_toolbar.props.page = ViewToolbar(self.abiword_canvas) view_toolbar.props.icon_name = 'toolbar-view' view_toolbar.props.label = _('View') toolbar_box.toolbar.insert(view_toolbar, -1) separator = Gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) toolbar_box.show_all() self.set_toolbar_box(toolbar_box) if os.path.exists('/tmp/3'): os.remove('/tmp/3') text_toolbar = ToolbarButton() text_toolbar.props.page = TextToolbar(self.abiword_canvas) text_toolbar.props.icon_name = 'format-text' text_toolbar.props.label = _('Text') toolbar_box.toolbar.insert(text_toolbar, -1) para_toolbar = ToolbarButton() para_toolbar.props.page = ParagraphToolbar(self.abiword_canvas) para_toolbar.props.icon_name = 'paragraph-bar' para_toolbar.props.label = _('Paragraph') toolbar_box.toolbar.insert(para_toolbar, -1) list_toolbar = ToolbarButton() list_toolbar.props.page = ListToolbar(self.abiword_canvas) list_toolbar.props.icon_name = 'toolbar-bulletlist' list_toolbar.props.label = _('Bullet List') toolbar_box.toolbar.insert(list_toolbar, -1) insert_toolbar = ToolbarButton() insert_toolbar.props.page = InsertToolbar(self.abiword_canvas) insert_toolbar.props.icon_name = 'insert-table' insert_toolbar.props.label = _('Table') toolbar_box.toolbar.insert(insert_toolbar, -1) separator = Gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) bold = ToggleToolButton('format-text-bold') bold.set_tooltip(_('Bold')) bold_id = bold.connect('clicked', lambda sender: self.abiword_canvas.toggle_bold()) self.abiword_canvas.connect('bold', lambda abi, b: self._setToggleButtonState(bold, b, bold_id)) toolbar_box.toolbar.insert(bold, -1) italic = ToggleToolButton('format-text-italic') italic.set_tooltip(_('Italic')) italic_id = italic.connect('clicked', lambda sender: self.abiword_canvas.toggle_italic()) self.abiword_canvas.connect('italic', lambda abi, b: self._setToggleButtonState(italic, b, italic_id)) toolbar_box.toolbar.insert(italic, -1) underline = ToggleToolButton('format-text-underline') underline.set_tooltip(_('Underline')) underline_id = underline.connect('clicked', lambda sender: self.abiword_canvas.toggle_underline()) self.abiword_canvas.connect('underline', lambda abi, b: self._setToggleButtonState(underline, b, underline_id)) toolbar_box.toolbar.insert(underline, -1) separator = Gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) color = ColorToolButton() color.connect('color-set', self._text_color_cb, self.abiword_canvas) tool_item = Gtk.ToolItem() tool_item.add(color) toolbar_box.toolbar.insert(tool_item, -1) self.abiword_canvas.connect('color', lambda abi, r, g, b: color.set_color(Gdk.Color(r * 65535, g * 65535, b * 65535))) separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) separator.show() toolbar_box.toolbar.insert(separator, -1) stop = StopButton(self) toolbar_box.toolbar.insert(stop, -1) toolbar_box.show_all() self.set_toolbar_box(toolbar_box) self._zoom_handler = self.abiword_canvas.connect("zoom", self.__zoom_cb)
def make_toolbar(self): toolbar_box = ToolbarBox() toolbar = toolbar_box.toolbar activity_button = ToolButton() activity_button.set_icon_widget(ActivityIcon(None)) toolbar.insert(activity_button, -1) utils.make_separator(toolbar, False) edit_toolbar = EditToolbar() edit_toolbar.undo.props.visible = False edit_toolbar.redo.props.visible = False edit_toolbar.separator.props.visible = False edit_toolbar.copy.connect("clicked", self.copy_cb) edit_toolbar.copy.props.accelerator = "<Ctrl><Shift>C" edit_toolbar.paste.connect("clicked", self.paste_cb) edit_toolbar.paste.props.accelerator = "<Ctrl><Shift>V" self.copy_button = edit_toolbar.copy self.copy_button.set_sensitive(False) edit_toolbar_button = ToolbarButton(page=edit_toolbar, icon_name="toolbar-edit") toolbar_box.toolbar.insert(edit_toolbar_button, -1) view_toolbar = Gtk.Toolbar() boton_toolbar_view = ToolbarButton(page=view_toolbar, icon_name="toolbar-view") toolbar.insert(boton_toolbar_view, -1) background_color_button = ColorToolButton() background_color_button.set_color(self.background_color) background_color_button.set_title("Background color") background_color_button.connect("color-set", self.background_color_changed) view_toolbar.insert(background_color_button, -1) text_color_button = ColorToolButton() text_color_button.set_color(self.text_color) text_color_button.set_title("Text color") text_color_button.connect("color-set", self.text_color_changed) view_toolbar.insert(text_color_button, -1) item_font_size = FontSize() item_font_size.set_font_size(self.font_size, False) item_font_size.connect("changed", self.font_size_changed) view_toolbar.insert(item_font_size, -1) utils.make_separator(view_toolbar, False) button_left = Gtk.RadioToolButton() button_left.set_icon_name('go-left') button_left.set_tooltip_text("Move 'add' button to the left") view_toolbar.insert(button_left, -1) button_right = Gtk.RadioToolButton.new_from_widget(button_left) button_right.set_icon_name('go-right') button_right.set_tooltip_text("Move 'add' button to the right") view_toolbar.insert(button_right, -1) if self.button_position == Gtk.PackType.START: button_left.set_active(True) elif self.button_position == Gtk.PackType.END: button_right.set_active(True) button_left.connect("toggled", self.move_button, Gtk.PackType.START) button_right.connect("toggled", self.move_button, Gtk.PackType.END) view_toolbar.show_all() self.button_new = ToolButton("add") self.button_new.props.accelerator = "<Ctrl><Shift>T" self.button_new.connect("clicked", lambda button: self.notebook.new_terminal()) toolbar.insert(self.button_new, -1) utils.make_separator(toolbar, True) button_stop = ToolButton("activity-stop") button_stop.props.accelerator = "<Ctrl><Shift>C" button_stop.connect("clicked", self._close) toolbar.insert(button_stop, -1) toolbar.show_all() self.set_toolbar_box(toolbar_box)