[console/wip/cdavis/adaptive-states] window: Use AdwAdaptiveState for adaptivity
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [console/wip/cdavis/adaptive-states] window: Use AdwAdaptiveState for adaptivity
- Date: Sat, 8 Oct 2022 02:11:50 +0000 (UTC)
commit 04fa64f029b0028f07cf631208a534f283e797db
Author: Christopher Davis <christopherdavis gnome org>
Date: Fri Oct 7 21:48:11 2022 -0400
window: Use AdwAdaptiveState for adaptivity
Allows us to drop our size_allocate callback and the
narrow property.
build-aux/flatpak/org.gnome.Console.Devel.json | 33 +++++++++++++++++++++
src/kgx-window.c | 41 +++++---------------------
src/kgx-window.h | 1 -
src/kgx-window.ui | 27 ++++++++++-------
4 files changed, 57 insertions(+), 45 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Console.Devel.json b/build-aux/flatpak/org.gnome.Console.Devel.json
index a0c1a96..cc81428 100644
--- a/build-aux/flatpak/org.gnome.Console.Devel.json
+++ b/build-aux/flatpak/org.gnome.Console.Devel.json
@@ -49,6 +49,39 @@
}
]
},
+ {
+ "name" : "libsass",
+ "buildsystem" : "meson",
+ "sources" : [
+ {
+ "type" : "git",
+ "url" : "https://github.com/lazka/libsass.git",
+ "branch" : "meson"
+ }
+ ]
+ },
+ {
+ "name" : "sassc",
+ "buildsystem" : "meson",
+ "sources" : [
+ {
+ "type" : "git",
+ "url" : "https://github.com/lazka/sassc.git",
+ "branch" : "meson"
+ }
+ ]
+ },
+ {
+ "name" : "libadwaita",
+ "buildsystem" : "meson",
+ "sources" : [
+ {
+ "type" : "git",
+ "url" : "https://gitlab.gnome.org/GNOME/libadwaita.git",
+ "branch" : "wip/exalm/adaptive-states"
+ }
+ ]
+ },
{
"name" : "gnome-console",
"builddir" : true,
diff --git a/src/kgx-window.c b/src/kgx-window.c
index 7795d8a..3331318 100644
--- a/src/kgx-window.c
+++ b/src/kgx-window.c
@@ -45,7 +45,6 @@ G_DEFINE_TYPE (KgxWindow, kgx_window, ADW_TYPE_APPLICATION_WINDOW)
enum {
PROP_0,
PROP_SETTINGS,
- PROP_NARROW,
LAST_PROP
};
@@ -95,9 +94,6 @@ kgx_window_get_property (GObject *object,
case PROP_SETTINGS:
g_value_set_object (value, self->settings);
break;
- case PROP_NARROW:
- g_value_set_boolean (value, self->narrow);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -119,28 +115,6 @@ static void new_tab_activated (GSimpleAction *action,
gpointer data);
-static void
-kgx_window_size_allocate (GtkWidget *widget,
- int width,
- int height,
- int baseline)
-{
- KgxWindow *self = KGX_WINDOW (widget);
- gboolean narrow = width < 400;
-
- if (narrow != self->narrow) {
- self->narrow = narrow;
- g_object_notify_by_pspec (G_OBJECT (self), pspecs[PROP_NARROW]);
-
- if (!narrow && kgx_pages_count (KGX_PAGES (self->pages)) > 0) {
- adw_tab_overview_set_open (ADW_TAB_OVERVIEW (self->tab_overview), FALSE);
- }
- }
-
- GTK_WIDGET_CLASS (kgx_window_parent_class)->size_allocate (widget, width, height, baseline);
-}
-
-
static gboolean
kgx_window_close_request (GtkWindow *window)
{
@@ -279,6 +253,12 @@ create_tab_cb (KgxWindow *self)
return kgx_pages_get_selected_page (KGX_PAGES (self->pages));
}
+static void
+narrow_state_exited (KgxWindow *self)
+{
+ if (kgx_pages_count (KGX_PAGES (self->pages)) > 0)
+ adw_tab_overview_set_open (ADW_TAB_OVERVIEW (self->tab_overview), FALSE);
+}
static void
kgx_window_class_init (KgxWindowClass *klass)
@@ -291,8 +271,6 @@ kgx_window_class_init (KgxWindowClass *klass)
object_class->set_property = kgx_window_set_property;
object_class->get_property = kgx_window_get_property;
- widget_class->size_allocate = kgx_window_size_allocate;
-
window_class->close_request = kgx_window_close_request;
pspecs[PROP_SETTINGS] =
@@ -300,11 +278,6 @@ kgx_window_class_init (KgxWindowClass *klass)
KGX_TYPE_SETTINGS,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
- pspecs[PROP_NARROW] =
- g_param_spec_boolean ("narrow", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
g_object_class_install_properties (object_class, LAST_PROP, pspecs);
gtk_widget_class_set_template_from_resource (widget_class,
@@ -330,6 +303,7 @@ kgx_window_class_init (KgxWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, status_changed);
gtk_widget_class_bind_template_callback (widget_class, extra_drag_drop);
gtk_widget_class_bind_template_callback (widget_class, create_tab_cb);
+ gtk_widget_class_bind_template_callback (widget_class, narrow_state_exited);
}
@@ -451,7 +425,6 @@ tab_switcher_activated (GSimpleAction *action,
adw_tab_overview_set_open (ADW_TAB_OVERVIEW (self->tab_overview), TRUE);
}
-
static GActionEntry win_entries[] = {
{ "new-window", new_activated, NULL, NULL, NULL },
{ "new-tab", new_tab_activated, NULL, NULL, NULL },
diff --git a/src/kgx-window.h b/src/kgx-window.h
index e38c3d6..7c9dc42 100644
--- a/src/kgx-window.h
+++ b/src/kgx-window.h
@@ -60,7 +60,6 @@ struct _KgxWindow
int last_rows;
guint timeout;
- gboolean narrow;
gboolean close_anyway;
/* Template widgets */
diff --git a/src/kgx-window.ui b/src/kgx-window.ui
index 32ba096..c7127da 100644
--- a/src/kgx-window.ui
+++ b/src/kgx-window.ui
@@ -31,6 +31,8 @@
</menu>
<template class="KgxWindow" parent="AdwApplicationWindow">
<signal name="notify::is-active" handler="active_changed" swapped="no"/>
+ <property name="width-request">360</property>
+ <property name="height-request">294</property>
<property name="content">
<object class="AdwTabOverview" id="tab_overview">
<property name="enable-new-tab">True</property>
@@ -123,13 +125,12 @@
</child>
<child type="end">
<object class="AdwTabButton" id="tab_button">
- <property name="visible" bind-source="KgxWindow" bind-property="narrow"
bind-flags="sync-create"/>
+ <property name="visible">False</property>
<property name="action-name">win.tab-switcher</property>
</object>
</child>
<child type="end">
- <object class="GtkButton">
- <property name="visible" bind-source="KgxWindow" bind-property="narrow"
bind-flags="sync-create|invert-boolean"/>
+ <object class="GtkButton" id="new_tab_button">
<property name="can-focus">0</property>
<property name="receives-default">0</property>
<property name="action-name">win.new-tab</property>
@@ -140,13 +141,8 @@
</object>
</child>
<child>
- <object class="GtkRevealer">
- <property name="reveal-child" bind-source="KgxWindow" bind-property="narrow"
bind-flags="sync-create|invert-boolean"/>
- <property name="child">
- <object class="AdwTabBar" id="tab_bar">
- <signal name="extra-drag-drop" handler="extra_drag_drop" swapped="no"/>
- </object>
- </property>
+ <object class="AdwTabBar" id="tab_bar">
+ <signal name="extra-drag-drop" handler="extra_drag_drop" swapped="no"/>
</object>
</child>
<child>
@@ -183,6 +179,17 @@
</property>
</object>
</property>
+ <child>
+ <object class="AdwAdaptiveState" id="narrow_state">
+ <conditions>
+ <condition type="max-width">400</condition>
+ </conditions>
+ <setter object="tab_button" property="visible">True</setter>
+ <setter object="new_tab_button" property="visible">False</setter>
+ <setter object="tab_bar" property="visible">False</setter>
+ <signal name="exit" handler="narrow_state_exited" swapped="yes"/>
+ </object>
+ </child>
<style>
<class name="terminal-window"/>
</style>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]