Yattm - unified GTK instant-messaging client logo
   [Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003]

Home - Main Page - Data Structures - File List - Data Fields - Globals

input_list.c File Reference

#include "intl.h"
#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
#include "globals.h"
#include "debug.h"
#include "dialog.h"
#include "input_list.h"
#include "value_pair.h"

Include dependency graph for input_list.c:

Include dependency graph

Go to the source code of this file.

Functions

void eb_input_render (input_list *il, GtkWidget *box)
void eb_input_cancel (input_list *il)
void eb_input_accept (input_list *il)
GList * eb_input_to_value_pair (input_list *il)
void eb_update_from_value_pair (input_list *il, GList *vp)


Function Documentation

void eb_input_accept input_list   il
 

Definition at line 129 of file input_list.c.

References EB_INPUT_CHECKBOX, EB_INPUT_ENTRY, MAX_PREF_LEN, _input_list::next, _input_list::type, and _input_list::widget.

Referenced by update_plugin_prefs().

00130 {
00131     if(!il)
00132     {
00133         return;
00134     }
00135 
00136     switch(il->type)
00137     {
00138         case EB_INPUT_CHECKBOX:
00139             {
00140             }
00141             break;
00142         case EB_INPUT_ENTRY:
00143             {
00144                 GtkWidget * w = il->widget.entry.entry;
00145                 char * text = gtk_entry_get_text(GTK_ENTRY(w));
00146                 strncpy(il->widget.entry.value, text, MAX_PREF_LEN);
00147                 gtk_entry_set_text(GTK_ENTRY(w), il->widget.entry.value);
00148 
00149             }
00150             break;
00151     }
00152 
00153     eb_input_accept(il->next);
00154 }

void eb_input_cancel input_list   il
 

Definition at line 102 of file input_list.c.

References EB_INPUT_CHECKBOX, EB_INPUT_ENTRY, _input_list::next, _input_list::type, and _input_list::widget.

00103 {
00104     if(!il)
00105     {
00106         return;
00107     }
00108 
00109     switch(il->type)
00110     {
00111         case EB_INPUT_CHECKBOX:
00112             {
00113                 *(il->widget.checkbox.value)
00114                     = il->widget.checkbox.saved_value;
00115             }
00116             break;
00117         case EB_INPUT_ENTRY:
00118             {
00119                 GtkWidget * w = il->widget.entry.entry;
00120                 char * text = il->widget.entry.value;
00121                 gtk_entry_set_text(GTK_ENTRY(w), text);
00122             }
00123             break;
00124     }
00125 
00126     eb_input_cancel(il->next);
00127 }

void eb_input_render input_list   il,
GtkWidget *    box
 

Definition at line 32 of file input_list.c.

References eb_button(), EB_INPUT_CHECKBOX, EB_INPUT_ENTRY, _input_list::next, _input_list::type, and _input_list::widget.

Referenced by plugin_selected().

00033 {
00034     /* XXX: for backwards compatibility remove later */
00035     char *item_label=NULL;
00036 
00037     if(!il)
00038     {
00039         return;
00040     }
00041 
00042     /* XXX: for backwards compatibility change later */
00043     switch(il->type)
00044     {
00045         case EB_INPUT_CHECKBOX:
00046             if(il->widget.checkbox.label)
00047                 item_label = il->widget.checkbox.label;
00048             else
00049                 item_label = il->widget.checkbox.name;
00050 
00051             break;
00052         case EB_INPUT_ENTRY:
00053             if(il->widget.entry.label)
00054                 item_label = il->widget.entry.label;
00055             else
00056                 item_label = il->widget.entry.name;
00057 
00058             break;
00059     }
00060     /* End b/w comp code */
00061 
00062     switch(il->type)
00063     {
00064         case EB_INPUT_CHECKBOX:
00065             {
00066                 eb_button(item_label, /* XXX */
00067                         il->widget.checkbox.value,
00068                         box);
00069                 il->widget.checkbox.saved_value =
00070                     *(il->widget.checkbox.value);
00071             }
00072             break;
00073         case EB_INPUT_ENTRY:
00074             {
00075                 GtkWidget * hbox = gtk_hbox_new(FALSE, 0);
00076                 GtkWidget * widget = gtk_label_new(item_label); /* XXX */
00077                 gtk_widget_set_usize(widget, 100, 15);
00078                 gtk_box_pack_start(GTK_BOX(hbox),
00079                         widget, FALSE, FALSE, 0);
00080                 gtk_widget_show(widget);
00081 
00082                 widget = gtk_entry_new();
00083                 il->widget.entry.entry = widget;
00084                 gtk_entry_set_text(GTK_ENTRY(widget),
00085                         il->widget.entry.value);
00086                 gtk_box_pack_start(GTK_BOX(hbox),
00087                         widget, FALSE, FALSE, 0);
00088                 gtk_widget_show(widget);
00089 
00090                 gtk_box_pack_start(GTK_BOX(box), hbox,
00091                         FALSE, FALSE, 0);
00092                 gtk_widget_show(hbox);
00093 
00094 
00095             }
00096             break;
00097     }
00098 
00099     eb_input_render(il->next, box);
00100 }

