Commit f73f7f57 authored by Alberto Fanjul's avatar Alberto Fanjul

Keep preferences and shorcuts after AppMenu removal

parent aab92fc4
Pipeline #47037 passed with stages
in 6 minutes and 13 seconds
......@@ -387,6 +387,7 @@ public class Application : Gtk.Application
const Accel[] single_accels = {
{"app.new", "<Primary>N",},
{"app.quit", "<Primary>Q"},
{"app.shortcuts", "<Shift><Primary>question"},
{"app.help", "F1"},
{"win.search", "<Primary>F"},
......
......@@ -46,6 +46,11 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
private RemoteManager d_remote_manager;
private Notifications d_notifications;
private PreferencesDialog d_preferences;
#if GTK_SHORTCUTS_WINDOW
private Gtk.ShortcutsWindow d_shortcuts;
#endif
// Widgets
[GtkChild]
......@@ -157,9 +162,16 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
{"close", on_close_activated},
{"reload", on_reload_activated},
{"author-details-repo", on_repo_author_details_activated},
{"preferences", on_preferences_activated},
{"select", on_select_activated, null, "false", null}
};
#if GTK_SHORTCUTS_WINDOW
private const ActionEntry[] shortcut_window_entries = {
{"shortcuts", on_shortcuts_activated}
};
#endif
[GtkCallback]
private void dash_button_clicked(Gtk.Button dash)
{
......@@ -269,6 +281,10 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
add_action_entries(win_entries, this);
#if GTK_SHORTCUTS_WINDOW
add_action_entries(shortcut_window_entries, this);
#endif
d_notifications = new Notifications(d_overlay);
var selact = lookup_action("select");
......@@ -695,6 +711,53 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
author_details.show();
}
private void on_preferences_activated()
{
unowned List<Gtk.Window> wnds = application.get_windows();
// Create preferences dialog if needed
if (d_preferences == null)
{
d_preferences = Builder.load_object<PreferencesDialog>("ui/gitg-preferences.ui", "preferences");
d_preferences.destroy.connect((w) => {
d_preferences = null;
});
}
if (wnds != null)
{
d_preferences.set_transient_for(wnds.data);
}
d_preferences.present();
}
private void on_shortcuts_activated()
{
#if GTK_SHORTCUTS_WINDOW
unowned List<Gtk.Window> wnds = application.get_windows();
// Create shortcuts window if needed
if (d_shortcuts == null)
{
d_shortcuts = Builder.load_object<Gtk.ShortcutsWindow>("ui/gitg-shortcuts.ui", "shortcuts-gitg");
d_shortcuts.destroy.connect((w) => {
d_shortcuts = null;
});
}
if (wnds != null)
{
d_shortcuts.set_transient_for(wnds.data);
}
d_shortcuts.present();
#endif
}
private void on_current_activity_changed()
{
notify_property("current_activity");
......
......@@ -8,12 +8,24 @@
<attribute name="action">win.reload</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">win.preferences</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Author Details</attribute>
<attribute name="action">win.author-details-repo</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
</item>
</section>
</menu>
<menu id="win-menu-dash">
<section>
......
......@@ -12,6 +12,13 @@
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Windows</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;primary&gt;&lt;shift&gt;question</property>
<property name="title" translatable="yes" context="shortcut window">Open shortcut window</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment