From: Fredrik Tolf Date: Sun, 14 Oct 2007 00:35:25 +0000 (+0200) Subject: Change dolconf-wnd to normal dialog semantics. X-Git-Tag: 1.0~15 X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=5668485ca093b3ae72eccca01fcfe06fbe338dae;p=doldaconnect.git Change dolconf-wnd to normal dialog semantics. --- diff --git a/config/util/dolconf-wnd.desc b/config/util/dolconf-wnd.desc index 8e7a55c..386d055 100644 --- a/config/util/dolconf-wnd.desc +++ b/config/util/dolconf-wnd.desc @@ -3,15 +3,15 @@ ;hasaccels: y :wnd name: wnd title: "Dolda Connect configurator" var: y sig(delete_event): astcancel :vbox - :menubar - :menuitem label: _Main - :menu - $smenuitem name: save stock: SAVE sig: activate - $menuitem name: hup label: "_Apply settings now" sig: activate accel: "CONTROL+A" - $smenuitem name: quit stock: QUIT sig: activate - end - end - end +# :menubar +# :menuitem label: _Main +# :menu +# $smenuitem name: save stock: SAVE sig: activate +# $menuitem name: hup label: "_Apply settings now" sig: activate accel: "CONTROL+A" +# $smenuitem name: quit stock: QUIT sig: activate +# end +# end +# end :notebook pos: LEFT fill: y expand: y :table rows: 4 cols: 2 nblabel: "_Published info" $mlbl label: "Screen _name" mwidget: nick tx: 0 ty: 0 @@ -60,5 +60,10 @@ end end end + :hbtnbox layout: END + $sbtn name: ok stock: OK sig: activate + $sbtn name: cancel stock: CANCEL sig: activate accel: Escape + $sbtn name: apply stock: APPLY sig: activate + end end end diff --git a/config/util/dolconf.c b/config/util/dolconf.c index 75d89c7..52cffe1 100644 --- a/config/util/dolconf.c +++ b/config/util/dolconf.c @@ -346,7 +346,7 @@ int readconfig(void) return(rv); } -void writeconfig(void) +int writeconfig(void) { FILE *cf; struct cfvar *var; @@ -355,7 +355,7 @@ void writeconfig(void) if((cf = fopen(cfname, "w")) == NULL) { msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Could not open the configuration file for writing: %s"), strerror(errno)); - return; + return(-1); } fputs("# This file was generated by dolconf v" VERSION "\n\n", cf); for(var = config; var->name != NULL; var++) { @@ -394,6 +394,7 @@ void writeconfig(void) } fclose(cf); dirty = 0; + return(0); } void fillcfw(void) @@ -704,27 +705,52 @@ void cb_cfw_uinet_toggled(GtkWidget *widget, gpointer uudata) gtk_widget_set_sensitive(GTK_WIDGET(cfw_uibox), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))); } -void cb_cfw_hup_activate(GtkWidget *widget, gpointer uudata) +int hupserver(int disperr) { - int tag; + int tag, ret; struct dc_response *resp; if(dc_connectsync2(dc_srv_local, DC_LATEST) < 0) { - msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not connect to server")); - return; + if(disperr) + msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not connect to server")); + return(-1); } if(dc_login(NULL, 1, dc_convnone, NULL) != DC_LOGIN_ERR_SUCCESS) { dc_disconnect(); - msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not connect to server")); - return; + if(disperr) + msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not connect to server")); + return(-1); } + ret = 0; tag = dc_queuecmd(NULL, NULL, L"hup", NULL); if((resp = dc_gettaggedrespsync(tag)) != NULL) { - if(resp->code != 200) - msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not connect to server")); + if(resp->code != 200) { + if(disperr) + msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not connect to server")); + ret = -1; + } dc_freeresp(resp); } dc_disconnect(); + return(ret); +} + +int saveconfig(void) +{ + struct cfvar *cv; + + if((cv = cfwvalid()) != NULL) { + msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, cv->vld->invmsg, cv->rname); + return(-1); + } + cfw2conf(); + return(writeconfig()); +} + +/* +void cb_cfw_hup_activate(GtkWidget *widget, gpointer uudata) +{ + hupserver(1); } void cb_cfw_save_activate(GtkWidget *widget, gpointer uudata) @@ -749,6 +775,29 @@ void cb_cfw_quit_activate(GtkWidget *widget, gpointer uudata) gtk_main_quit(); state = -1; } +*/ + +void cb_cfw_ok_activate(GtkWidget *widget, gpointer uudata) +{ + if(saveconfig()) + return; + hupserver(0); + gtk_main_quit(); + state = -1; +} + +void cb_cfw_cancel_activate(GtkWidget *widget, gpointer uudata) +{ + gtk_main_quit(); + state = -1; +} + +void cb_cfw_apply_activate(GtkWidget *widget, gpointer uudata) +{ + if(saveconfig()) + return; + hupserver(1); +} int main(int argc, char **argv) {