GList* eb_input_to_value_pair input_list   il
 

Definition at line 156 of file input_list.c.

References EB_INPUT_CHECKBOX, EB_INPUT_ENTRY, MAX_PREF_LEN, MAX_PREF_NAME_LEN, _input_list::next, _input_list::type, value_pair_add(), and _input_list::widget.

Referenced by write_module_prefs().

00157 {
00158     GList *vp=NULL;
00159     char key[MAX_PREF_NAME_LEN];
00160     char value[MAX_PREF_LEN];
00161     char *ptr=NULL;
00162 
00163     for(; il; il=il->next)
00164     {
00165         switch(il->type)
00166         {
00167             case EB_INPUT_CHECKBOX:
00168                 {
00169                     sprintf(key, "%s", il->widget.checkbox.name);
00170                     for( ptr=strchr(key, ' '); ptr; ptr=strchr(ptr, ' '))
00171                         *ptr='_';
00172                     sprintf(value, "%i", *il->widget.checkbox.value);
00173                     vp=value_pair_add(vp, key, value);
00174                 }
00175                 break;
00176             case EB_INPUT_ENTRY:
00177                 {
00178                     sprintf(key, "%s", il->widget.entry.name);
00179                     for( ptr=strchr(key, ' '); ptr; ptr=strchr(ptr, ' '))
00180                         *ptr='_';
00181                     vp=value_pair_add(vp, key, il->widget.entry.value);
00182                 }
00183                 break;
00184         }
00185     }
00186     return(vp);
00187 }

void eb_update_from_value_pair input_list   il,
GList *    vp
 

Definition at line 189 of file input_list.c.

References DBG_CORE, eb_debug, EB_INPUT_CHECKBOX, EB_INPUT_ENTRY, MAX_PREF_LEN, MAX_PREF_NAME_LEN, _input_list::next, _input_list::type, value_pair_get_value(), and _input_list::widget.

Referenced by load_service_plugin(), and load_utility_plugin().

00190 {
00191     char key[MAX_PREF_NAME_LEN];
00192     char *value;
00193     char *ptr=NULL;
00194 
00195     if(!il || ! vp)
00196         return;
00197     for(; il; il=il->next)
00198     {
00199         switch(il->type)
00200         {
00201             case EB_INPUT_CHECKBOX:
00202                 {
00203                     if(!il->widget.checkbox.value) {
00204                         eb_debug(DBG_CORE, "checkbox.value is NULL\n");
00205                         break;
00206                     }
00207                     sprintf(key, "%s", il->widget.checkbox.name);
00208                     for( ptr=strchr(key, ' '); ptr; ptr=strchr(ptr, ' '))
00209                         *ptr='_';
00210                     value=value_pair_get_value(vp, key);
00211 
00212                     /* XXX
00213                      * this block is to convert old prefs files to new format.
00214                      * this should be removed after about two or three versions
00215                      * have been released.  We're currently in 0.4.2
00216                      */
00217                     if(!value && il->widget.checkbox.label) {
00218                         sprintf(key, "%s", il->widget.checkbox.label);
00219                         for( ptr=strchr(key, ' '); ptr; ptr=strchr(ptr, ' '))
00220                             *ptr='_';
00221                         value=value_pair_get_value(vp, key);
00222                     }
00223 
00224                     /* Was there a matching entry? */
00225                     if(value) {
00226                         *il->widget.checkbox.value=atoi(value);
00227                         g_free(value);
00228                     }
00229                 }
00230                 break;
00231             case EB_INPUT_ENTRY:
00232                 {
00233                     if(!il->widget.entry.value) {
00234                         eb_debug(DBG_CORE, "entry.value is NULL\n");
00235                         break;
00236                     }
00237                     sprintf(key, "%s", il->widget.entry.name);
00238                     for( ptr=strchr(key, ' '); ptr; ptr=strchr(ptr, ' '))
00239                         *ptr='_';
00240                     value=value_pair_get_value(vp, key);
00241                     
00242                     /* XXX
00243                      * this block is to convert old prefs files to new format.
00244                      * this should be removed after about two or three versions
00245                      * have been released.  We're currently in 0.4.2
00246                      */
00247                     if(!value && il->widget.entry.label) {
00248                         sprintf(key, "%s", il->widget.entry.label);
00249                         for( ptr=strchr(key, ' '); ptr; ptr=strchr(ptr, ' '))
00250                             *ptr='_';
00251                         value=value_pair_get_value(vp, key);
00252                     }
00253 
00254                     /* Was there a matching entry? */
00255                     if(value) {
00256                         strncpy(il->widget.entry.value, value, MAX_PREF_LEN);
00257                         g_free(value);
00258                     }
00259                 }
00260                 break;
00261         }
00262     }
00263 }


Contact: Andy Maloney     [Documentation generated by doxygen]