[buoh/cleanups: 28/31] buoh-window: port to GtkBuilder



commit 7327bfc067c92a847407800785f0c876b02c891e
Author: Jan Tojnar <jtojnar gmail com>
Date:   Tue Jan 22 09:14:40 2019 +0100

    buoh-window: port to GtkBuilder
    
    also stop using GtkUiManager

 data/buoh-ui.xml                  |  58 ----
 data/meson.build                  |   2 +
 data/org.gnome.buoh.gresource.xml |   3 +-
 data/ui/menus.ui                  | 180 +++++++++++
 data/ui/window.ui                 | 129 ++++++++
 src/buoh-application.c            |  27 ++
 src/buoh-application.h            |   1 +
 src/buoh-window.c                 | 644 +++++++++++++++-----------------------
 src/buoh-window.h                 |   2 +-
 9 files changed, 593 insertions(+), 453 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 638406f..bebe700 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,9 +1,11 @@
 ui_files = files(
   'ui/add-comic-dialog.ui',
+  'ui/menus.ui',
   'ui/comic-list.ui',
   'ui/properties-dialog.ui',
   'ui/view-comic.ui',
   'ui/view-message.ui',
+  'ui/window.ui',
 )
 if gtk_builder_tool.found()
   foreach ui : ui_files
diff --git a/data/org.gnome.buoh.gresource.xml b/data/org.gnome.buoh.gresource.xml
index a8e54ed..b8cb6b8 100644
--- a/data/org.gnome.buoh.gresource.xml
+++ b/data/org.gnome.buoh.gresource.xml
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/buoh">
-    <file>buoh-ui.xml</file>
     <file>ui/add-comic-dialog.ui</file>
+    <file alias="gtk/menus.ui">ui/menus.ui</file>
     <file>ui/comic-list.ui</file>
     <file>ui/properties-dialog.ui</file>
     <file>ui/view-comic.ui</file>
     <file>ui/view-message.ui</file>
+    <file>ui/window.ui</file>
   </gresource>
 </gresources>
diff --git a/data/ui/menus.ui b/data/ui/menus.ui
new file mode 100644
index 0000000..3da7e80
--- /dev/null
+++ b/data/ui/menus.ui
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <menu id="menubar">
+    <submenu>
+      <attribute name="label" translatable="yes">_Comic</attribute>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Add…</attribute>
+          <attribute name="action">win.comic-add</attribute>
+          <attribute name="icon">list-add</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Remove</attribute>
+          <attribute name="action">win.comic-remove</attribute>
+          <attribute name="icon">list-remove</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name="action">win.comic-save-a-copy</attribute>
+          <attribute name="label" translatable="yes">_Save a Copy…</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Copy Location</attribute>
+          <attribute name="action">win.comic-copy-uri</attribute>
+        </item>
+        <item>
+          <attribute name="action">win.comic-properties</attribute>
+          <attribute name="icon">document-properties</attribute>
+          <attribute name="label" translatable="yes">_Properties…</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Quit</attribute>
+          <attribute name="action">win.comic-quit</attribute>
+          <attribute name="icon">application-exit</attribute>
+        </item>
+      </section>
+    </submenu>
+    <submenu>
+      <attribute name="label" translatable="yes">_View</attribute>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Toolbar</attribute>
+          <attribute name="action">win.view-toolbar</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">St_atusbar</attribute>
+          <attribute name="action">win.view-statusbar</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">Zoom _In</attribute>
+          <attribute name="action">win.view-zoom-in</attribute>
+          <attribute name="icon">zoom-in</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">Zoom _Out</attribute>
+          <attribute name="action">win.view-zoom-out</attribute>
+          <attribute name="icon">zoom-out</attribute>
+        </item>
+        <item>
+          <attribute name="action">win.view-zoom-normal</attribute>
+          <attribute name="icon">zoom-original</attribute>
+          <attribute name="label" translatable="yes">_Normal Size</attribute>
+        </item>
+        <item>
+          <attribute name="action">win.view-zoom-mode</attribute>
+          <attribute name="target">best-fit</attribute>
+          <attribute name="icon">zoom-fit-best</attribute>
+          <attribute name="label" translatable="yes">_Best Fit</attribute>
+        </item>
+        <item>
+          <attribute name="action">win.view-zoom-mode</attribute>
+          <attribute name="target">fit-width</attribute>
+          <attribute name="label" translatable="yes">Fit Comic _Width</attribute>
+        </item>
+      </section>
+    </submenu>
+    <submenu>
+      <attribute name="label" translatable="yes">_Go</attribute>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Previous Comic</attribute>
+          <attribute name="action">win.go-previous</attribute>
+          <attribute name="icon">go-previous</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Next Comic</attribute>
+          <attribute name="action">win.go-next</attribute>
+          <attribute name="icon">go-next</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_First Comic</attribute>
+          <attribute name="action">win.go-first</attribute>
+          <attribute name="icon">go-first</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Last Comic</attribute>
+          <attribute name="action">win.go-last</attribute>
+          <attribute name="icon">go-last</attribute>
+        </item>
+      </section>
+    </submenu>
+    <submenu>
+      <attribute name="label" translatable="yes">_Help</attribute>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_About</attribute>
+          <attribute name="action">win.help-about</attribute>
+          <attribute name="icon">help-about</attribute>
+        </item>
+      </section>
+    </submenu>
+  </menu>
+  <menu id="view-popup">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Previous Comic</attribute>
+        <attribute name="action">win.go-previous</attribute>
+        <attribute name="icon">go-previous</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Next Comic</attribute>
+        <attribute name="action">win.go-next</attribute>
+        <attribute name="icon">go-next</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Zoom _In</attribute>
+        <attribute name="action">win.view-zoom-in</attribute>
+        <attribute name="icon">zoom-in</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Zoom _Out</attribute>
+        <attribute name="action">win.view-zoom-out</attribute>
+        <attribute name="icon">zoom-out</attribute>
+      </item>
+      <item>
+        <attribute name="action">win.view-zoom-normal</attribute>
+        <attribute name="icon">zoom-original</attribute>
+        <attribute name="label" translatable="yes">_Normal Size</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="action">win.comic-save-a-copy</attribute>
+        <attribute name="label" translatable="yes">_Save a Copy…</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Copy Location</attribute>
+        <attribute name="action">win.comic-copy-uri</attribute>
+      </item>
+      <item>
+        <attribute name="action">win.comic-properties</attribute>
+        <attribute name="icon">document-properties</attribute>
+        <attribute name="label" translatable="yes">_Properties…</attribute>
+      </item>
+    </section>
+  </menu>
+  <menu id="list-popup">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Add…</attribute>
+        <attribute name="action">win.comic-add</attribute>
+        <attribute name="icon">list-add</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Remove</attribute>
+        <attribute name="action">win.comic-remove</attribute>
+        <attribute name="icon">list-remove</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/data/ui/window.ui b/data/ui/window.ui
new file mode 100644
index 0000000..c6b1468
--- /dev/null
+++ b/data/ui/window.ui
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+  <requires lib="gtk+" version="3.20"/>
+  <template class="BuohWindow" parent="GtkApplicationWindow">
+    <property name="default-width">600</property>
+    <property name="default-height">300</property>
+    <property name="title" translatable="yes">Buoh</property>
+    <property name="icon-name">buoh</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">1</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkToolbar" id="toolbar">
+            <property name="visible">1</property>
+            <child>
+              <object class="GtkToolButton" id="GoPreviousItem">
+                <property name="visible">1</property>
+                <property name="tooltip-text" translatable="yes">Go to the previous comic</property>
+                <property name="action-name">win.go-previous</property>
+                <property name="label" translatable="yes">_Previous</property>
+                <property name="use-underline">1</property>
+                <property name="icon-name">go-previous</property>
+              </object>
+              <packing>
+                <property name="homogeneous">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="GoNextItem">
+                <property name="visible">1</property>
+                <property name="tooltip-text" translatable="yes">Go to the next comic</property>
+                <property name="action-name">win.go-next</property>
+                <property name="label" translatable="yes">_Next</property>
+                <property name="use-underline">1</property>
+                <property name="icon-name">go-next</property>
+              </object>
+              <packing>
+                <property name="homogeneous">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparatorToolItem">
+                <property name="visible">1</property>
+              </object>
+              <packing>
+                <property name="homogeneous">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="ViewZoomInItem">
+                <property name="visible">1</property>
+                <property name="tooltip-text" translatable="yes">Increase the comic size</property>
+                <property name="action-name">win.view-zoom-in</property>
+                <property name="label" translatable="yes">Zoom _in</property>
+                <property name="use-underline">1</property>
+                <property name="icon-name">zoom-in</property>
+              </object>
+              <packing>
+                <property name="homogeneous">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="ViewZoomOutItem">
+                <property name="visible">1</property>
+                <property name="tooltip-text" translatable="yes">Decrease the comic size</property>
+                <property name="action-name">win.view-zoom-out</property>
+                <property name="label" translatable="yes">Zoom ou_t</property>
+                <property name="use-underline">1</property>
+                <property name="icon-name">zoom-out</property>
+              </object>
+              <packing>
+                <property name="homogeneous">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="ViewZoomNormalItem">
+                <property name="visible">1</property>
+                <property name="tooltip-text" translatable="yes">Use the normal comic size</property>
+                <property name="action-name">win.view-zoom-normal</property>
+                <property name="label" translatable="yes">N_ormal Size</property>
+                <property name="use-underline">1</property>
+                <property name="icon-name">zoom-original</property>
+              </object>
+              <packing>
+                <property name="homogeneous">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkPaned">
+            <property name="visible">1</property>
+            <property name="can-focus">1</property>
+            <property name="position">230</property>
+            <child>
+              <object class="BuohComicList" id="comic_list">
+                <property name="visible">1</property>
+                <property name="can-focus">1</property>
+              </object>
+            </child>
+            <child>
+              <object class="BuohView" id="view">
+                <property name="visible">1</property>
+                <property name="can-focus">1</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">1</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkStatusbar" id="statusbar">
+            <property name="visible">1</property>
+          </object>
+          <packing>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/buoh-application.c b/src/buoh-application.c
index 813c7ea..182efc5 100644
--- a/src/buoh-application.c
+++ b/src/buoh-application.c
@@ -403,6 +403,7 @@ buoh_application_class_init (BuohApplicationClass *klass)
         object_class->finalize = buoh_application_finalize;
 
         app_class->activate = buoh_application_activate;
