X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-keypad.c;h=3c51926f187b184f737b6eae27dd845f1dcd0060;hb=33cdbdf7e095370cf04240eed21344205a487191;hp=f3b1df39c067851ac1ae5d6a57dbbd51a1fef927;hpb=c502669e3fbc97a792a6c0064a72cfb9690d7d23;p=pspp diff --git a/src/ui/gui/psppire-keypad.c b/src/ui/gui/psppire-keypad.c index f3b1df39c0..3c51926f18 100644 --- a/src/ui/gui/psppire-keypad.c +++ b/src/ui/gui/psppire-keypad.c @@ -25,44 +25,16 @@ enum { n_SIGNALS }; -static void psppire_keypad_class_init (PsppireKeypadClass *klass); -static void psppire_keypad_init (PsppireKeypad *kp); - static guint keypad_signals [n_SIGNALS] = { 0 }; -GType -psppire_keypad_get_type (void) -{ - static GType kp_type = 0; - - if (!kp_type) - { - static const GTypeInfo kp_info = - { - sizeof (PsppireKeypadClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) psppire_keypad_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PsppireKeypad), - 0, - (GInstanceInitFunc) psppire_keypad_init, - }; - - kp_type = g_type_register_static (GTK_TYPE_EVENT_BOX, "PsppireKeypad", - &kp_info, 0); - } - - return kp_type; -} +G_DEFINE_TYPE (PsppireKeypad, psppire_keypad, GTK_TYPE_EVENT_BOX) static GObjectClass * parent_class = NULL; static void psppire_keypad_dispose (GObject *obj) { - PsppireKeypad *kp = (PsppireKeypad *)obj; + PsppireKeypad *kp = PSPPIRE_KEYPAD (obj); if (kp->dispose_has_run) return; @@ -139,7 +111,7 @@ button_click (GtkButton *b, PsppireKeypad *kp) const gchar *s = g_hash_table_lookup (kp->frag_table, b); - if ( s ) + if (s) g_signal_emit (kp, keypad_signals [INSERT_SYNTAX], 0, s); else g_signal_emit (kp, keypad_signals [ERASE], 0); @@ -166,7 +138,7 @@ add_button (PsppireKeypad *kp, GtkWidget **button, 30 * cols / (float) rows); g_hash_table_insert (kp->frag_table, *button, - (void *) keypad_insert_text[(button - &kp->digit[0])] ); + (void *) keypad_insert_text[(button - &kp->digit[0])]); g_signal_connect (*button, "clicked", G_CALLBACK (button_click), kp); @@ -211,7 +183,7 @@ key_release_callback (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - if ( ! gtk_widget_has_focus (widget)) + if (! gtk_widget_has_focus (widget)) return FALSE; switch (event->keyval) @@ -332,7 +304,7 @@ psppire_keypad_init (PsppireKeypad *kp) g_snprintf (buf, 5, "%d", i); kp->digit[i] = gtk_button_new_with_label (buf); - if ( i == 0 ) + if (i == 0) add_button (kp, &kp->digit[i], digit_hoffset + 0, digit_hoffset + 2, digit_voffset + 3, digit_voffset + 4);