Python gi.repository.Gtk.HeaderBar() Examples

The following are 24 code examples of gi.repository.Gtk.HeaderBar(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: headerbar.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def _build_widgets(self):
        """
        Generate the HeaderBar widgets
        """
        self.set_show_close_button(True)

        left_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        right_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

        # Hide the search button if nothing is found
        if Database.get_default().count > 0:
            self.search_btn.show_()
        else:
            self.search_btn.hide_()

        left_box.add(self.add_btn)

        right_box.pack_start(self.search_btn, False, False, 0)
        right_box.pack_start(self.select_btn, False, False, 0)
        right_box.pack_start(self.cancel_btn, False, False, 0)
        right_box.pack_end(self.settings_btn, False, False, 3)

        self.pack_start(left_box)
        self.pack_end(right_box) 
Example #2
Source File: headerbars.py    From Apostrophe with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        self.hb = Gtk.HeaderBar().new()
        self.hb.props.show_close_button = True

        self.hb_revealer = Gtk.Revealer(name="titlebar-revealer-pv")
        self.hb_revealer.add(self.hb)
        self.hb_revealer.props.transition_duration = 750
        self.hb_revealer.set_transition_type(
            Gtk.RevealerTransitionType.CROSSFADE)
        self.hb_revealer.show()
        self.hb_revealer.set_reveal_child(True)

        self.hb_container = Gtk.Frame(name="titlebar-container")
        self.hb_container.set_shadow_type(Gtk.ShadowType.NONE)
        self.hb_container.add(self.hb_revealer)
        self.hb_container.show()

        self.hb.show_all() 
Example #3
Source File: edit.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def _build_widgets(self):
        header_bar = Gtk.HeaderBar()
        header_bar.set_show_close_button(False)
        header_bar.set_title(_("Edit {} - {}".format(self._account.username,
                                                     self._account.provider)))
        self.set_titlebar(header_bar)
        # Save btn
        self.save_btn = Gtk.Button()
        self.save_btn.set_label(_("Save"))
        self.save_btn.connect("clicked", self._on_save)
        self.save_btn.get_style_context().add_class("suggested-action")
        header_bar.pack_end(self.save_btn)

        self.close_btn = Gtk.Button()
        self.close_btn.set_label(_("Close"))
        self.close_btn.connect("clicked", self._on_quit)

        header_bar.pack_start(self.close_btn)

        self.account_config = AccountConfig(edit=True, account=self._account)
        self.account_config.connect("changed", self._on_account_config_changed)

        self.add(self.account_config) 
Example #4
Source File: gnupg.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def _build_widgets(self):
        header_bar = Gtk.HeaderBar()
        header_bar.set_show_close_button(True)
        header_bar.set_title(_("GPG paraphrase"))
        apply_btn = Gtk.Button()
        apply_btn.set_label(_("Import"))
        apply_btn.get_style_context().add_class("suggested-action")
        apply_btn.connect("clicked", self.__on_apply)
        header_bar.pack_end(apply_btn)
        self.set_titlebar(header_bar)

        container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.paraphrase_widget = SettingsBoxWithEntry(_("Paraphrase"), True)
        container.pack_start(self.paraphrase_widget, False, False, 0)
        container.get_style_context().add_class("settings-main-container")
        self.add(container) 
Example #5
Source File: preferences_dialog.py    From ebook-viewer with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, window):
        """
        Provides
        :param window: Main application window reference, serves as communication hub
        """
        super(Gtk.HeaderBar, self).__init__()
        self.set_show_close_button(False)

        try:
            self.set_has_subtitle(True)
        except AttributeError:
            pass # Too bad?

        # Set default window title
        self.props.title = _("Preferences")
        self.__window = window
        self.__menu = Gtk.Menu()
        # Fill it with all the wigets
        self.__populate_headerbar() 
Example #6
Source File: header_bar.py    From hazzy with GNU General Public License v2.0 6 votes vote down vote up
def main():
    window = Gtk.Window()

    box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    window.add(box)

    title = "Custom HeaderBar"
    subtitle = "with fullscreen toggle button"
    header_bar = HeaderBar(window, title=title, subtitle=subtitle)
    window.set_titlebar(header_bar)

    window.set_default_size(600, 300)
    window.connect('destroy', Gtk.main_quit)

    window.show_all()
    Gtk.main() 
