summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/common/fe.h1
-rw-r--r--src/common/outbound.c31
-rw-r--r--src/fe-gtk/gtkutil.c51
-rw-r--r--src/fe-text/fe-text.c4
4 files changed, 87 insertions, 0 deletions
diff --git a/src/common/fe.h b/src/common/fe.h
index b67329ec..2ca15c60 100644
--- a/src/common/fe.h
+++ b/src/common/fe.h
@@ -122,6 +122,7 @@ void fe_set_lag (server *serv, long lag);
 void fe_set_throttle (server *serv);
 void fe_set_away (server *serv);
 void fe_serverlist_open (session *sess);
+void fe_get_bool (char *title, char *prompt, void *callback, void *userdata);
 void fe_get_str (char *prompt, char *def, void *callback, void *ud);
 void fe_get_int (char *prompt, int def, void *callback, void *ud);
 #define FRF_WRITE 1				/* save file */
diff --git a/src/common/outbound.c b/src/common/outbound.c
index d63f8532..db6b3d5b 100644
--- a/src/common/outbound.c
+++ b/src/common/outbound.c
@@ -1941,6 +1941,36 @@ typedef struct
 } getvalinfo;
 
 static void
+get_bool_cb (int val, getvalinfo *info)
+{
+	char buf[512];
+
+	snprintf (buf, sizeof (buf), "%s %d", info->cmd, val);
+	if (is_session (info->sess))
+		handle_command (info->sess, buf, FALSE);
+
+	free (info->cmd);
+	free (info);
+}
+
+static int
+cmd_getbool (struct session *sess, char *tbuf, char *word[], char *word_eol[])
+{
+	getvalinfo *info;
+
+	if (!word[4][0])
+		return FALSE;
+
+	info = malloc (sizeof (*info));
+	info->cmd = strdup (word[2]);
+	info->sess = sess;
+
+	fe_get_bool (word[3], word_eol[4], get_bool_cb, info);
+
+	return TRUE;
+}
+
+static void
 get_int_cb (int cancel, int val, getvalinfo *info)
 {
 	char buf[512];
@@ -3934,6 +3964,7 @@ const struct commands xc_cmds[] = {
 	 N_("FLUSHQ, flushes the current server's send queue")},
 	{"GATE", cmd_gate, 0, 0, 1,
 	 N_("GATE <host> [<port>], proxies through a host, port defaults to 23")},
+	{"GETBOOL", cmd_getbool, 0, 0, 1, "GETBOOL <command> <title> <text>"},
 	{"GETFILE", cmd_getfile, 0, 0, 1, "GETFILE [-folder] [-multi] [-save] <command> <title> [<initial>]"},
 	{"GETINT", cmd_getint, 0, 0, 1, "GETINT <default> <command> <prompt>"},
 	{"GETSTR", cmd_getstr, 0, 0, 1, "GETSTR <default> <command> <prompt>"},
diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c
index 282b952c..a6870253 100644
--- a/src/fe-gtk/gtkutil.c
+++ b/src/fe-gtk/gtkutil.c
@@ -374,6 +374,28 @@ gtkutil_get_number_response (GtkDialog *dialog, gint arg1, gpointer spin)
 	}
 }
 
+static void
+gtkutil_get_bool_response (GtkDialog *dialog, gint arg1, gpointer spin)
+{
+	void (*callback) (int value, void *user_data);
+	void *user_data;
+
+	callback = g_object_get_data (G_OBJECT (dialog), "cb");
+	user_data = g_object_get_data (G_OBJECT (dialog), "ud");
+
+	switch (arg1)
+	{
+	case GTK_RESPONSE_REJECT:
+		callback (0, user_data);
+		gtk_widget_destroy (GTK_WIDGET (dialog));
+		break;
+	case GTK_RESPONSE_ACCEPT:
+		callback (1, user_data);
+		gtk_widget_destroy (GTK_WIDGET (dialog));
+		break;
+	}
+}
+
 void
 fe_get_int (char *msg, int def, void *callback, void *userdata)
 {
@@ -417,6 +439,35 @@ fe_get_int (char *msg, int def, void *callback, void *userdata)
 	gtk_widget_show_all (dialog);
 }
 
+void
+fe_get_bool (char *title, char *prompt, void *callback, void *userdata)
+{
+	GtkWidget *dialog;
+	GtkWidget *prompt_label;
+	extern GtkWidget *parent_window;
+
+	dialog = gtk_dialog_new_with_buttons (title, NULL, 0,
+		GTK_STOCK_NO, GTK_RESPONSE_REJECT,
+		GTK_STOCK_YES, GTK_RESPONSE_ACCEPT,
+		NULL);
+	gtk_box_set_homogeneous (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), TRUE);
+	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent_window));
+
+
+	g_object_set_data (G_OBJECT (dialog), "cb", callback);
+	g_object_set_data (G_OBJECT (dialog), "ud", userdata);
+
+	prompt_label = gtk_label_new (prompt);
+
+	g_signal_connect (G_OBJECT (dialog), "response",
+		G_CALLBACK (gtkutil_get_bool_response), NULL);
+
+	gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), prompt_label);
+
+	gtk_widget_show_all (dialog);
+}
+
 GtkWidget *
 gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback,
 					 void *userdata, char *labeltext)
diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c
index 341272f4..c8b64ab0 100644
--- a/src/fe-text/fe-text.c
+++ b/src/fe-text/fe-text.c
@@ -818,6 +818,10 @@ fe_serverlist_open (session *sess)
 {
 }
 void
+fe_get_bool (char *title, char *prompt, void *callback, void *userdata)
+{
+}
+void
 fe_get_str (char *prompt, char *def, void *callback, void *ud)
 {
 }