After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 694036 - Controller widget for GdStack
Controller widget for GdStack
Status: RESOLVED FIXED
Product: libgd
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: libgd maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-02-17 18:32 UTC by William Jon McCann
Modified: 2013-02-18 22:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add GdStackSwitcher (19.71 KB, patch)
2013-02-18 05:58 UTC, William Jon McCann
reviewed Details | Review
Add GdStackSwitcher (19.71 KB, patch)
2013-02-18 16:01 UTC, William Jon McCann
accepted-commit_now Details | Review
Add GdStackSwitcher (18.73 KB, patch)
2013-02-18 17:12 UTC, William Jon McCann
reviewed Details | Review
Add GdStackSwitcher (18.77 KB, patch)
2013-02-18 19:59 UTC, William Jon McCann
committed Details | Review

Description William Jon McCann 2013-02-17 18:32:47 UTC
I think it would be good to have a controller widget that can drive a GdStack. This would probably look like an exclusive button bar. I would like to just connect the controller to the stack and have it populated automatically. Clicking the buttons on the controller should change the view of the stack. I could then add this widget to the custom-title property of GdHeaderBar.
Comment 1 Paolo Borelli 2013-02-17 18:37:46 UTC
see also https://bugzilla.gnome.org/show_bug.cgi?id=693113 where I proposed something similar for GdMainToolbar

I'll leave that one open in case we want to improve the main toolbar api, but I like the idea of an ad hoc widget.
Comment 2 William Jon McCann 2013-02-18 05:58:53 UTC
Created attachment 236551 [details] [review]
Add GdStackSwitcher
Comment 3 Cosimo Cecchi 2013-02-18 15:41:01 UTC
Review of attachment 236551 [details] [review]:

Looks pretty good to me; I have two smaller comments below.

::: libgd/gd-stack-switcher.c
@@ +168,3 @@
+
+  button = g_hash_table_lookup (self->priv->buttons, widget);
+  gtk_container_add (GTK_CONTAINER (self), button);

gtk_container_remove maybe?

::: libgd/gd-stack.c
@@ +51,3 @@
+  CHILD_REMOVED,
+  NUM_SIGNALS
+};

Can't you use the "add" and "remove" signals of GtkContainer for this?
Comment 4 William Jon McCann 2013-02-18 15:58:09 UTC
Review of attachment 236551 [details] [review]:

::: libgd/gd-stack-switcher.c
@@ +168,3 @@
+
+  button = g_hash_table_lookup (self->priv->buttons, widget);
+  gtk_container_add (GTK_CONTAINER (self), button);

oops.

::: libgd/gd-stack.c
@@ +51,3 @@
+  CHILD_REMOVED,
+  NUM_SIGNALS
+};

Unfortunately not. I think they are emitted before the item is added.
Comment 5 William Jon McCann 2013-02-18 16:01:54 UTC
Created attachment 236621 [details] [review]
Add GdStackSwitcher
Comment 6 Cosimo Cecchi 2013-02-18 16:05:07 UTC
Review of attachment 236621 [details] [review]:

Not even if you use g_signal_connect_after? The default handler should run first. If that's not an option, this looks good with the following minor fix.

::: libgd/gd-stack-switcher.c
@@ +98,3 @@
+                           NULL);
+  if (title == NULL || title[0] == '\0')
+    g_warning ("Title not set for stack");

I'd say "Title not set for stack child" here.
Comment 7 William Jon McCann 2013-02-18 17:12:45 UTC
Created attachment 236632 [details] [review]
Add GdStackSwitcher
Comment 8 Cosimo Cecchi 2013-02-18 17:31:17 UTC
Review of attachment 236632 [details] [review]:

Much better. I have just a few more comments that went unnoticed before, sorry for the back and forth.

::: libgd/gd-stack-switcher.c
@@ +49,3 @@
+  context = gtk_widget_get_style_context (GTK_WIDGET (switcher));
+  gtk_style_context_add_class (context, "linked");
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);

I think you should just call gtk_orientable_set_orientation (GTK_ORIENTATION_HORIZONTAL) on the box.
The parent class will set the orientable style classes automatically.

@@ +75,3 @@
+{
+  char *title;
+  char *name;

Seems unused now

@@ +193,3 @@
+ * gd_stack_switcher_set_stack:
+ * @switcher: a #GdStackSwitcher
+ * @stack: a #GdStack

Should have (allow-none) I think

@@ +240,3 @@
+ *
+ * Return value: (transfer none): the stack, or %NULL if
+ *    none has been set explicitely.

"explicitly"?

@@ +329,3 @@
+
+GtkWidget *
+gd_stack_switcher_new (void)

Maybe make this take a GdStack too? It's convenient to create it that way from C.
Comment 9 William Jon McCann 2013-02-18 19:59:30 UTC
Review of attachment 236632 [details] [review]:

::: libgd/gd-stack-switcher.c
@@ +329,3 @@
+
+GtkWidget *
+gd_stack_switcher_new (void)

I had that in the first version I made. But I took it out. I'm not sure I like _new functions taking arguments in general. It makes it much harder to maintain api stability. We can add it later if we want.
Comment 10 William Jon McCann 2013-02-18 19:59:47 UTC
Created attachment 236661 [details] [review]
Add GdStackSwitcher
Comment 11 Cosimo Cecchi 2013-02-18 20:52:37 UTC
Review of attachment 236661 [details] [review]:

OK, this looks good then! Thanks.
Comment 12 William Jon McCann 2013-02-18 22:04:37 UTC
Attachment 236661 [details] pushed as 4c44014 - Add GdStackSwitcher