diff options
author | jcid <devnull@localhost> | 2008-05-19 22:10:17 +0200 |
---|---|---|
committer | jcid <devnull@localhost> | 2008-05-19 22:10:17 +0200 |
commit | 30e06ecfe0aaa38cfaef24838226dffdca07a0ff (patch) | |
tree | a5e02057b675ec8da67fd71adefd9d887fcbc9f7 /src | |
parent | 3a2b767fe6db080dd68527d3fb1476aabd217de3 (diff) |
- Made CTRL-l focus the location bar instead of popping up a dialog.
Diffstat (limited to 'src')
-rw-r--r-- | src/ui.cc | 58 | ||||
-rw-r--r-- | src/ui.hh | 12 | ||||
-rw-r--r-- | src/uicmd.cc | 12 | ||||
-rw-r--r-- | src/uicmd.hh | 1 |
4 files changed, 54 insertions, 29 deletions
@@ -55,11 +55,16 @@ public: int NewInput::handle(int e) { int k = event_key(); - bool ctrl = event_state(CTRL); _MSG("NewInput::handle event=%d\n", e); - if (ctrl && (k == 'o' || k == 'r' || k == HomeKey || k == EndKey)) - return 0; + if (event_state(CTRL)) { + if (e == KEY && k == 'l') { + // Trick to make text selected when already focused. + throw_focus(); take_focus(); + return 0; + } else if (k == 'o' || k == 'r' || k == HomeKey || k == EndKey) + return 0; + } if ((e == KEY || e == KEYUP) && k == UpKey || k == DownKey || k == PageUpKey || k == PageDownKey) { _MSG(" {Up|Down|PgUp|PgDn} ret = 1\n"); @@ -203,6 +208,7 @@ static void color_change_cb(Widget *wid, void *data) static void location_cb(Widget *wid, void *data) { Input *i = (Input*)wid; + UI *ui = (UI*)i->window(); /* This test is necessary because WHEN_ENTER_KEY also includes * other events we're not interested in. For instance pressing @@ -211,6 +217,9 @@ static void location_cb(Widget *wid, void *data) if (event_key() == ReturnKey) { a_UIcmd_open_urlstr(i->window()->user_data(), i->value()); } + if (ui->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) { + ui->set_panelmode(UI_HIDDEN); + } } @@ -275,7 +284,9 @@ static void b1_cb(Widget *wid, void *cb_data) */ static void fullscreen_cb(Widget *wid, void *data) { - ((UI*)data)->fullscreen_cb_i(); + /* todo: do we want to toggle fullscreen or panelmode? + maybe we need to add another button?*/ + ((UI*)data)->panelmode_cb_i(); } /* @@ -588,14 +599,14 @@ UI::UI(int win_w, int win_h, const char* label, const UI *cur_ui) : PanelSize = cur_ui->PanelSize; CuteColor = cur_ui->CuteColor; Small_Icons = cur_ui->Small_Icons; - Fullscreen = cur_ui->Fullscreen; + Panelmode = cur_ui->Panelmode; } else { // Set some default values //PanelSize = P_tiny, CuteColor = 26, Small_Icons = 0; PanelSize = prefs.panel_size; Small_Icons = prefs.small_icons; CuteColor = 206; - Fullscreen = prefs.fullwindow_start; + Panelmode = (UIPanelmode) prefs.fullwindow_start; } @@ -675,7 +686,7 @@ UI::UI(int win_w, int win_h, const char* label, const UI *cur_ui) : customize(0); - if (Fullscreen) { + if (Panelmode) { Panel->hide(); StatusPanel->hide(); } @@ -711,7 +722,10 @@ int UI::handle(int event) a_UIcmd_findtext_dialog((BrowserWindow*) user_data()); ret = 1; } else if (k == 'l') { - a_UIcmd_open_url_dialog(user_data()); + if (Panelmode == UI_HIDDEN) { + set_panelmode(UI_TEMPORARILY_SHOW_PANELS); + } + focus_location(); ret = 1; } else if (k == 'n') { a_UIcmd_browser_window_new(w(), h(), this); @@ -729,7 +743,7 @@ int UI::handle(int event) a_UIcmd_search_dialog(user_data()); ret = 1; } else if (k == ' ') { - fullscreen_cb_i(); + panelmode_cb_i(); ret = 1; } } @@ -930,19 +944,35 @@ void UI::color_change_cb_i() } /* - * Toggle the Control Panel out of the way + * Set or remove the Panelmode flag and update the UI accordingly */ -void UI::fullscreen_cb_i() +void UI::set_panelmode(UIPanelmode mode) { - if (!Fullscreen) { + if (mode == UI_HIDDEN) { Panel->hide(); StatusPanel->hide(); - Fullscreen = true; } else { + /* UI_NORMAL or UI_TEMPORARILY_SHOW_PANELS */ Panel->show(); StatusPanel->show(); - Fullscreen = false; } + Panelmode = mode; +} + +/* + * Get the value of the panelmode flag + */ +UIPanelmode UI::get_panelmode() +{ + return Panelmode; +} + +/* + * Toggle the Control Panel out of the way + */ +void UI::panelmode_cb_i() +{ + set_panelmode((UIPanelmode) !Panelmode); } /* @@ -25,6 +25,12 @@ typedef enum { UI_SEARCH } UIButton; +typedef enum { + UI_NORMAL = 0, /* make sure it's compatible with bool */ + UI_HIDDEN = 1, + UI_TEMPORARILY_SHOW_PANELS +} UIPanelmode; + // Private class class NewProgressBox; @@ -50,7 +56,7 @@ class UI : public fltk::Window { int PanelSize, CuteColor, Small_Icons; int xpos, bw, bh, fh, lh, lbl; - bool Fullscreen; + UIPanelmode Panelmode; PackedGroup *make_toolbar(int tw, int th); PackedGroup *make_location(); @@ -79,6 +85,8 @@ public: void customize(int flags); void button_set_sens(UIButton btn, int sens); void paste_url(); + void set_panelmode(UIPanelmode mode); + UIPanelmode get_panelmode(); Widget *fullscreen_button() { return FullScreen; } void fullscreen_toggle() { FullScreen->do_callback(); } @@ -87,7 +95,7 @@ public: void panel_cb_i(); void color_change_cb_i(); void toggle_cb_i(); - void fullscreen_cb_i(); + void panelmode_cb_i(); void imageload_toggle(); }; diff --git a/src/uicmd.cc b/src/uicmd.cc index f3da2d0a..aef6ea55 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -356,18 +356,6 @@ void a_UIcmd_open_file(void *vbw) } /* - * Get an URL from a dialog and open it - */ -void a_UIcmd_open_url_dialog(void *vbw) -{ - const char *urlstr; - - if ((urlstr = a_Dialog_input("Please enter a URL:"))) { - a_UIcmd_open_urlstr(vbw, urlstr); - } -} - -/* * Returns a newly allocated string holding a search url generated from * a string of keywords (separarated by blanks) and prefs.search_url. * The search string is urlencoded. diff --git a/src/uicmd.hh b/src/uicmd.hh index 1378367c..ab2acaf1 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -23,7 +23,6 @@ void a_UIcmd_stop(void *vbw); void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url); void a_UIcmd_open_file(void *vbw); const char *a_UIcmd_select_file(); -void a_UIcmd_open_url_dialog(void *vbw); void a_UIcmd_search_dialog(void *vbw); void a_UIcmd_book(void *vbw); void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url); |