~midori/midori/trunk

« back to all changes in this revision

Viewing changes to katze/gtk3-compat.c

  • Committer: RabbitBot
  • Author(s): gue5t
  • Date: 2015-08-15 15:11:29 UTC
  • mfrom: (7016.2.1 last-placeholders)
  • Revision ID: rabbitbot-20150815151129-j1egvqs16z3eb5i8
Fix last known GTK2 entry placeholder text bugs

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
    return FALSE;
167
167
}
168
168
 
 
169
static void
 
170
sokoke_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
 
169
180
void
170
181
gtk_entry_set_placeholder_text (GtkEntry*    entry,
171
182
                                const gchar* default_text)
172
183
{
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);
176
187
 
177
188
    if (default_text == NULL)
 
189
    {
178
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
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);
196
225
    }
197
226
    else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
198
227
    {