170
sokoke_on_entry_popup (GtkEntry *entry,
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);
170
181
gtk_entry_set_placeholder_text (GtkEntry* entry,
171
182
const gchar* default_text)
173
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
186
g_object_set_data (G_OBJECT (entry), "sokoke_default_text", (gpointer)default_text);
177
188
if (default_text == NULL)
178
190
g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (0));
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);
206
else if (old_default_text == NULL)
181
208
g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (1));
182
209
sokoke_widget_set_pango_font_style (GTK_WIDGET (entry), PANGO_STYLE_ITALIC);
193
220
G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
194
221
g_signal_connect (entry, "notify::text",
195
222
G_CALLBACK (sokoke_on_entry_text_changed), NULL);
223
g_signal_connect (entry, "populate-popup",
224
G_CALLBACK (sokoke_on_entry_popup), NULL);
197
226
else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))