+        app_class->startup = buoh_application_startup;
 }
 
 static void
@@ -467,6 +468,32 @@ buoh_application_activate (GApplication *buoh)
         }
 }
 
+void
+buoh_application_startup (GApplication *app)
+{
+        const gchar *comic_properties_accel[2] = { "<alt>Return", NULL };
+        const gchar *comic_quit_accel[2] = { "<control>Q", NULL };
+        const gchar *view_zoom_in_accel[2] = { "<control>plus", NULL };
+        const gchar *view_zoom_out_accel[2] = { "<control>minus", NULL };
+        const gchar *view_zoom_normal_accel[2] = { "<control>0", NULL };
+        const gchar *go_previous_accel[2] = { "<alt>Left", NULL };
+        const gchar *go_next_accel[2] = { "<alt>Right", NULL };
+        const gchar *go_first_accel[2] = { "<control>Home", NULL };
+        const gchar *go_last_accel[2] = { "<control>End", NULL };
+
+        G_APPLICATION_CLASS (buoh_application_parent_class)->startup (app);
+
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.comic-properties", 
comic_properties_accel);
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.comic-quit", comic_quit_accel);
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.view-zoom-in", 
view_zoom_in_accel);
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.view-zoom-out", 
view_zoom_out_accel);
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.view-zoom-normal", 
view_zoom_normal_accel);
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.go-previous", go_previous_accel);
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.go-next", go_next_accel);
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.go-first", go_first_accel);
+        gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.go-last", go_last_accel);
+}
+
 GtkTreeModel *
 buoh_application_get_comics_model (BuohApplication *buoh)
 {
diff --git a/src/buoh-application.h b/src/buoh-application.h
index e4eff99..8571af2 100644
--- a/src/buoh-application.h
+++ b/src/buoh-application.h
@@ -40,6 +40,7 @@ BuohApplication *buoh_application_get_instance       (void);
 BuohApplication *buoh_application_new                (void);
 
 void             buoh_application_activate           (GApplication    *buoh);
+void             buoh_application_startup            (GApplication    *buoh);
 GtkTreeModel    *buoh_application_get_comics_model   (BuohApplication *buoh);
 const gchar     *buoh_application_get_datadir        (BuohApplication *buoh);
 
diff --git a/src/buoh-window.c b/src/buoh-window.c
index 03bad92..0314101 100644
--- a/src/buoh-window.c
+++ b/src/buoh-window.c
@@ -36,18 +36,17 @@
 #include "buoh-comic-list.h"
 
 struct _BuohWindow {
-        GtkWindow       parent;
-
-        GtkActionGroup *action_group;
-        GtkUIManager   *ui_manager;
+        GtkApplicationWindow parent;
 
+        GtkWidget      *toolbar;
+        GtkWidget      *comic_list;
+        GtkWidget      *view;
         GtkWidget      *statusbar;
+        GtkWidget      *list_popup;
+        GtkWidget      *view_popup;
         guint           view_message_cid;
         guint           help_message_cid;
 
-        BuohView       *view;
-        BuohComicList  *comic_list;
-
         GList          *properties;
         GtkWidget      *add_dialog;
 
@@ -77,18 +76,6 @@ static void buoh_window_comic_save_to_disk_set_sensitive (BuohWindow      *windo
                                                           gboolean         sensitive);
 
 /* Callbacks */
-static void buoh_window_ui_manager_connect_proxy_cb     (GtkUIManager     *manager,
-                                                         GtkAction        *action,
-                                                         GtkWidget        *proxy,
-                                                         gpointer          gdata);
-static void buoh_window_ui_manager_disconnect_proxy_cb  (GtkUIManager     *manager,
-                                                         GtkAction        *action,
-                                                         GtkWidget        *proxy,
-                                                         gpointer          gdata);
-static void buoh_window_menu_item_select_cb             (GtkMenuItem      *proxy,
-                                                         gpointer          gdata);
-static void buoh_window_menu_item_deselect_cb           (GtkMenuItem      *proxy,
-                                                         gpointer          gdata);
 static void buoh_window_view_status_change_cb           (GObject          *object,
                                                          GParamSpec       *arg,
                                                          gpointer          gdata);
@@ -112,123 +99,114 @@ static void     buoh_window_properties_dialog_destroyed (GtkWidget        *dialo
                                                          gpointer          gdata);
 
 /* Action callbacks */
-static void buoh_window_cmd_comic_add                   (GtkAction        *action,
+static void buoh_window_cmd_comic_add                   (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_comic_remove                (GtkAction        *action,
+static void buoh_window_cmd_comic_remove                (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_comic_save_a_copy           (GtkAction        *action,
+static void buoh_window_cmd_comic_save_a_copy           (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_comic_copy_location         (GtkAction        *action,
+static void buoh_window_cmd_comic_copy_location         (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_comic_properties            (GtkAction        *action,
+static void buoh_window_cmd_comic_properties            (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_comic_quit                  (GtkAction        *action,
+static void buoh_window_cmd_comic_quit                  (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_view_toolbar                (GtkAction        *action,
+static void buoh_window_cmd_view_toolbar                (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_view_statusbar              (GtkAction        *action,
+static void buoh_window_cmd_view_statusbar              (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_view_zoom_in                (GtkAction        *action,
+static void buoh_window_cmd_view_zoom_in                (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_view_zoom_out               (GtkAction        *action,
+static void buoh_window_cmd_view_zoom_out               (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_view_zoom_normal            (GtkAction        *action,
+static void buoh_window_cmd_view_zoom_normal            (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_view_zoom_best_fit          (GtkAction        *action,
+static void buoh_window_cmd_view_zoom_mode              (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_view_zoom_fit_width         (GtkAction        *action,
+static void buoh_window_cmd_go_previous                 (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_go_previous                 (GtkAction        *action,
+static void buoh_window_cmd_go_next                     (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_go_next                     (GtkAction        *action,
+static void buoh_window_cmd_go_first                    (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_go_first                    (GtkAction        *action,
+static void buoh_window_cmd_go_last                     (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_go_last                     (GtkAction        *action,
+static void buoh_window_cmd_help_about                  (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
-static void buoh_window_cmd_help_about                  (GtkAction        *action,
+
+static void activate_toggle                             (GSimpleAction    *action,
+                                                         GVariant         *parameter,
+                                                         gpointer          gdata);
+
+static void activate_radio                              (GSimpleAction    *action,
+                                                         GVariant         *parameter,
                                                          gpointer          gdata);
 
 static void buoh_window_update_title                    (BuohWindow       *window);
 static void buoh_window_update_zoom_mode                (BuohWindow       *window);
 
-static const GtkActionEntry menu_entries[] = {
-
-        /* Top Level */
-        { "Comic", NULL, N_("_Comic") },
-        { "View", NULL, N_("_View") },
-        { "Go", NULL, N_("_Go") },
-        { "Help", NULL, N_("_Help") },
-
+static const GActionEntry menu_entries[] = {
         /* Comic menu */
-        { "ComicAdd", GTK_STOCK_ADD, N_("_Add…"), NULL,
-          N_("Add a comic to the comic list"),
-          G_CALLBACK (buoh_window_cmd_comic_add) },
-        { "ComicRemove", GTK_STOCK_REMOVE, N_("_Remove"), NULL,
-          N_("Remove this comic from the comic list"),
-          G_CALLBACK (buoh_window_cmd_comic_remove) },
-        { "ComicSaveACopy", NULL, N_("_Save a Copy…"), NULL,
-          N_("Save the current comic with a new filename"),
-          G_CALLBACK (buoh_window_cmd_comic_save_a_copy) },
-        { "ComicCopyURI", NULL, N_("_Copy Location"), NULL,
-          N_("Copy the location of this comic to clipboard"),
-          G_CALLBACK (buoh_window_cmd_comic_copy_location) },
-        { "ComicProperties", GTK_STOCK_PROPERTIES, N_("_Properties…"), "<alt>Return",
-          N_("View the properties of this comic"),
-          G_CALLBACK (buoh_window_cmd_comic_properties) },
-        { "ComicQuit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q",
-          N_("Quit application"),
-          G_CALLBACK (buoh_window_cmd_comic_quit) },
+        { "comic-add",
+          buoh_window_cmd_comic_add },
+        { "comic-remove",
+          buoh_window_cmd_comic_remove },
+        { "comic-save-a-copy",
+          buoh_window_cmd_comic_save_a_copy },
+        { "comic-copy-uri",
+          buoh_window_cmd_comic_copy_location },
+        { "comic-properties",
+          buoh_window_cmd_comic_properties },
+        { "comic-quit",
+          buoh_window_cmd_comic_quit },
 
         /* View menu*/
-        { "ViewZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _In"), "<control>plus",
-          N_("Increase the comic size"),
-          G_CALLBACK (buoh_window_cmd_view_zoom_in) },
-        { "ViewZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _Out"), "<control>minus",
-          N_("Decrease the comic size"),
-          G_CALLBACK (buoh_window_cmd_view_zoom_out) },
-        { "ViewZoomNormal", GTK_STOCK_ZOOM_100, N_("_Normal Size"), "<control>0",
-          N_("Use the normal comic size"),
-          G_CALLBACK (buoh_window_cmd_view_zoom_normal) },
+        { "view-toolbar",
+          activate_toggle, NULL, "true", buoh_window_cmd_view_toolbar },
+        { "view-statusbar",
+          activate_toggle, NULL, "true", buoh_window_cmd_view_statusbar },
+        { "view-zoom-in",
+          buoh_window_cmd_view_zoom_in },
+        { "view-zoom-out",
+          buoh_window_cmd_view_zoom_out },
+        { "view-zoom-normal",
+          buoh_window_cmd_view_zoom_normal },
+        { "view-zoom-mode",
+          activate_radio, "s", "'free'", buoh_window_cmd_view_zoom_mode },
 
         /* Go menu */
-        { "GoPrevious", GTK_STOCK_GO_BACK, N_("_Previous Comic"), "<alt>Left",
-          N_("Go to the previous comic"),
-          G_CALLBACK (buoh_window_cmd_go_previous) },
-        { "GoNext", GTK_STOCK_GO_FORWARD, N_("_Next Comic"), "<alt>Right",
-          N_("Go to the next comic"),
-          G_CALLBACK (buoh_window_cmd_go_next) },
-        { "GoFirst", GTK_STOCK_GOTO_FIRST, N_("_First Comic"), "<control>Home",
-          N_("Go to the first comic"),
-          G_CALLBACK (buoh_window_cmd_go_first) },
-        { "GoLast", GTK_STOCK_GOTO_LAST, N_("_Last Comic"), "<control>End",
-          N_("Go to the last comic"),
-          G_CALLBACK (buoh_window_cmd_go_last) },
+        { "go-previous",
+          buoh_window_cmd_go_previous },
+        { "go-next",
+          buoh_window_cmd_go_next },
+        { "go-first",
+          buoh_window_cmd_go_first },
+        { "go-last",
+          buoh_window_cmd_go_last },
 
         /* Help menu */
-        { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL,
-          N_("Display credits for the Buoh online comic reader creators"),
-          G_CALLBACK (buoh_window_cmd_help_about) }
+        { "help-about",
+          buoh_window_cmd_help_about }
 };
 
-static const GtkToggleActionEntry menu_toggle_entries[] = {
-
-        /* View menu*/
-        { "ViewToolbar", NULL, N_("_Toolbar"), NULL,
-          N_("Changes the visibility of the toolbar"),
-          G_CALLBACK (buoh_window_cmd_view_toolbar), TRUE },
-        { "ViewStatusbar", NULL, N_("St_atusbar"), NULL,
-          N_("Changes the visibility of the statusbar"),
-          G_CALLBACK (buoh_window_cmd_view_statusbar), TRUE },
-        { "ViewZoomBestFit", GTK_STOCK_ZOOM_FIT, N_("_Best Fit"), NULL,
-          N_("Make the current comic fill the window"),
-          G_CALLBACK (buoh_window_cmd_view_zoom_best_fit) },
-        { "ViewZoomFitWidth", GTK_STOCK_ZOOM_FIT, N_("Fit Comic _Width"), NULL,
-          N_("Make the current comic fill the window width"),
-          G_CALLBACK (buoh_window_cmd_view_zoom_fit_width) }
-};
-
-G_DEFINE_TYPE (BuohWindow, buoh_window, GTK_TYPE_WINDOW)
+G_DEFINE_TYPE (BuohWindow, buoh_window, GTK_TYPE_APPLICATION_WINDOW)
 
 static void
 buoh_window_init (BuohWindow *buoh_window)
@@ -236,99 +214,46 @@ buoh_window_init (BuohWindow *buoh_window)
         GtkWidget        *tree_view;
         GtkTreeModel     *model;
         GtkTreeSelection *selection;
-        GtkWidget        *vbox, *paned, *menubar;
-        GtkWidget        *toolbar;
-        GtkActionGroup   *action_group;
-        GtkAction        *action;
-        GtkAccelGroup    *accel_group;
-        GError           *error = NULL;
+        GActionMap       *action_map;
+        GAction          *action;
         gboolean          visible_toolbar;
         gboolean          visible_statusbar;
         BuohViewZoomMode  zoom_mode;
 
-        gtk_window_set_title (GTK_WINDOW (buoh_window), "Buoh");
-        gtk_window_set_icon_name (GTK_WINDOW (buoh_window), "buoh");
+        g_type_ensure (BUOH_TYPE_COMIC_LIST);
+        g_type_ensure (BUOH_TYPE_VIEW);
+        gtk_widget_init_template (GTK_WIDGET (buoh_window));
 
         buoh_window->properties = NULL;
         buoh_window->add_dialog = NULL;
         buoh_window->buoh_settings = g_settings_new (GS_BUOH_SCHEMA);
         buoh_window->lockdown_settings = g_settings_new (GS_LOCKDOWN_SCHEMA);
 
-        vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-
         /* Menu bar */
-        action_group = gtk_action_group_new ("MenuActions");
-        buoh_window->action_group = action_group;
-        gtk_action_group_set_translation_domain (action_group, NULL);
-        gtk_action_group_add_actions (action_group, menu_entries,
-                                      G_N_ELEMENTS (menu_entries),
-                                      (gpointer) buoh_window);
-
-        gtk_action_group_add_toggle_actions (action_group, menu_toggle_entries,
-                                             G_N_ELEMENTS (menu_toggle_entries),
-                                             (gpointer) buoh_window);
-
-        buoh_window->ui_manager = gtk_ui_manager_new ();
-        gtk_ui_manager_insert_action_group (buoh_window->ui_manager,
-                                            action_group, 0);
-
-        accel_group = gtk_ui_manager_get_accel_group (buoh_window->ui_manager);
-        gtk_window_add_accel_group (GTK_WINDOW (buoh_window), accel_group);
-
-        if (!gtk_ui_manager_add_ui_from_resource (buoh_window->ui_manager,
-                                                  "/org/gnome/buoh/buoh-ui.xml",
-                                                  &error)) {
-                buoh_debug ("Could not merge buoh-ui.xml: %s", error->message);
-                g_error_free (error);
-        }
-
-        g_signal_connect (buoh_window->ui_manager, "connect_proxy",
-                          G_CALLBACK (buoh_window_ui_manager_connect_proxy_cb),
-                          (gpointer) buoh_window);
-        g_signal_connect (buoh_window->ui_manager, "disconnect_proxy",
-                          G_CALLBACK (buoh_window_ui_manager_disconnect_proxy_cb),
-                          (gpointer) buoh_window);
+        action_map = G_ACTION_MAP (buoh_window);
+        g_action_map_add_action_entries (action_map, menu_entries, G_N_ELEMENTS (menu_entries), buoh_window);
 
         /* Menu */
-        menubar = gtk_ui_manager_get_widget (buoh_window->ui_manager,
-                                             "/MainMenu");
-        gtk_box_pack_start (GTK_BOX (vbox), menubar,
-                            FALSE, FALSE, 0);
-        gtk_widget_show (menubar);
-
         /* Set the active status to the "View [toolbar | statusbar]" menu entry*/
         visible_toolbar = g_settings_get_boolean (buoh_window->buoh_settings,
                                                   GS_SHOW_TOOLBAR);
-        action = gtk_action_group_get_action (action_group, "ViewToolbar");
-        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-                                      visible_toolbar);
+        action = g_action_map_lookup_action (action_map, "view-toolbar");
+        g_action_change_state (G_ACTION (action), g_variant_new_boolean (visible_toolbar));
 
         visible_statusbar = g_settings_get_boolean (buoh_window->buoh_settings,
                                                     GS_SHOW_STATUSBAR);
-        action = gtk_action_group_get_action (action_group, "ViewStatusbar");
-        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-                                      visible_statusbar);
+        action = g_action_map_lookup_action (action_map, "view-statusbar");
+        g_action_change_state (G_ACTION (action), g_variant_new_boolean (visible_statusbar));
 
         /* Toolbar */
-        toolbar = gtk_ui_manager_get_widget (buoh_window->ui_manager,
-                                             "/Toolbar");
-        gtk_box_pack_start (GTK_BOX (vbox), toolbar,
-                            FALSE, FALSE, 0);
-        gtk_widget_show (toolbar);
-        g_object_set (G_OBJECT (toolbar),
+        g_object_set (G_OBJECT (buoh_window->toolbar),
                       "visible", visible_toolbar,
                       NULL);
 
-        /* Pane */
-        paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
-        /* FIXME: Remember side position */
-        gtk_paned_set_position (GTK_PANED (paned), 230);
-
         /* buoh view */
-        buoh_window->view = BUOH_VIEW (buoh_view_new ());
         zoom_mode = g_settings_get_enum (buoh_window->buoh_settings,
                                          GS_ZOOM_MODE);
-        buoh_view_set_zoom_mode (buoh_window->view, zoom_mode);
+        buoh_view_set_zoom_mode (BUOH_VIEW (buoh_window->view), zoom_mode);
         g_signal_connect (G_OBJECT (buoh_window->view), "notify::status",
                           G_CALLBACK (buoh_window_view_status_change_cb),
                           (gpointer) buoh_window);
@@ -341,39 +266,21 @@ buoh_window_init (BuohWindow *buoh_window)
         g_signal_connect (G_OBJECT (buoh_window->view), "key-press-event",
                           G_CALLBACK (buoh_window_comic_view_key_press_cb),
                           (gpointer) buoh_window);
-        gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET (buoh_window->view),
-                         TRUE, FALSE);
-        gtk_widget_show (GTK_WIDGET (buoh_window->view));
 
         /* buoh comic list */
-        buoh_window->comic_list = BUOH_COMIC_LIST (buoh_comic_list_new ());
         model = buoh_application_get_comics_model (buoh_application_get_instance ());
-        buoh_comic_list_set_model (buoh_window->comic_list, model);
-        buoh_comic_list_set_view (buoh_window->comic_list, buoh_window->view);
-        gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (buoh_window->comic_list),
-                         TRUE, FALSE);
-        gtk_widget_show (GTK_WIDGET (buoh_window->comic_list));
-
-        gtk_box_pack_start (GTK_BOX (vbox), paned,
-                            TRUE, TRUE, 0);
-        gtk_widget_show (paned);
+        buoh_comic_list_set_model (BUOH_COMIC_LIST (buoh_window->comic_list), model);
+        buoh_comic_list_set_view (BUOH_COMIC_LIST (buoh_window->comic_list), BUOH_VIEW (buoh_window->view));
 
         /* Status bar */
-        buoh_window->statusbar = gtk_statusbar_new ();
         buoh_window->view_message_cid = gtk_statusbar_get_context_id
                 (GTK_STATUSBAR (buoh_window->statusbar), "view_message");
         buoh_window->help_message_cid = gtk_statusbar_get_context_id
                 (GTK_STATUSBAR (buoh_window->statusbar), "help_message");
-        gtk_box_pack_end (GTK_BOX (vbox), buoh_window->statusbar,
-                          FALSE, TRUE, 0);
-        gtk_widget_show (buoh_window->statusbar);
         g_object_set (G_OBJECT (buoh_window->statusbar),
                       "visible", visible_statusbar, NULL);
 
-        gtk_container_add (GTK_CONTAINER (buoh_window), vbox);
-        gtk_widget_show (vbox);
-
-        tree_view = buoh_comic_list_get_list (buoh_window->comic_list);
+        tree_view = buoh_comic_list_get_list (BUOH_COMIC_LIST (buoh_window->comic_list));
         selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
         g_signal_connect (G_OBJECT (tree_view), "button-press-event",
                           G_CALLBACK (buoh_window_comic_list_button_press_cb),
@@ -387,18 +294,40 @@ buoh_window_init (BuohWindow *buoh_window)
 
         buoh_window_comic_actions_set_sensitive (buoh_window, FALSE);
         buoh_window_comic_save_to_disk_set_sensitive (buoh_window, FALSE);
-        buoh_window_set_sensitive (buoh_window, "ComicRemove", FALSE);
+        buoh_window_set_sensitive (buoh_window, "comic-remove", FALSE);
         buoh_window_update_zoom_mode (buoh_window);
-
-        gtk_widget_grab_focus (GTK_WIDGET (buoh_window->view));
+        GEnumClass *enum_class = g_type_class_ref (BUOH_TYPE_VIEW_ZOOM_MODE);
+        action = g_action_map_lookup_action (action_map, "view-zoom-mode");
+        g_type_class_unref (enum_class);
+        g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_string (g_enum_get_value 
(enum_class, zoom_mode)->value_nick));
+
+        buoh_window->list_popup = gtk_menu_new_from_model (G_MENU_MODEL (gtk_application_get_menu_by_id 
(GTK_APPLICATION (buoh_application_get_instance ()), "list-popup")));
+        gtk_menu_attach_to_widget (GTK_MENU (buoh_window->list_popup),
+                                   buoh_window->comic_list,
+                                   NULL);
+        buoh_window->view_popup = gtk_menu_new_from_model (G_MENU_MODEL (gtk_application_get_menu_by_id 
(GTK_APPLICATION (buoh_application_get_instance ()), "view-popup")));
+        gtk_menu_attach_to_widget (GTK_MENU (buoh_window->view_popup),
+                                   buoh_window->view,
+                                   NULL);
+
+
+        gtk_widget_grab_focus (buoh_window->view);
 }
 
 static void
 buoh_window_class_init (BuohWindowClass *klass)
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
         object_class->finalize = buoh_window_finalize;
+
+        gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/buoh/ui/window.ui");
+
+        gtk_widget_class_bind_template_child (widget_class, BuohWindow, comic_list);
+        gtk_widget_class_bind_template_child (widget_class, BuohWindow, view);
+        gtk_widget_class_bind_template_child (widget_class, BuohWindow, statusbar);
+        gtk_widget_class_bind_template_child (widget_class, BuohWindow, toolbar);
 }
 
 static void
@@ -408,10 +337,6 @@ buoh_window_finalize (GObject *object)
 
         buoh_debug ("buoh-window finalize");
 
-        g_clear_object (&buoh_window->ui_manager);
-
-        g_clear_object (&buoh_window->action_group);
-
         g_clear_object (&buoh_window->buoh_settings);
 
         g_clear_object (&buoh_window->lockdown_settings);
@@ -434,16 +359,12 @@ buoh_window_new (void)
 {
         GtkWidget *buoh_window;
 
-        buoh_window = GTK_WIDGET (g_object_new (BUOH_TYPE_WINDOW,
-                                                "type", GTK_WINDOW_TOPLEVEL,
-                                                "default-width", 600,
-                                                "default-height", 300,
-                                                NULL));
+        buoh_window = GTK_WIDGET (g_object_new (BUOH_TYPE_WINDOW, NULL));
         return buoh_window;
 }
 
 static void
-buoh_window_cmd_comic_add (GtkAction *action, gpointer gdata)
+buoh_window_cmd_comic_add (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow *window = BUOH_WINDOW (gdata);
 
@@ -459,7 +380,7 @@ buoh_window_cmd_comic_add (GtkAction *action, gpointer gdata)
 }
 
 static void
-buoh_window_cmd_comic_remove (GtkAction *action, gpointer gdata)
+buoh_window_cmd_comic_remove (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
         GtkTreeModel     *model = buoh_application_get_comics_model (buoh_application_get_instance ());
@@ -470,7 +391,7 @@ buoh_window_cmd_comic_remove (GtkAction *action, gpointer gdata)
         const gchar      *cm_id;
         gboolean          valid;
 
-        current_cm = buoh_comic_list_get_selected (window->comic_list);
+        current_cm = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
 
         if (!current_cm) {
                 return;
@@ -488,7 +409,7 @@ buoh_window_cmd_comic_remove (GtkAction *action, gpointer gdata)
                 g_object_unref (cm);
 
                 if (g_ascii_strcasecmp (current_cm_id, cm_id) == 0) {
-                        buoh_comic_list_clear_selection (window->comic_list);
+                        buoh_comic_list_clear_selection (BUOH_COMIC_LIST (window->comic_list));
                         gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                                             COMIC_LIST_VISIBLE, FALSE,
                                             -1);
@@ -500,7 +421,7 @@ buoh_window_cmd_comic_remove (GtkAction *action, gpointer gdata)
 }
 
 static void
-buoh_window_cmd_comic_save_a_copy (GtkAction *action, gpointer gdata)
+buoh_window_cmd_comic_save_a_copy (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         GtkWidget        *chooser;
         GtkFileFilter    *filter;
@@ -531,7 +452,7 @@ buoh_window_cmd_comic_save_a_copy (GtkAction *action, gpointer gdata)
                                                          folder);
         }
 
-        comic  = buoh_view_get_comic (window->view);
+        comic  = buoh_view_get_comic (BUOH_VIEW (window->view));
         image = buoh_comic_get_image (comic);
 
         suggested = buoh_comic_get_filename (comic);
@@ -581,10 +502,10 @@ buoh_window_cmd_comic_save_a_copy (GtkAction *action, gpointer gdata)
 }
 
 static void
-buoh_window_cmd_comic_copy_location (GtkAction *action, gpointer gdata)
+buoh_window_cmd_comic_copy_location (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow *window = BUOH_WINDOW (gdata);
-        BuohComic  *comic = buoh_view_get_comic (window->view);
+        BuohComic  *comic = buoh_view_get_comic (BUOH_VIEW (window->view));
 
         if (comic) {
                 const gchar *uri = buoh_comic_get_uri (comic);
@@ -610,10 +531,10 @@ buoh_window_properties_dialog_destroyed (GtkWidget *dialog, gpointer gdata)
 }
 
 static void
-buoh_window_cmd_comic_properties (GtkAction *action, gpointer gdata)
+buoh_window_cmd_comic_properties (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
-        BuohComicManager *cm  = buoh_comic_list_get_selected (window->comic_list);
+        BuohComicManager *cm  = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
         BuohComicManager *cm2 = NULL;
         GtkWidget        *dialog;
         const gchar      *id1, *id2;
@@ -649,7 +570,7 @@ buoh_window_cmd_comic_properties (GtkAction *action, gpointer gdata)
 }
 
 static void
-buoh_window_cmd_comic_quit (GtkAction *action, gpointer gdata)
+buoh_window_cmd_comic_quit (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow *window = BUOH_WINDOW (gdata);
 
@@ -657,150 +578,159 @@ buoh_window_cmd_comic_quit (GtkAction *action, gpointer gdata)
 }
 
 static void
-buoh_window_cmd_view_toolbar (GtkAction *action, gpointer gdata)
+buoh_window_cmd_view_toolbar (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow  *window = BUOH_WINDOW (gdata);
-        GtkWidget   *toolbar;
         gboolean     visible;
 
-        visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+        visible = g_variant_get_boolean (parameter);
         g_settings_set_boolean (window->buoh_settings,
                                 GS_SHOW_TOOLBAR, visible);
 
-        toolbar = gtk_ui_manager_get_widget (window->ui_manager, "/Toolbar");
-        g_object_set (G_OBJECT (toolbar), "visible",
+        g_object_set (G_OBJECT (window->toolbar), "visible",
                       visible,
                       NULL);
+
+        g_simple_action_set_state (action, parameter);
 }
 
 static void
-buoh_window_cmd_view_statusbar (GtkAction *action, gpointer gdata)
+buoh_window_cmd_view_statusbar (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow  *window = BUOH_WINDOW (gdata);
         gboolean     visible;
 
-        visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+        visible = g_variant_get_boolean (parameter);
         g_settings_set_boolean (window->buoh_settings,
                                 GS_SHOW_STATUSBAR, visible);
 
         g_object_set (G_OBJECT (window->statusbar),
                       "visible", visible,
                       NULL);
+
+        g_simple_action_set_state (action, parameter);
 }
 
 static void
-buoh_window_cmd_view_zoom_in (GtkAction *action, gpointer gdata)
+buoh_window_view_zoom_free (gpointer data)
 {
-        BuohWindow *window = BUOH_WINDOW (gdata);
+        GAction *action = g_action_map_lookup_action (G_ACTION_MAP (data), "view-zoom-mode");
+        g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_string ("free"));
 
-        buoh_view_zoom_in (window->view);
+        g_settings_set_enum (BUOH_WINDOW (data)->buoh_settings,
+                             GS_ZOOM_MODE, VIEW_ZOOM_FREE);
 }
 
 static void
-buoh_window_cmd_view_zoom_out (GtkAction *action, gpointer gdata)
+buoh_window_cmd_view_zoom_in (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow *window = BUOH_WINDOW (gdata);
 
-        buoh_view_zoom_out (window->view);
+        buoh_view_zoom_in (BUOH_VIEW (window->view));
+
+        buoh_window_view_zoom_free (gdata);
 }
 
 static void
-buoh_window_cmd_view_zoom_normal (GtkAction *action, gpointer gdata)
+buoh_window_cmd_view_zoom_out (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow *window = BUOH_WINDOW (gdata);
 
-        buoh_view_zoom_normal_size (window->view);
+        buoh_view_zoom_out (BUOH_VIEW (window->view));
+
+        buoh_window_view_zoom_free (gdata);
 }
 
 static void
-buoh_window_cmd_view_zoom_best_fit (GtkAction *action, gpointer gdata)
+buoh_window_cmd_view_zoom_normal (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow *window = BUOH_WINDOW (gdata);
 
-        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
-                buoh_view_zoom_best_fit (window->view);
-                g_settings_set_enum (window->buoh_settings,
-                                     GS_ZOOM_MODE, VIEW_ZOOM_BEST_FIT);
-        } else {
-                buoh_view_zoom_normal_size (window->view);
-                g_settings_set_enum (window->buoh_settings,
-                                     GS_ZOOM_MODE, VIEW_ZOOM_FREE);
-        }
+        buoh_view_zoom_normal_size (BUOH_VIEW (window->view));
+
+        buoh_window_view_zoom_free (gdata);
 }
 
 static void
-buoh_window_cmd_view_zoom_fit_width (GtkAction *action, gpointer gdata)
+buoh_window_cmd_view_zoom_mode (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
-        BuohWindow *window = BUOH_WINDOW (gdata);
+        BuohWindow  *window = BUOH_WINDOW (gdata);
+        const gchar *zoom_mode = g_variant_get_string (parameter, NULL);
 
-        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
-                buoh_view_zoom_fit_width (window->view);
+        if (strcmp(zoom_mode, "best-fit") == 0) {
+                buoh_view_zoom_best_fit (BUOH_VIEW (window->view));
+                g_settings_set_enum (window->buoh_settings,
+                                     GS_ZOOM_MODE, VIEW_ZOOM_BEST_FIT);
+        } else if (strcmp(zoom_mode, "fit-width") == 0) {
+                buoh_view_zoom_fit_width (BUOH_VIEW (window->view));
                 g_settings_set_enum (window->buoh_settings,
                                      GS_ZOOM_MODE, VIEW_ZOOM_FIT_WIDTH);
         } else {
-                buoh_view_zoom_normal_size (window->view);
+                buoh_view_zoom_normal_size (BUOH_VIEW (window->view));
                 g_settings_set_enum (window->buoh_settings,
                                      GS_ZOOM_MODE, VIEW_ZOOM_FREE);
         }
+
+        g_simple_action_set_state (action, parameter);
 }
 
 static void
-buoh_window_cmd_go_previous (GtkAction *action, gpointer gdata)
+buoh_window_cmd_go_previous (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
         BuohComicManager *comic_manager;
         BuohComic        *comic;
 
-        comic_manager = buoh_comic_list_get_selected (window->comic_list);
+        comic_manager = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
 
         comic = buoh_comic_manager_get_previous (comic_manager);
 
-        buoh_view_set_comic (window->view, comic);
+        buoh_view_set_comic (BUOH_VIEW (window->view), comic);
 }
 
 static void
-buoh_window_cmd_go_next (GtkAction *action, gpointer gdata)
+buoh_window_cmd_go_next (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
         BuohComicManager *comic_manager;
         BuohComic        *comic;
 
-        comic_manager = buoh_comic_list_get_selected (window->comic_list);
+        comic_manager = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
 
         comic = buoh_comic_manager_get_next (comic_manager);
 
-        buoh_view_set_comic (window->view, comic);
+        buoh_view_set_comic (BUOH_VIEW (window->view), comic);
 }
 
 static void
-buoh_window_cmd_go_first (GtkAction *action, gpointer gdata)
+buoh_window_cmd_go_first (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
         BuohComicManager *comic_manager;
         BuohComic        *comic;
 
-        comic_manager = buoh_comic_list_get_selected (window->comic_list);
+        comic_manager = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
 
         comic = buoh_comic_manager_get_first (comic_manager);
 
-        buoh_view_set_comic (window->view, comic);
+        buoh_view_set_comic (BUOH_VIEW (window->view), comic);
 }
 static void
-buoh_window_cmd_go_last (GtkAction *action, gpointer gdata)
+buoh_window_cmd_go_last (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
         BuohComicManager *comic_manager;
         BuohComic        *comic;
 
-        comic_manager = buoh_comic_list_get_selected (window->comic_list);
+        comic_manager = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
 
         comic = buoh_comic_manager_get_last (comic_manager);
 
-        buoh_view_set_comic (window->view, comic);
+        buoh_view_set_comic (BUOH_VIEW (window->view), comic);
 }
 
 static void
-buoh_window_cmd_help_about (GtkAction *action, gpointer gdata)
+buoh_window_cmd_help_about (GSimpleAction *action, GVariant *parameter, gpointer gdata)
 {
         BuohWindow         *window = BUOH_WINDOW (gdata);
         static const gchar *authors[] = {
@@ -821,13 +751,33 @@ buoh_window_cmd_help_about (GtkAction *action, gpointer gdata)
                                NULL);
 }
 
+static void
+activate_toggle (GSimpleAction *action,
+                 GVariant      *parameter,
+                 gpointer       user_data)
+{
+        GVariant *state;
+
+        state = g_action_get_state (G_ACTION (action));
+        g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state)));
+        g_variant_unref (state);
+}
+
+static void
+activate_radio (GSimpleAction *action,
+                GVariant      *parameter,
+                gpointer       user_data)
+{
+        g_action_change_state (G_ACTION (action), parameter);
+}
+
 static void
 buoh_window_update_title (BuohWindow *window)
 {
         BuohComicManager *cm;
         gchar            *title = NULL;
 
-        cm = buoh_comic_list_get_selected (window->comic_list);
+        cm = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
 
         if (cm) {
                 title = g_strdup_printf ("%s — Buoh",
@@ -843,9 +793,8 @@ buoh_window_update_title (BuohWindow *window)
 static void
 buoh_window_set_sensitive (BuohWindow *window, const gchar *name, gboolean sensitive)
 {
-        GtkAction *action = gtk_action_group_get_action (window->action_group,
-                                                         name);
-        gtk_action_set_sensitive (action, sensitive);
+        GSimpleAction *action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), name));
+        g_simple_action_set_enabled (action, sensitive);
 }
 
 static void
@@ -853,21 +802,21 @@ buoh_window_comic_browsing_actions_set_sensitive (BuohWindow *window, gboolean s
 {
         BuohComicManager *cm;
 
-        cm = buoh_comic_list_get_selected (window->comic_list);
+        cm = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
 
-        buoh_window_set_sensitive (window, "GoPrevious",
-                                      sensitive ?
+        buoh_window_set_sensitive (window, "go-previous",
+                                   sensitive ?
                                    !buoh_comic_manager_is_the_first (cm) :
                                    sensitive);
-        buoh_window_set_sensitive (window, "GoNext",
-                                      sensitive ?
+        buoh_window_set_sensitive (window, "go-next",
+                                   sensitive ?
                                    !buoh_comic_manager_is_the_last (cm) :
                                    sensitive);
-        buoh_window_set_sensitive (window, "GoFirst",
+        buoh_window_set_sensitive (window, "go-first",
                                    sensitive ?
                                    !buoh_comic_manager_is_the_first (cm) :
                                    sensitive);
-        buoh_window_set_sensitive (window, "GoLast",
+        buoh_window_set_sensitive (window, "go-last",
                                    sensitive ?
                                    !buoh_comic_manager_is_the_last (cm) :
                                    sensitive);
@@ -878,19 +827,18 @@ buoh_window_comic_actions_set_sensitive (BuohWindow *window, gboolean sensitive)
 {
         buoh_window_comic_browsing_actions_set_sensitive (window, sensitive);
 
-        buoh_window_set_sensitive (window, "ComicProperties", sensitive);
-        buoh_window_set_sensitive (window, "ComicCopyURI",    sensitive);
-        buoh_window_set_sensitive (window, "ViewZoomIn",
-                                   buoh_view_is_max_zoom (window->view) ?
+        buoh_window_set_sensitive (window, "comic-properties", sensitive);
+        buoh_window_set_sensitive (window, "comic-copy-uri",    sensitive);
+        buoh_window_set_sensitive (window, "view-zoom-in",
+                                   buoh_view_is_max_zoom (BUOH_VIEW (window->view)) ?
                                    FALSE : sensitive);
-        buoh_window_set_sensitive (window, "ViewZoomOut",
-                                   buoh_view_is_min_zoom (window->view) ?
+        buoh_window_set_sensitive (window, "view-zoom-out",
+                                   buoh_view_is_min_zoom (BUOH_VIEW (window->view)) ?
                                    FALSE : sensitive);
-        buoh_window_set_sensitive (window, "ViewZoomNormal",
-                                   buoh_view_is_normal_size (window->view) ?
+        buoh_window_set_sensitive (window, "view-zoom-normal",
+                                   buoh_view_is_normal_size (BUOH_VIEW (window->view)) ?
                                    FALSE : sensitive);
-        buoh_window_set_sensitive (window, "ViewZoomBestFit", sensitive);
-        buoh_window_set_sensitive (window, "ViewZoomFitWidth", sensitive);
+        buoh_window_set_sensitive (window, "view-zoom-mode", sensitive);
 }
 
 static void
@@ -903,72 +851,10 @@ buoh_window_comic_save_to_disk_set_sensitive (BuohWindow *window, gboolean sensi
                 save_disabled = TRUE;
         }
 
-        buoh_window_set_sensitive (window, "ComicSaveACopy",
+        buoh_window_set_sensitive (window, "comic-save-a-copy",
                                    (save_disabled) ?  FALSE : sensitive);
 }
 
-static void
-buoh_window_ui_manager_connect_proxy_cb (GtkUIManager *manager,
-                                         GtkAction    *action,
-                                         GtkWidget    *proxy,
-                                         gpointer      gdata)
-{
-        if (GTK_IS_MENU_ITEM (proxy)) {
-                g_signal_connect (proxy, "select",
-                                  G_CALLBACK (buoh_window_menu_item_select_cb),
-                                  gdata);
-                g_signal_connect (proxy, "deselect",
-                                  G_CALLBACK (buoh_window_menu_item_deselect_cb),
-                                  gdata);
-        }
-}
-
-static void
-buoh_window_ui_manager_disconnect_proxy_cb (GtkUIManager *manager,
-                                            GtkAction    *action,
-                                            GtkWidget    *proxy,
-                                            gpointer      gdata)
-{
-        if (GTK_IS_MENU_ITEM (proxy)) {
-                g_signal_handlers_disconnect_by_func
-                        (proxy,
-                         G_CALLBACK (buoh_window_menu_item_select_cb),
-                         gdata);
-                g_signal_handlers_disconnect_by_func
-                        (proxy,
-                         G_CALLBACK (buoh_window_menu_item_deselect_cb),
-                         gdata);
-        }
-}
-
-static void
-buoh_window_menu_item_select_cb (GtkMenuItem *proxy, gpointer gdata)
-
-{
-        BuohWindow *window = BUOH_WINDOW (gdata);
-        GtkAction  *action;
-        gchar      *message = NULL;
-
-        action = g_object_get_data (G_OBJECT (proxy),  "gtk-action");
-        g_assert (action != NULL);
-
-        g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
-        if (message) {
-                gtk_statusbar_push (GTK_STATUSBAR (window->statusbar),
-                                    window->help_message_cid, message);
-                g_free (message);
-        }
-}
-
-static void
-buoh_window_menu_item_deselect_cb (GtkMenuItem *proxy, gpointer gdata)
-{
-        BuohWindow *window = BUOH_WINDOW (gdata);
-
-        gtk_statusbar_pop (GTK_STATUSBAR (window->statusbar),
-                           window->help_message_cid);
-}
-
 static void
 buoh_window_view_status_change_cb (GObject *object, GParamSpec *arg, gpointer gdata)
 {
@@ -979,7 +865,7 @@ buoh_window_view_status_change_cb (GObject *object, GParamSpec *arg, gpointer gd
         GtkStatusbar     *statusbar = GTK_STATUSBAR (window->statusbar);
         gchar            *message = NULL;
 
-        cm = buoh_comic_list_get_selected (window->comic_list);
+        cm = buoh_comic_list_get_selected (BUOH_COMIC_LIST (window->comic_list));
 
         switch (buoh_view_get_status (view)) {
         case STATE_MESSAGE_WELCOME:
@@ -1030,27 +916,15 @@ static void
 buoh_window_update_zoom_mode (BuohWindow *window)
 {
         BuohViewZoomMode  zoom_mode;
-        GtkAction        *action;
-
-        zoom_mode = buoh_view_get_zoom_mode (window->view);
-
-        action = gtk_action_group_get_action (window->action_group,
-                                              "ViewZoomBestFit");
-        g_signal_handlers_block_by_func
-                (action, G_CALLBACK (buoh_window_cmd_view_zoom_best_fit), window);
-        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-                                      zoom_mode == VIEW_ZOOM_BEST_FIT);
-        g_signal_handlers_unblock_by_func
-                (action, G_CALLBACK (buoh_window_cmd_view_zoom_best_fit), window);
-
-        action = gtk_action_group_get_action (window->action_group,
-                                              "ViewZoomFitWidth");
-        g_signal_handlers_block_by_func
-                (action, G_CALLBACK (buoh_window_cmd_view_zoom_fit_width), window);
-        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-                                      zoom_mode == VIEW_ZOOM_FIT_WIDTH);
-        g_signal_handlers_unblock_by_func
-                (action, G_CALLBACK (buoh_window_cmd_view_zoom_fit_width), window);
+        GAction          *action;
+
+        zoom_mode = buoh_view_get_zoom_mode (BUOH_VIEW (window->view));
+
+        action = g_action_map_lookup_action (G_ACTION_MAP (window),
+                                             "view-zoom-mode");
+        GEnumClass *enum_class = g_type_class_ref (BUOH_TYPE_VIEW_ZOOM_MODE);
+        g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_string (g_enum_get_value 
(enum_class, zoom_mode)->value_nick));
+        g_type_class_unref (enum_class);
 }
 
 static void
@@ -1058,12 +932,12 @@ buoh_window_view_zoom_change_cb (BuohView *view, gpointer gdata)
 {
         BuohWindow *window = BUOH_WINDOW (gdata);
 
-        buoh_window_set_sensitive (window, "ViewZoomIn",
-                                   !buoh_view_is_max_zoom (window->view));
-        buoh_window_set_sensitive (window, "ViewZoomOut",
-                                   !buoh_view_is_min_zoom (window->view));
-        buoh_window_set_sensitive (window, "ViewZoomNormal",
-                                   !buoh_view_is_normal_size (window->view));
+        buoh_window_set_sensitive (window, "view-zoom-in",
+                                   !buoh_view_is_max_zoom (BUOH_VIEW (window->view)));
+        buoh_window_set_sensitive (window, "view-zoom-out",
+                                   !buoh_view_is_min_zoom (BUOH_VIEW (window->view)));
+        buoh_window_set_sensitive (window, "view-zoom-normal",
+                                   !buoh_view_is_normal_size (BUOH_VIEW (window->view)));
 
         buoh_window_update_zoom_mode (window);
 
@@ -1074,16 +948,12 @@ static gboolean
 buoh_window_comic_list_button_press_cb (GtkWidget *widget, GdkEventButton *event, gpointer gdata)
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
-        GtkWidget        *popup;
         GtkTreeSelection *selection;
 
         if (event->button == 3) {
                 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
                 if (gtk_tree_selection_get_selected (selection, NULL, NULL)) {
-                        popup = gtk_ui_manager_get_widget (window->ui_manager, "/ListPopup");
-
-                        gtk_menu_popup_at_pointer (GTK_MENU (popup),
-                                                   (const GdkEvent *) event);
+                        gtk_menu_popup_at_pointer (GTK_MENU (window->list_popup), (const GdkEvent *) event);
                         return TRUE;
                 }
         }
@@ -1095,7 +965,6 @@ static gboolean
 buoh_window_comic_list_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer gdata)
 {
         BuohWindow       *window = BUOH_WINDOW (gdata);
-        GtkWidget        *popup;
         GtkTreeSelection *selection;
         guint             state;
 
@@ -1105,10 +974,7 @@ buoh_window_comic_list_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpoi
             event->keyval == GDK_KEY_F10) {
                 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
                 if (gtk_tree_selection_get_selected (selection, NULL, NULL)) {
-                        popup = gtk_ui_manager_get_widget (window->ui_manager, "/ListPopup");
-
-                        gtk_menu_popup_at_pointer (GTK_MENU (popup),
-                                                   (const GdkEvent *) event);
+                        gtk_menu_popup_at_pointer (GTK_MENU (window->list_popup), (const GdkEvent *) event);
                         return TRUE;
                 }
         }
@@ -1123,10 +989,10 @@ buoh_window_comic_list_selection_change_cb (GtkTreeSelection *selection, gpointe
 
         if (gtk_tree_selection_get_selected (selection, NULL, NULL)) {
                 buoh_window_update_title (window);
-                buoh_window_set_sensitive (window, "ComicRemove", TRUE);
+                buoh_window_set_sensitive (window, "comic-remove", TRUE);
         } else {
                 gtk_window_set_title (GTK_WINDOW (window), "Buoh");
-                buoh_window_set_sensitive (window, "ComicRemove", FALSE);
+                buoh_window_set_sensitive (window, "comic-remove", FALSE);
         }
 }
 
@@ -1134,20 +1000,16 @@ static gboolean
 buoh_window_comic_view_button_press_cb (GtkWidget *widget, GdkEventButton *event, gpointer gdata)
 {
         BuohWindow     *window = BUOH_WINDOW (gdata);
-        GtkWidget      *popup;
         BuohViewStatus  view_status;
 
-        view_status = buoh_view_get_status (window->view);
+        view_status = buoh_view_get_status (BUOH_VIEW (window->view));
         if (view_status != STATE_COMIC_LOADING &&
             view_status != STATE_COMIC_LOADED) {
                 return FALSE;
         }
 
         if (event->button == 3) {
-                popup = gtk_ui_manager_get_widget (window->ui_manager, "/ViewPopup");
-
-                gtk_menu_popup_at_pointer (GTK_MENU (popup),
-                                           (const GdkEvent *) event);
+                gtk_menu_popup_at_pointer (GTK_MENU (window->view_popup), (const GdkEvent *) event);
                 return TRUE;
         }
 
@@ -1158,11 +1020,10 @@ static gboolean
 buoh_window_comic_view_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer gdata)
 {
         BuohWindow     *window = BUOH_WINDOW (gdata);
-        GtkWidget      *popup;
         guint           state;
         BuohViewStatus  view_status;
 
-        view_status = buoh_view_get_status (window->view);
+        view_status = buoh_view_get_status (BUOH_VIEW (window->view));
         if (view_status != STATE_COMIC_LOADING &&
             view_status != STATE_COMIC_LOADED) {
                 return FALSE;
@@ -1172,10 +1033,7 @@ buoh_window_comic_view_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpoi
 
         if (state == GDK_SHIFT_MASK &&
             event->keyval == GDK_KEY_F10) {
-                popup = gtk_ui_manager_get_widget (window->ui_manager, "/ViewPopup");
-
-                gtk_menu_popup_at_pointer (GTK_MENU (popup),
-                                           (const GdkEvent *) event);
+                gtk_menu_popup_at_pointer (GTK_MENU (window->view_popup), (const GdkEvent *) event);
 
                 return TRUE;
         }
diff --git a/src/buoh-window.h b/src/buoh-window.h
index ae408ec..f8b31e7 100644
--- a/src/buoh-window.h
+++ b/src/buoh-window.h
@@ -25,7 +25,7 @@
 G_BEGIN_DECLS
 
 #define BUOH_TYPE_WINDOW buoh_window_get_type()
-G_DECLARE_FINAL_TYPE (BuohWindow, buoh_window, BUOH, WINDOW, GtkWindow)
+G_DECLARE_FINAL_TYPE (BuohWindow, buoh_window, BUOH, WINDOW, GtkApplicationWindow)
 
 GtkWidget *buoh_window_new      (void);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]