Example #7
Source File: file_dialog.py    From hazzy with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(FileDialog, self).__init__(*args, **kwargs)

        self.set_titlebar(Gtk.HeaderBar(show_close_button=True))
        self.set_title("Open File")
        self.add_button("_Open", Gtk.ResponseType.OK)
        self.add_button("_Cancel", Gtk.ResponseType.CANCEL)
        self.set_default_response(Gtk.ResponseType.OK)

        #TODO Add file filters based on extensions given in INI

        filefiler = Gtk.FileFilter()
        filefiler.add_pattern('*.ngc')
        filefiler.set_name('G-code')
        self.add_filter(filefiler)

        filefiler = Gtk.FileFilter()
        filefiler.add_pattern('*')
        filefiler.set_name('All Files')
        self.add_filter(filefiler)

        self.show_all() 
Example #8
Source File: headerbar.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self):
        Gtk.HeaderBar.__init__(self)

        self.search_btn = HeaderBarToggleButton("system-search-symbolic",
                                                _("Search"))
        self.add_btn = HeaderBarButton("list-add-symbolic",
                                       _("Add a new account"))
        self.settings_btn = HeaderBarButton("open-menu-symbolic",
                                            _("Settings"))
        self.select_btn = HeaderBarButton("object-select-symbolic",
                                          _("Selection mode"))

        self.cancel_btn = Gtk.Button(label=_("Cancel"))

        self.popover = None

        self._build_widgets() 
Example #9
Source File: main.py    From Dindo-Bot with MIT License 5 votes vote down vote up
def create_header_bar(self, title):
		### Header Bar
		hb = Gtk.HeaderBar(title=title)
		logo = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/logo.png'), 24, 24)
		hb.pack_start(Gtk.Image(pixbuf=logo))
		hb.set_show_close_button(True)
		self.set_titlebar(hb)
		## Settings button
		self.settings_button = Gtk.Button()
		self.settings_button.set_image(Gtk.Image(icon_name='open-menu-symbolic'))
		self.settings_button.connect('clicked', lambda button: self.popover.show_all())
		hb.pack_end(self.settings_button)
		self.popover = Gtk.Popover(relative_to=self.settings_button, position=Gtk.PositionType.BOTTOM)
		self.popover.set_border_width(2)
		box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
		self.popover.add(box)
		# Preferences button
		preferences_button = Gtk.ModelButton(' Preferences')
		preferences_button.set_alignment(0, 0.5)
		preferences_button.set_image(Gtk.Image(icon_name='preferences-desktop'))
		preferences_button.connect('clicked', self.on_preferences_button_clicked)
		box.add(preferences_button)
		# Accounts button
		accounts_button = Gtk.ModelButton(' Accounts')
		accounts_button.set_alignment(0, 0.5)
		accounts_button.set_image(Gtk.Image(icon_name='dialog-password'))
		accounts_button.connect('clicked', self.on_accounts_button_clicked)
		box.add(accounts_button)
		# Take Game Screenshot button
		self.take_screenshot_button = Gtk.ModelButton(' Take Game Screenshot')
		self.take_screenshot_button.set_alignment(0, 0.5)
		self.take_screenshot_button.set_image(Gtk.Image(icon_name='camera-photo'))
		self.take_screenshot_button.set_sensitive(False)
		self.take_screenshot_button.connect('clicked', self.on_take_screenshot_button_clicked)
		box.add(self.take_screenshot_button)
		# Open Log File button
		open_log_button = Gtk.ModelButton(' Open Log File')
		open_log_button.set_alignment(0, 0.5)
		open_log_button.set_image(Gtk.Image(icon_name='text-x-generic'))
		open_log_button.connect('clicked', lambda button: tools.open_file_in_editor(logger.get_filename()))
		box.add(open_log_button)
		# About button
		about_button = Gtk.ModelButton(' About')
		about_button.set_alignment(0, 0.5)
		about_button.set_image(Gtk.Image(icon_name='help-about'))
		about_button.connect('clicked', self.on_about_button_clicked)
		box.add(about_button) 
