X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-keypad.c;h=d4eeff6119a177926a19a38cc79355e09297c462;hb=adf4bc614f52fd20d34190dc710af5db9a897c40;hp=af0e592487f795179bb8cc76fde26e0d8fb46a3c;hpb=5d5b324c12dc799e6e4dc3230e93edaa7d0a0272;p=pspp diff --git a/src/ui/gui/psppire-keypad.c b/src/ui/gui/psppire-keypad.c index af0e592487..d4eeff6119 100644 --- a/src/ui/gui/psppire-keypad.c +++ b/src/ui/gui/psppire-keypad.c @@ -1,37 +1,34 @@ -/* PSPP - computes sample statistics. - Copyright (C) 2007 Free Software Foundation, Inc. +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ - -#include -#include -#include -#include + along with this program. If not, see . */ + +#include +#include #include #include "psppire-keypad.h" enum { INSERT_SYNTAX, + ERASE, n_SIGNALS }; static void psppire_keypad_class_init (PsppireKeypadClass *klass); static void psppire_keypad_init (PsppireKeypad *kp); -static guint keypad_signals[n_SIGNALS] = { 0 }; +static guint keypad_signals [n_SIGNALS] = { 0 }; GType psppire_keypad_get_type (void) @@ -106,6 +103,16 @@ psppire_keypad_class_init (PsppireKeypadClass *klass) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + + keypad_signals[ERASE] = g_signal_new ("erase", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (PsppireKeypadClass, + keypad), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } @@ -115,10 +122,10 @@ psppire_keypad_class_init (PsppireKeypadClass *klass) The order of these must correspond to the order of the button declarations */ -static const char *keypad_insert_text[] = { +static const char * const keypad_insert_text[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "+", "-", "*", "**", "/", "=", "<>", "<", "<=", - ">", ">=", "&", "|", "~", "(", ")" + ">", ">=", "&", "|", "~", "()", NULL }; @@ -131,7 +138,11 @@ button_click (GtkButton *b, PsppireKeypad *kp) { const gchar *s = g_hash_table_lookup (kp->frag_table, b); - g_signal_emit (kp, keypad_signals [INSERT_SYNTAX], 0, s); + + if ( s ) + g_signal_emit (kp, keypad_signals [INSERT_SYNTAX], 0, s); + else + g_signal_emit (kp, keypad_signals [ERASE], 0); } static const gint cols = 6; @@ -195,9 +206,6 @@ enter_leave_notify (GtkWidget *widget, if (event->type == GDK_ENTER_NOTIFY) gtk_widget_grab_focus (widget); - if (event->type == GDK_LEAVE_NOTIFY) - GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - return FALSE; } @@ -206,7 +214,7 @@ key_release_callback (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - if ( ! (GTK_WIDGET_FLAGS (widget) & GTK_HAS_FOCUS) ) + if ( ! gtk_widget_has_focus (widget)) return FALSE; switch (event->keyval) @@ -302,8 +310,7 @@ psppire_keypad_init (PsppireKeypad *kp) const int digit_voffset = 0; const int digit_hoffset = 3; - GTK_WIDGET_SET_FLAGS (kp, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (kp, GTK_HAS_FOCUS); + gtk_widget_set_can_focus (GTK_WIDGET (kp), TRUE); kp->dispose_has_run = FALSE; @@ -325,7 +332,7 @@ psppire_keypad_init (PsppireKeypad *kp) { int j = i - 1; char buf[5]; - snprintf (buf, 5, "%d", i); + g_snprintf (buf, 5, "%d", i); kp->digit[i] = gtk_button_new_with_label (buf); if ( i == 0 ) @@ -369,12 +376,15 @@ psppire_keypad_init (PsppireKeypad *kp) g_markup_printf_escaped ("xy"); label = gtk_label_new ("**"); + gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); kp->star_star = gtk_button_new (); gtk_container_add (GTK_CONTAINER (kp->star_star), label); + gtk_widget_show (label); + add_button (kp, &kp->star_star, 0, 1, 4, 5);