Merge lp:~midori/midori/settingsGetAction into lp:midori

Proposed by Cris Dywan
Status: Work in progress
Proposed branch: lp:~midori/midori/settingsGetAction
Merge into: lp:midori
Diff against target: 242 lines (+94/-43)
6 files modified
extensions/statusbar-features.c (+13/-31)
katze/katze-utils.c (+2/-0)
midori/midori-contextaction.vala (+19/-0)
midori/midori-preferences.c (+4/-11)
midori/midori-settings.vala (+54/-0)
midori/midori-websettings.c (+2/-1)
To merge this branch: bzr merge lp:~midori/midori/settingsGetAction
Reviewer Review Type Date Requested Status
Midori Devs Pending
Review via email: mp+264447@code.launchpad.net

Commit message

Implement Midori.Settings.get_action

To post a comment you must log in.

Unmerged revisions

6985. By Cris Dywan

Statusbar Features use midori_context_action_create_widget

6984. By Cris Dywan

Implement Midori.Settings.get_action

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/statusbar-features.c'
2--- extensions/statusbar-features.c 2015-06-06 12:32:23 +0000
3+++ extensions/statusbar-features.c 2015-07-10 18:30:41 +0000
4@@ -39,7 +39,9 @@
5 GtkWidget* button)
6 {
7 GtkToolbarStyle style = katze_object_get_enum (toolbar, "toolbar-style");
8- const gchar* text = g_object_get_data (G_OBJECT (button), "feature-label");
9+ GtkAction* action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (button));
10+ gchar* text;
11+ g_object_get (action, "short-name", &text, NULL);
12 switch (style)
13 {
14 case GTK_TOOLBAR_BOTH:
15@@ -58,6 +60,7 @@
16 default:
17 g_assert_not_reached ();
18 }
19+ g_free (text);
20 }
21
22 static void
23@@ -114,12 +117,7 @@
24 {
25 const gchar* kind = NULL;
26 GtkWidget* button;
27- GtkWidget* image;
28- if (!strcmp (property, "auto-load-images")
29- || !strcmp (property, "enable-javascript")
30- || !strcmp (property, "enable-plugins"))
31- kind = "toggle";
32- else if (!strcmp (property, "identify-as"))
33+ if (!strcmp (property, "identify-as"))
34 kind = "custom-user-agent";
35 else if (strstr (property, "font") != NULL)
36 kind = "font";
37@@ -139,7 +137,13 @@
38 return button;
39 }
40
41- button = katze_property_proxy (settings, property, kind);
42+ button = midori_context_action_create_widget (midori_settings_get_action (MIDORI_SETTINGS (settings), property));
43+ if (GTK_IS_CHECK_BUTTON (button) && gtk_button_get_image (GTK_BUTTON (button)))
44+ {
45+ gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
46+ gtk_button_set_label (GTK_BUTTON (button), "");
47+ gtk_widget_show (gtk_button_get_image (GTK_BUTTON (button)));
48+ }
49 if (GTK_IS_BIN (button))
50 {
51 GtkWidget* label = gtk_bin_get_child (GTK_BIN (button));
52@@ -147,29 +151,7 @@
53 gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
54 }
55
56- if (!strcmp (property, "auto-load-images"))
57- {
58- g_object_set_data (G_OBJECT (button), "feature-label", _("Images"));
59- image = gtk_image_new_from_stock (STOCK_IMAGE, GTK_ICON_SIZE_MENU);
60- gtk_button_set_image (GTK_BUTTON (button), image);
61- gtk_widget_set_tooltip_text (button, _("Load images automatically"));
62- }
63- else if (!strcmp (property, "enable-javascript"))
64- {
65- g_object_set_data (G_OBJECT (button), "feature-label", _("Scripts"));
66- image = gtk_image_new_from_stock (STOCK_SCRIPT, GTK_ICON_SIZE_MENU);
67- gtk_button_set_image (GTK_BUTTON (button), image);
68- gtk_widget_set_tooltip_text (button, _("Enable scripts"));
69- }
70- else if (!strcmp (property, "enable-plugins"))
71- {
72- if (!midori_web_settings_has_plugin_support ())
73- gtk_widget_hide (button);
74- g_object_set_data (G_OBJECT (button), "feature-label", _("Netscape plugins"));
75- image = gtk_image_new_from_stock (MIDORI_STOCK_PLUGINS, GTK_ICON_SIZE_MENU);
76- gtk_button_set_image (GTK_BUTTON (button), image);
77- gtk_widget_set_tooltip_text (button, _("Enable Netscape plugins"));
78- }
79+ g_assert (g_strcmp0 (kind, "shut up the warning for now"));
80 if (GTK_IS_TOOLBAR (toolbar) && GTK_IS_BUTTON (button))
81 {
82 statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
83
84=== modified file 'katze/katze-utils.c'
85--- katze/katze-utils.c 2014-05-20 02:15:05 +0000
86+++ katze/katze-utils.c 2015-07-10 18:30:41 +0000
87@@ -316,6 +316,8 @@
88 * Since 0.2.1 the proxy may contain a label if the platform
89 * has according widgets.
90 *
91+ * Deprecated: 0.6.0: Use #MidoriSettings.get_action() instead.
92+ *
93 * Return value: (transfer full): a new widget
94 **/
95 GtkWidget*
96
97=== modified file 'midori/midori-contextaction.vala'
98--- midori/midori-contextaction.vala 2015-06-06 12:20:44 +0000
99+++ midori/midori-contextaction.vala 2015-07-10 18:30:41 +0000
100@@ -92,6 +92,25 @@
101 }
102 #endif
103
104+ /* Button defined here to allow "unowned" return for the benefit of C */
105+ Gtk.Button button;
106+ public GLib.Object? object { get; set; default = null; }
107+ public string? property { get; set; default = null; }
108+ public virtual unowned Gtk.Widget create_widget () {
109+ GLib.ParamSpec? pspec = object.get_class ().find_property (property);
110+ if (pspec.value_type == typeof (bool)) {
111+ button = new Gtk.CheckButton ();
112+ button.bind_property ("active", object, property);
113+ } else {
114+ button = new Gtk.Button ();
115+ }
116+ button.label = label;
117+ button.tooltip_text = tooltip;
118+ if (stock_id != null)
119+ button.image = new Gtk.Image.from_stock (stock_id, Gtk.IconSize.BUTTON);
120+ return button;
121+ }
122+
123 Gtk.ToolButton toolitem;
124 public override unowned Gtk.Widget create_tool_item () {
125 toolitem = base.create_tool_item () as Gtk.ToolButton;
126
127=== modified file 'midori/midori-preferences.c'
128--- midori/midori-preferences.c 2015-07-06 21:26:46 +0000
129+++ midori/midori-preferences.c 2015-07-10 18:30:41 +0000
130@@ -349,8 +349,7 @@
131 /* Page "Behavior" */
132 PAGE_NEW (GTK_STOCK_SELECT_COLOR, _("Behavior"));
133 FRAME_NEW (NULL);
134- button = katze_property_proxy (settings, "auto-load-images", NULL);
135- gtk_button_set_label (GTK_BUTTON (button), _("Load images automatically"));
136+ button = midori_context_action_create_widget (midori_settings_get_action (MIDORI_SETTINGS (settings), "auto-load-images"));
137 INDENTED_ADD (button);
138 button = katze_property_proxy (settings, "enable-spell-checking", NULL);
139 gtk_button_set_label (GTK_BUTTON (button), _("Enable Spell Checking"));
140@@ -577,17 +576,11 @@
141 gtk_label_set_markup (GTK_LABEL (label), markup);
142 g_free (markup);
143 katze_preferences_add_widget (preferences, label, "filled");
144- button = katze_property_proxy (settings, "enable-offline-web-application-cache", NULL);
145- gtk_button_set_label (GTK_BUTTON (button), _("Enable offline web application cache"));
146+ button = midori_context_action_create_widget (midori_settings_get_action (MIDORI_SETTINGS (settings), "enable-offline-web-application-cache"));
147 katze_preferences_add_widget (preferences, button, "indented");
148- button = katze_property_proxy (settings, "enable-html5-local-storage", NULL);
149- gtk_button_set_label (GTK_BUTTON (button), _("Enable HTML5 local storage support"));
150+ button = midori_context_action_create_widget (midori_settings_get_action (MIDORI_SETTINGS (settings), "enable-html5-local-storage"));
151 katze_preferences_add_widget (preferences, button, "spanned");
152- button = katze_property_proxy (settings, "strip-referer", NULL);
153- /* i18n: Reworded: Shorten details propagated when going to another page */
154- gtk_button_set_label (GTK_BUTTON (button), _("Strip referrer details sent to websites"));
155- /* i18n: Referer here is not a typo but a technical term */
156- gtk_widget_set_tooltip_text (button, _("Whether the \"Referer\" header should be shortened to the hostname"));
157+ button = midori_context_action_create_widget (midori_settings_get_action (MIDORI_SETTINGS (settings), "strip-referer"));
158 katze_preferences_add_widget (preferences, button, "indented");
159 katze_preferences_add_widget (preferences, gtk_label_new (NULL), "indented");
160 button = gtk_label_new (_("Delete pages from history after:"));
161
162=== modified file 'midori/midori-settings.vala'
163--- midori/midori-settings.vala 2013-11-24 21:50:38 +0000
164+++ midori/midori-settings.vala 2015-07-10 18:30:41 +0000
165@@ -189,5 +189,59 @@
166 || property == "user-stylesheet-uri"
167 || property.has_suffix ("-width");
168 }
169+
170+ /* Determines if Netscape plugins are supported. This can also
171+ indicate that plugins are forcibly disabled for testing.
172+ Since: 0.6.0 */
173+ public static bool has_plugin_support () {
174+ if (strcmp (GLib.Environment.get_variable ("MIDORI_DEBUG"), "unarmed") == 0)
175+ return false;
176+ if (strcmp (GLib.Environment.get_variable ("MOZ_PLUGIN_PATH"), "/") == 0)
177+ return false;
178+ return true;
179+ }
180+
181+ /* Since: 0.6.0 */
182+ public Midori.ContextAction? get_action (string property) {
183+ var action = new Midori.ContextAction (property, null, null, null);
184+ GLib.ParamSpec? pspec = get_class ().find_property (property);
185+ if (pspec == null) {
186+ GLib.warning (_("Property '%s' is invalid for %s"),
187+ property, get_class ().get_type ().name ());
188+ return action;
189+ }
190+
191+ action.object = this;
192+ action.property = property;
193+
194+ action.label = pspec.get_nick ();
195+ action.tooltip = pspec.get_blurb ();
196+
197+ if (property == "enable-offline-web-application-cache")
198+ action.label = _("Enable offline web application cache");
199+ else if (property == "enable-html5-local-storage")
200+ action.label = _("Enable HTML5 local storage support");
201+ else if (property == "strip-referer") {
202+ /* i18n: Reworded: Shorten details propagated when going to another page */
203+ action.label = _("Strip referrer details sent to websites");
204+ /* i18n: Referer here is not a typo but a technical term */
205+ action.tooltip = _("Whether the \"Referer\" header should be shortened to the hostname");
206+ } else if (property == "auto-load-images") {
207+ action.label = action.tooltip = _("Load images automatically");
208+ action.short_label = _("Images");
209+ action.stock_id = "image-x-generic";
210+ } else if (property == "enable-javascript") {
211+ action.label = action.tooltip = _("Enable scripts");
212+ action.short_label = _("Scripts");
213+ action.stock_id = "text-x-javascript";
214+ } else if (property == "enable-plugins") {
215+ action.label = action.tooltip = _("Enable Netscape plugins");
216+ action.short_label = _("Netscape plugins");
217+ action.stock_id = "application-x-shockwave-flash";
218+ action.visible = has_plugin_support ();
219+ } else if (property == "")
220+ action.label = _("");
221+ return action;
222+ }
223 }
224 }
225
226=== modified file 'midori/midori-websettings.c'
227--- midori/midori-websettings.c 2015-07-06 21:26:46 +0000
228+++ midori/midori-websettings.c 2015-07-10 18:30:41 +0000
229@@ -609,11 +609,12 @@
230 * Returns: %TRUE if Netscape plugins can be used
231 *
232 * Since: 0.4.4
233+ * Deprecated: 0.6.0: Use #MidoriSettings.has_plugin_support instead.
234 **/
235 gboolean
236 midori_web_settings_has_plugin_support (void)
237 {
238- return !midori_debug ("unarmed") && g_strcmp0 (g_getenv ("MOZ_PLUGIN_PATH"), "/");
239+ return midori_settings_has_plugin_support ();
240 }
241
242 /**

Subscribers

People subscribed via source and target branches

to all changes: