Skip to content

Commit 81c631f

Browse files
committed
webhelper: Improve style
* Reorder calls to be more consistent when it doesn't affect behavior; * Remove unnecessary call setting a default value; * Better manage line length.
1 parent add6a5c commit 81c631f

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

webhelper/src/gwh-browser.c

+6-12
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ on_web_view_context_menu (WebKitWebView *view,
400400
WebKitContextMenuItem *item;
401401
WebKitContextMenu *submenu;
402402
GSimpleAction *action;
403-
GVariant *action_state;
403+
gboolean zoom_text_only;
404404

405405
webkit_context_menu_append (context_menu,
406406
webkit_context_menu_item_new_separator ());
@@ -442,21 +442,15 @@ on_web_view_context_menu (WebKitWebView *view,
442442
/* full content zoom */
443443
webkit_context_menu_append (submenu,
444444
webkit_context_menu_item_new_separator ());
445-
action_state = g_variant_new_boolean (
446-
!webkit_settings_get_zoom_text_only (webkit_web_view_get_settings (view)));
447-
448-
action = g_simple_action_new_stateful (
449-
"full-content-zoom",
450-
NULL,
451-
action_state
452-
);
445+
zoom_text_only = webkit_settings_get_zoom_text_only (webkit_web_view_get_settings (view));
446+
action = g_simple_action_new_stateful ("full-content-zoom", NULL,
447+
g_variant_new_boolean (!zoom_text_only));
448+
g_signal_connect (action, "activate",
449+
G_CALLBACK (on_item_full_content_zoom_activate), self);
453450
item = webkit_context_menu_item_new_from_gaction (G_ACTION (action),
454451
_("Full-_content zoom"),
455452
NULL);
456-
g_simple_action_set_enabled (action, TRUE);
457453
webkit_context_menu_append (submenu, item);
458-
g_signal_connect (action, "activate",
459-
G_CALLBACK (on_item_full_content_zoom_activate), self);
460454
g_object_unref (action);
461455

462456
g_signal_emit (self, signals[POPULATE_POPUP], 0, context_menu);

webhelper/src/gwh-plugin.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,21 @@ on_browser_populate_popup (GwhBrowser *browser,
256256
{
257257
GSimpleAction *action;
258258
gboolean auto_reload = FALSE;
259-
GVariant *action_state;
260259
WebKitContextMenuItem *item;
261260

262261
webkit_context_menu_append (menu,
263262
webkit_context_menu_item_new_separator ());
264263

265264
g_object_get (G_OBJECT (G_settings), "browser-auto-reload", &auto_reload,
266265
NULL);
267-
action_state = g_variant_new_boolean (auto_reload);
268-
action = g_simple_action_new_stateful ("browser-auto-reload",
269-
NULL, action_state);
266+
action = g_simple_action_new_stateful ("browser-auto-reload", NULL,
267+
g_variant_new_boolean (auto_reload));
268+
g_signal_connect (action, "activate",
269+
G_CALLBACK (on_item_auto_reload_toggled), NULL);
270270
item = webkit_context_menu_item_new_from_gaction (G_ACTION (action),
271271
_("Reload upon document saving"),
272272
NULL);
273273
webkit_context_menu_append (menu, item);
274-
g_signal_connect (action, "activate",
275-
G_CALLBACK (on_item_auto_reload_toggled), NULL);
276274
g_object_unref (action);
277275
}
278276

0 commit comments

Comments
 (0)