[cheese/wip/cdavis/hdywindow] Use HdyWindow and HdyHeaderBar




commit 765a72fab59ea067ab63b499b75954f0e7638fc6
Author: Christopher Davis <brainblasted disroot org>
Date:   Sat Dec 26 22:15:02 2020 -0800

    Use HdyWindow and HdyHeaderBar
    
    Gives us nice rounded corners.

 data/cheese-main-window.ui  | 64 ++++++++++++++++++++++++++++++++++++++++++++-
 data/headerbar.ui           | 59 -----------------------------------------
 data/org.gnome.Cheese.yml   |  5 ++++
 meson.build                 |  3 ++-
 src/cheese-application.vala |  1 +
 src/cheese-window.vala      | 18 +++----------
 src/meson.build             |  1 +
 7 files changed, 75 insertions(+), 76 deletions(-)
---
diff --git a/data/cheese-main-window.ui b/data/cheese-main-window.ui
index bdaf5a18..65973939 100644
--- a/data/cheese-main-window.ui
+++ b/data/cheese-main-window.ui
@@ -1,12 +1,74 @@
 <?xml version="1.0"?>
 <interface domain="cheese">
   <requires lib="gtk+" version="3.10"/>
-    <template class="CheeseMainWindow" parent="GtkApplicationWindow">
+    <menu id="primary_menu">
+      <section>
+        <item>
+          <attribute name="accel">F11</attribute>
+          <attribute name="label" translatable="yes">_Fullscreen</attribute>
+          <attribute name="action">app.fullscreen</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">P_references</attribute>
+          <attribute name="action">app.preferences</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+          <attribute name="action">app.shortcuts</attribute>
+        </item>
+        <item>
+          <attribute name="accel">F1</attribute>
+          <attribute name="label" translatable="yes">_Help</attribute>
+          <attribute name="action">app.help</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_About Cheese</attribute>
+          <attribute name="action">app.about</attribute>
+        </item>
+      </section>
+    </menu>
+    <template class="CheeseMainWindow" parent="HdyApplicationWindow">
         <child>
   <object class="GtkBox" id="main_vbox">
     <property name="orientation">vertical</property>
     <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <property name="visible">True</property>
+    <child>
+      <object class="HdyHeaderBar" id="header_bar">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="title" translatable="yes">Take a Photo</property>
+        <property name="show-close-button">True</property>
+        <style>
+          <class name="titlebar"/>
+        </style>
+        <child>
+          <object class="GtkMenuButton" id="menu_button">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="receives_default">False</property>
+            <property name="use_underline">True</property>
+            <property name="menu_model">primary_menu</property>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="icon_name">open-menu-symbolic</property>
+                <property name="icon_size">1</property>
+              </object>
+            </child>
+            <style>
+              <class name="image-button"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
     <child>
       <object class="GtkBox" id="content_area">
         <property name="vexpand">True</property>
diff --git a/data/headerbar.ui b/data/headerbar.ui
index 8068b472..7bbeb703 100644
--- a/data/headerbar.ui
+++ b/data/headerbar.ui
@@ -1,61 +1,2 @@
 <interface domain="cheese">
-  <menu id="primary_menu">
-    <section>
-      <item>
-        <attribute name="accel">F11</attribute>
-        <attribute name="label" translatable="yes">_Fullscreen</attribute>
-        <attribute name="action">app.fullscreen</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">P_references</attribute>
-        <attribute name="action">app.preferences</attribute>
-      </item>
-    </section>
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
-        <attribute name="action">app.shortcuts</attribute>
-      </item>
-      <item>
-        <attribute name="accel">F1</attribute>
-        <attribute name="label" translatable="yes">_Help</attribute>
-        <attribute name="action">app.help</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_About Cheese</attribute>
-        <attribute name="action">app.about</attribute>
-      </item>
-    </section>
-  </menu>
-  <object class="GtkHeaderBar" id="header_bar">
-    <property name="can_focus">False</property>
-    <property name="title" translatable="yes">Take a Photo</property>
-    <property name="show-close-button">True</property>
-    <style>
-      <class name="titlebar"/>
-    </style>
-    <child>
-      <object class="GtkMenuButton" id="menu_button">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="receives_default">False</property>
-        <property name="use_underline">True</property>
-        <property name="menu_model">primary_menu</property>
-        <child>
-          <object class="GtkImage">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="icon_name">open-menu-symbolic</property>
-            <property name="icon_size">1</property>
-          </object>
-        </child>
-        <style>
-          <class name="image-button"/>
-        </style>
-      </object>
-      <packing>
-        <property name="pack_type">end</property>
-      </packing>
-    </child>
-  </object>
 </interface>