Example #10
Source File: preferences.py    From drawing with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, is_beta, wants_csd, **kwargs):
		super().__init__(**kwargs)
		if wants_csd:
			header_bar = Gtk.HeaderBar(visible=True, title=_("Preferences"), \
			                                             show_close_button=True)
			self.set_titlebar(header_bar)
			stack_switcher = Gtk.StackSwitcher(visible=True, stack=self.stack, \
			                                            halign=Gtk.Align.CENTER)
			header_bar.set_custom_title(stack_switcher)
			self.set_default_size(480, 500)
		else:
			stack_sidebar = Gtk.StackSidebar(visible=True, stack=self.stack)
			stack_sidebar.set_size_request(140, -1)
			self.content_area.pack_start(stack_sidebar, False, False, 0)
			self.set_default_size(600, 400) # Not high enough but the golden
			# ratio is more important than usability

		self.page_builder_images()
		self.page_builder_tools()
		self.page_builder_advanced(is_beta)

	# Each page_* attribute is a GtkGrid. The page_builder_* methods declare
	# their grid to be the currently filled one, and reset the counter.
	# Then, the page_builder_* methods will call the add_* methods, who will
	# build accurate widgets to be packed on the grid by the attach_* methods.

	############################################################################ 
Example #11
Source File: header_bar.py    From ebook-viewer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, window):
        """
        Provides
        :param window: Main application window reference, serves as communication hub
        """
        super(Gtk.HeaderBar, self).__init__()
        self.set_show_close_button(True)
        # Set default window title
        self.props.title = _("Easy eBook Viewer")
        self.__window = window
        self.__menu = Gtk.Menu()
        # Fill it with all the wigets
        self.__populate_headerbar()
        self.job_running = False 
Example #12
Source File: about.py    From hazzy with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, app_window):
        Gtk.AboutDialog.__init__(self, use_header_bar=False)

        self.set_transient_for(app_window)
        self.set_modal(True)

        self.header_bar = Gtk.HeaderBar(title='About')
        self.set_titlebar(self.header_bar)

        logo = GdkPixbuf.Pixbuf.new_from_file(LOGO)
        self.set_logo(logo)

        self.set_program_name("A touchscreen UI")

        self.set_version(VERSION)

        self.set_comments('LinuxCNC: {} \n GTK: {}'.format(LCNC_VERSION, GTK_VERSION))

        self.set_website(VERSION_URL)
        self.set_website_label(VERSION_URL)

        self.set_copyright(COPYRIGHT)
        self.set_license_type(LICENSE)

        self.set_authors(AUTHORS)
        self.set_title("Hazzy")

        self.connect("response", self.on_response)
        self.show() 
Example #13
Source File: headerbar.py    From runsqlrun with MIT License 5 votes vote down vote up
def __init__(self, win):
        super(HeaderBar, self).__init__()
        self.win = win

        self.set_show_close_button(True)
        self.set_title('RunSQLRun')
        self.set_subtitle('Database query tool')

        self.pack_start(self._btn_from_command('app', 'neweditor'))
        self.pack_start(self._btn_from_command('editor', 'run'))

        # gears button
        menu = Gio.Menu()

        action = Gio.SimpleAction.new('manage_connections', None)
        action.connect('activate', self.on_manage_connections)
        self.win.app.add_action(action)
        menu.append('Manage connections', 'app.manage_connections')

        action = Gio.SimpleAction.new('about', None)
        action.connect('activate', self.on_show_about)
        self.win.app.add_action(action)
        menu.append('About RunSQLRun', 'app.about')

        btn = Gtk.MenuButton()
        icon = Gio.ThemedIcon(name="preferences-system-symbolic")
        image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
        btn.add(image)
        btn.set_popover(Gtk.Popover.new_from_model(btn, menu))
        self.pack_end(btn) 
