/[pspp]/psppire/src/var_type_dialog.c
ViewVC logotype

Diff of /psppire/src/var_type_dialog.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jmd, Wed Nov 2 09:44:02 2005 UTC revision 1.2 by jmd, Wed Nov 2 13:17:29 2005 UTC
# Line 29  Line 29 
29    
30  #include "var.h"  #include "var.h"
31    
32  /* callback for when any of thie radio buttons are toggled */  struct tgs
33    {
34      struct var_type_dialog *dialog;
35      gint button;
36    };
37    
38    
39    /* callback for when any of the radio buttons are toggled */
40  static void          static void        
41  on_toggle(GtkToggleButton *togglebutton,  on_toggle_1(GtkToggleButton *togglebutton, gpointer user_data)
42                gpointer user_data)  {
43      struct tgs *tgs = user_data;
44    
45      if ( gtk_toggle_button_get_active(togglebutton) == FALSE)
46        return ;
47    
48      tgs->dialog->active_button = tgs->button;
49    }
50    
51    
52    /* callback for when any of the radio buttons are toggled */
53    static void        
54    on_toggle_2(GtkToggleButton *togglebutton, gpointer user_data)
55  {  {
   gint i;  
56    struct var_type_dialog *dialog = user_data;    struct var_type_dialog *dialog = user_data;
57    if ( gtk_toggle_button_get_active(togglebutton) == FALSE)    if ( gtk_toggle_button_get_active(togglebutton) == FALSE)
58      return ;      return ;
59        
60    for(i = 0; i < num_BUTTONS; ++i )    switch (dialog->active_button)
61      {      {
62        if ( gtk_toggle_button_get_active      case BUTTON_STRING:
63             (GTK_TOGGLE_BUTTON(dialog->radioButton[i])) )        gtk_widget_hide(dialog->label_decimals);
64          {        gtk_widget_hide(dialog->entry_decimals);
65            switch (i)        break;
66              {      default:
67              case BUTTON_STRING:        gtk_widget_show(dialog->label_decimals);
68                gtk_widget_hide(dialog->label_decimals);        gtk_widget_show(dialog->entry_decimals);
69                gtk_widget_hide(dialog->entry_decimals);        break;
               break;  
             default:  
               gtk_widget_show(dialog->label_decimals);  
               gtk_widget_show(dialog->entry_decimals);  
               break;  
             }  
           break;  
         }  
70      }      }
   
   
71  }  }
72    
73    
# Line 102  var_type_dialog_create(GladeXML *xml) Line 110  var_type_dialog_create(GladeXML *xml)
110    dialog->ok = glade_xml_get_widget(xml,"var_type_ok");    dialog->ok = glade_xml_get_widget(xml,"var_type_ok");
111    
112    
113      static struct tgs tgs[num_BUTTONS];
114    for (i = 0 ; i < num_BUTTONS; ++i )    for (i = 0 ; i < num_BUTTONS; ++i )
115      {      {
116          tgs[i].dialog = dialog;
117          tgs[i].button = i;
118        g_signal_connect(dialog->radioButton[i], "toggled",        g_signal_connect(dialog->radioButton[i], "toggled",
119                         G_CALLBACK(on_toggle), dialog);                         G_CALLBACK(on_toggle_1), &tgs[i]);
     }  
120    
121          g_signal_connect(dialog->radioButton[i], "toggled",
122                           G_CALLBACK(on_toggle_2), dialog);
123    
124        }
125    
126    return dialog;    return dialog;
127  }  }
128    
129    
130    /* Set a particular button to be active */
131    void
132    var_type_dialog_set_active_button(struct var_type_dialog *dialog, gint b)
133    {
134      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->radioButton[b]),
135                                   TRUE);
136      dialog->active_button = b;
137    }
138    
139  /* Set up the state of the dialog box to match the variable VAR */  /* Set up the state of the dialog box to match the variable VAR */
140  void  void
# Line 143  var_type_dialog_set_state(struct var_typ Line 163  var_type_dialog_set_state(struct var_typ
163    /* Populate the radio button states */    /* Populate the radio button states */
164    switch (write_spec.type)    switch (write_spec.type)
165      {      {
166        case FMT_F:
167          var_type_dialog_set_active_button(dialog, BUTTON_NUMERIC);
168          gtk_widget_show(dialog->label_decimals);
169          gtk_widget_show(dialog->entry_decimals);
170          break;
171      case FMT_A:      case FMT_A:
172        gtk_toggle_button_set_active        var_type_dialog_set_active_button(dialog, BUTTON_STRING);
         (GTK_TOGGLE_BUTTON (dialog->radioButton[BUTTON_STRING]),  
          TRUE);  
173        gtk_widget_hide(dialog->label_decimals);        gtk_widget_hide(dialog->label_decimals);
174        gtk_widget_hide(dialog->entry_decimals);        gtk_widget_hide(dialog->entry_decimals);
175        break;        break;
176      case FMT_COMMA:      case FMT_COMMA:
177        gtk_toggle_button_set_active        var_type_dialog_set_active_button(dialog, BUTTON_COMMA);
         (GTK_TOGGLE_BUTTON (dialog->radioButton[BUTTON_COMMA]),  
          TRUE);  
178        gtk_widget_show(dialog->label_decimals);        gtk_widget_show(dialog->label_decimals);
179        gtk_widget_show(dialog->entry_decimals);        gtk_widget_show(dialog->entry_decimals);
180        break;        break;
181      case FMT_DOT:      case FMT_DOT:
182        gtk_toggle_button_set_active        var_type_dialog_set_active_button(dialog, BUTTON_DOT);
         (GTK_TOGGLE_BUTTON (dialog->radioButton[BUTTON_DOT]),  
          TRUE);  
183        gtk_widget_show(dialog->label_decimals);        gtk_widget_show(dialog->label_decimals);
184        gtk_widget_show(dialog->entry_decimals);        gtk_widget_show(dialog->entry_decimals);
185        break;        break;
186      case FMT_DOLLAR:      case FMT_DOLLAR:
187        gtk_toggle_button_set_active        var_type_dialog_set_active_button(dialog, BUTTON_DOLLAR);
         (GTK_TOGGLE_BUTTON (dialog->radioButton[BUTTON_DOLLAR]),  
          TRUE);  
188        gtk_widget_show(dialog->label_decimals);        gtk_widget_show(dialog->label_decimals);
189        gtk_widget_show(dialog->entry_decimals);        gtk_widget_show(dialog->entry_decimals);
190        break;        break;
# Line 192  var_type_dialog_show(struct var_type_dia Line 209  var_type_dialog_show(struct var_type_dia
209  /* Callbacks for the Variable Type Dialog Box */  /* Callbacks for the Variable Type Dialog Box */
210    
211  gint  gint
212  on_var_type_ok_clicked  on_var_type_ok_clicked(GtkWidget *w, gint idx, gpointer data)
 (GtkWidget *w, gint idx, gpointer data)  
213  {  {
   g_print("OK\n");  
   
214    gtk_widget_hide(w);    gtk_widget_hide(w);
215    
216    return FALSE;    return FALSE;
# Line 204  on_var_type_ok_clicked Line 218  on_var_type_ok_clicked
218    
219    
220  gint  gint
221  on_var_type_cancel_clicked  on_var_type_cancel_clicked(GtkWidget *w, gint idx, gpointer data)
 (GtkWidget *w, gint idx, gpointer data)  
222  {  {
   
223    gtk_widget_hide(w);    gtk_widget_hide(w);
224    
225    return FALSE;    return FALSE;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26