aboutsummaryrefslogtreecommitdiff
path: root/src/dialog.cc
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2011-07-24 13:47:24 -0400
committerJorge Arellano Cid <jcid@dillo.org>2011-07-24 13:47:24 -0400
commit378a4098e362794b4feb3d75e40b6ada697c47e9 (patch)
treea0e7e1dd5ed6790227e0f98cf7e17021cb089277 /src/dialog.cc
parent58d8a78e4c89ba7609cb16ba8b4462235137fd58 (diff)
Added multiple search engines (with several 'search_url' lines in dillorc)
This patch adds the PREFS_STRINGS type to the prefsparser, which allows having multiple different strings asociated with one dillorc option (stored in a list)
Diffstat (limited to 'src/dialog.cc')
-rw-r--r--src/dialog.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/dialog.cc b/src/dialog.cc
index 9b3f8db2..7bde3dd2 100644
--- a/src/dialog.cc
+++ b/src/dialog.cc
@@ -22,6 +22,8 @@
#include <FL/Fl_Output.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Secret_Input.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Menu_Item.H>
#include "msg.h"
#include "dialog.hh"
@@ -75,6 +77,24 @@ int CustInput3::handle(int e)
}
return Fl_Input::handle(e);
}
+
+/*
+ * Used to make the ENTER key activate the CustChoice
+ */
+class CustChoice : public Fl_Choice {
+public:
+ CustChoice (int x, int y, int w, int h, const char* l=0) :
+ Fl_Choice(x,y,w,h,l) {};
+ int handle(int e) {
+ if (e == FL_KEYBOARD && Fl::event_key() == FL_Enter &&
+ (Fl::event_state() & (FL_SHIFT|FL_CTRL|FL_ALT|FL_META)) == 0) {
+ MSG("CustChoice: ENTER\n");
+ return Fl_Choice::handle(FL_PUSH);
+ }
+ return Fl_Choice::handle(e);
+ };
+};
+
//----------------------------------------------------------------------------
@@ -104,6 +124,7 @@ static void input_cb(Fl_Widget *button, void *number)
*/
const char *a_Dialog_input(const char *msg)
{
+ static Fl_Menu_Item *pm = 0;
int ww = 450, wh = 130, gap = 10, ih = 60, bw = 80, bh = 30;
input_answer = 0;
@@ -134,6 +155,26 @@ const char *a_Dialog_input(const char *msg)
c_inp->labelsize(14);
c_inp->textsize(14);
+ CustChoice *ch = new CustChoice(1*gap,ih+3*gap,180,24);
+ if (!pm) {
+ int n_it = dList_length(prefs.search_urls);
+ pm = new Fl_Menu_Item[n_it+1];
+ memset(pm, '\0', sizeof(Fl_Menu_Item[n_it+1]));
+ for (int i = 0; i < n_it; i++) {
+ char *p, *q, label[32];
+ char *url = (char *)dList_nth_data(prefs.search_urls, i);
+ if ((p = strstr(url, "//")) && (q = strstr(p+2,"/"))) {
+ strncpy(label,p+2,MIN(q-p-2,31));
+ label[MIN(q-p-2,31)] = 0;
+ }
+ pm[i].label(FL_NORMAL_LABEL, strdup(label));
+ }
+ }
+ ch->tooltip("Select search engine");
+ ch->menu(pm);
+ ch->value(prefs.search_url_idx);
+ ch->textcolor(FL_DARK_BLUE);
+
int xpos = ww-2*(gap+bw), ypos = ih+3*gap;
Fl_Return_Button *rb = new Fl_Return_Button(xpos, ypos, bw, bh, "OK");
rb->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
@@ -156,6 +197,8 @@ const char *a_Dialog_input(const char *msg)
/* we have a string, save it */
dFree(input_str);
input_str = dStrdup(c_inp->value());
+ MSG("a_Dialog_input value() = %d\n", ch->value());
+ prefs.search_url_idx = ch->value();
}
delete window;