Example #14
Source File: silaty.py    From Silaty with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        Gtk.Window.__init__(self)
        GLib.threads_init()
        Gst.init(None)

        # Set parent widget
        self.parent = parent
        self.lock_location_updates = False

        # Init dialog
        self.dialog = None

        # Tweak window
        self.set_decorated(True)
        self.set_icon_name('silaty')
        self.set_modal(True)
        self.set_resizable(False)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect('delete-event', self.hide_window)
        #self.set_default_size(429, 440)
        self.headerbar = Gtk.HeaderBar()

        # Set up mainbox
        self.mainbox = Gtk.Box()
        self.mainbox.set_orientation(Gtk.Orientation.HORIZONTAL)

        self.prayertimes = Prayertime()
        self.prayertimes.calculate()
        #self.prayertimes.notify('Title', 'This is a test.')

        # Set language
        set_language(self.prayertimes.options.language)
        if self.prayertimes.options.language == 'Arabic':
            #self.set_gravity(Gdk.Gravity.NORTH_EAST)
            #self.set_direction(Gtk.TextDirection.RTL)
            Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL)

        # Set layout
        self.set_layout()

        if self.prayertimes.options.start_minimized == False:
            self.show_all()
            self.sidebar.emit("window-shown") 
Example #15
Source File: main.py    From PiHole-Panel with GNU General Public License v3.0 5 votes vote down vote up
def draw_header_bar(self):

        hb = Gtk.HeaderBar()
        hb.set_show_close_button(True)
        self.set_titlebar(hb)

        button = Gtk.Button()
        icon = Gio.ThemedIcon(name="open-menu-symbolic")
        image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
        button.add(image)
        hb.pack_end(button)

        button.connect("clicked", self.draw_sub_window)

        return button 
Example #16
Source File: dialog.py    From Dindo-Bot with MIT License 5 votes vote down vote up
def __init__(self, title, transient_for=None, destroy_on_response=True):
		Gtk.Dialog.__init__(self, modal=True, transient_for=transient_for, title=title)
		self.set_border_width(10)
		self.set_resizable(False)
		if destroy_on_response:
			self.connect('response', lambda dialog, response: self.destroy())
		# Header Bar
		hb = Gtk.HeaderBar(title=title)
		hb.set_show_close_button(True)
		self.set_titlebar(hb) 
Example #17
Source File: settings.py    From Audio-Cutter with GNU General Public License v3.0 5 votes vote down vote up
def _build_widgets(self):
        """Build Settings Window widgets."""
        # HeaderBar
        headerbar = Gtk.HeaderBar()
        headerbar.set_show_close_button(True)
        headerbar.set_title(_("Settings"))
        self.set_titlebar(headerbar) 
Example #18
Source File: headerbar.py    From Audio-Cutter with GNU General Public License v3.0 5 votes vote down vote up
def get_default():
        """Return the default instnace of HeaderBar."""
        if HeaderBar.instance is None:
            HeaderBar.instance = HeaderBar()
        return HeaderBar.instance 
Example #19
Source File: headerbar.py    From Audio-Cutter with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        GObject.GObject.__init__(self)
        Gtk.HeaderBar.__init__(self)
        self.play_btn = Gtk.Button()
        self._open_btn = Gtk.Button()
        self.menu_btn = Gtk.Button()
        self.set_title(_("Audio Cutter"))
        self.set_show_close_button(True)
        self._setup_widgets() 
Example #20
Source File: widgets.py    From nautilus-folder-icons with GNU General Public License v3.0 5 votes vote down vote up
def _build_header_bar(self):
        """Setup window headerbar."""
        # Header bar
        headerbar = Gtk.HeaderBar()
        headerbar_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                      spacing=3)

        title = Gtk.Label()
        title.set_text(_("Icon Chooser"))
        title.get_style_context().add_class("title")
        headerbar_container.pack_start(title, False, False, 0)

        subtitle = Gtk.Label()
        subtitle.get_style_context().add_class("subtitle")
        subtitle_text = ", ".join(self._folders)
        subtitle.set_text(subtitle_text)
        subtitle.set_ellipsize(Pango.EllipsizeMode.END)
        subtitle.set_tooltip_text(subtitle_text)
        subtitle.props.max_width_chars = 30
        headerbar_container.pack_start(subtitle, False, False, 0)

        headerbar.set_custom_title(headerbar_container)
        headerbar.set_show_close_button(False)

        # Search Button
        self._search_btn = Gtk.ToggleButton()
        search_icn = Gio.ThemedIcon(name="system-search-symbolic")
        search_img = Gtk.Image.new_from_gicon(search_icn, Gtk.IconSize.BUTTON)
        self._search_btn.set_image(search_img)

        # Cancel Button
        close_button = Gtk.Button()
        close_button.set_label(_("Close"))
        close_button.connect("clicked", self._close_window)

        headerbar.pack_start(close_button)
        headerbar.pack_end(self._search_btn)
        self.set_titlebar(headerbar) 
