aboutsummaryrefslogtreecommitdiff
path: root/src/dialog.cc
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2011-07-24 13:47:25 -0400
committerJorge Arellano Cid <jcid@dillo.org>2011-07-24 13:47:25 -0400
commita748ecd3ed4b9f620f6b3b911a23f689902cdffd (patch)
tree7431c26b0de72ac9d768cf3652bca0f217e64951 /src/dialog.cc
parent378a4098e362794b4feb3d75e40b6ada697c47e9 (diff)
Added an optional label to dillorc's search_url. Format: "[<label> ]<url>"
Diffstat (limited to 'src/dialog.cc')
-rw-r--r--src/dialog.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/dialog.cc b/src/dialog.cc
index 7bde3dd2..85121c63 100644
--- a/src/dialog.cc
+++ b/src/dialog.cc
@@ -86,7 +86,8 @@ 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 &&
+ if (e == FL_KEYBOARD &&
+ (Fl::event_key() == FL_Enter || Fl::event_key() == FL_Down) &&
(Fl::event_state() & (FL_SHIFT|FL_CTRL|FL_ALT|FL_META)) == 0) {
MSG("CustChoice: ENTER\n");
return Fl_Choice::handle(FL_PUSH);
@@ -160,14 +161,12 @@ const char *a_Dialog_input(const char *msg)
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));
+ for (int i = 0, j = 0; i < n_it; i++) {
+ char *label, *url, *source;
+ source = (char *)dList_nth_data(prefs.search_urls, i);
+ if (a_Misc_parse_search_url(source, &label, &url) < 0)
+ continue;
+ pm[j++].label(FL_NORMAL_LABEL, strdup(label));
}
}
ch->tooltip("Select search engine");