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 780424 - Port widgets to templates
Port widgets to templates
Status: RESOLVED OBSOLETE
Product: gnome-photos
Classification: Applications
Component: general
3.23.x
Other All
: Normal normal
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
: 776513 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-03-22 21:44 UTC by Alessandro Bono
Modified: 2018-01-23 10:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
embed: Port to template (5.91 KB, patch)
2017-03-22 21:58 UTC, Alessandro Bono
none Details | Review
main-window: Port to template (4.62 KB, patch)
2017-03-22 21:58 UTC, Alessandro Bono
none Details | Review
main-toolbar: Rename variable (12.20 KB, patch)
2017-03-22 21:58 UTC, Alessandro Bono
committed Details | Review
main-toolbar: Remove unecessary function call (1.19 KB, patch)
2017-03-22 21:58 UTC, Alessandro Bono
none Details | Review
main-toolbar: Port to template (4.07 KB, patch)
2017-03-22 21:59 UTC, Alessandro Bono
none Details | Review
main-toolbar: Rename a variable (12.36 KB, patch)
2017-03-23 07:39 UTC, Debarshi Ray
committed Details | Review
dropdown: Port to template (4.96 KB, patch)
2017-03-23 22:54 UTC, Alessandro Bono
committed Details | Review
embed: Port to template (6.65 KB, patch)
2017-03-23 22:54 UTC, Alessandro Bono
none Details | Review
main-window: Port to template (4.50 KB, patch)
2017-03-23 22:54 UTC, Alessandro Bono
committed Details | Review
main-toolbar: Remove unecessary function call (1.19 KB, patch)
2017-03-23 22:54 UTC, Alessandro Bono
committed Details | Review
main-toolbar: Port to template (4.88 KB, patch)
2017-03-23 22:55 UTC, Alessandro Bono
committed Details | Review
dropdown: Remove redundant function call (1.13 KB, patch)
2017-03-25 11:26 UTC, Debarshi Ray
committed Details | Review
dropdown, theme: Remove custom photos-dropdown style class (14.46 KB, patch)
2017-03-25 11:26 UTC, Debarshi Ray
committed Details | Review
dropdown: Port to template (5.08 KB, patch)
2017-03-25 11:27 UTC, Debarshi Ray
committed Details | Review
spinner-box: Don't set any extra properties in g_object_new (1.94 KB, patch)
2017-03-29 07:41 UTC, Debarshi Ray
committed Details | Review
embed: Port to template (6.76 KB, patch)
2017-03-29 07:41 UTC, Debarshi Ray
none Details | Review
embed: Port to template (6.75 KB, patch)
2017-03-29 08:00 UTC, Debarshi Ray
committed Details | Review
main-window: Port to template (4.50 KB, patch)
2017-05-10 11:08 UTC, Debarshi Ray
committed Details | Review
main-toolbar: Port to template (4.56 KB, patch)
2017-05-10 12:33 UTC, Debarshi Ray
committed Details | Review

Description Alessandro Bono 2017-03-22 21:44:22 UTC
We should start to use more *.ui files to declare the GUI.
Comment 1 Alessandro Bono 2017-03-22 21:58:40 UTC
Created attachment 348539 [details] [review]
embed: Port to template
Comment 2 Alessandro Bono 2017-03-22 21:58:46 UTC
Created attachment 348540 [details] [review]
main-window: Port to template
Comment 3 Alessandro Bono 2017-03-22 21:58:51 UTC
Created attachment 348541 [details] [review]
main-toolbar: Rename variable
Comment 4 Alessandro Bono 2017-03-22 21:58:57 UTC
Created attachment 348542 [details] [review]
main-toolbar: Remove unecessary function call
Comment 5 Alessandro Bono 2017-03-22 21:59:04 UTC
Created attachment 348543 [details] [review]
main-toolbar: Port to template
Comment 6 Debarshi Ray 2017-03-23 06:50:54 UTC
*** Bug 776513 has been marked as a duplicate of this bug. ***
Comment 7 Debarshi Ray 2017-03-23 07:08:18 UTC
Review of attachment 348539 [details] [review]:

Thanks for working on this Alessandro! Somehow it doesn't apply on top of master or gnome-3-24. Does it need a rebase?

Some quick comments:

::: src/photos-embed.ui
@@ +1,1 @@
+<?xml version="1.0" encoding="UTF-8"?>

Could you please add a copyright/license notice here? src/photos-share-dialog.ui has one.

@@ +4,3 @@
+  <template class="PhotosEmbed" parent="GtkBox">
+    <property name="visible">1</property>
+    <property name="orientation">GTK_ORIENTATION_VERTICAL</property>

Does this work? Shouldn't it be 'vertical' instead?

@@ +12,3 @@
+            <property name="visible">1</property>
+            <property name="homogeneous">1</property>
+            <property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>

Does this work? Shouldn't it be 'crossfade' instead?
Comment 8 Debarshi Ray 2017-03-23 07:16:44 UTC
Review of attachment 348540 [details] [review]:

