r398 - trunk
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Jan 12 00:44:29 EST 2008
Author: icculus
Date: 2008-01-12 00:44:29 -0500 (Sat, 12 Jan 2008)
New Revision: 398
Modified:
trunk/gui_gtkplus2.c
Log:
Disable the "next" button on the destination page when the text entry is blank.
Modified: trunk/gui_gtkplus2.c
===================================================================
--- trunk/gui_gtkplus2.c 2008-01-12 04:58:16 UTC (rev 397)
+++ trunk/gui_gtkplus2.c 2008-01-12 05:44:29 UTC (rev 398)
@@ -39,6 +39,8 @@
PAGE_FINAL
} WizardPages;
+static WizardPages currentpage = PAGE_INTRO;
+static gboolean canfwd = TRUE;
static GtkWidget *gtkwindow = NULL;
static GtkWidget *pagetitle = NULL;
static GtkWidget *notebook = NULL;
@@ -64,19 +66,22 @@
} click_value = CLICK_NONE;
-static void prepare_wizard(const char *name, gint page,
+static void prepare_wizard(const char *name, WizardPages page,
boolean can_back, boolean can_fwd)
{
char *markup = g_markup_printf_escaped(
"<span size='large' weight='bold'>%s</span>",
name);
+ currentpage = page;
+ canfwd = can_fwd;
+
gtk_label_set_markup(GTK_LABEL(pagetitle), markup);
g_free(markup);
gtk_widget_set_sensitive(back, can_back);
gtk_widget_set_sensitive(next, can_fwd);
- gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), page);
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), (gint) page);
assert(click_value == CLICK_NONE);
assert(gtkwindow != NULL);
@@ -117,7 +122,7 @@
} // pump_events
-static int run_wizard(const char *name, gint page,
+static int run_wizard(const char *name, WizardPages page,
boolean can_back, boolean can_fwd)
{
int retval = CLICK_NONE;
@@ -152,6 +157,7 @@
} // else
} // signal_clicked
+
static void signal_browse_clicked(GtkButton *_button, gpointer data)
{
GtkWidget *dialog = gtk_file_chooser_dialog_new (
@@ -185,9 +191,22 @@
// !!! FIXME: Could warn when the target directory already contains files?
gtk_widget_destroy(dialog);
-}
+} // signal_browse_clicked
+static void signal_dest_changed(GtkComboBox *combo, gpointer user_data)
+{
+ // Disable the forward button when the destination entry is blank.
+ if ((currentpage == PAGE_DESTINATION) && (canfwd))
+ {
+ gchar *str = gtk_combo_box_get_active_text(combo);
+ const gboolean filled_in = ((str != NULL) && (*str != '\0'));
+ g_free(str);
+ gtk_widget_set_sensitive(next, filled_in);
+ } // if
+} // signal_dest_changed
+
+
static uint8 MojoGui_gtkplus2_priority(boolean istty)
{
// gnome-session exports this environment variable since 2002.
@@ -373,6 +392,9 @@
GtkWidget *alignment;
GtkWidget *hbox;
+ currentpage = PAGE_INTRO;
+ canfwd = TRUE;
+
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), title);
gtk_container_set_border_width(GTK_CONTAINER(window), 8);
@@ -489,6 +511,8 @@
gtk_label_set_line_wrap(GTK_LABEL(widget), FALSE);
alignment = gtk_alignment_new(0.5, 0.5, 1, 0);
destination = gtk_combo_box_entry_new_text();
+ gtk_signal_connect(GTK_OBJECT(destination), "changed",
+ GTK_SIGNAL_FUNC(signal_dest_changed), NULL);
gtk_container_add(GTK_CONTAINER(alignment), destination);
gtk_box_pack_start(GTK_BOX(hbox), alignment, TRUE, TRUE, 0);
browse = create_button(hbox, "gtk-open",
@@ -738,14 +762,13 @@
can_back, can_fwd);
str = gtk_combo_box_get_active_text(combo);
- if ((str == NULL) || (*str == '\0'))
- *command = 0;
- else
- {
- retval = entry->xstrdup(str);
- g_free(str);
- } // else
+ // shouldn't ever be empty ("next" should be disabled in that case).
+ assert( (*command <= 0) || ((str != NULL) && (*str != '\0')) );
+
+ retval = entry->xstrdup(str);
+ g_free(str);
+
for (i = recnum-1; i >= 0; i--)
gtk_combo_box_remove_text(combo, i);
More information about the mojosetup-commits
mailing list