Example #21
Source File: gnupg.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def _build_widgets(self):
        header_bar = Gtk.HeaderBar()
        header_bar.set_show_close_button(True)
        header_bar.set_title(_("GPG fingerprint"))
        self.set_titlebar(header_bar)

        container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        keys = GPG.get_default().get_keys()
        self.__add_keys(keys["public"], _("Public keys"), container)
        self.__add_keys(keys["private"], _("Private keys"), container)

        container.get_style_context().add_class("settings-main-container")
        self.add(container) 
Example #22
Source File: settings.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def _build_widgets(self):
        header_bar = Gtk.HeaderBar()
        header_bar.set_show_close_button(True)
        self.set_titlebar(header_bar)
        header_bar.set_custom_title(self.stack_switcher)
        self.stack_switcher.set_stack(self.stack)
        self.stack.get_style_context().add_class("settings-main-container")

        appearance_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        dark_theme = SwitchSettingsBox(_("Dark theme"), _("Use a dark theme, if possible"), "night-mode")
        dark_theme.connect("changed", self.__on_dark_theme_changed)
        appearance_container.pack_start(dark_theme, False, False, 0)
        self.stack.add_titled(appearance_container, "appearance", _("Appearance"))

        behaviour_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        clear_database = ClickableSettingsBox(_("Clear the database"), _("Erase existing accounts"))
        clear_database.connect("button-press-event", self.__on_clear_database_clicked)
        behaviour_container.pack_start(clear_database, False, False, 0)
        self.stack.add_titled(behaviour_container, "behaviour", _("Behaviour"))

        backup_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        gpg_location = ClickableSettingsBox(_("GPG keys location"),
                                            Settings.get_default().gpg_location)
        gpg_location.connect("button-press-event", self.__on_gpg_location_clicked)

        backup_container.pack_start(gpg_location, False, False, 0)
        self.stack.add_titled(backup_container, "backup", _("Backup"))

        self.add(self.stack) 
Example #23
Source File: add.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def _build_widgets(self):
        """Create the Add Account widgets."""
        # Header Bar
        header_bar = Gtk.HeaderBar()
        header_bar.set_show_close_button(False)
        header_bar.set_title(_("Add a new account"))
        self.set_titlebar(header_bar)
        # Next btn
        self.add_btn = Gtk.Button()
        self.add_btn.set_label(_("Add"))
        self.add_btn.connect("clicked", self._on_add)
        self.add_btn.get_style_context().add_class("suggested-action")
        self.add_btn.set_sensitive(False)
        header_bar.pack_end(self.add_btn)

        # QR code scan btn
        from ...application import Application
        self.scan_btn = HeaderBarButton("qrscanner-symbolic",
                                        _("Scan QR code"))
        if Application.USE_QRSCANNER and can_use_qrscanner():
            self.scan_btn.connect("clicked", self._on_scan)
            header_bar.pack_end(self.scan_btn)

        # Back btn
        self.close_btn = Gtk.Button()
        self.close_btn.set_label(_("Close"))
        self.close_btn.connect("clicked", self._on_quit)

        header_bar.pack_start(self.close_btn)

        self.account_config = AccountConfig()
        self.account_config.connect("changed", self._on_account_config_changed)

        self.add(self.account_config) 
Example #24
Source File: headerbar.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def get_default():
        """
        :return: Default instance of HeaderBar
        """
        if HeaderBar.instance is None:
            HeaderBar.instance = HeaderBar()
        return HeaderBar.instance