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
1=== modified file 'extensions/cookie-manager/cookie-manager-page.c'
2--- extensions/cookie-manager/cookie-manager-page.c 2013-06-26 21:54:50 +0000
3+++ extensions/cookie-manager/cookie-manager-page.c 2015-08-10 23:48:40 +0000
4@@ -163,7 +163,7 @@
5 g_object_unref(priv->filter);
6
7 /* if a filter is set, apply it again but ignore the place holder text */
8- if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_has_default"))
9+ if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_showing_default"))
10 {
11 filter_text = gtk_entry_get_text(GTK_ENTRY(priv->filter_entry));
12 if (*filter_text != '\0')
13@@ -575,7 +575,7 @@
14 if (toplevel != NULL)
15 gtk_window_set_icon_name(GTK_WINDOW(dialog), gtk_window_get_icon_name(GTK_WINDOW(toplevel)));
16
17- if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_has_default"))
18+ if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_showing_default"))
19 {
20 filter_text = gtk_entry_get_text(GTK_ENTRY(priv->filter_entry));
21 if (*filter_text != '\0')
22@@ -808,7 +808,7 @@
23 if (priv->ignore_changed_filter)
24 return;
25
26- if (!g_object_get_data (G_OBJECT (editable), "sokoke_has_default"))
27+ if (!g_object_get_data (G_OBJECT (editable), "sokoke_showing_default"))
28 text = gtk_entry_get_text(GTK_ENTRY(editable));
29 else
30 text = NULL;
31
32=== modified file 'katze/gtk3-compat.c'
33--- katze/gtk3-compat.c 2015-03-15 19:09:28 +0000
34+++ katze/gtk3-compat.c 2015-08-10 23:48:40 +0000
35@@ -166,17 +166,44 @@
36 return FALSE;
37 }
38
39+static void
40+sokoke_on_entry_popup (GtkEntry *entry,
41+ GtkWidget *popup,
42+ gpointer user_data)
43+{
44+ /* If the user selects paste in the popup, we should hide the default
45+ when the menu closes so it pastes into a clean entry */
46+ g_signal_connect_swapped (popup, "destroy", G_CALLBACK (
47+ sokoke_hide_placeholder_text), entry);
48+}
49+
50 void
51 gtk_entry_set_placeholder_text (GtkEntry* entry,
52 const gchar* default_text)
53 {
54 /* Note: The default text initially overwrites any previous text */
55- gchar* old_value = g_object_get_data (G_OBJECT (entry), "sokoke_default_text");
56+ gchar* old_default_text = g_object_get_data (G_OBJECT (entry), "sokoke_default_text");
57 g_object_set_data (G_OBJECT (entry), "sokoke_default_text", (gpointer)default_text);
58
59 if (default_text == NULL)
60+ {
61 g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (0));
62- else if (!old_value)
63+ g_signal_handlers_disconnect_by_func (entry,
64+ G_CALLBACK (sokoke_on_entry_drag_motion), NULL);
65+ g_signal_handlers_disconnect_by_func (entry,
66+ G_CALLBACK (sokoke_on_entry_focus_in_event), NULL);
67+ g_signal_handlers_disconnect_by_func (entry,
68+ G_CALLBACK (sokoke_on_entry_drag_leave), NULL);
69+ g_signal_handlers_disconnect_by_func (entry,
70+ G_CALLBACK (sokoke_on_entry_drag_drop), NULL);
71+ g_signal_handlers_disconnect_by_func (entry,
72+ G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
73+ g_signal_handlers_disconnect_by_func (entry,
74+ G_CALLBACK (sokoke_on_entry_text_changed), NULL);
75+ g_signal_handlers_disconnect_by_func (entry,
76+ G_CALLBACK (sokoke_on_entry_popup), NULL);
77+ }
78+ else if (old_default_text == NULL)
79 {
80 g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (1));
81 sokoke_widget_set_pango_font_style (GTK_WIDGET (entry), PANGO_STYLE_ITALIC);
82@@ -193,6 +220,8 @@
83 G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
84 g_signal_connect (entry, "notify::text",
85 G_CALLBACK (sokoke_on_entry_text_changed), NULL);
86+ g_signal_connect (entry, "populate-popup",
87+ G_CALLBACK (sokoke_on_entry_popup), NULL);
88 }
89 else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
90 {
91
92=== modified file 'midori/midori-locationaction.c'
93--- midori/midori-locationaction.c 2015-07-06 21:26:46 +0000
94+++ midori/midori-locationaction.c 2015-08-10 23:48:40 +0000
95@@ -981,7 +981,10 @@
96 midori_location_action_changed_cb (GtkEntry* entry,
97 MidoriLocationAction* location_action)
98 {
99- katze_assign (location_action->text, g_strdup (gtk_entry_get_text (entry)));
100+ if (g_object_get_data (G_OBJECT (entry), "sokoke_showing_default"))
101+ katze_assign (location_action->text, g_strdup (""));
102+ else
103+ katze_assign (location_action->text, g_strdup (gtk_entry_get_text (entry)));
104 }
105
106 static void

Subscribers

People subscribed via source and target branches

to all changes: