X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-buttonbox.c;h=ab7fe3d41bb976f996a4ca27b075c85c564dbdb5;hb=ac5fc2c85d86f1a14cdea0a215666ab39b44a1dc;hp=921375f82e82e21fd6d090e949cdebea4e92d6c0;hpb=b06c888cf2e8c126b04d4678120439533a5086e5;p=pspp
diff --git a/src/ui/gui/psppire-buttonbox.c b/src/ui/gui/psppire-buttonbox.c
index 921375f82e..ab7fe3d41b 100644
--- a/src/ui/gui/psppire-buttonbox.c
+++ b/src/ui/gui/psppire-buttonbox.c
@@ -1,21 +1,18 @@
-/*
- PSPPIRE --- A Graphical User Interface for PSPP
- Copyright (C) 2007 Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2007 Free Software Foundation
- 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. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
#include
@@ -26,6 +23,8 @@
#include "psppire-buttonbox.h"
#include "psppire-dialog.h"
+#include "helper.h"
+
#include
#define _(msgid) gettext (msgid)
@@ -59,7 +58,7 @@ psppire_button_box_get_type (void)
};
button_box_type = g_type_register_static (GTK_TYPE_BUTTON_BOX,
- "PsppireButtonBox", &button_box_info, 0);
+ "PsppireButtonBox", &button_box_info, G_TYPE_FLAG_ABSTRACT);
}
return button_box_type;
@@ -143,9 +142,9 @@ psppire_button_box_class_init (PsppireButtonBoxClass *class)
button_flags =
g_param_spec_flags ("buttons",
- _("Buttons"),
- _("The mask that decides what buttons appear in the button box"),
- G_TYPE_PSPPIRE_BUTTON_MASK,
+ "Buttons",
+ "The mask that decides what buttons appear in the button box",
+ PSPPIRE_TYPE_BUTTON_MASK,
PSPPIRE_BUTTON_OK_MASK |
PSPPIRE_BUTTON_CANCEL_MASK |
PSPPIRE_BUTTON_RESET_MASK |
@@ -186,6 +185,12 @@ close_dialog (GtkWidget *w, gpointer data)
close_and_respond (w, GTK_RESPONSE_CLOSE);
}
+static void
+continue_button_clicked (GtkWidget *w, gpointer data)
+{
+ close_and_respond (w, PSPPIRE_RESPONSE_CONTINUE);
+}
+
static void
ok_button_clicked (GtkWidget *w, gpointer data)
@@ -222,12 +227,37 @@ refresh_clicked (GtkWidget *w, gpointer data)
}
+
+static void
+on_validity_change (GtkWidget *toplevel, gboolean valid, gpointer data)
+{
+ PsppireButtonBox *bb = data;
+
+ /* Set the sensitivity of all the 'executive order' buttons */
+ gtk_widget_set_sensitive (GTK_WIDGET (bb->button[PSPPIRE_BUTTON_OK]), valid);
+ gtk_widget_set_sensitive (GTK_WIDGET (bb->button[PSPPIRE_BUTTON_PASTE]), valid);
+ gtk_widget_set_sensitive (GTK_WIDGET (bb->button[PSPPIRE_BUTTON_GOTO]), valid);
+ gtk_widget_set_sensitive (GTK_WIDGET (bb->button[PSPPIRE_BUTTON_CONTINUE]), valid);
+}
+
+static void
+on_realize (GtkWidget *buttonbox, gpointer data)
+{
+ GtkWidget *toplevel = gtk_widget_get_toplevel (buttonbox);
+
+ if ( PSPPIRE_IS_DIALOG (toplevel))
+ {
+ g_signal_connect (toplevel, "validity-changed",
+ G_CALLBACK (on_validity_change), buttonbox);
+ }
+}
+
static void
psppire_button_box_init (PsppireButtonBox *bb)
{
bb->button[PSPPIRE_BUTTON_OK] = gtk_button_new_from_stock (GTK_STOCK_OK);
- gtk_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_OK]);
+ psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_OK]);
g_signal_connect (bb->button[PSPPIRE_BUTTON_OK], "clicked",
G_CALLBACK (ok_button_clicked), NULL);
g_object_set (bb->button[PSPPIRE_BUTTON_OK], "no-show-all", TRUE, NULL);
@@ -235,7 +265,7 @@ psppire_button_box_init (PsppireButtonBox *bb)
bb->button[PSPPIRE_BUTTON_GOTO] =
gtk_button_new_from_stock (GTK_STOCK_JUMP_TO);
- gtk_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_GOTO]);
+ psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_GOTO]);
g_signal_connect (bb->button[PSPPIRE_BUTTON_GOTO], "clicked",
G_CALLBACK (goto_button_clicked), NULL);
g_object_set (bb->button[PSPPIRE_BUTTON_GOTO], "no-show-all", TRUE, NULL);
@@ -244,36 +274,44 @@ psppire_button_box_init (PsppireButtonBox *bb)
bb->button[PSPPIRE_BUTTON_CONTINUE] =
gtk_button_new_with_mnemonic (_("Continue"));
- gtk_box_pack_start_defaults (GTK_BOX (bb),
+ GTK_WIDGET_SET_FLAGS (bb->button[PSPPIRE_BUTTON_CONTINUE],
+ GTK_CAN_DEFAULT);
+
+ g_signal_connect (bb->button[PSPPIRE_BUTTON_CONTINUE], "realize",
+ G_CALLBACK (gtk_widget_grab_default), NULL);
+
+ psppire_box_pack_start_defaults (GTK_BOX (bb),
bb->button[PSPPIRE_BUTTON_CONTINUE]);
+ g_signal_connect (bb->button[PSPPIRE_BUTTON_CONTINUE], "clicked",
+ G_CALLBACK (continue_button_clicked), NULL);
g_object_set (bb->button[PSPPIRE_BUTTON_CONTINUE],
"no-show-all", TRUE, NULL);
- bb->button[PSPPIRE_BUTTON_PASTE] = gtk_button_new_with_mnemonic (_("_Paste"));
+ bb->button[PSPPIRE_BUTTON_PASTE] = gtk_button_new_from_stock (GTK_STOCK_PASTE);
g_signal_connect (bb->button[PSPPIRE_BUTTON_PASTE], "clicked",
G_CALLBACK (paste_button_clicked), NULL);
- gtk_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_PASTE]);
+ psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_PASTE]);
g_object_set (bb->button[PSPPIRE_BUTTON_PASTE], "no-show-all", TRUE, NULL);
bb->button[PSPPIRE_BUTTON_CANCEL] = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
g_signal_connect (bb->button[PSPPIRE_BUTTON_CANCEL], "clicked",
G_CALLBACK (close_dialog), NULL);
- gtk_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_CANCEL]);
+ psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_CANCEL]);
g_object_set (bb->button[PSPPIRE_BUTTON_CANCEL], "no-show-all", TRUE, NULL);
- bb->button[PSPPIRE_BUTTON_RESET] = gtk_button_new_from_stock (GTK_STOCK_REFRESH);
+ bb->button[PSPPIRE_BUTTON_RESET] = gtk_button_new_from_stock ("pspp-stock-reset");
g_signal_connect (bb->button[PSPPIRE_BUTTON_RESET], "clicked",
G_CALLBACK (refresh_clicked), NULL);
- gtk_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_RESET]);
+ psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_RESET]);
g_object_set (bb->button[PSPPIRE_BUTTON_RESET], "no-show-all", TRUE, NULL);
bb->button[PSPPIRE_BUTTON_HELP] = gtk_button_new_from_stock (GTK_STOCK_HELP);
- gtk_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_HELP]);
+ psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_HELP]);
g_object_set (bb->button[PSPPIRE_BUTTON_HELP], "no-show-all", TRUE, NULL);
@@ -294,6 +332,8 @@ psppire_button_box_init (PsppireButtonBox *bb)
g_value_unset (&value);
}
+
+ g_signal_connect (bb, "realize", G_CALLBACK (on_realize), NULL);
}