00001
00016 #define GITK_LIB_C
00017 #define GITK_WIDGET_C
00018
00019 #include "gitkincludes.h"
00020
00031 void gitk__widget_set_value(GitkDialogPtr const dialog,GitkDialogAccessType access_type,gchar * const widget_id,const gchar * const name,const gchar * const data) {
00032 GitkEvent event;
00033
00034 g_assert(dialog);
00035 g_assert(widget_id);
00036 g_assert(name);
00037
00038
00039
00040 gitk_dialog_set_content(dialog,access_type,NULL,gitk_get_widget_child_xpath_expression(widget_id,name),data);
00041
00042
00043 event.type=GITK_EVENT_TYPE_ON_CHANGED;
00044 event.data=NULL;
00045 gitk_dialog_process_event(dialog,widget_id,&event);
00046
00047
00048 }
00049
00061 gchar *gitk__widget_get_value(GitkDialogPtr const dialog,GitkDialogAccessType access_type,gchar * const widget_id,const gchar * const name) {
00062 xmlNodePtr widget,cur;
00063 gchar *value=NULL;
00064
00065 g_assert(dialog);
00066 g_assert(widget_id);
00067 g_assert(name);
00068
00069 gitk_log2("gitk_widget_get_value(\"%s\",\"%s\")",widget_id,name);
00070
00071 if((widget=gitk__dialog_get_widget(dialog,access_type,widget_id))!=NULL) {
00072 if((cur=widget->children)!=NULL) {
00073 while(cur) {
00074
00075 if(!xmlNodeIsText(cur) && !strcasecmp(cur->name,name)) {
00076 value=xmlNodeGetContent(cur);
00077 gitk_log3("gitk_widget_get_value(\"%s\",\"%s\")=\"%s\"",widget_id,name,gitk_save_get_string(value));
00078 break;
00079 }
00080 cur=cur->next;
00081 }
00082 }
00083 else gitk_log2("gitk_widget_get_value(\"%s\",\"%s\") has no children",widget_id,name);
00084 }
00085 else gitk_log2("gitk_widget_get_value(\"%s\",\"%s\") not found",widget_id,name);
00086 return(value);
00087 }
00088
00094 GitkWidgetType gitk_widget_get_type(xmlNodePtr widget) {
00095 xmlChar *attr;
00096 GitkWidgetType type=GITK_WIDGET_TYPE_UNDEF;
00097
00098 if((attr=xmlGetProp(widget,"type"))) {
00100 if(!strncmp(attr,"action\0",7)) {
00101 type=GITK_WIDGET_TYPE_ACTION;
00102 }
00103 else if(!strncmp(attr,"characterinput_",15) || !strncmp(attr,"characterinput\0",15)) {
00104 type=GITK_WIDGET_TYPE_CHARACTERINPUT;
00105 if(attr[14] && !strncmp(&attr[15],"alpahbetic",10)) type=GITK_WIDGET_TYPE_CHARACTERINPUT_ALPHABETIC;
00106 }
00107 else if(!strncmp(attr,"optionchoice_",13) || !strncmp(attr,"optionchoice\0",13)) {
00108 type=GITK_WIDGET_TYPE_OPTIONCHOICE;
00109 if(attr[12] && (!strncmp(&attr[13],"boolean",7))) {
00110 type=GITK_WIDGET_TYPE_OPTIONCHOICE_BOOLEAN;
00111 }
00112 if(attr[12] && (!strncmp(&attr[13],"single_",7) || !strncmp(&attr[13],"single\0",7))) {
00113 type=GITK_WIDGET_TYPE_OPTIONCHOICE_SINGLE;
00114 if(attr[19] && (!strncmp(&attr[20],"compact",7))) type=GITK_WIDGET_TYPE_OPTIONCHOICE_SINGLE_COMPACT;
00115 }
00116 }
00117 else if(!strncmp(attr,"label\0",6)) {
00118 type=GITK_WIDGET_TYPE_LABEL;
00119 }
00120
00121 xmlFree(attr);
00122 }
00123 return(type);
00124 }