1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
|
/*
*
* Copyright (c) International Business Machines Corp., 2001
*
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Module: selection_cb.c
*/
#include <frontend.h>
#include <gtk/gtk.h>
#include "support.h"
#include "help.h"
#include "selection_cb.h"
/*
*
* void on_selection_window_clist_select_row (GtkCList *, gint, gint, GdkEventButton *, gpointer)
*
* Description:
* This routine is called whenever a row is selected.
* All we do is ensure that the "Next" button is
* sensitive to allow the operation to be initiated.
*
* Entry:
* clist - address of GtkCList object that received select-row signal
* row - index of row selected
* column - index of column selected on current row
* event - address of structure to obtain additional context information
* user_data - address of user data bound to clist (not used)
*
* Exit:
* Returns nothing.
*
*/
void on_selection_window_clist_select_row (GtkCList *clist, gint row, gint column,
GdkEventButton *event, gpointer user_data)
{
GtkWidget *next_button = lookup_widget (GTK_WIDGET (clist), "selection_window_next_button");
if (!(GTK_WIDGET_IS_SENSITIVE (next_button)))
{
gtk_widget_set_sensitive (next_button, TRUE);
gtk_widget_grab_default (next_button);
}
}
/*
*
* void on_selection_window_clist_unselect_row (GtkCList *, gint, gint, GdkEventButton *, gpointer)
*
* Description:
* This routine is called whenever a row is unselected.
* All we do is ensure that the "Next" button is
* not sensitive to disallow the operation from being
* initiated until a choice is made.
*
* Entry:
* clist - address of GtkCList object that received unselect-row signal
* row - index of row deselected
* column - index of column deselected on current row
* event - address of structure to obtain additional context information
* user_data - address of user data bound to clist (not used)
*
* Exit:
* Returns nothing.
*
*/
void on_selection_window_clist_unselect_row (GtkCList *clist, gint row, gint column,
GdkEventButton *event, gpointer user_data)
{
GtkWidget *next_button = lookup_widget (GTK_WIDGET (clist), "selection_window_next_button");
if (g_list_length (clist->selection) == 0 && GTK_WIDGET_IS_SENSITIVE (next_button))
gtk_widget_set_sensitive (next_button, FALSE);
}
/*
*
* void on_selection_window_clist_select_row_extra (GtkCList *, gint, gint, GdkEventButton *, gpointer)
*
* Description:
* This routine is called whenever a row is selected.
* All we do is ensure that the "Next" button is
* sensitive to allow the operation to be initiated.
* Before we make it sensitive though we ensure the
* selection_window_entry field has viable characters.
*
* NOTE: This callback is not part of the default selection
* window handlers. It is connected when someone creates a
* a GtkEntry field that requires coordination with a selection
* from the selection_window_clist.
*
* Entry:
* clist - address of GtkCList object that received select-row signal
* row - index of row selected
* column - index of column selected on current row
* event - address of structure to obtain additional context information
* user_data - address of user data bound to clist (not used)
*
* Exit:
* Returns nothing.
*
*/
void on_selection_window_clist_select_row_extra (GtkCList *clist, gint row, gint column,
GdkEventButton *event, gpointer user_data)
{
GtkWidget *entry = lookup_widget (GTK_WIDGET (clist), "selection_window_entry");
GtkWidget *next_button = lookup_widget (GTK_WIDGET (clist), "selection_window_next_button");
if (!(editable_field_is_blank (GTK_EDITABLE (entry))) &&
!(GTK_WIDGET_IS_SENSITIVE (next_button)))
gtk_widget_set_sensitive (next_button, TRUE);
}
/*
*
* void on_selection_window_entry_changed (GtkEditable *, gpointer)
*
* Description:
* This routine is called whenever the editable text
* entry field in the selection window has changed.
* If the entry is void of characters or only contains
* whitespace then we disable the next button. If it
* selection_window_clist has been selected and the
* entry now has text then we ensure that the next
* button is enabled.
*
* NOTE: This callback is not part of the default selection
* window handlers. It is connected when someone creates a
* a GtkEntry field that requires coordination with a selection
* from the selection_window_clist.
*
* Entry:
* editable - address of GtkEditable descendant object that
* received changed signal
* user_data - address of user data bound to widget (not used)
*
* Exit:
* Returns nothing.
*
*/
void on_selection_window_entry_changed (GtkEditable *editable, gpointer user_data)
{
GtkWidget *next_button = lookup_widget (GTK_WIDGET (editable), "selection_window_next_button");
if (editable_field_is_blank (editable))
{
if (GTK_WIDGET_IS_SENSITIVE (next_button))
gtk_widget_set_sensitive (next_button, FALSE);
}
else
{
GtkCList *clist = (GtkCList *)lookup_widget (GTK_WIDGET (editable), "selection_window_clist");
if (g_list_length (clist->selection) > 0)
{
if (!(GTK_WIDGET_IS_SENSITIVE (next_button)))
gtk_widget_set_sensitive (next_button, TRUE);
}
}
}
/*
*
* void inactivate_next_button (GtkWidget *)
*
* Description:
* This routine makes the "Next" button insensitive if it
* is currently sensitive to user input.
*
* Entry:
* widget - a widget in the same window as the next button
*
* Exit:
* "Next" button is so insensitive as to hurt your feelings
*
*/
void inactivate_next_button (GtkWidget *widget)
{
GtkWidget *next_button;
next_button = lookup_widget (widget, "selection_window_next_button");
if (GTK_WIDGET_IS_SENSITIVE (next_button))
gtk_widget_set_sensitive (next_button, FALSE);
}
/*
*
* void on_empty_selection_clist_set_label_text (GtkWidget *, gchar *)
*
* Description:
* This routine changes the selection window instruction label
* text to indicate that the selection list contains no items
* for selection.
*
* Entry:
* widget - a widget in the same window as the selection window label
* message - optional user-specified message
*
* Exit:
* The selection window instruction label text is changed.
*
*/
void on_empty_selection_clist_set_label_text (GtkWidget *widget, gchar *message)
{
GtkWidget *label;
label = lookup_widget (widget, "selection_window_instruction_label");
if (label)
{
if (message)
gtk_label_set_text (GTK_LABEL (label), message);
else
gtk_label_set_text (GTK_LABEL (label), _("No items were found to populate the selection list"));
}
}
/*
*
* void on_options_window_help_button_clicked (GtkButton *, gpointer)
*
* Description:
* This routine displays help on the options/configuration window.
*
* Entry:
* button - address of the GtkButton widget
* user_data - address of user data bound with signal (not used)
*
* Exit:
* See description.
*
*/
void on_options_window_help_button_clicked (GtkButton *button, gpointer user_data)
{
GtkWidget *parent;
parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
display_help_window (GTK_WINDOW (parent), options_window_help_text);
}
/*
*
* void on_selection_window_help_button_clicked (GtkButton *, gpointer)
*
* Description:
* This routine displays help on the standard selection window.
*
* Entry:
* button - address of the GtkButton widget
* user_data - contains address of text to display
*
* Exit:
* See description.
*
*/
void on_selection_window_help_button_clicked (GtkButton *button, gpointer user_data)
{
if (user_data == NULL)
display_popup_window (_("No help available"), _("No help available"));
else
{
GtkWidget *parent;
parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
display_help_window (GTK_WINDOW (parent), user_data);
}
}
|