summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@beryl-project.org>2007-06-06 16:31:09 +0200
committerDennis Kasprzyk <onestone@beryl-project.org>2007-06-06 16:31:09 +0200
commit4f7169b3b30da042f5ed4a96edaeab98998bede7 (patch)
treee6467f0b7198e86003384a0fd55742d1c1f00b94
parente9761659c0c4369de3e11a1b02d0b0f892595120 (diff)
downloadccs-settings-4f7169b3b30da042f5ed4a96edaeab98998bede7.tar.gz
ccs-settings-4f7169b3b30da042f5ed4a96edaeab98998bede7.tar.bz2
Removed string restrictions
-rw-r--r--src/main.c143
1 files changed, 7 insertions, 136 deletions
diff --git a/src/main.c b/src/main.c
index 0b0603d..85d871e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -271,10 +271,7 @@ void cb_option(GtkWidget * w, CCSSetting * o)
case TypeString:
{
const gchar * s;
- if (o->info.forString.allowedValues)
- s=gtk_combo_box_get_active_text(GTK_COMBO_BOX(widgets->w));
- else
- s = gtk_entry_get_text(GTK_ENTRY(widgets->w));
+ s = gtk_entry_get_text(GTK_ENTRY(widgets->w));
ccsSetString(o,s);
}
break;
@@ -365,30 +362,6 @@ void cb_option(GtkWidget * w, CCSSetting * o)
ccsSetAction(o,action);
}
break;
- case TypeList:
- {
- if (o->info.forList.listType==TypeString &&
- o->info.forList.listInfo->forString.allowedValues)
- {
- CCSSettingValueList l = NULL;
-
- //multiple-choice
- gint i;
- CCSStringList j = o->info.forList.listInfo->forString.allowedValues;
- for (i=0;j;j=j->next)
- {
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->l[i])))
- {
- CCSSettingValue *val = malloc(sizeof(CCSSettingValue));
- val->value.asString = strdup(j->data);
- l = ccsSettingValueListAppend(l,val);
- }
- i++;
- }
- ccsSetList(o, l);
- }
- }
- break;
default:
break;
}
@@ -544,23 +517,8 @@ void set_widgets_for_setting(CCSSetting * s)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->w),b_val);
break;
case TypeString:
- if (s->info.forString.allowedValues)
- {
- i=0;
- str_l = s->info.forString.allowedValues;
- ccsGetString(s,&s_val);
- for (;str_l;str_l=str_l->next)
- {
- if (strcmp(str_l->data,s_val)==0)
- gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->w),i);
- i++;
- }
- }
- else
- {
- ccsGetString(s,&s_val);
- gtk_entry_set_text(GTK_ENTRY(widgets->w),s_val);
- }
+ ccsGetString(s,&s_val);
+ gtk_entry_set_text(GTK_ENTRY(widgets->w),s_val);
break;
case TypeMatch:
ccsGetMatch(s,&s_val);
@@ -646,29 +604,7 @@ void set_widgets_for_setting(CCSSetting * s)
{
CCSSettingType typ = s->info.forList.listType;
- if (typ==TypeString &&
- s->info.forList.listInfo->forString.allowedValues)
- {
- gint i=0;
- str_l = s->info.forList.listInfo->forString.allowedValues;
- for (;str_l;str_l=str_l->next)
- {
- CCSStringList l,list;
- CCSSettingValueList vl;
- ccsGetList(s,&vl);
- l = ccsGetStringListFromValueList(vl);
- list = l;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->l[i]),FALSE);
- for (;list;list=list->next)
- {
- if (strcmp(list->data,str_l->data)==0)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->l[i]),TRUE);
- }
- ccsStringListFree(l, TRUE);
- i++;
- }
- }
- else if (typ==TypeString)
+ if (typ==TypeString)
{
CCSStringList l,list;
@@ -905,33 +841,10 @@ void do_if_numeric_group(CCSSetting * o, SETGroupWidget * w)
w->hasany=TRUE;
}
}
-void do_if_string_choice_group(CCSSetting * o, SETGroupWidget * w)
-{
- if ((o->type==TypeString) && o->info.forString.allowedValues)
- {
- GtkWidget * hbox = gtk_hbox_new(FALSE,2);
- GtkWidget * vbox = gtk_vbox_new(FALSE,2);
- CCSStringList i;
- SETOptionWidgets * widgets = o->privatePtr;
- gtk_box_pack_start(GTK_BOX(w->widget),hbox,FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(hbox),make_info_button(o),FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(hbox),vbox,TRUE,TRUE,0);
- gtk_box_pack_start(GTK_BOX(vbox),my_label_new(o->shortDesc),FALSE,FALSE,0);
- widgets->w=gtk_combo_box_new_text();
- for (i=o->info.forString.allowedValues;i;i=i->next)
- {
- gtk_combo_box_append_text(GTK_COMBO_BOX(widgets->w),i->data); // yes this is correct
- }
- set_widgets_for_setting(o);
- g_signal_connect(widgets->w,"changed",G_CALLBACK(cb_option),o);
- gtk_box_pack_start(GTK_BOX(vbox),widgets->w,FALSE,FALSE,0);
- w->hasany=TRUE;
- }
-}
void do_if_string_group(CCSSetting * o, SETGroupWidget * w)
{
- if ((o->type==TypeString) && !o->info.forString.allowedValues)
+ if ((o->type==TypeString))
{
GtkWidget * hbox = gtk_hbox_new(FALSE,2);
GtkWidget * vbox = gtk_vbox_new(FALSE,2);
@@ -1173,46 +1086,7 @@ void do_if_edge_group(CCSSetting * o, SETGroupWidget * w)
}
}
#define OPT_PER_LINE 3
-void do_if_option_list_group(CCSSetting * o, SETGroupWidget * w)
-{
- if (o->type==TypeList && o->info.forList.listType==TypeString &&
- o->info.forList.listInfo->forString.allowedValues)
- {
- GtkWidget * hbox, *vbox, *tabl, *fram;
- gint i, l=-1, c=0;
- CCSStringList j;
- hbox = gtk_hbox_new(FALSE,2);
- SETOptionWidgets * widgets = o->privatePtr;
- fram = gtk_frame_new(o->shortDesc);
- gtk_box_pack_start(GTK_BOX(w->widget),fram,FALSE,FALSE,0);
- gtk_container_add(GTK_CONTAINER(fram),hbox);
- gtk_box_pack_start(GTK_BOX(hbox),make_info_button(o),FALSE,FALSE,0);
- vbox = gtk_vbox_new(FALSE,2);
- gtk_box_pack_start(GTK_BOX(hbox),vbox,TRUE,TRUE,0);
- tabl=gtk_table_new(OPT_PER_LINE,1,TRUE);
- gtk_box_pack_start(GTK_BOX(vbox),tabl,FALSE,FALSE,0);
- i=0;
- widgets->l=malloc(sizeof(GtkWidget *)*ccsStringListLength(o->info.forList.listInfo->forString.allowedValues));
- for (j=o->info.forList.listInfo->forString.allowedValues;j;j=j->next)
- {
- GtkWidget * cbut;
- if (i%OPT_PER_LINE==0)
- {
- l++;
- c=0;
- }
- else
- c++;
- cbut = gtk_check_button_new_with_label(j->data);
- gtk_table_attach_defaults(GTK_TABLE(tabl),cbut,c,c+1,l,l+1);
- widgets->l[i]=cbut;
- g_signal_connect(cbut,"toggled",G_CALLBACK(cb_option),o);
- i++;
- }
- set_widgets_for_setting(o);
- w->hasany=TRUE;
- }
-}
+
void cb_sl_edited(GtkWidget * w, gchar * treepath, gchar * value, CCSSetting * o)
{
GtkTreeIter it;
@@ -1313,8 +1187,7 @@ void cb_move_dn(GtkWidget * w, CCSSetting * o)
}
void do_if_string_list_group(CCSSetting * o, SETGroupWidget * w)
{
- if (o->type==TypeList && o->info.forList.listType==TypeString &&
- !o->info.forList.listInfo->forString.allowedValues)
+ if (o->type==TypeList && o->info.forList.listType==TypeString)
{
GtkWidget * hbox;
GtkCellRenderer * celr;
@@ -1410,8 +1283,6 @@ void do_if_non_file_string_list_group(CCSSetting * o, SETGroupWidget * w)
void do_if_choice_option_group(CCSSetting * o, SETGroupWidget * w)
{
do_if_toggle_group(o,w);
- do_if_string_choice_group(o,w);
- do_if_option_list_group(o,w);
do_if_bell_group(o,w);
}
void setup_actions(gchar * group)