Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Tab Panel to Peas API #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions core/browser.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Midori {
[GtkChild]
Gtk.HeaderBar panelbar;
[GtkChild]
Gtk.Stack panel;
public Gtk.Stack panel;
[GtkChild]
Gtk.ToggleButton panel_toggle;
[GtkChild]
Expand All @@ -68,7 +68,7 @@ namespace Midori {
[GtkChild]
Navigationbar navigationbar;
[GtkChild]
Gtk.Stack tabs;
public Gtk.Stack tabs;
[GtkChild]
public Gtk.Overlay overlay;
[GtkChild]
Expand Down Expand Up @@ -141,6 +141,7 @@ namespace Midori {
// Plug only after the app is connected and everything is setup
var extensions = Plugins.get_default ().plug<BrowserActivatable> ("browser", this);
extensions.extension_added.connect ((info, extension) => ((BrowserActivatable)extension).activate ());
extensions.extension_removed.connect ((info, extension) => ((BrowserActivatable)extension).deactivate ());
extensions.foreach ((extensions, info, extension) => { extensions.extension_added (info, extension); });
});

Expand Down Expand Up @@ -253,7 +254,19 @@ namespace Midori {
}

// Reveal panel toggle after panels are added
panel.add.connect ((widget) => { panel_toggle.show (); });
panel.add.connect ((widget) => {
panel_toggle.show ();
var settings = CoreSettings.get_default ();
if (settings.show_panel) {
lookup_action ("panel").change_state (true);
}
});
panel.remove.connect ((widget) => {
panel_toggle.visible = panel.get_children ().length () > 0;
if (!panel_toggle.visible) {
panel.hide ();
}
});
}

void update_decoration_layout () {
Expand Down Expand Up @@ -309,6 +322,7 @@ namespace Midori {
if (panel_toggle.visible) {
action.set_state (state);
panel.visible = state.get_boolean ();
CoreSettings.get_default ().show_panel = panel.visible;
update_decoration_layout ();
}
}
Expand Down
6 changes: 6 additions & 0 deletions core/settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ namespace Midori {
set_boolean ("extensions", "lib%s.so".printf (plugin), enabled);
}

public bool show_panel { get {
return get_boolean ("settings", "show-panel", false);
} set {
set_boolean ("settings", "show-panel", value, false);
} }

public bool enable_spell_checking { get {
return get_boolean ("settings", "enable-spell-checking", true);
} set {
Expand Down
2 changes: 1 addition & 1 deletion core/switcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Midori {
public class Switcher : Gtk.Box {
HashTable<Gtk.Widget, Tally> buttons;
public Gtk.Stack? stack { get; set; }
public bool show_close_buttons { get; protected set; }
internal bool show_close_buttons { get; protected set; }

construct {
buttons = new HashTable<Gtk.Widget, Tally> (direct_hash, direct_equal);
Expand Down
3 changes: 3 additions & 0 deletions data/gtk3.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
.titlebar .tab:only-child {
box-shadow: none;
}
.tab image, .tab spinner {
padding: 0 2px;
}
.tab button {
padding: 0;
margin: 0;
Expand Down
6 changes: 6 additions & 0 deletions extensions/tab-panel.plugin.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Plugin]
Module=tab-panel
IAge=3
Icon=view-list-symbolic
_Name=Tab Panel
_Description=Show tabs in a vertical panel
34 changes: 34 additions & 0 deletions extensions/tab-panel.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright (C) 2008-2018 Christian Dywan <[email protected]>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

See the file COPYING for the full license text.
*/

namespace TabPanel {
public class Frontend : Object, Midori.BrowserActivatable {
public Midori.Browser browser { owned get; set; }

public void activate () {
var switcher = new Midori.Switcher ();
switcher.stack = browser.tabs;
switcher.orientation = Gtk.Orientation.VERTICAL;
switcher.show ();
browser.panel.add_titled (switcher, "tab-panel", _("Tab Panel"));
browser.panel.child_set (switcher, "icon-name", "view-list-symbolic");
deactivate.connect (() => {
switcher.destroy ();
});
}
}
}

[ModuleInit]
public void peas_register_types(TypeModule module) {
((Peas.ObjectModule)module).register_extension_type (
typeof (Midori.BrowserActivatable), typeof (TabPanel.Frontend));
}
2 changes: 2 additions & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ extensions/bookmarks.plugin.in
extensions/bookmarks.vala
extensions/status-clock.plugin.in
extensions/status-clock.vala
extensions/tab-panel.plugin.in
extensions/tab-panel.vala
ui/bookmarks-button.ui
ui/browser.ui
ui/clear-private-data.ui
Expand Down
2 changes: 2 additions & 0 deletions ui/tally.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="visible">yes</property>
<property name="hexpand">yes</property>
<child>
<object class="MidoriFavicon" id="favicon">
<!-- menu -->
Expand All @@ -27,6 +28,7 @@
<!-- As per docs, when ellipsized and expanded max width is the minimum -->
<property name="width-chars">8</property>
<property name="max-width-chars">500</property>
<property name="hexpand">yes</property>
<property name="visible">yes</property>
</object>
</child>
Expand Down