summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c0c618e)
raw | patch | inline | side by side (parent: c0c618e)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 27 Jan 2008 23:54:51 +0000 (23:54 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 27 Jan 2008 23:54:51 +0000 (23:54 +0000) |
src/widgets/toolbox.cpp | patch | blob | history |
index 56f33bf9677660f79ab2e9b89d5c4a77f03a2aa1..46bee15968aafe3a5f1cda6c8e1ff11473652e52 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
}
-gboolean
-sp_text_toolbox_size_keypress (GtkWidget */*w*/, GdkEventKey *event, gpointer /*data*/)
-{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (!desktop) return FALSE;
-
- switch (get_group0_keyval (event)) {
- case GDK_Escape: // defocus
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- return TRUE; // I consumed the event
- break;
- case GDK_Return: // defocus
- case GDK_KP_Enter:
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- return TRUE; // I consumed the event
- break;
- }
- return FALSE;
-}
-
gboolean
sp_text_toolbox_family_keypress (GtkWidget */*w*/, GdkEventKey *event, GObject *tbl)
{
if (g_object_get_data (tbl, "size-block")) return;
+ // If this is not from selecting a size in the list (in which case get_active will give the
+ // index of the selected item, otherwise -1) and not from user pressing Enter/Return, do not
+ // process this event. This fixes GTK's stupid insistence on sending an activate change every
+ // time any character gets typed or deleted, which made this control nearly unusable in 0.45.
+ if (gtk_combo_box_get_active (cbox) < 0 && !g_object_get_data (tbl, "enter-pressed"))
+ return;
+
+ g_object_set_data (tbl, "enter-pressed", gpointer(0));
+
char *text = gtk_combo_box_get_active_text (cbox);
SPCSSAttr *css = sp_repr_css_attr_new ();
_("Text: Change font size"));
sp_repr_css_attr_unref (css);
+ gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+}
+
+gboolean
+sp_text_toolbox_size_keypress (GtkWidget */*w*/, GdkEventKey *event, GObject *tbl)
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (!desktop) return FALSE;
- if (gtk_combo_box_get_active (cbox) > 0) // if this was from drop-down (as opposed to type-in), defocus
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ switch (get_group0_keyval (event)) {
+ case GDK_Escape: // defocus
+ gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ return TRUE; // I consumed the event
+ break;
+ case GDK_Return: // defocus
+ case GDK_KP_Enter:
+ g_object_set_data (tbl, "enter-pressed", gpointer(1));
+ GtkComboBox *cbox = GTK_COMBO_BOX(g_object_get_data (G_OBJECT (tbl), "combo-box-size"));
+ sp_text_toolbox_size_changed (cbox, tbl);
+ gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ return TRUE; // I consumed the event
+ break;
+ }
+ return FALSE;
}
void
gtk_box_pack_start (GTK_BOX (tbl), cbox, FALSE, FALSE, 0);
g_object_set_data (G_OBJECT (tbl), "combo-box-size", cbox);
g_signal_connect (G_OBJECT (cbox), "changed", G_CALLBACK (sp_text_toolbox_size_changed), tbl);
- gtk_signal_connect(GTK_OBJECT(cbox), "key-press-event", GTK_SIGNAL_FUNC(sp_text_toolbox_size_keypress), NULL);
+ gtk_signal_connect(GTK_OBJECT(gtk_bin_get_child(GTK_BIN(cbox))), "key-press-event", GTK_SIGNAL_FUNC(sp_text_toolbox_size_keypress), tbl);
//spacer
aux_toolbox_space (tbl, 4);