def __init__(self): Gtk.HBox.__init__(self) self.get_style_context().add_class('shortcutsbar') self.pmb = ServiceLocator.get_popover_menu_builder() self.current_bottom = None self.create_top_toolbar() self.populate_top_toolbar() self.create_right_toolbar() self.populate_right_toolbar() self.pack_start(self.top_icons, True, True, 0) self.pack_end(self.right_icons, False, False, 0)
def __init__(self): Gtk.PopoverMenu.__init__(self) self.get_style_context().add_class('open-docs-popover') self.pmb = ServiceLocator.get_popover_menu_builder() self.stack = self.get_child() self.vbox = Gtk.VBox() self.vbox.set_margin_top(9) self.vbox.set_margin_bottom(10) self.vbox.set_margin_left(10) self.vbox.set_margin_right(10) self.document_list = Gtk.ListBox() self.document_list.set_sort_func(self.sort_function) self.document_list_selection = Gtk.ListBox() self.document_list_selection.set_sort_func(self.sort_function) self.in_selection_mode = False self.scrolled_window = Gtk.ScrolledWindow() self.scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrolled_window.add(self.document_list) self.scrolled_window.set_max_content_height(336) self.scrolled_window.set_max_content_width(398) self.scrolled_window.set_propagate_natural_height(True) self.scrolled_window.set_propagate_natural_width(True) self.scrolled_window.set_shadow_type(Gtk.ShadowType.NONE) self.set_root_document_button = Gtk.Button() self.set_root_document_button.set_label(_('Set one Document as Root')) self.set_root_document_button.get_style_context().add_class('flat') self.set_root_document_button.get_style_context().add_class( 'like-model') self.set_root_document_button.set_can_focus(False) self.set_root_document_button.get_child().set_xalign(0) self.unset_root_document_button = Gtk.Button() self.unset_root_document_button.set_label(_('Unset Root Document')) self.unset_root_document_button.get_style_context().add_class('flat') self.unset_root_document_button.get_style_context().add_class( 'like-model') self.unset_root_document_button.set_can_focus(False) self.unset_root_document_button.get_child().set_xalign(0) self.root_explaination1 = Gtk.Label( _('Click on a document in the list below to set it as root.')) self.root_explaination1.set_margin_top(6) self.root_explaination1.set_xalign(0) self.root_explaination1.get_style_context().add_class( 'explaination-header') self.root_explaination2 = Gtk.Label( _('The root document will get built, no matter which document\nyou are currently editing, and it will always display in the .pdf\npreview. The build log will also refer to the root document.\nThis is often useful for working on large projects where typically\na top level document (the root) will contain multiple lower\nlevel files via include statements.' )) self.root_explaination2.set_xalign(0) self.root_explaination2.get_style_context().add_class('explaination') self.root_explaination2.set_margin_top(15) self.root_explaination2.set_margin_bottom(10) self.root_explaination_box = Gtk.VBox() self.root_explaination_box.pack_start(self.root_explaination1, False, False, 0) self.root_explaination_box.pack_start(self.root_explaination2, False, False, 0) self.root_explaination_revealer = Gtk.Revealer() self.root_explaination_revealer.add(self.root_explaination_box) self.root_explaination_revealer.set_reveal_child(False) self.vbox.pack_start(self.root_explaination_revealer, False, False, 0) self.vbox.pack_start(self.scrolled_window, False, False, 0) self.pmb.add_separator(self.vbox) self.vbox.pack_start(self.set_root_document_button, False, False, 0) self.vbox.pack_start(self.unset_root_document_button, False, False, 0) self.vbox.show_all() self.stack.add_named(self.vbox, 'main')
def __init__(self): Gtk.HeaderBar.__init__(self) self.pmb = ServiceLocator.get_popover_menu_builder() self.set_show_close_button(True) # sidebar toggle self.sidebar_toggle_revealer = Gtk.Revealer() self.sidebar_toggle = Gtk.ToggleButton() self.sidebar_toggle.set_image( Gtk.Image.new_from_icon_name('builder-view-left-pane-symbolic', Gtk.IconSize.MENU)) self.sidebar_toggle.set_can_focus(False) self.sidebar_toggle.set_tooltip_text('Toggle sidebar (F9)') self.pack_start(self.sidebar_toggle) # open documents button self.document_chooser = DocumentChooser() self.open_document_button_label = Gtk.HBox() self.open_document_button_label.pack_start(Gtk.Label('Open'), False, False, 0) self.open_document_button_label.pack_start( Gtk.Image.new_from_icon_name('pan-down-symbolic', Gtk.IconSize.MENU), False, False, 0) self.open_document_button = Gtk.MenuButton() self.open_document_button.set_can_focus(False) self.open_document_button.set_tooltip_text( 'Open a document (Ctrl+Shift+O)') self.open_document_button.set_use_popover(True) self.open_document_button.add(self.open_document_button_label) self.open_document_button.get_style_context().add_class("text-button") self.open_document_button.get_style_context().add_class("image-button") self.open_document_button.set_popover(self.document_chooser) self.pack_start(self.open_document_button) self.open_document_blank_button = Gtk.Button.new_with_label('Open...') self.open_document_blank_button.set_tooltip_text( 'Open a document (Ctrl+O)') self.pack_start(self.open_document_blank_button) self.new_document_button = Gtk.MenuButton() self.new_document_button_label = Gtk.HBox() image = Gtk.Image.new_from_icon_name('document-new-symbolic', Gtk.IconSize.BUTTON) image.set_margin_right(6) self.new_document_button_label.pack_start(image, False, False, 0) image = Gtk.Image.new_from_icon_name('pan-down-symbolic', Gtk.IconSize.BUTTON) self.new_document_button_label.pack_start(image, False, False, 0) self.new_document_button.add(self.new_document_button_label) self.new_document_button.set_can_focus(False) self.new_document_button.set_tooltip_text( 'Create a new document (Ctrl+N)') self.new_document_button.get_style_context().add_class("text-button") self.new_document_button.get_style_context().add_class("image-button") self.pack_start(self.new_document_button) self.new_document_menu = Gio.Menu() self.new_document_menu.append_item( Gio.MenuItem.new('New LaTeX Document', 'win.new-latex-document')) self.new_document_menu.append_item( Gio.MenuItem.new('New BibTeX Document', 'win.new-bibtex-document')) self.new_document_button.set_menu_model(self.new_document_menu) # workspace menu self.insert_workspace_menu() # save document button self.save_document_button = Gtk.Button.new_with_label('Save') self.save_document_button.set_can_focus(False) self.save_document_button.set_tooltip_text( 'Save the current document (Ctrl+S)') self.pack_end(self.save_document_button) # preview toggle self.preview_toggle = Gtk.ToggleButton() self.preview_toggle.set_image( Gtk.Image.new_from_icon_name('view-paged-symbolic', Gtk.IconSize.MENU)) self.preview_toggle.set_can_focus(False) self.preview_toggle.set_tooltip_text('Toggle preview (F10)') self.pack_end(self.preview_toggle) # build button wrapper self.build_wrapper = Gtk.VBox() self.pack_end(self.build_wrapper) # title / open documents popover self.center_widget = document_switcher_viewgtk.OpenDocsButton() self.set_custom_title(self.center_widget)
def __init__(self): Gtk.HeaderBar.__init__(self) self.pmb = ServiceLocator.get_popover_menu_builder() self.set_show_close_button(True) # sidebar toggle self.sidebar_toggle_revealer = Gtk.Revealer() self.sidebar_toggle = Gtk.ToggleButton() self.sidebar_toggle.set_image( Gtk.Image.new_from_icon_name('builder-view-left-pane-symbolic', Gtk.IconSize.MENU)) self.sidebar_toggle.set_can_focus(False) self.sidebar_toggle.set_tooltip_text(_('Toggle sidebar') + ' (F9)') self.pack_start(self.sidebar_toggle) # open documents button self.document_chooser = document_chooser_viewgtk.DocumentChooser() self.open_document_button_label = Gtk.HBox() self.open_document_button_label.pack_start(Gtk.Label(_('Open')), False, False, 0) self.open_document_button_label.pack_start( Gtk.Image.new_from_icon_name('pan-down-symbolic', Gtk.IconSize.MENU), False, False, 0) self.open_document_button = Gtk.MenuButton() self.open_document_button.set_can_focus(False) self.open_document_button.set_tooltip_text( _('Open a document') + ' (' + _('Shift') + '+' + _('Ctrl') + '+O)') self.open_document_button.set_use_popover(True) self.open_document_button.add(self.open_document_button_label) self.open_document_button.get_style_context().add_class('text-button') self.open_document_button.get_style_context().add_class('image-button') self.open_document_button.set_popover(self.document_chooser) self.pack_start(self.open_document_button) self.open_document_blank_button = Gtk.Button.new_with_label( _('Open') + '...') self.open_document_blank_button.set_tooltip_text( _('Open a document') + ' (' + _('Ctrl') + '+O)') self.open_document_blank_button.set_action_name( 'win.open-document-dialog') self.pack_start(self.open_document_blank_button) box = Gtk.HBox() self.new_latex_document_button = Gtk.Button.new_from_icon_name( 'document-new-symbolic', Gtk.IconSize.BUTTON) self.new_latex_document_button.set_tooltip_text( _('Create a new LaTeX document') + ' (' + _('Ctrl') + '+N)') self.new_latex_document_button.set_action_name( 'win.new-latex-document') box.pack_start(self.new_latex_document_button, False, False, 0) self.new_document_button = Gtk.MenuButton() image = Gtk.Image.new_from_icon_name('pan-down-symbolic', Gtk.IconSize.BUTTON) self.new_document_button.set_image(image) self.new_document_button.set_can_focus(False) self.new_document_button.set_tooltip_text(_('Create a new document')) self.new_document_button.get_style_context().add_class( 'new-document-menu-button') box.pack_start(self.new_document_button, False, False, 0) box.get_style_context().add_class('linked') self.pack_start(box) self.new_document_menu = Gio.Menu() self.new_document_menu.append_item( Gio.MenuItem.new(_('New LaTeX Document'), 'win.new-latex-document')) self.new_document_menu.append_item( Gio.MenuItem.new(_('New BibTeX Document'), 'win.new-bibtex-document')) self.new_document_button.set_menu_model(self.new_document_menu) # workspace menu self.insert_workspace_menu() # save document button self.save_document_button = Gtk.Button.new_with_label(_('Save')) self.save_document_button.set_can_focus(False) self.save_document_button.set_tooltip_text( _('Save the current document') + ' (' + _('Ctrl') + '+S)') self.save_document_button.set_action_name('win.save') self.pack_end(self.save_document_button) # help and preview toggles box = Gtk.HBox() self.preview_toggle = Gtk.ToggleButton() self.preview_toggle.set_image( Gtk.Image.new_from_icon_name('view-paged-symbolic', Gtk.IconSize.MENU)) self.preview_toggle.set_can_focus(False) self.preview_toggle.set_tooltip_text(_('Toggle preview') + ' (F10)') box.pack_start(self.preview_toggle, False, False, 0) self.help_toggle = Gtk.ToggleButton() self.help_toggle.set_image( Gtk.Image.new_from_icon_name('help-browser-symbolic', Gtk.IconSize.MENU)) self.help_toggle.set_can_focus(False) self.help_toggle.set_tooltip_text(_('Toggle help') + ' (F1)') box.pack_start(self.help_toggle, False, False, 0) box.get_style_context().add_class('linked') self.pack_end(box) # build button wrapper self.build_wrapper = Gtk.VBox() self.pack_end(self.build_wrapper) # title / open documents popover self.center_widget = document_switcher_viewgtk.OpenDocsButton() self.set_custom_title(self.center_widget)
def __init__(self): Gtk.HeaderBar.__init__(self) self.pmb = ServiceLocator.get_popover_menu_builder() self.set_show_close_button(True) # sidebar toggles box = Gtk.HBox() self.document_structure_toggle = Gtk.ToggleButton() self.document_structure_toggle.set_image( Gtk.Image.new_from_icon_name('view-list-bullet-symbolic', Gtk.IconSize.MENU)) self.document_structure_toggle.set_can_focus(False) self.document_structure_toggle.set_tooltip_text( _('Toggle document structure') + ' (F2)') box.pack_start(self.document_structure_toggle, False, False, 0) self.symbols_toggle = Gtk.ToggleButton() self.symbols_toggle.set_image( Gtk.Image.new_from_icon_name('own-symbols-misc-text-symbolic', Gtk.IconSize.MENU)) self.symbols_toggle.set_can_focus(False) self.symbols_toggle.set_tooltip_text(_('Toggle symbols') + ' (F3)') box.pack_start(self.symbols_toggle, False, False, 0) box.get_style_context().add_class('linked') self.pack_start(box) # open documents button self.document_chooser = document_chooser_viewgtk.DocumentChooser() self.open_document_button_label = Gtk.HBox() self.open_document_button_label.pack_start(Gtk.Label(_('Open')), False, False, 0) self.open_document_button_label.pack_start( Gtk.Image.new_from_icon_name('pan-down-symbolic', Gtk.IconSize.MENU), False, False, 0) self.open_document_button = Gtk.MenuButton() self.open_document_button.set_can_focus(False) self.open_document_button.set_tooltip_text( _('Open a document') + ' (' + _('Shift') + '+' + _('Ctrl') + '+O)') self.open_document_button.set_use_popover(True) self.open_document_button.add(self.open_document_button_label) self.open_document_button.get_style_context().add_class('text-button') self.open_document_button.get_style_context().add_class('image-button') self.open_document_button.set_popover(self.document_chooser) self.pack_start(self.open_document_button) self.open_document_blank_button = Gtk.Button.new_with_label( _('Open') + '...') self.open_document_blank_button.set_tooltip_text( _('Open a document') + ' (' + _('Ctrl') + '+O)') self.open_document_blank_button.set_action_name( 'win.open-document-dialog') self.pack_start(self.open_document_blank_button) popover = Gtk.PopoverMenu() stack = popover.get_child() box = Gtk.VBox() self.pmb.set_box_margin(box) self.pmb.add_action_button(box, _('New LaTeX Document'), 'win.new-latex-document', keyboard_shortcut=_('Ctrl') + '+N') self.pmb.add_action_button(box, _('New BibTeX Document'), 'win.new-bibtex-document') stack.add_named(box, 'main') box.show_all() box = Gtk.HBox() box.pack_start( Gtk.Image.new_from_icon_name('document-new-symbolic', Gtk.IconSize.MENU), False, False, 0) box.pack_end( Gtk.Image.new_from_icon_name('pan-down-symbolic', Gtk.IconSize.MENU), False, False, 0) box.set_size_request(40, -1) self.new_document_button = Gtk.MenuButton() self.new_document_button.add(box) self.new_document_button.set_use_popover(True) self.new_document_button.set_can_focus(False) self.new_document_button.set_tooltip_text(_('Create a new document')) self.new_document_button.get_style_context().add_class( 'new-document-menu-button') self.new_document_button.set_popover(popover) self.pack_start(self.new_document_button) # workspace menu self.session_file_buttons = list() self.insert_workspace_menu() # save document button self.save_document_button = Gtk.Button.new_with_label(_('Save')) self.save_document_button.set_can_focus(False) self.save_document_button.set_tooltip_text( _('Save the current document') + ' (' + _('Ctrl') + '+S)') self.save_document_button.set_action_name('win.save') self.pack_end(self.save_document_button) # help and preview toggles box = Gtk.HBox() self.preview_toggle = Gtk.ToggleButton() self.preview_toggle.set_image( Gtk.Image.new_from_icon_name('view-paged-symbolic', Gtk.IconSize.MENU)) self.preview_toggle.set_can_focus(False) self.preview_toggle.set_tooltip_text(_('Toggle preview') + ' (F10)') box.pack_start(self.preview_toggle, False, False, 0) self.help_toggle = Gtk.ToggleButton() self.help_toggle.set_image( Gtk.Image.new_from_icon_name('help-browser-symbolic', Gtk.IconSize.MENU)) self.help_toggle.set_can_focus(False) self.help_toggle.set_tooltip_text(_('Toggle help') + ' (F1)') box.pack_start(self.help_toggle, False, False, 0) box.get_style_context().add_class('linked') self.pack_end(box) # build button wrapper self.build_wrapper = Gtk.VBox() self.pack_end(self.build_wrapper) # title / open documents popover self.center_widget = document_switcher_viewgtk.OpenDocsButton() self.set_custom_title(self.center_widget)