diff --git a/data/org.gnome.Cheese.yml b/data/org.gnome.Cheese.yml
index bb829571..e8954378 100644
--- a/data/org.gnome.Cheese.yml
+++ b/data/org.gnome.Cheese.yml
@@ -64,6 +64,11 @@ modules:
         url: http://git.0pointer.net/clone/libcanberra.git
         commit: c0620e432650e81062c1967cc669829dbd29b310
         disable-shallow-clone: true
+  - name: libhandy
+    buildsystem: meson
+    sources:
+      - type: git
+        url: https://gitlab.gnome.org/GNOME/libhandy.git
   - name: cheese
     buildsystem: meson
     config-opts:
diff --git a/meson.build b/meson.build
index 7ef4075f..76bd5f42 100644
--- a/meson.build
+++ b/meson.build
@@ -109,7 +109,8 @@ gnome_desktop_dep = dependency('gnome-desktop-3.0')
 gstreamer_dep = dependency('gstreamer-1.0')
 gstreamer_pbutils_dep = dependency('gstreamer-pbutils-1.0')
 gstreamer_plugins_bad_dep = dependency('gstreamer-plugins-bad-1.0', version: '>= 1.4')
-gtk_dep = dependency('gtk+-3.0', version: '>= 3.13.4')
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.24.1')
+libhandy_dep = dependency('libhandy-1', version: '>= 1.0.0')
 libcanberra_dep = dependency('libcanberra')
 libcanberra_gtk_lib = meson.get_compiler('c').find_library('canberra-gtk3')
 libcanberra_gtk3_dep = declare_dependency(dependencies: [libcanberra_gtk_lib])
diff --git a/src/cheese-application.vala b/src/cheese-application.vala
index 0bc02407..5ef7e51f 100644
--- a/src/cheese-application.vala
+++ b/src/cheese-application.vala
@@ -91,6 +91,7 @@ public class Cheese.Application : Gtk.Application
 
         // Calls gtk_init() with no arguments.
         base.startup ();
+        Hdy.init ();
     }
 
     /**
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index cc119b68..569d009c 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -32,7 +32,7 @@ const int FULLSCREEN_TIMEOUT_INTERVAL = 5 * 1000;
 const uint EFFECTS_PER_PAGE = 9;
 
 [GtkTemplate (ui = "/org/gnome/Cheese/cheese-main-window.ui")]
-public class Cheese.MainWindow : Gtk.ApplicationWindow
+public class Cheese.MainWindow : Hdy.ApplicationWindow
 {
     private const GLib.ActionEntry actions[] = {
         { "file-open", on_file_open },
@@ -47,16 +47,14 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
 
     private Clutter.Script clutter_builder;
 
-    private Gtk.Builder header_bar_ui = new Gtk.Builder.from_resource ("/org/gnome/Cheese/headerbar.ui");
-
-    private Gtk.HeaderBar header_bar;
-
     private GLib.Settings settings;
 
     [GtkChild]
     private GtkClutter.Embed viewport_widget;
     [GtkChild]
     private Gtk.Widget main_vbox;
+    [GtkChild]
+    private Hdy.HeaderBar header_bar;
     private Eog.ThumbNav thumb_nav;
     private Cheese.ThumbView thumb_view;
     [GtkChild]
@@ -121,16 +119,6 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
     public MainWindow (Gtk.Application application)
     {
         GLib.Object (application: application);
-
-        header_bar = header_bar_ui.get_object ("header_bar") as Gtk.HeaderBar;
-
-        Gtk.Settings settings = Gtk.Settings.get_default ();
-
-        if (settings.gtk_dialogs_use_header)
-        {
-            header_bar.visible = true;
-            this.set_titlebar (header_bar);
-        }
     }
 
     private void set_window_title (string title)
diff --git a/src/meson.build b/src/meson.build
index 74f62b16..1014b6ca 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -20,6 +20,7 @@ deps = [
   libcanberra_dep,
   libcanberra_gtk3_dep,
   libcheese_gtk_dep,
+  libhandy_dep,
   posix_dep,
 ]
 


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