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 759164 - [PATCHes] Rework EphyEncodingDialog.
[PATCHes] Rework EphyEncodingDialog.
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Interface
git master
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-12-08 09:54 UTC by Arnaud B.
Modified: 2015-12-10 11:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
EphyEncodingDialog: Use activate-on-single-click. (2.04 KB, patch)
2015-12-08 09:54 UTC, Arnaud B.
committed Details | Review
EphyEncodingDialog: Use a GtkSwitch. (11.09 KB, patch)
2015-12-08 09:55 UTC, Arnaud B.
none Details | Review
EphyEncodingDialog: Use a GtkSwitch. (11.70 KB, patch)
2015-12-08 11:26 UTC, Arnaud B.
committed Details | Review
EphyEncodingDialog: Rework. (51.14 KB, patch)
2015-12-09 16:56 UTC, Arnaud B.
committed Details | Review

Description Arnaud B. 2015-12-08 09:54:58 UTC
Created attachment 316916 [details] [review]
EphyEncodingDialog: Use activate-on-single-click.

Here are some rework patches for the EphyEncodingDialog:
* the first one uses activate-on-single-click;
* the second one uses a GtkSwitch instead of the current radios.
Comment 1 Arnaud B. 2015-12-08 09:55:35 UTC
Created attachment 316917 [details] [review]
EphyEncodingDialog: Use a GtkSwitch.
Comment 2 Michael Catanzaro 2015-12-08 10:12:10 UTC
Review of attachment 316916 [details] [review]:

I think it's fine to do this, but if so, we should reload the page with the new encoding when closing the dialog (unless it has already happened in response to a click), otherwise you're out of luck if you want to change the encoding using only a keyboard.

::: src/ephy-encoding-dialog.c
@@ -293,3 @@
 	activate_choice (dialog);
-
-	g_object_unref (dialog);

Hm, I also do not see why this was present; it looks like a bug to me. But I am confused why the dialog did not crash previously.

Does your new patch introduce a crash when this line is not removed?
Comment 3 Michael Catanzaro 2015-12-08 10:14:24 UTC
Review of attachment 316917 [details] [review]:

I see a warning when clicking the toggle:

** (epiphany:4478): CRITICAL **: activate_choice: assertion 'EPHY_IS_EMBED (dialog->embed)' failed

::: src/ephy-encoding-dialog.c
@@ +275,3 @@
 		activate_choice (dialog);
 	}
+	// TODO select safe default in list, or find another solution

ISO-8859-1
Comment 4 Arnaud B. 2015-12-08 10:31:06 UTC
(In reply to Michael Catanzaro from comment #2)
> I think it's fine to do this, but if so, we should reload the page with the
> new encoding when closing the dialog (unless it has already happened in
> response to a click), otherwise you're out of luck if you want to change the
> encoding using only a keyboard.

You can always activate with keyboard with “enter”. I even think it’s more natural than to have the page reload each time you click an “array” key.

> Hm, I also do not see why this was present; it looks like a bug to me. But I
> am confused why the dialog did not crash previously.

I think it is because the work was done in the selection function, blocking the one of the activation one.

> Does your new patch introduce a crash when this line is not removed?

Yeps.
Comment 5 Arnaud B. 2015-12-08 11:26:52 UTC
Created attachment 316925 [details] [review]
EphyEncodingDialog: Use a GtkSwitch.

My first implementation of the GtkSwitch was a bit stupi^Wnaive, and that caused the warnings you saw. Here is a more correct patch.

About the default encoding to select in the list, I agree, but that will be another story (no regression there).
Comment 6 Arnaud B. 2015-12-09 16:56:10 UTC
Created attachment 317052 [details] [review]
EphyEncodingDialog: Rework.

So. This patch is ugly, it does more than two^Wtwenty things, but it solves (I think) most of the problem related to the EphyEncodingDialog class. I’m presenting it for getting advices, tracking bugs, etc. If someone has an idea on how to split it, it might be a thing to do also…
Comment 7 Michael Catanzaro 2015-12-09 19:06:22 UTC
Review of attachment 317052 [details] [review]:

Accepted after comments.

::: src/ephy-encoding-dialog.c
@@ +49,3 @@
 	/* from the UI file */
+	GtkStack   *type_stack;
+	GtkSwitch  *default_switch;

I prefer not to align these.

@@ +308,3 @@
+
+static void
+free_row_user_data (gpointer user_data)

As Carlos would say, we don't need a function just to call g_free, so please remove this and use g_free directly.

But, why is this correct? Is not the user data the EphyEncodingRow? Then it should be freed with g_object_unref, no?

@@ +340,3 @@
+sort_encodings (gconstpointer a, gconstpointer b)
+{
+	EphyEncoding *enc1 = (EphyEncoding*)a;

(EphyEncoding *)

@@ +386,3 @@
+	WebKitWebView *view;
+	EphyEncoding *enc_node;
+	EphyLanguageGroup groups;	// int

No need for this comment.

@@ +387,3 @@
+	EphyEncoding *enc_node;
+	EphyLanguageGroup groups;	// int
+	GList *recent, *related = NULL;

Put these on separate lines.

@@ +401,3 @@
+	if (recent != NULL)
+	{
+		recent = g_list_sort (recent, (GCompareFunc) sort_encodings);

No space after the cast.

@@ +402,3 @@
+	{
+		recent = g_list_sort (recent, (GCompareFunc) sort_encodings);
+		g_list_foreach (recent, (GFunc) add_list_item, dialog->recent_list_box);

Same.

::: src/ephy-encoding-row.c
@@ +34,3 @@
+
+	/* from the UI file */
+	GtkLabel     *encoding_label;

I prefer not to add extra spaces before the asterisks except in parameter lists.

@@ +126,3 @@
+	object_class->get_property = ephy_encoding_row_get_property;
+
+	g_object_class_install_property (object_class,

Please instead keep a static array of property IDs, and use g_object_class_install_properties once at the bottom of class_init instead. Look at any of my recent "use g_object_class_install_properties" commits as an example. The advantage of this approach is that we can refer to properties within the class using a constant rather than a string literal. (There is also a performance advantage to doing that, not that it would matter for the encodings dialog.)

@@ +132,3 @@
+	                                                      "encoding",
+	                                                      EPHY_TYPE_ENCODING,
+	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));

G_PARAM_STATIC_STRINGS

::: src/window-commands.c
@@ +1699,3 @@
+			      EphyWindow *window)
+{
+	EphyEncodingDialog* dialog;

EphyEncodingDialog *dialog;
Comment 8 Arnaud B. 2015-12-10 11:22:22 UTC
Commited, thanks. =)