1 /* 2 * gretl -- Gnu Regression, Econometrics and Time-series Library 3 * Copyright (C) 2001 Allin Cottrell and Riccardo "Jack" Lucchetti 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef DLGUTILS_H 21 #define DLGUTILS_H 22 23 enum { 24 GRETL_DLG_MODAL = 1 << 0, 25 GRETL_DLG_BLOCK = 1 << 1, 26 GRETL_DLG_RESIZE = 1 << 2, 27 GRETL_DLG_QUASI_MODAL = 1 << 3, 28 GRETL_DLG_UNDECORATED = 1 << 4 29 }; 30 31 typedef enum { 32 VARCLICK_NONE, 33 VARCLICK_INSERT_ID, 34 VARCLICK_INSERT_NAME, 35 VARCLICK_INSERT_TEXT 36 } Varclick; 37 38 enum { 39 OPT_TYPE_RADIO, 40 OPT_TYPE_COMBO, 41 OPT_TYPE_CHECK 42 }; 43 44 struct combo_opts_ { 45 gretlopt *optp; 46 gretlopt *vals; 47 const char **strs; 48 }; 49 50 /* convenience abbreviations */ 51 52 #define button_is_active(b) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b)) 53 #define widget_get_int(w,s) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), s)) 54 #define widget_set_int(w,s,i) g_object_set_data(G_OBJECT(w), s, GINT_TO_POINTER(i)) 55 #define spinner_get_int(b) gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(b)) 56 57 /* variant functions for incompatible GTK versions */ 58 59 GtkWidget *combo_box_text_new_with_entry (void); 60 gchar *combo_box_get_active_text (gpointer p); 61 void combo_box_append_text (gpointer p, const gchar *s); 62 void combo_box_prepend_text (gpointer p, const gchar *s); 63 void combo_box_remove (gpointer p, int pos); 64 65 #if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 24 66 # define gtk_combo_box_text_new gtk_combo_box_new_text 67 #endif 68 69 GtkWidget *get_active_edit_id (void); 70 71 GtkWidget *get_active_edit_name (void); 72 73 GtkWidget *get_active_edit_text (void); 74 75 void set_active_edit_name (GtkWidget *w); 76 77 void raise_and_focus_dialog (GtkEditable *entry, 78 GtkWidget *parent); 79 80 gboolean esc_kills_window (GtkWidget *w, GdkEventKey *key, 81 gpointer p); 82 83 typedef struct combo_opts_ combo_opts; 84 85 GtkWidget *gretl_dialog_new (const char *title, GtkWidget *parent, 86 unsigned char flags); 87 88 gint gretl_dialog_set_destruction (GtkWidget *w, gpointer p); 89 90 int maybe_raise_dialog (void); 91 92 void set_plugin_dialog_open (gboolean s); 93 94 void vbox_add_hsep (GtkWidget *vbox); 95 96 void pack_in_hbox (GtkWidget *w, GtkWidget *vbox, int vspace); 97 98 GtkWidget *cancel_delete_button (GtkWidget *hbox, GtkWidget *targ); 99 100 GtkWidget *cancel_button (GtkWidget *hbox); 101 102 GtkWidget *close_button (GtkWidget *hbox); 103 104 GtkWidget *ok_button (GtkWidget *hbox); 105 106 GtkWidget *ok_validate_button (GtkWidget *hbox, int *retptr, 107 int *valptr); 108 109 GtkWidget *apply_button (GtkWidget *hbox); 110 111 GtkWidget *next_button (GtkWidget *hbox); 112 113 GtkWidget *back_button (GtkWidget *hbox); 114 115 void sensitize_conditional_on (GtkWidget *w, GtkWidget *b); 116 117 void desensitize_conditional_on (GtkWidget *w, GtkWidget *b); 118 119 void set_double_from_spinner (GtkSpinButton *b, double *x); 120 121 void set_int_from_spinner (GtkSpinButton *b, int *k); 122 123 GtkWidget *gretl_option_check_button (const char *label, 124 gretlopt *popt, 125 gretlopt val); 126 127 GtkWidget *gretl_option_check_button_switched (const char *label, 128 gretlopt *popt, 129 gretlopt val); 130 131 void blocking_edit_dialog (int ci, const char *title, 132 const char *info, const char *deflt, 133 void (*okfunc)(), void *okptr, 134 Varclick click, GtkWidget *parent, 135 int *canceled); 136 137 void edit_dialog (int ci, const char *title, 138 const char *info, const char *deflt, 139 void (*okfunc)(), void *okptr, 140 Varclick click, GtkWidget *parent); 141 142 void edit_dialog_reset (dialog_t *dlg); 143 144 const gchar *edit_dialog_get_text (dialog_t *dlg); 145 146 gchar *edit_dialog_special_get_text (dialog_t *dlg); 147 148 int edit_dialog_get_action (const dialog_t *dlg); 149 150 gretlopt edit_dialog_get_opt (const dialog_t *dlg); 151 152 gpointer edit_dialog_get_data (dialog_t *dlg); 153 154 GtkWidget *edit_dialog_get_window (dialog_t *dlg); 155 156 void edit_dialog_close (dialog_t *dlg); 157 158 gchar *entry_box_get_trimmed_text (GtkWidget *w); 159 160 GtkWidget *gretl_opts_combo (combo_opts *opts, int deflt); 161 162 GtkWidget *gretl_opts_combo_masked (combo_opts *opts, int deflt, 163 const int *masked); 164 165 GtkWidget *gretl_opts_combo_full (combo_opts *opts, int deflt, 166 const int *masked, 167 GCallback callback, 168 gpointer calldata); 169 170 dialog_opts *dialog_opts_new (int n, int type, 171 gretlopt *optp, 172 const gretlopt *vals, 173 const char **strs); 174 175 void dialog_opts_free (dialog_opts *opts); 176 177 void set_combo_box_strings_from_list (GtkWidget *box, GList *list); 178 179 void set_combo_box_default_text (GtkComboBox *box, const char *s); 180 181 void depopulate_combo_box (GtkComboBox *box); 182 183 gboolean widget_get_pointer_info (GtkWidget *w, gint *x, gint *y, 184 GdkModifierType *mask); 185 186 void gretl_emulated_dialog_add_structure (GtkWidget *dlg, 187 GtkWidget **pvbox, 188 GtkWidget **pbbox); 189 190 #endif /* DLGUTILS_H */ 191