Merge lp:~gue5t/midori/last-placeholders into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: Cris Dywan
Approved revision: 7017
Merged at revision: 7021
Proposed branch: lp:~gue5t/midori/last-placeholders
Merge into: lp:midori
Diff against target: 106 lines (+38/-6)
3 files modified
extensions/cookie-manager/cookie-manager-page.c (+3/-3)
katze/gtk3-compat.c (+31/-2)
midori/midori-locationaction.c (+4/-1)
To merge this branch: bzr merge lp:~gue5t/midori/last-placeholders
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+267599@code.launchpad.net

Commit message

Fix last known GTK2 entry placeholder text bugs

Description of the change

This branch fixes the last bugs I could find with GTK2 entry placeholder text. One is that cookie permissions was still using the old string to check placeholder visibility, but this branch also ensures that signal handlers for placeholder maintenance are removed when setting a NULL placeholder and makes right-click paste work properly.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Maybe we should have some #define or utility function like sokoke_gtk_entry_has_default afterall..

review: Needs Information
Revision history for this message
Cris Dywan (kalikiana) wrote :

Aside from that finding an easier approach for testing this sort of thing, but that's always a matter of brainstorming and takes time.

Revision history for this message
Cris Dywan (kalikiana) wrote :

Let's not block on that for now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/cookie-manager/cookie-manager-page.c'
--- extensions/cookie-manager/cookie-manager-page.c 2013-06-26 21:54:50 +0000
+++ extensions/cookie-manager/cookie-manager-page.c 2015-08-10 23:48:40 +0000
@@ -163,7 +163,7 @@
163 g_object_unref(priv->filter);163 g_object_unref(priv->filter);
164164
165 /* if a filter is set, apply it again but ignore the place holder text */165 /* if a filter is set, apply it again but ignore the place holder text */
166 if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_has_default"))166 if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_showing_default"))
167 {167 {
168 filter_text = gtk_entry_get_text(GTK_ENTRY(priv->filter_entry));168 filter_text = gtk_entry_get_text(GTK_ENTRY(priv->filter_entry));
169 if (*filter_text != '\0')169 if (*filter_text != '\0')
@@ -575,7 +575,7 @@
575 if (toplevel != NULL)575 if (toplevel != NULL)
576 gtk_window_set_icon_name(GTK_WINDOW(dialog), gtk_window_get_icon_name(GTK_WINDOW(toplevel)));576 gtk_window_set_icon_name(GTK_WINDOW(dialog), gtk_window_get_icon_name(GTK_WINDOW(toplevel)));
577577
578 if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_has_default"))578 if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_showing_default"))
579 {579 {
580 filter_text = gtk_entry_get_text(GTK_ENTRY(priv->filter_entry));580 filter_text = gtk_entry_get_text(GTK_ENTRY(priv->filter_entry));
581 if (*filter_text != '\0')581 if (*filter_text != '\0')
@@ -808,7 +808,7 @@
808 if (priv->ignore_changed_filter)808 if (priv->ignore_changed_filter)
809 return;809 return;
810810
811 if (!g_object_get_data (G_OBJECT (editable), "sokoke_has_default"))811 if (!g_object_get_data (G_OBJECT (editable), "sokoke_showing_default"))
812 text = gtk_entry_get_text(GTK_ENTRY(editable));812 text = gtk_entry_get_text(GTK_ENTRY(editable));
813 else813 else
814 text = NULL;814 text = NULL;
815815
=== modified file 'katze/gtk3-compat.c'
--- katze/gtk3-compat.c 2015-03-15 19:09:28 +0000
+++ katze/gtk3-compat.c 2015-08-10 23:48:40 +0000
@@ -166,17 +166,44 @@
166 return FALSE;166 return FALSE;
167}167}
168168
169static void
170sokoke_on_entry_popup (GtkEntry *entry,
171 GtkWidget *popup,
172 gpointer user_data)
173{
174 /* If the user selects paste in the popup, we should hide the default
175 when the menu closes so it pastes into a clean entry */
176 g_signal_connect_swapped (popup, "destroy", G_CALLBACK (
177 sokoke_hide_placeholder_text), entry);
178}
179
169void180void
170gtk_entry_set_placeholder_text (GtkEntry* entry,181gtk_entry_set_placeholder_text (GtkEntry* entry,
171 const gchar* default_text)182 const gchar* default_text)
172{183{
173 /* Note: The default text initially overwrites any previous text */184 /* Note: The default text initially overwrites any previous text */
174 gchar* old_value = g_object_get_data (G_OBJECT (entry), "sokoke_default_text");185 gchar* old_default_text = g_object_get_data (G_OBJECT (entry), "sokoke_default_text");
175 g_object_set_data (G_OBJECT (entry), "sokoke_default_text", (gpointer)default_text);186 g_object_set_data (G_OBJECT (entry), "sokoke_default_text", (gpointer)default_text);
176187
177 if (default_text == NULL)188 if (default_text == NULL)
189 {
178 g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (0));190 g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (0));
179 else if (!old_value)191 g_signal_handlers_disconnect_by_func (entry,
192 G_CALLBACK (sokoke_on_entry_drag_motion), NULL);
193 g_signal_handlers_disconnect_by_func (entry,
194 G_CALLBACK (sokoke_on_entry_focus_in_event), NULL);
195 g_signal_handlers_disconnect_by_func (entry,
196 G_CALLBACK (sokoke_on_entry_drag_leave), NULL);
197 g_signal_handlers_disconnect_by_func (entry,
198 G_CALLBACK (sokoke_on_entry_drag_drop), NULL);
199 g_signal_handlers_disconnect_by_func (entry,
200 G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
201 g_signal_handlers_disconnect_by_func (entry,
202 G_CALLBACK (sokoke_on_entry_text_changed), NULL);
203 g_signal_handlers_disconnect_by_func (entry,
204 G_CALLBACK (sokoke_on_entry_popup), NULL);
205 }
206 else if (old_default_text == NULL)
180 {207 {
181 g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (1));208 g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (1));
182 sokoke_widget_set_pango_font_style (GTK_WIDGET (entry), PANGO_STYLE_ITALIC);209 sokoke_widget_set_pango_font_style (GTK_WIDGET (entry), PANGO_STYLE_ITALIC);
@@ -193,6 +220,8 @@
193 G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);220 G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
194 g_signal_connect (entry, "notify::text",221 g_signal_connect (entry, "notify::text",
195 G_CALLBACK (sokoke_on_entry_text_changed), NULL);222 G_CALLBACK (sokoke_on_entry_text_changed), NULL);
223 g_signal_connect (entry, "populate-popup",
224 G_CALLBACK (sokoke_on_entry_popup), NULL);
196 }225 }
197 else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))226 else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
198 {227 {
199228
=== modified file 'midori/midori-locationaction.c'
--- midori/midori-locationaction.c 2015-07-06 21:26:46 +0000
+++ midori/midori-locationaction.c 2015-08-10 23:48:40 +0000
@@ -981,7 +981,10 @@
981midori_location_action_changed_cb (GtkEntry* entry,981midori_location_action_changed_cb (GtkEntry* entry,
982 MidoriLocationAction* location_action)982 MidoriLocationAction* location_action)
983{983{
984 katze_assign (location_action->text, g_strdup (gtk_entry_get_text (entry)));984 if (g_object_get_data (G_OBJECT (entry), "sokoke_showing_default"))
985 katze_assign (location_action->text, g_strdup (""));
986 else
987 katze_assign (location_action->text, g_strdup (gtk_entry_get_text (entry)));
985}988}
986989
987static void990static void

Subscribers

People subscribed via source and target branches

to all changes: