[libadwaita/wip/exalm/browsing-view] a
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/browsing-view] a
- Date: Wed, 12 Oct 2022 03:19:01 +0000 (UTC)
commit 9c8345986a5deea53feb1f24b46a4b4dc5e3b5af
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Oct 10 20:21:10 2022 +0400
a
src/adw-browsing-view.c | 74 ++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 61 insertions(+), 13 deletions(-)
---
diff --git a/src/adw-browsing-view.c b/src/adw-browsing-view.c
index 950759f8..bbb9bbc2 100644
--- a/src/adw-browsing-view.c
+++ b/src/adw-browsing-view.c
@@ -93,6 +93,14 @@ enum {
static GParamSpec *props[LAST_PROP];
+enum {
+ SIGNAL_PUSHED,
+ SIGNAL_POPPED,
+ LAST_SIGNAL,
+};
+
+static guint signals[LAST_SIGNAL];
+
static void
adw_browsing_view_child_dispose (GObject *object)
{
@@ -312,12 +320,6 @@ adw_browsing_view_child_buildable_init (GtkBuildableIface *iface)
iface->add_child = adw_browsing_view_child_buildable_add_child;
}
-
-
-
-
-
-
static void
switch_child (AdwBrowsingView *self,
AdwBrowsingViewChild *prev_child,
@@ -398,11 +400,17 @@ push_to_stack (AdwBrowsingView *self,
if (child == previous_child)
return;
- // FIXME: check if the child is anywhere in the stack
+ if (g_list_find (self->navigation_stack, child)) {
+ g_critical ("Child '%s' is already in navigation stack\n",
+ adw_browsing_view_child_get_title (child));
+ return;
+ }
self->navigation_stack = g_list_prepend (self->navigation_stack, child);
switch_child (self, previous_child, child, FALSE, animate);
+
+ g_signal_emit (self, signals[SIGNAL_PUSHED], 0);
}
static void
@@ -421,6 +429,8 @@ pop_from_stack (AdwBrowsingView *self,
new_child = adw_browsing_view_get_visible_child (self);
switch_child (self, previous_child, new_child, TRUE, animate);
+
+ g_signal_emit (self, signals[SIGNAL_POPPED], 0, previous_child);
}
static void
@@ -465,10 +475,6 @@ browsing_pop_cb (AdwBrowsingView *self)
adw_browsing_view_pop (self, TRUE);
}
-
-
-
-
static void
adw_browsing_view_measure (GtkWidget *widget,
GtkOrientation orientation,
@@ -701,6 +707,40 @@ adw_browsing_view_class_init (AdwBrowsingViewClass *klass)
g_object_class_install_properties (object_class, LAST_PROP, props);
+ /**
+ * AdwBrowsingView::pushed:
+ *
+ * TODO
+ *
+ * Since: 1.3
+ */
+ signals[SIGNAL_PUSHED] =
+ g_signal_new ("pushed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+
+ /**
+ * AdwBrowsingView::popped:
+ * @child: TODO
+ *
+ * TODO
+ *
+ * Since: 1.3
+ */
+ signals[SIGNAL_POPPED] =
+ g_signal_new ("popped",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ ADW_TYPE_BROWSING_VIEW_CHILD);
+
gtk_widget_class_install_action (widget_class, "browsing.push", "s",
(GtkWidgetActionActivateFunc) browsing_push_cb);
gtk_widget_class_install_action (widget_class, "browsing.pop", NULL,
@@ -1022,7 +1062,11 @@ adw_browsing_view_remove (AdwBrowsingView *self,
g_return_if_fail (ADW_IS_BROWSING_VIEW (self));
g_return_if_fail (GTK_IS_WIDGET (child));
- wrapper = g_hash_table_lookup (self->child_mapping, child);
+ if (ADW_IS_BROWSING_VIEW_CHILD (child) &&
+ gtk_widget_get_parent (child) == GTK_WIDGET (self))
+ wrapper = child;
+ else
+ wrapper = g_hash_table_lookup (self->child_mapping, child);
if (wrapper == NULL) {
g_critical ("Tried to remove non-child %s %p from AdwBrowsingView %p",
@@ -1088,7 +1132,11 @@ adw_browsing_view_push (AdwBrowsingView *self,
g_return_if_fail (ADW_IS_BROWSING_VIEW (self));
g_return_if_fail (GTK_IS_WIDGET (child));
- wrapper = g_hash_table_lookup (self->child_mapping, child);
+ if (ADW_IS_BROWSING_VIEW_CHILD (child) &&
+ gtk_widget_get_parent (child) == GTK_WIDGET (self))
+ wrapper = ADW_BROWSING_VIEW_CHILD (child);
+ else
+ wrapper = g_hash_table_lookup (self->child_mapping, child);
animate = !!animate;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]