[libadwaita/wip/exalm/tab-overview: 9/9] Demo
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/tab-overview: 9/9] Demo
- Date: Fri, 26 Aug 2022 21:16:21 +0000 (UTC)
commit dfc7c77358bd80cbc69b3802b41d9496a8bfd225
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Aug 12 03:15:10 2022 +0400
Demo
demo/pages/tab-view/adw-tab-view-demo-window.c | 67 ++++++++++++++++++-
demo/pages/tab-view/adw-tab-view-demo-window.ui | 87 ++++++++++++++++---------
2 files changed, 123 insertions(+), 31 deletions(-)
---
diff --git a/demo/pages/tab-view/adw-tab-view-demo-window.c b/demo/pages/tab-view/adw-tab-view-demo-window.c
index 4462e535..85bddcd5 100644
--- a/demo/pages/tab-view/adw-tab-view-demo-window.c
+++ b/demo/pages/tab-view/adw-tab-view-demo-window.c
@@ -7,14 +7,24 @@ struct _AdwTabViewDemoWindow
AdwWindow parent_instance;
AdwTabView *view;
AdwTabBar *tab_bar;
+ AdwTabOverview *tab_overview;
GActionMap *tab_action_group;
AdwTabPage *menu_page;
+ gboolean narrow;
};
G_DEFINE_TYPE (AdwTabViewDemoWindow, adw_tab_view_demo_window, ADW_TYPE_WINDOW)
+enum {
+ PROP_0,
+ PROP_NARROW,
+ LAST_PROP,
+};
+
+static GParamSpec *props[LAST_PROP];
+
char **icon_names = NULL;
gsize n_icon_names = 0;
@@ -96,6 +106,8 @@ add_page (AdwTabViewDemoWindow *self,
adw_tab_page_set_icon (page, icon);
adw_tab_page_set_indicator_activatable (page, TRUE);
+ adw_tab_page_set_thumbnail_xalign (page, 0.5);
+ adw_tab_page_set_thumbnail_yalign (page, 0.5);
return page;
}
@@ -401,8 +413,8 @@ static void
page_detached_cb (AdwTabViewDemoWindow *self,
AdwTabPage *page)
{
- if (!adw_tab_view_get_n_pages (self->view))
- gtk_window_close (GTK_WINDOW (self));
+// if (!adw_tab_view_get_n_pages (self->view))
+// gtk_window_close (GTK_WINDOW (self));
}
static void
@@ -497,6 +509,43 @@ extra_drag_drop_cb (AdwTabViewDemoWindow *self,
return GDK_EVENT_STOP;
}
+static void
+adw_tab_view_demo_window_size_allocate (GtkWidget *widget,
+ int width,
+ int height,
+ int baseline)
+{
+ AdwTabViewDemoWindow *self = ADW_TAB_VIEW_DEMO_WINDOW (widget);
+ gboolean narrow = width < 600;
+
+ if (self->narrow != narrow) {
+ self->narrow = narrow;
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NARROW]);
+ }
+
+ GTK_WIDGET_CLASS (adw_tab_view_demo_window_parent_class)->size_allocate (widget,
+ width,
+ height,
+ baseline);
+}
+
+static void
+adw_tab_view_demo_window_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ AdwTabViewDemoWindow *self = ADW_TAB_VIEW_DEMO_WINDOW (object);
+
+ switch (prop_id) {
+ case PROP_NARROW:
+ g_value_set_boolean (value, self->narrow);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
static void
adw_tab_view_demo_window_dispose (GObject *object)
{
@@ -514,10 +563,21 @@ adw_tab_view_demo_window_class_init (AdwTabViewDemoWindowClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = adw_tab_view_demo_window_dispose;
+ object_class->get_property = adw_tab_view_demo_window_get_property;
+
+ widget_class->size_allocate = adw_tab_view_demo_window_size_allocate;
+
+ props[PROP_NARROW] =
+ g_param_spec_boolean ("narrow", NULL, NULL,
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, props);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Adwaita1/Demo/ui/pages/tab-view/adw-tab-view-demo-window.ui");
gtk_widget_class_bind_template_child (widget_class, AdwTabViewDemoWindow, view);
gtk_widget_class_bind_template_child (widget_class, AdwTabViewDemoWindow, tab_bar);
+ gtk_widget_class_bind_template_child (widget_class, AdwTabViewDemoWindow, tab_overview);
gtk_widget_class_bind_template_callback (widget_class, page_detached_cb);
gtk_widget_class_bind_template_callback (widget_class, setup_menu_cb);
gtk_widget_class_bind_template_callback (widget_class, create_window_cb);
@@ -558,6 +618,9 @@ adw_tab_view_demo_window_init (AdwTabViewDemoWindow *self)
adw_tab_bar_setup_extra_drop_target (self->tab_bar,
GDK_ACTION_COPY,
(GType[1]) { G_TYPE_STRING }, 1);
+ adw_tab_overview_setup_extra_drop_target (self->tab_overview,
+ GDK_ACTION_COPY,
+ (GType[1]) { G_TYPE_STRING }, 1);
}
AdwTabViewDemoWindow *
diff --git a/demo/pages/tab-view/adw-tab-view-demo-window.ui b/demo/pages/tab-view/adw-tab-view-demo-window.ui
index a53ad72e..ad4041d4 100644
--- a/demo/pages/tab-view/adw-tab-view-demo-window.ui
+++ b/demo/pages/tab-view/adw-tab-view-demo-window.ui
@@ -6,41 +6,70 @@
<property name="title" translatable="yes">Tab View Demo</property>
<property name="default-width">800</property>
<property name="default-height">600</property>
+ <property name="width-request">360</property>
<property name="content">
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkHeaderBar">
- <child type="start">
- <object class="GtkButton">
- <property name="action-name">win.tab-new</property>
- <property name="icon-name">tab-new-symbolic</property>
+ <object class="AdwTabOverview" id="tab_overview">
+ <property name="view">view</property>
+ <property name="enable-new-tab">True</property>
+ <property name="new-tab-action-name">win.tab-new</property>
+ <signal name="extra-drag-drop" handler="extra_drag_drop_cb" swapped="true"/>
+ <property name="child">
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar">
+ <child type="start">
+ <object class="GtkButton">
+ <property name="action-name">win.window-new</property>
+ <property name="icon-name">window-new-symbolic</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="AdwTabButton">
+ <property name="visible" bind-source="AdwTabViewDemoWindow" bind-property="narrow"
bind-flags="sync-create"/>
+ <property name="view">view</property>
+ <property name="action-name">overview.open</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkButton">
+ <property name="visible" bind-source="AdwTabViewDemoWindow" bind-property="narrow"
bind-flags="invert-boolean"/>
+ <property name="icon-name">view-grid-symbolic</property>
+ <property name="tooltip-text" translatable="yes">View Open Tabs</property>
+ <property name="action-name">overview.open</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkButton">
+ <property name="visible" bind-source="AdwTabViewDemoWindow" bind-property="narrow"
bind-flags="invert-boolean"/>
+ <property name="action-name">win.tab-new</property>
+ <property name="icon-name">tab-new-symbolic</property>
+ </object>
+ </child>
</object>
</child>
- <child type="end">
- <object class="GtkButton">
- <property name="action-name">win.window-new</property>
- <property name="icon-name">window-new-symbolic</property>
+ <child>
+ <object class="AdwTabBar" id="tab_bar">
+ <property name="visible" bind-source="AdwTabViewDemoWindow" bind-property="narrow"
bind-flags="invert-boolean"/>
+ <property name="view">view</property>
+ <signal name="extra-drag-drop" handler="extra_drag_drop_cb" swapped="true"/>
+ </object>
+ </child>
+ <child>
+ <object class="AdwTabView" id="view">
+ <property name="vexpand">True</property>
+ <property name="menu-model">tab_menu</property>
+ <signal name="page-detached" handler="page_detached_cb" swapped="true"/>
+ <signal name="setup-menu" handler="setup_menu_cb" swapped="true"/>
+ <signal name="create-window" handler="create_window_cb" swapped="true"/>
+ <signal name="indicator-activated" handler="indicator_activated_cb" swapped="true"/>
+ <style>
+ <class name="view"/>
+ </style>
</object>
</child>
</object>
- </child>
- <child>
- <object class="AdwTabBar" id="tab_bar">
- <property name="view">view</property>
- <signal name="extra-drag-drop" handler="extra_drag_drop_cb" swapped="true"/>
- </object>
- </child>
- <child>
- <object class="AdwTabView" id="view">
- <property name="vexpand">True</property>
- <property name="menu-model">tab_menu</property>
- <signal name="page-detached" handler="page_detached_cb" swapped="true"/>
- <signal name="setup-menu" handler="setup_menu_cb" swapped="true"/>
- <signal name="create-window" handler="create_window_cb" swapped="true"/>
- <signal name="indicator-activated" handler="indicator_activated_cb" swapped="true"/>
- </object>
- </child>
+ </property>
</object>
</property>
</template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]