::: src/photos-main-window.c
@@ -458,3 @@
-  widget_class->delete_event = photos_main_window_delete_event;
-  widget_class->key_press_event = photos_main_window_key_press_event;
-  widget_class->window_state_event = photos_main_window_window_state_event;

I slightly prefer to set them through the virtual function pointers, when it is a direct parent class, and use the XML only as a replacement for g_signal_connect*. The vfuncs are generally faster than signals. While that doesn't matter in this case, it makes a difference for things that can be called from a fast path. eg., "draw".

::: src/photos-main-window.ui
@@ +5,3 @@
+    <property name="resizable">1</property>
+    <property name="show-menubar">0</property>
+    <property name="window-position">GTK_WIN_POS_CENTER</property>

Shouldn't it be 'center'?
Comment 9 Debarshi Ray 2017-03-23 07:38:21 UTC
Review of attachment 348541 [details] [review]:

::: src/photos-main-toolbar.c
@@ +55,3 @@
   GtkWidget *selection_button;
   GtkWidget *selection_menu;
+  GtkWidget *header_bar;

Nitpick: would be nice to also retain the order.
Comment 10 Debarshi Ray 2017-03-23 07:39:09 UTC
Created attachment 348551 [details] [review]
main-toolbar: Rename a variable
Comment 11 Alessandro Bono 2017-03-23 22:49:26 UTC
(In reply to Debarshi Ray from comment #7)
> Review of attachment 348539 [details] [review] [review]:
> @@ +12,3 @@
> +            <property name="visible">1</property>
> +            <property name="homogeneous">1</property>
> +            <property
> name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
> 
> Does this work? Shouldn't it be 'crossfade' instead?

It seems to work anyway.

From https://developer.gnome.org/gtk3/stable/GtkBuilder.html
GtkBuilder can parse textual representations for the most common property types: [...] enumerations (can be specified by their name, nick or integer value)

Furthermore, gtk-builder-tool (https://developer.gnome.org/gtk3/stable/gtk-builder-tool.html) doesn't complain about it.
Comment 12 Alessandro Bono 2017-03-23 22:54:37 UTC
Created attachment 348621 [details] [review]
dropdown: Port to template
Comment 13 Alessandro Bono 2017-03-23 22:54:42 UTC
Created attachment 348622 [details] [review]
embed: Port to template
Comment 14 Alessandro Bono 2017-03-23 22:54:52 UTC
Created attachment 348623 [details] [review]
main-window: Port to template
Comment 15 Alessandro Bono 2017-03-23 22:54:56 UTC
Created attachment 348624 [details] [review]
main-toolbar: Remove unecessary function call
Comment 16 Alessandro Bono 2017-03-23 22:55:02 UTC
Created attachment 348625 [details] [review]
main-toolbar: Port to template
Comment 17 Debarshi Ray 2017-03-24 23:56:11 UTC
(In reply to Alessandro Bono from comment #11)
> (In reply to Debarshi Ray from comment #7)
> > Review of attachment 348539 [details] [review] [review] [review]:
> > @@ +12,3 @@
> > +            <property name="visible">1</property>
> > +            <property name="homogeneous">1</property>
> > +            <property
> > name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
> > 
> > Does this work? Shouldn't it be 'crossfade' instead?
> 
> It seems to work anyway.
> 
> From https://developer.gnome.org/gtk3/stable/GtkBuilder.html
> GtkBuilder can parse textual representations for the most common property
> types: [...] enumerations (can be specified by their name, nick or integer
> value)
> 
> Furthermore, gtk-builder-tool
> (https://developer.gnome.org/gtk3/stable/gtk-builder-tool.html) doesn't
> complain about it.

Yes, you're right. I think I have always seen enums being referred to by their integer value or nickname. So I never though the C name would work. Since it works, I agree that it is a better choice in a C program. It's more consistent with C code which helps when grepping.
Comment 18 Debarshi Ray 2017-03-25 00:19:30 UTC
Review of attachment 348622 [details] [review]:

Thanks for the new patches, Alessandro!

::: src/photos-embed.ui
@@ +20,3 @@
+-->
+<interface>
+  <requires lib="gtk+" version="3.20"/>

One minor thing. Does this XML really need gtk+ >= 3.20? I don't see anything that's so new. It seems to me that the version is often just mindlessly put in the XML. We should either maintain / use the right version, or just remove it. Actually ensuring that we have the right version across each and every XML file seems tedious. Instead we could just do a run-time check at startup - like we do for GEGL.
Comment 19 Debarshi Ray 2017-03-25 11:25:24 UTC
Review of attachment 348621 [details] [review]:

::: src/photos-dropdown.c
@@ -121,3 @@
-  context = gtk_widget_get_style_context (GTK_WIDGET (self));
-  gtk_style_context_add_class (context, "photos-dropdown");
-  gtk_widget_hide (GTK_WIDGET(self));

We should have already removed the "hide" and the custom style class during the GtkPopover port. Sorry for overlooking it.

@@ -124,1 @@
   gtk_widget_show_all (GTK_WIDGET (self->grid));

This can be moved to the XML as visible=1. That's also what gnome-documents does.

@@ +127,3 @@
   object_class->dispose = photos_dropdown_dispose;
+
+  widget_class = GTK_WIDGET_CLASS (class);

Nitpick: should be in the definition line.
Comment 20 Debarshi Ray 2017-03-25 11:26:37 UTC
Created attachment 348694 [details] [review]
dropdown: Remove redundant function call

I took the liberty to split out the Popover specific bits into separate commits, fixed the above nits and pushed to master.
Comment 21 Debarshi Ray 2017-03-25 11:26:55 UTC
Created attachment 348695 [details] [review]
dropdown, theme: Remove custom photos-dropdown style class
Comment 22 Debarshi Ray 2017-03-25 11:27:12 UTC
Created attachment 348696 [details] [review]
dropdown: Port to template
Comment 23 Debarshi Ray 2017-03-29 07:40:22 UTC
Review of attachment 348622 [details] [review]:

::: src/photos-embed.ui
@@ +28,3 @@
+        <property name="visible">1</property>
+        <child type="overlay">
+          <object class="GtkStack" id="stack">

The GtkStack is not an overlaid child. Only the SpinnerBox is.

@@ +30,3 @@
+          <object class="GtkStack" id="stack">
+            <property name="visible">1</property>
+            <property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>

I don't know if it makes a difference, but strictly speaking, we should set the "expand" child property.

@@ +34,3 @@
+        </child>
+        <child type="overlay">
+          <object class="PhotosSpinnerBox" id="spinner_box"/>

We need to fix the construction of SpinnerBox, so that photos_spinner_new is the same as 'g_object_new (PHOTOS_TYPE_SPINNER_BOX, NULL)'. Right now it isn't.
Comment 24 Debarshi Ray 2017-03-29 07:41:10 UTC
Created attachment 348921 [details] [review]
spinner-box: Don't set any extra properties in g_object_new
Comment 25 Debarshi Ray 2017-03-29 07:41:26 UTC
Created attachment 348922 [details] [review]
embed: Port to template
Comment 26 Debarshi Ray 2017-03-29 08:00:24 UTC
Created attachment 348923 [details] [review]
embed: Port to template

I had misplaced the "expand".
Comment 27 Debarshi Ray 2017-05-10 11:08:13 UTC
Review of attachment 348623 [details] [review]:

Looks good to me.

::: src/photos-main-window.ui
@@ +20,3 @@
+-->
+<interface>
+  <requires lib="gtk+" version="3.20"/>

Nitpick: let's drop the gtk+ version. They tend to get copy-pasted around and often don't reflect reality.
Comment 28 Debarshi Ray 2017-05-10 11:08:46 UTC
Created attachment 351532 [details] [review]
main-window: Port to template

Pushed after dropping the 'requires'.
Comment 29 Debarshi Ray 2017-05-10 12:17:08 UTC
Review of attachment 348624 [details] [review]:

Sure, why not.

(We are not using the virtual functions that gnome-documents uses to let different MainToolbar implementations create their own search bars, and since commit ad0bab7c194f21b09b4d711a0aa2d9e3a68997b2 this function is just a one liner.)
Comment 30 Debarshi Ray 2017-05-10 12:32:28 UTC
Review of attachment 348625 [details] [review]:

Thanks Alessandro. Looks good apart from some teeny-weeny nitpicks.

::: src/photos-main-toolbar.c
@@ +811,3 @@
   object_class->set_property = photos_main_toolbar_set_property;
 
+  widget_class = GTK_WIDGET_CLASS (class);

Nitpick: should go with the definition.

::: src/photos-main-toolbar.ui
@@ +20,3 @@
+-->
+<interface>
+  <requires lib="gtk+" version="3.20"/>

Nitpick: let's drop the gtk+ version. They tend to get copy-pasted around and often don't reflect reality.

@@ +25,3 @@
+    <property name="orientation">GTK_ORIENTATION_VERTICAL</property>
+    <child>
+      <object class="PhotosHeaderBar" id="header_bar"/>

Nitpick: should have 'visible=1' to match the C code. Doesn't seem to make a difference in practice.

::: src/photos.gresource.xml
@@ +28,3 @@
     <file alias="export-dialog.ui" preprocess="xml-stripblanks" compressed="true">photos-export-dialog.ui</file>
     <file alias="main-window.ui" preprocess="xml-stripblanks" compressed="true">photos-main-window.ui</file>
+    <file alias="main-toolbar.ui" preprocess="xml-stripblanks" compressed="true">photos-main-toolbar.ui</file>

Nitpick: alphabetical order.
Comment 31 Debarshi Ray 2017-05-10 12:33:13 UTC
Created attachment 351541 [details] [review]
main-toolbar: Port to template
Comment 32 GNOME Infrastructure Team 2018-01-23 10:12:05 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-photos/issues/62.