[gnome-notes] meson: Port to libhandy-1
- From: Isaque Galdino de Araujo <igaldino src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-notes] meson: Port to libhandy-1
- Date: Tue, 4 May 2021 13:10:20 +0000 (UTC)
commit d43ad6a74ff424c2a1961c7a5586ef367dfb11c1
Author: Jonathan Kang <jonathankang gnome org>
Date: Tue Sep 22 16:56:40 2020 +0800
meson: Port to libhandy-1
data/resources/bjb-window-base.ui | 135 +++++++++++++-------------------------
data/resources/list-view.ui | 5 --
src/bjb-application.c | 4 ++
src/bjb-window-base.c | 27 ++++----
src/bjb-window-base.h | 3 +-
5 files changed, 64 insertions(+), 110 deletions(-)
---
diff --git a/data/resources/bjb-window-base.ui b/data/resources/bjb-window-base.ui
index 10e3331..1899010 100644
--- a/data/resources/bjb-window-base.ui
+++ b/data/resources/bjb-window-base.ui
@@ -1,18 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <template class="BjbWindowBase" parent="GtkApplicationWindow">
+ <template class="BjbWindowBase" parent="HdyApplicationWindow">
<property name="can_focus">False</property>
<child>
<object class="HdyLeaflet" id="main_leaflet">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition-type">slide</property>
+ <signal name="notify::visible-child" handler="notify_header_visible_child_cb" swapped="yes"/>
+ <signal name="notify::fold" handler="notify_fold_cb" object="BjbWindowBase" after="yes"
swapped="yes"/>
<child>
<object class="GtkBox" id="sidebar_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">False</property>
<property name="orientation">vertical</property>
+ <child>
+ <object class="HdyHeaderBar" id="headerbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="show-close-button">True</property>
+ <property name="title" translatable="yes">All Notes</property>
+ <child>
+ <object class="GtkButton" id="new_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_New</property>
+ <property name="use-underline">True</property>
+ <signal name="clicked" handler="on_new_note_clicked" swapped="yes"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="main_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip-text" translatable="yes">Open menu</property>
+ <property name="popover">main_menu</property>
+ <property name="receives_default">True</property>
+ <child>
+ <object class="GtkImage" id="main_button_image">
+ <property name="visible">True</property>
+ <property name="icon_name">open-menu-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<object class="BjbSearchToolbar" id="search_bar">
<property name="visible">True</property>
@@ -22,7 +63,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -45,7 +86,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
@@ -65,68 +106,9 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
- </object>
- </child>
- </object>
- </child>
- <child type="titlebar">
- <object class="HdyTitleBar">
- <property name="visible">True</property>
- <child>
- <object class="HdyLeaflet" id="header_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">horizontal</property>
- <property name="transition-type">slide</property>
- <property name="mode-transition-duration" bind-source="main_leaflet"
bind-property="mode-transition-duration" bind-flags="bidirectional|sync-create"/>
- <property name="child-transition-duration" bind-source="main_leaflet"
bind-property="child-transition-duration" bind-flags="bidirectional|sync-create"/>
- <signal name="notify::visible-child" handler="notify_header_visible_child_cb" swapped="yes"/>
- <signal name="notify::fold" handler="notify_fold_cb" object="BjbWindowBase" after="yes"
swapped="yes"/>
- <child>
- <object class="GtkHeaderBar" id="headerbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">All Notes</property>
- <child>
- <object class="GtkButton" id="new_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_New</property>
- <property name="use-underline">True</property>
- <signal name="clicked" handler="on_new_note_clicked" swapped="yes"/>
- </object>
- </child>
- <child>
- <object class="GtkMenuButton" id="main_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip-text" translatable="yes">Open menu</property>
- <property name="popover">main_menu</property>
- <property name="receives_default">True</property>
- <child>
- <object class="GtkImage" id="main_button_image">
- <property name="visible">True</property>
- <property name="icon_name">open-menu-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkSeparator" id="headerbar_separator">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <style>
- <class name="sidebar"/>
- </style>
- </object>
- </child>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkHeaderBar" id="note_headerbar">
+ <object class="HdyHeaderBar" id="note_headerbar">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="show-close-button">True</property>
@@ -400,6 +382,7 @@
</object>
<object class="HdyHeaderGroup" id="header_group">
+ <property name="decorate-all" bind-source="main_leaflet" bind-property="folded"
bind-flags="sync-create"/>
<headerbars>
<headerbar name="headerbar"/>
<headerbar name="note_headerbar"/>
@@ -412,28 +395,4 @@
<property name="max-width-chars">60</property>
<signal name="changed" handler="on_title_changed" swapped="yes"/>
</object>
-
- <object class="GtkSizeGroup">
- <property name="mode">horizontal</property>
- <widgets>
- <widget name="headerbar" />
- <widget name="sidebar_box" />
- </widgets>
- </object>
-
- <object class="GtkSizeGroup">
- <property name="mode">horizontal</property>
- <widgets>
- <widget name="headerbar_separator" />
- <widget name="main_leaflet_separator" />
- </widgets>
- </object>
-
- <object class="GtkSizeGroup">
- <property name="mode">horizontal</property>
- <widgets>
- <widget name="note_headerbar" />
- <widget name="note_box" />
- </widgets>
- </object>
</interface>
diff --git a/data/resources/list-view.ui b/data/resources/list-view.ui
index 6292662..64cdf1b 100644
--- a/data/resources/list-view.ui
+++ b/data/resources/list-view.ui
@@ -8,10 +8,6 @@
<child>
<object class="HdyClamp">
<property name="visible">True</property>
- <property name="margin_top">32</property>
- <property name="margin_bottom">32</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
<child>
<object class="GtkListBox" id="list_box">
@@ -27,6 +23,5 @@
</object>
</child>
-
</template>
</interface>
diff --git a/src/bjb-application.c b/src/bjb-application.c
index e364e54..7ee831d 100644
--- a/src/bjb-application.c
+++ b/src/bjb-application.c
@@ -423,6 +423,10 @@ bijiben_startup (GApplication *application)
self->settings = bjb_settings_new ();
gtk_window_set_default_icon_name ("org.gnome.Notes");
+
+ /* Initialize libhandy. */
+ hdy_init ();
+
bjb_apply_style (self);
gtk_application_set_accels_for_action (GTK_APPLICATION (application), "win.close", vaccels_close);
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index c2c4a2c..c5fb432 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -38,7 +38,7 @@ static guint bjb_win_base_signals [BJB_WIN_BASE_SIGNALS] = { 0 };
struct _BjbWindowBase
{
- GtkApplicationWindow parent_instance;
+ HdyApplicationWindow parent_instance;
BjbSettings *settings;
BjbController *controller;
@@ -63,7 +63,6 @@ struct _BjbWindowBase
gint pos_y;
gboolean is_maximized;
- HdyLeaflet *header_box;
HdyLeaflet *main_leaflet;
HdyHeaderGroup *header_group;
GtkRevealer *back_revealer;
@@ -78,35 +77,29 @@ struct _BjbWindowBase
};
/* Gobject */
-G_DEFINE_TYPE (BjbWindowBase, bjb_window_base, GTK_TYPE_APPLICATION_WINDOW)
+G_DEFINE_TYPE (BjbWindowBase, bjb_window_base, HDY_TYPE_APPLICATION_WINDOW)
static void
switch_to_sidebar (BjbWindowBase *self)
{
- hdy_leaflet_set_visible_child (self->header_box, self->headerbar);
hdy_leaflet_set_visible_child (self->main_leaflet, self->sidebar_box);
}
static void
switch_to_note_view (BjbWindowBase *self)
{
- hdy_leaflet_set_visible_child (self->header_box, self->note_headerbar);
hdy_leaflet_set_visible_child (self->main_leaflet, self->note_box);
}
static void
update_fold_state (BjbWindowBase *self)
{
- GtkWidget *header_child;
- HdyFold fold;
+ gboolean folded;
- header_child = hdy_leaflet_get_visible_child (self->header_box);
- fold = hdy_leaflet_get_fold (self->header_box);
+ folded = hdy_leaflet_get_folded (self->main_leaflet);
- hdy_header_group_set_focus (self->header_group, fold == HDY_FOLD_FOLDED ? GTK_HEADER_BAR(header_child) :
NULL);
-
- gtk_widget_set_visible (GTK_WIDGET(self->back_revealer), fold == HDY_FOLD_FOLDED);
- gtk_revealer_set_reveal_child (self->back_revealer, fold == HDY_FOLD_FOLDED);
+ gtk_widget_set_visible (GTK_WIDGET(self->back_revealer), folded);
+ gtk_revealer_set_reveal_child (self->back_revealer, folded);
}
static void
@@ -131,8 +124,9 @@ on_note_renamed (BijiItem *note,
if (str == NULL || strlen(str) == 0)
str = _("Untitled");
gtk_entry_set_text (GTK_ENTRY (self->title_entry), str);
- gtk_header_bar_set_custom_title (GTK_HEADER_BAR (self->note_headerbar),
+ hdy_header_bar_set_custom_title (HDY_HEADER_BAR (self->note_headerbar),
self->title_entry);
+ gtk_widget_show (self->title_entry);
}
static void
@@ -632,7 +626,6 @@ bjb_window_base_class_init (BjbWindowBaseClass *klass)
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Notes/ui/bjb-window-base.ui");
- gtk_widget_class_bind_template_child (widget_class, BjbWindowBase, header_box);
gtk_widget_class_bind_template_child (widget_class, BjbWindowBase, main_leaflet);
gtk_widget_class_bind_template_child (widget_class, BjbWindowBase, header_group);
gtk_widget_class_bind_template_child (widget_class, BjbWindowBase, back_revealer);
@@ -686,6 +679,8 @@ destroy_note_if_needed (BjbWindowBase *self)
if (self->note_view && GTK_IS_WIDGET (self->note_view))
gtk_widget_destroy (GTK_WIDGET (self->note_view));
+ gtk_widget_hide (self->title_entry);
+
self->note_view = NULL;
}
@@ -774,7 +769,7 @@ bjb_window_base_load_note_item (BjbWindowBase *self, BijiItem *item)
self->note = note;
self->note_view = bjb_note_view_new (w, note);
- gtk_container_add (GTK_CONTAINER (self->note_box), GTK_WIDGET (self->note_view));
+ gtk_box_pack_end (GTK_BOX (self->note_box), GTK_WIDGET (self->note_view), TRUE, TRUE, 0);
gtk_widget_show (GTK_WIDGET (self->note_view));
bjb_note_view_grab_focus (self->note_view);
}
diff --git a/src/bjb-window-base.h b/src/bjb-window-base.h
index 5681b8c..aa3262e 100644
--- a/src/bjb-window-base.h
+++ b/src/bjb-window-base.h
@@ -1,13 +1,14 @@
#pragma once
#include <gtk/gtk.h>
+#include <handy.h>
#include <libbiji/libbiji.h>
#include "bjb-controller.h"
#define BJB_TYPE_WINDOW_BASE (bjb_window_base_get_type ())
-G_DECLARE_FINAL_TYPE (BjbWindowBase, bjb_window_base, BJB, WINDOW_BASE, GtkApplicationWindow)
+G_DECLARE_FINAL_TYPE (BjbWindowBase, bjb_window_base, BJB, WINDOW_BASE, HdyApplicationWindow)
typedef enum {
BJB_WINDOW_BASE_MAIN_VIEW,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]