;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
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
return(rv);
}
-void writeconfig(void)
+int writeconfig(void)
{
FILE *cf;
struct cfvar *var;
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++) {
}
fclose(cf);
dirty = 0;
+ return(0);
}
void fillcfw(void)
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)
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)
{