annotate src/uicmd.cc @ 2012:bfb8bc9ddf62

Avoid lots of flicker while resizing the window (when "buffered_drawing" is set to 0 or 1)
author Jorge Arellano Cid <jcid@dillo.org>
date Fri, 13 May 2011 14:14:43 -0400
parents a204cc949c1a
children f542084fa707
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * File: uicmd.cc
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 *
35
d9e7b35430de Updated copyright lines
jcid
parents: 27
diff changeset
4 * Copyright (C) 2005-2007 Jorge Arellano Cid <jcid@dillo.org>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 * the Free Software Foundation; either version 3 of the License, or
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 * (at your option) any later version.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 // Functions/Methods for commands triggered from the UI
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15 #include <stdio.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16 #include <stdarg.h>
27
52953eeba59d Hooked vertical scrolling to the mouse wheel.
jcid
parents: 22
diff changeset
17 #include <math.h> /* for rint */
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
18
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
19 #include <FL/Fl.H>
1814
e68d4792c2fa some uicmd
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
20 #include <FL/Fl_Widget.H>
1824
78ff21c985f0 more uicmd
corvid <corvid@lavabit.com>
parents: 1814
diff changeset
21 #include <FL/Fl_Double_Window.H>
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
22 #include <FL/Fl_Wizard.H>
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
23 #include <FL/Fl_Box.H>
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1926
diff changeset
24 #include <FL/names.h>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25
1053
64e078b7a711 Refactor the preferences parser
Tim Nieradzik, Jorge Arellano Cid
parents: 1037
diff changeset
26 #include "paths.hh"
1209
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
27 #include "keys.hh"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 #include "ui.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 #include "uicmd.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 #include "timeout.hh"
1126
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
31 #include "utf8.hh"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32 #include "menu.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 #include "dialog.hh"
1109
39febe63d2c9 add support for --xid command line option
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1101
diff changeset
34 #include "xembed.hh"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 #include "bookmark.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 #include "history.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 #include "msg.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 #include "prefs.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 #include "dw/fltkviewport.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 #include "nav.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43
433
jcid
parents: 404
diff changeset
44 #define DEFAULT_TAB_LABEL "Dillo"
jcid
parents: 404
diff changeset
45
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
46 // Handy macro
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
47 #define BW2UI(bw) ((UI*)((bw)->ui))
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
48
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 // Platform idependent part
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 using namespace dw::core;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 // FLTK related
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 using namespace dw::fltk;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56 * Local data
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58 static char *save_dir = NULL;
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1926
diff changeset
59 static UI *Gui;
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
60
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
61 /*
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
62 * Forward declarations
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
63 */
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
64 static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus);
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
65
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
66 //----------------------------------------------------------------------------
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
67
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
68 /*
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
69 * CustTabs ---------------------------------------------------------------
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
70 */
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
71
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
72 /*
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
73 * stores the respective UI pointer
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
74 */
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
75 class CustTabButton : public Fl_Button {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
76 UI *ui_;
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
77 public:
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
78 CustTabButton (int x,int y,int w,int h, const char* label = 0) :
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
79 Fl_Button (x,y,w,h,label) { ui_ = NULL; };
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
80 void ui(UI *pui) { ui_ = pui; }
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
81 UI *ui(void) { return ui_; }
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
82 };
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
83
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
84 /*
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
85 * Allows fine control of the tabbed interface
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
86 */
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
87 class CustTabs : public CustGroup {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
88 int tab_w, tab_h, tab_n;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
89 Fl_Wizard *Wizard;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
90 int tabcolor_inactive, tabcolor_active, curtab_idx;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
91 public:
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
92 CustTabs (int ww, int wh, int th, const char *lbl=0) :
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
93 CustGroup(0,0,ww,th,lbl) {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
94 tab_w = 80, tab_h = th, tab_n = 0, curtab_idx = -1;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
95 tabcolor_active = FL_DARK_CYAN; tabcolor_inactive = 206;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
96 Fl_Box *w = new Fl_Box(0,0,0,0,"i n v i s i b l e");
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
97 w->box(FL_NO_BOX);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
98 resizable(0);
2012
bfb8bc9ddf62 Avoid lots of flicker while resizing the window
Jorge Arellano Cid <jcid@dillo.org>
parents: 1991
diff changeset
99 box(FL_FLAT_BOX);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
100 end();
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
101
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
102 Wizard = new Fl_Wizard(0,tab_h,ww,wh-tab_h);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
103 Wizard->end();
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
104 };
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
105 int handle(int e);
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
106 UI *add_new_tab(UI *old_ui, int focus);
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
107 void remove_tab(UI *ui);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
108 Fl_Wizard *wizard(void) { return Wizard; }
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
109 int get_btn_idx(UI *ui);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
110 int num_tabs() { return (children() - 1); } // substract invisible box
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
111 void switch_tab(CustTabButton *cbtn);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
112 void prev_tab(void);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
113 void next_tab(void);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
114
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
115 void set_tab_label(UI *ui, const char *title);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
116 };
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
117
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
118 /*
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
119 * Callback for mouse click
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
120 */
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
121 static void tab_btn_cb (Fl_Widget *w, void *cb_data)
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
122 {
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
123 CustTabButton *btn = (CustTabButton*) w;
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
124 CustTabs *tabs = (CustTabs*) cb_data;
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
125 int b = Fl::event_button();
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
126
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
127 if (b == FL_LEFT_MOUSE) {
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
128 tabs->switch_tab(btn);
1991
a204cc949c1a Set middle click as default for close tab (+ right_click_closes_tab in dillorc)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1990
diff changeset
129 } else if ((b == FL_RIGHT_MOUSE && prefs.right_click_closes_tab) ||
a204cc949c1a Set middle click as default for close tab (+ right_click_closes_tab in dillorc)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1990
diff changeset
130 (b == FL_MIDDLE_MOUSE && !prefs.right_click_closes_tab)) {
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
131 // TODO: just an example, not necessarily final
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
132 a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(btn->ui()));
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
133 }
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
134 }
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
135
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
136 int CustTabs::handle(int e)
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
137 {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
138 int ret = 0;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
139
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
140 _MSG("CustTabs::handle e=%s\n", fl_eventnames[e]);
1930
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
141 if (e == FL_KEYBOARD) {
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
142 return 0; // Receive as shortcut
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
143 } else if (e == FL_SHORTCUT) {
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
144 UI *ui = (UI*)wizard()->value();
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
145 BrowserWindow *bw = a_UIcmd_get_bw_by_widget(ui);
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
146 KeysCommand_t cmd = Keys::getKeyCmd();
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
147 if (Fl::event_key() == FL_Escape) {
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
148 // Hide findbar if present
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
149 ui->findbar_toggle(0);
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
150 ret = 1;
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
151 } else if (cmd == KEYS_NOP) {
1930
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
152 // Do nothing
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
153 } else if (cmd == KEYS_NEW_TAB) {
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
154 a_UIcmd_open_url_nt(bw, NULL, 1);
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
155 ret = 1;
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
156 } else if (cmd == KEYS_CLOSE_TAB) {
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
157 a_UIcmd_close_bw(bw);
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
158 ret = 1;
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
159 } else if (cmd == KEYS_LEFT_TAB) {
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
160 MSG("CustTabs::handle KEYS_LEFT_TAB\n");
1930
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
161 ret = 1;
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
162 } else if (cmd == KEYS_RIGHT_TAB) {
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
163 MSG("CustTabs::handle KEYS_RIGHT_TAB\n");
1930
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
164 ret = 1;
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
165 } else if (cmd == KEYS_NEW_WINDOW) {
1957
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
166 a_UIcmd_open_url_nw(bw, NULL);
1930
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
167 ret = 1;
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
168 } else if (cmd == KEYS_FULLSCREEN) {
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
169 MSG("CustTabs::handle KEYS_FULLSCREEN\n");
1930
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
170 ret = 1;
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
171 } else if (cmd == KEYS_CLOSE_ALL) {
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
172 a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL);
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
173 ret = 1;
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
174 }
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
175
49dda3dfbcad Moved some keyboard events from class UI to class CustTabs (where they belong)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1929
diff changeset
176 } else if (e == FL_KEYUP) {
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
177 int k = Fl::event_key();
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
178 // We're only interested in some flags
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
179 unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
180 if (k == FL_Up || k == FL_Down || k == FL_Tab) {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
181 ;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
182 } else if (k == FL_Left || k == FL_Right) {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
183 if (modifier == FL_SHIFT) {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
184 (k == FL_Left) ? prev_tab() : next_tab();
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
185 ret = 1;
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
186 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
187 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
188 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
189
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
190 return (ret) ? ret : CustGroup::handle(e);
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
191 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
192
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
193 /*
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
194 * Create a new tab with its own UI
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
195 */
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
196 UI *CustTabs::add_new_tab(UI *old_ui, int focus)
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
197 {
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
198 char tab_label[64];
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
199
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
200 current(0);
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
201 UI *new_ui = new UI(0,tab_h,Wizard->w(),Wizard->h(),0,old_ui);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
202 new_ui->tabs(this);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
203 Wizard->add(new_ui);
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1926
diff changeset
204 new_ui->show();
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
205
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
206 snprintf(tab_label, 64,"ctab%d", ++tab_n);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
207 CustTabButton *btn = new CustTabButton(num_tabs()*tab_w,0,tab_w,tab_h);
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
208 btn->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
209 btn->copy_label(tab_label);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
210 btn->clear_visible_focus();
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
211 btn->box(FL_PLASTIC_ROUND_UP_BOX);
1979
f10139946f43 Reenabled "focus_new_tab" dillorc pref (also SHIFT-middleclick to revert)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1957
diff changeset
212 btn->color(focus ? tabcolor_active : tabcolor_inactive);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
213 btn->ui(new_ui);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
214 add(btn);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
215 btn->redraw();
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
216 btn->callback(tab_btn_cb, this);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
217
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
218 if (focus)
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
219 switch_tab(btn);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
220 rearrange();
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
221
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
222 return new_ui;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
223 }
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
224
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
225 /*
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
226 * Remove tab by UI
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
227 */
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
228 void CustTabs::remove_tab(UI *ui)
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
229 {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
230 CustTabButton *btn;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
231
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
232 // remove label button
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
233 int idx = get_btn_idx(ui);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
234 btn = (CustTabButton*)child(idx);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
235 idx > 1 ? prev_tab() : next_tab();
1956
76ed17497099 Fix for redraw problem when closing a non-focused tab (with tabs=2)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1951
diff changeset
236
76ed17497099 Fix for redraw problem when closing a non-focused tab (with tabs=2)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1951
diff changeset
237 // WORKAROUND: with two tabs, closing the non-focused one, doesn't
76ed17497099 Fix for redraw problem when closing a non-focused tab (with tabs=2)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1951
diff changeset
238 // delete it from screen. This hide() call makes it work. --Jcid
76ed17497099 Fix for redraw problem when closing a non-focused tab (with tabs=2)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1951
diff changeset
239 btn->hide();
76ed17497099 Fix for redraw problem when closing a non-focused tab (with tabs=2)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1951
diff changeset
240
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
241 remove(idx);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
242 delete btn;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
243 rearrange();
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
244 redraw();
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
245
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
246 Wizard->remove(ui);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
247 delete(ui);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
248
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
249 if (num_tabs() == 0) {
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
250 window()->hide();
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
251 // TODO: free memory
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
252 //delete window();
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
253 }
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
254 }
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
255
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
256 int CustTabs::get_btn_idx(UI *ui)
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
257 {
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
258 for (int i = 1; i <= num_tabs(); ++i) {
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
259 CustTabButton *btn = (CustTabButton*)child(i);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
260 if (btn->ui() == ui)
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
261 return i;
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
262 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
263 return -1;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
264 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
265
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
266 void CustTabs::switch_tab(CustTabButton *cbtn)
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
267 {
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
268 int idx;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
269 CustTabButton *btn;
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
270 UI *old_ui = (UI*)Wizard->value();
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
271
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
272 if (cbtn->ui() != old_ui) {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
273 // Set old tab label to normal color
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
274 if ((idx = get_btn_idx(old_ui)) > 0) {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
275 btn = (CustTabButton*)child(idx);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
276 btn->color(tabcolor_inactive);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
277 btn->redraw();
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
278 }
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
279 Wizard->value(cbtn->ui());
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
280 cbtn->color(tabcolor_active);
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
281 cbtn->redraw();
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
282 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
283 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
284
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
285 void CustTabs::prev_tab()
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
286 {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
287 int idx;
1824
78ff21c985f0 more uicmd
corvid <corvid@lavabit.com>
parents: 1814
diff changeset
288
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
289 if ((idx = get_btn_idx((UI*)Wizard->value())) > 1)
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
290 switch_tab( (CustTabButton*)child(idx-1) );
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
291 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
292
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
293 void CustTabs::next_tab()
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
294 {
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
295 int idx;
1265
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
296
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
297 if ((idx = get_btn_idx((UI*)Wizard->value())) > 0 && idx < num_tabs())
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
298 switch_tab( (CustTabButton*)child(idx+1) );
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
299 }
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
300
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
301 /*
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
302 * Set this UI's tab button label
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
303 */
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
304 void CustTabs::set_tab_label(UI *ui, const char *label)
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
305 {
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
306 char title[128];
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
307 int idx = get_btn_idx(ui);
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
308
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
309 if (idx > 0) {
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
310 // Make a label for this tab
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
311 size_t tab_chars = 7, label_len = strlen(label);
1824
78ff21c985f0 more uicmd
corvid <corvid@lavabit.com>
parents: 1814
diff changeset
312
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
313 if (label_len > tab_chars)
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
314 tab_chars = a_Utf8_end_of_char(label, tab_chars - 1) + 1;
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
315 snprintf(title, tab_chars + 1, "%s", label);
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
316 if (label_len > tab_chars)
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
317 snprintf(title + tab_chars, 4, "...");
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
318
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
319 // Avoid unnecessary redraws
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
320 if (strcmp(child(idx)->label(), title)) {
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
321 child(idx)->copy_label(title);
1881
b7031da564fe FL_NO_BOX for tabs when labels not shown
corvid <corvid@lavabit.com>
parents: 1875
diff changeset
322 }
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
323 }
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
324 }
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
325
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
326
942
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
327 //----------------------------------------------------------------------------
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
328
1814
e68d4792c2fa some uicmd
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
329 static void win_cb (Fl_Widget *w, void *cb_data) {
1923
ba6b0e2de53c choice5 part2 (minor fix)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1922
diff changeset
330 int choice = 1;
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
331 CustTabs *tabs = (CustTabs*) cb_data;
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
332
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
333 if (tabs->num_tabs() > 1)
1922
f6cae9de62ab imported patch choice5
Jorge Arellano Cid <jcid@dillo.org>
parents: 1898
diff changeset
334 choice = a_Dialog_choice5("Window contains more than one tab.",
1990
617bb6ada10d less wordy close dialog buttons
corvid <corvid@lavabit.com>
parents: 1988
diff changeset
335 "Close", "Cancel", NULL, NULL, NULL);
1912
d3689f044909 fl_choice does not behave like fltk::choice did
corvid <corvid@lavabit.com>
parents: 1911
diff changeset
336 if (choice == 1)
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
337 while (tabs->num_tabs())
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
338 a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->wizard()->value()));
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
339 }
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
340
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
341 /*
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
342 * Given a UI or UI child widget, return its bw.
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
343 */
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
344 BrowserWindow *a_UIcmd_get_bw_by_widget(void *v_wid)
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
345 {
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
346 BrowserWindow *bw;
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
347 for (int i = 0; i < a_Bw_num(); ++i) {
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
348 bw = a_Bw_get(i);
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
349 if (((UI*)bw->ui)->contains((Fl_Widget*)v_wid)) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
350 return bw;
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
351 }
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
352 }
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
353 return NULL;
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
354 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
355
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
356 /*
1790
45b10f359e51 keys and mouse buttons
corvid <corvid@lavabit.com>
parents: 1730
diff changeset
357 * FLTK regards SHIFT + {Left, Right} as navigation keys.
378
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
358 * Special handling is required to override it. Here we route
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
359 * these events directly to the recipient.
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
360 * TODO: focus is not remembered correctly.
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
361 */
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
362 void a_UIcmd_send_event_to_tabs_by_wid(int e, void *v_wid)
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
363 {
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
364 BrowserWindow *bw = a_UIcmd_get_bw_by_widget(v_wid);
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
365 UI *ui = (UI*)bw->ui;
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
366 if (ui->tabs())
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
367 ui->tabs()->handle(e);
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
368 }
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
369
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
370 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
371 * Create a new UI and its associated BrowserWindow data structure.
72
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 56
diff changeset
372 * Use style from v_ui. If non-NULL it must be of type UI*.
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
373 */
1149
d76ff9ca5658 line length
Jorge Arellano Cid <jcid@dillo.org>
parents: 1137
diff changeset
374 BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh,
d76ff9ca5658 line length
Jorge Arellano Cid <jcid@dillo.org>
parents: 1137
diff changeset
375 uint32_t xid, const void *vbw)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
376 {
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
377 BrowserWindow *old_bw = (BrowserWindow*)vbw;
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
378 BrowserWindow *new_bw = NULL;
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
379 UI *old_ui = old_bw ? BW2UI(old_bw) : NULL;
1814
e68d4792c2fa some uicmd
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
380 Fl_Window *win;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
381
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
382 if (ww <= 0 || wh <= 0) {
8
ab2998c07f18 enabled geometry in preferences
jcid
parents: 0
diff changeset
383 // Set default geometry from dillorc.
ab2998c07f18 enabled geometry in preferences
jcid
parents: 0
diff changeset
384 ww = prefs.width;
ab2998c07f18 enabled geometry in preferences
jcid
parents: 0
diff changeset
385 wh = prefs.height;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
386 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
387
1137
f10904ac58b4 more xembed work
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1126
diff changeset
388 if (xid)
f10904ac58b4 more xembed work
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1126
diff changeset
389 win = new Xembed(xid, ww, wh);
1824
78ff21c985f0 more uicmd
corvid <corvid@lavabit.com>
parents: 1814
diff changeset
390 else if (prefs.buffered_drawing != 2)
78ff21c985f0 more uicmd
corvid <corvid@lavabit.com>
parents: 1814
diff changeset
391 win = new Fl_Window(ww, wh);
1137
f10904ac58b4 more xembed work
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1126
diff changeset
392 else
1824
78ff21c985f0 more uicmd
corvid <corvid@lavabit.com>
parents: 1814
diff changeset
393 win = new Fl_Double_Window(ww, wh);
1109
39febe63d2c9 add support for --xid command line option
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1101
diff changeset
394
2012
bfb8bc9ddf62 Avoid lots of flicker while resizing the window
Jorge Arellano Cid <jcid@dillo.org>
parents: 1991
diff changeset
395 win->box(FL_NO_BOX);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
396 CustTabs *DilloTabs = new CustTabs(ww, wh, 16);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
397 win->end();
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
398
1979
f10139946f43 Reenabled "focus_new_tab" dillorc pref (also SHIFT-middleclick to revert)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1957
diff changeset
399 int focus = 1;
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
400 new_bw = UIcmd_tab_new(DilloTabs, old_ui, focus);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
401 win->resizable(Gui);
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
402 win->show();
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
403
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
404 if (old_bw == NULL && prefs.xpos >= 0 && prefs.ypos >= 0) {
91
950979eb5ead - Enabled the geometry offset part (dillorc2).
jcid
parents: 86
diff changeset
405 // position the first window according to preferences
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
406 DilloTabs->window()->position(prefs.xpos, prefs.ypos);
91
950979eb5ead - Enabled the geometry offset part (dillorc2).
jcid
parents: 86
diff changeset
407 }
950979eb5ead - Enabled the geometry offset part (dillorc2).
jcid
parents: 86
diff changeset
408
1571
d0cbd6d81205 Fix segfault when closing window from WM.
corvid <corvid@lavabit.com>
parents: 1570
diff changeset
409 win->callback(win_cb, DilloTabs);
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
410
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
411 return new_bw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
412 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
413
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
414 /*
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
415 * Create a new Tab button, UI and its associated BrowserWindow data
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
416 * structure.
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
417 */
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
418 static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus)
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
419 {
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
420 _MSG(" UIcmd_tab_new\n");
386
a8f7106d78ee - Workaround for TabGroup max 128 limit.
jcid
parents: 378
diff changeset
421
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
422 // Create and set the UI
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
423 UI *new_ui = tabs->add_new_tab(old_ui, focus);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
424 Gui = new_ui;
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
425
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
426 // Now create the Dw render layout and viewport
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
427 FltkPlatform *platform = new FltkPlatform ();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
428 Layout *layout = new Layout (platform);
1730
2c90a2e90866 call layout->setBgColor() from web.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1661
diff changeset
429 style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
2c90a2e90866 call layout->setBgColor() from web.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1661
diff changeset
430 layout->setBgColor (bgColor);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
431
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1942
diff changeset
432 // set_render_layout() sets the proper viewport size
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1942
diff changeset
433 FltkViewport *viewport = new FltkViewport (0, 0, 0, 1);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
434 viewport->setBufferedDrawing (prefs.buffered_drawing ? true : false);
86
c6cecbed4727 - Made TopGroup a PackedGroup, simplifying UI code and removing workarounds.
jcid
parents: 72
diff changeset
435 layout->attachView (viewport);
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1942
diff changeset
436 new_ui->set_render_layout(viewport);
1951
36e6563b8daa Assorted minor changes (see verbose log)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1948
diff changeset
437 viewport->setScrollStep((int) rint(28.0 * prefs.font_factor));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
438
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
439 // Now, create a new browser window structure
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
440 BrowserWindow *new_bw = a_Bw_new();
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
441
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
442 // Reference the UI from the bw
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
443 new_bw->ui = (void *)new_ui;
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
444 // Copy the layout pointer into the bw data
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
445 new_bw->render_layout = (void*)layout;
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
446
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
447 // WORKAROUND: see findbar_toggle()
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
448 new_ui->findbar_toggle(0);
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
449
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
450 return new_bw;
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
451 }
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
452
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
453 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
454 * Close one browser window
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
455 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
456 void a_UIcmd_close_bw(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
457 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
458 BrowserWindow *bw = (BrowserWindow *)vbw;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
459 UI *ui = BW2UI(bw);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
460 Layout *layout = (Layout*)bw->render_layout;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
461
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
462 MSG("a_UIcmd_close_bw\n");
1275
be3365808be1 s/Bw_Force/BW_Force/g
Jorge Arellano Cid <jcid@dillo.org>
parents: 1265
diff changeset
463 a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
464 delete(layout);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
465 if (ui->tabs()) {
1931
36cec2fa951a Made remove_tab() work for non-focused tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
466 ui->tabs()->remove_tab(ui);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
467 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
468 a_Bw_free(bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
469 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
470
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
471 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
472 * Close all the browser windows
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
473 */
392
966b9162527d - Made ALT+q work.
jcid
parents: 388
diff changeset
474 void a_UIcmd_close_all_bw(void *)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
475 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
476 BrowserWindow *bw;
1923
ba6b0e2de53c choice5 part2 (minor fix)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1922
diff changeset
477 int choice = 1;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
478
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
479 if (a_Bw_num() > 1)
1990
617bb6ada10d less wordy close dialog buttons
corvid <corvid@lavabit.com>
parents: 1988
diff changeset
480 choice = a_Dialog_choice5("More than one open tab or window.",
617bb6ada10d less wordy close dialog buttons
corvid <corvid@lavabit.com>
parents: 1988
diff changeset
481 "Quit", "Cancel", NULL, NULL, NULL);
1912
d3689f044909 fl_choice does not behave like fltk::choice did
corvid <corvid@lavabit.com>
parents: 1911
diff changeset
482 if (choice == 1)
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
483 while ((bw = a_Bw_get(0)))
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
484 a_UIcmd_close_bw((void*)bw);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
485 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
486
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
487 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
488 * Open a new URL in the given browser window.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
489 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
490 * our custom "file:" URIs are normalized here too.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
491 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
492 void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
493 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
494 char *new_urlstr;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
495 DilloUrl *url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
496 int ch;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
497 BrowserWindow *bw = (BrowserWindow*)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
498
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
499 if (urlstr && *urlstr) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
500 /* Filter URL string */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
501 new_urlstr = a_Url_string_strip_delimiters(urlstr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
502
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
503 if (!dStrncasecmp(new_urlstr, "file:", 5)) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
504 /* file URI */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
505 ch = new_urlstr[5];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
506 if (!ch || ch == '.') {
1053
64e078b7a711 Refactor the preferences parser
Tim Nieradzik, Jorge Arellano Cid
parents: 1037
diff changeset
507 url = a_Url_new(Paths::getOldWorkingDir(), "file:");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
508 } else if (ch == '~') {
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
509 url = a_Url_new(dGethomedir(), "file:");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
510 } else {
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
511 url = a_Url_new(new_urlstr, "file:");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
512 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
513
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
514 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
515 /* common case */
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
516 url = a_Url_new(new_urlstr, NULL);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
517 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
518 dFree(new_urlstr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
519
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
520 if (url) {
1468
7fc6e6dca086 focus main on enter
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1449
diff changeset
521 a_UIcmd_open_url(bw, url);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
522 a_Url_free(url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
523 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
524 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
525 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
526
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
527 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
528 * Open a new URL in the given browser window
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
529 */
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
530 void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
531 {
1957
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
532 if (url) {
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
533 a_Nav_push(bw, url, NULL);
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
534 } else {
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
535 // Used to start a bw with a blank screen
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
536 BW2UI(bw)->focus_location();
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
537 a_UIcmd_set_buttons_sens(bw);
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
538 }
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1926
diff changeset
539 #if 0
1594
f27e5fed2e6b hide temporarily shown panel on a_UIcmd_open_url()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1591
diff changeset
540 if (BW2UI(bw)->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS)
f27e5fed2e6b hide temporarily shown panel on a_UIcmd_open_url()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1591
diff changeset
541 BW2UI(bw)->set_panelmode(UI_HIDDEN);
1468
7fc6e6dca086 focus main on enter
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1449
diff changeset
542 a_UIcmd_focus_main_area(bw);
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1926
diff changeset
543 #endif
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
544 }
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
545
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
546 static void UIcmd_open_url_nbw(BrowserWindow *new_bw, const DilloUrl *url)
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
547 {
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
548 /* When opening a new BrowserWindow (tab or real window) we focus
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
549 * Location if we don't yet have an URL, main otherwise.
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
550 */
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
551 if (url) {
1644
2650456b8199 filter automatic requests
corvid <corvid@lavabit.com>
parents: 1600
diff changeset
552 a_Nav_push(new_bw, url, NULL);
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
553 BW2UI(new_bw)->focus_main();
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
554 } else {
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
555 BW2UI(new_bw)->focus_location();
1957
2ac2b0e6aced Fixed button sensitivity when starting with an empty page
Jorge Arellano Cid <jcid@dillo.org>
parents: 1956
diff changeset
556 a_UIcmd_set_buttons_sens(new_bw);
1591
cf7f2d3312fb trim some spaces
corvid <corvid@lavabit.com>
parents: 1579
diff changeset
557 }
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
558 }
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
559
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
560 /*
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
561 * Open a new URL in a new browser window
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
562 */
11
4a5942beffdf Added some "const" qualifiers.
jcid
parents: 8
diff changeset
563 void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
1591
cf7f2d3312fb trim some spaces
corvid <corvid@lavabit.com>
parents: 1579
diff changeset
564 {
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
565 int w, h;
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
566 BrowserWindow *new_bw;
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
567
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
568 a_UIcmd_get_wh(bw, &w, &h);
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
569 new_bw = a_UIcmd_browser_window_new(w, h, 0, bw);
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
570
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
571 UIcmd_open_url_nbw(new_bw, url);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
572 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
573
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
574 /*
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
575 * Open a new URL in a new tab in the same browser window
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
576 */
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
577 void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus)
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
578 {
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
579 BrowserWindow *bw = (BrowserWindow *)vbw;
1982
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
580 BrowserWindow *new_bw = UIcmd_tab_new(BW2UI(bw)->tabs(),
8e0c182b52ee Made "new tab" and "new window" follow the style of the requesting UI
Jorge Arellano Cid <jcid@dillo.org>
parents: 1979
diff changeset
581 bw ? BW2UI(bw) : NULL, focus);
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
582 UIcmd_open_url_nbw(new_bw, url);
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
583 }
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
584
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
585 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
586 * Send the browser back to previous page
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
587 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
588 void a_UIcmd_back(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
589 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
590 a_Nav_back((BrowserWindow*)vbw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
591 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
592
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
593 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
594 * Popup the navigation menu of the Back button
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
595 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
596 void a_UIcmd_back_popup(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
597 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
598 a_Menu_history_popup((BrowserWindow*)vbw, -1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
599 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
600
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
601 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
602 * Send the browser to next page in the history list
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
603 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
604 void a_UIcmd_forw(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
605 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
606 a_Nav_forw((BrowserWindow*)vbw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
607 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
608
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
609 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
610 * Popup the navigation menu of the Forward button
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
611 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
612 void a_UIcmd_forw_popup(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
613 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
614 a_Menu_history_popup((BrowserWindow*)vbw, 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
615 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
616
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
617 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
618 * Send the browser to home URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
619 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
620 void a_UIcmd_home(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
621 {
1594
f27e5fed2e6b hide temporarily shown panel on a_UIcmd_open_url()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1591
diff changeset
622 a_UIcmd_open_url((BrowserWindow*)vbw, prefs.home);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
623 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
624
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
625 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
626 * Reload current URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
627 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
628 void a_UIcmd_reload(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
629 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
630 a_Nav_reload((BrowserWindow*)vbw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
631 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
632
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
633 /*
827
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
634 * Repush current URL
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
635 */
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
636 void a_UIcmd_repush(void *vbw)
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
637 {
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
638 a_Nav_repush((BrowserWindow*)vbw);
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
639 }
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
640
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
641 /*
1037
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
642 * Zero-delay URL redirection.
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
643 */
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
644 void a_UIcmd_redirection0(void *vbw, const DilloUrl *url)
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
645 {
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
646 a_Nav_redirection0((BrowserWindow*)vbw, url);
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
647 }
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
648
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
649 /*
40
b8319194f7da Added a save-directory preference (save_dir in dillorc2).
jcid
parents: 35
diff changeset
650 * Return a suitable filename for a given URL path.
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
651 */
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 50
diff changeset
652 static char *UIcmd_make_save_filename(const char *pathstr)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
653 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
654 size_t MaxLen = 64;
1120
corvid <corvid@lavabit.com>
parents: 1109
diff changeset
655 char *FileName, *newname, *o, *n;
corvid <corvid@lavabit.com>
parents: 1109
diff changeset
656 const char *name, *dir = a_UIcmd_get_save_dir();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
657
40
b8319194f7da Added a save-directory preference (save_dir in dillorc2).
jcid
parents: 35
diff changeset
658 if ((name = strrchr(pathstr, '/'))) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
659 if (strlen(++name) > MaxLen) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
660 name = name + strlen(name) - MaxLen;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
661 }
1090
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
662 /* Replace %20 and ' ' with '_' in Filename */
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
663 o = n = newname = dStrdup(name);
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
664 for (int i = 0; o[i]; i++) {
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
665 *n++ = (o[i] == ' ') ? '_' :
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
666 (o[i] == '%' && o[i+1] == '2' && o[i+2] == '0') ?
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
667 i+=2, '_' : o[i];
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
668 }
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
669 *n = 0;
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
670 FileName = dStrconcat(dir ? dir : "", newname, NULL);
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
671 dFree(newname);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
672 } else {
40
b8319194f7da Added a save-directory preference (save_dir in dillorc2).
jcid
parents: 35
diff changeset
673 FileName = dStrconcat(dir ? dir : "", pathstr, NULL);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
674 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
675 return FileName;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
676 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
677
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
678 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
679 * Get the default directory for saving files.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
680 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
681 const char *a_UIcmd_get_save_dir()
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
682 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
683 return save_dir;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
684 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
685
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
686 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
687 * Set the default directory for saving files.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
688 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
689 void a_UIcmd_set_save_dir(const char *dir)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
690 {
1096
bd988ddb1251 add a couple of const
Jorge Arellano Cid <jcid@dillo.org>
parents: 1090
diff changeset
691 const char *p;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
692
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
693 if (dir && (p = strrchr(dir, '/'))) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
694 dFree(save_dir);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
695 // assert a trailing '/'
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
696 save_dir = dStrconcat(dir, (p[1] != 0) ? "/" : "", NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
697 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
698 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
699
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
700 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
701 * Save current URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
702 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
703 void a_UIcmd_save(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
704 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
705 const char *name;
446
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
706 char *SuggestedName;
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
707 BrowserWindow *bw = (BrowserWindow *)vbw;
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
708 const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
709
446
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
710 if (url) {
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
711 a_UIcmd_set_save_dir(prefs.save_dir);
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
712 SuggestedName = UIcmd_make_save_filename(URL_PATH(url));
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
713 name = a_Dialog_save_file("Save Page as File", NULL, SuggestedName);
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
714 MSG("a_UIcmd_save: %s\n", name);
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
715 dFree(SuggestedName);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
716
446
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
717 if (name) {
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
718 a_Nav_save_url(bw, url, name);
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
719 }
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
720 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
721 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
722
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
723 /*
172
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
724 * Select a file
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
725 */
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
726 const char *a_UIcmd_select_file()
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
727 {
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
728 return a_Dialog_select_file("Select a File", NULL, NULL);
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
729 }
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
730
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
731 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
732 * Stop network activity on this bw.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
733 * The stop button was pressed: stop page (and images) downloads.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
734 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
735 void a_UIcmd_stop(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
736 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
737 BrowserWindow *bw = (BrowserWindow *)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
738
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
739 MSG("a_UIcmd_stop()\n");
376
9be38a4a0b14 - Disallowed loading images when expecting is set.
jcid
parents: 372
diff changeset
740 a_Nav_cancel_expect(bw);
1275
be3365808be1 s/Bw_Force/BW_Force/g
Jorge Arellano Cid <jcid@dillo.org>
parents: 1265
diff changeset
741 a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
742 a_UIcmd_set_buttons_sens(bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
743 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
744
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
745 /*
827
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
746 * Popup the tools menu
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
747 */
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
748 void a_UIcmd_tools(void *vbw, void *v_wid)
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
749 {
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
750 a_Menu_tools_popup((BrowserWindow*)vbw, v_wid);
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
751 }
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
752
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
753 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
754 * Open URL with dialog chooser
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
755 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
756 void a_UIcmd_open_file(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
757 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
758 char *name;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
759 DilloUrl *url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
760
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
761 name = a_Dialog_open_file("Open File", NULL, "");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
762
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
763 if (name) {
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
764 url = a_Url_new(name, "file:");
1594
f27e5fed2e6b hide temporarily shown panel on a_UIcmd_open_url()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1591
diff changeset
765 a_UIcmd_open_url((BrowserWindow*)vbw, url);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
766 a_Url_free(url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
767 dFree(name);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
768 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
769 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
770
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
771 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
772 * Returns a newly allocated string holding a search url generated from
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
773 * a string of keywords (separarated by blanks) and prefs.search_url.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
774 * The search string is urlencoded.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
775 */
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 50
diff changeset
776 static char *UIcmd_make_search_str(const char *str)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
777 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
778 char *keys = a_Url_encode_hex_str(str), *c = prefs.search_url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
779 Dstr *ds = dStr_sized_new(128);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
780 char *search_url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
781
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
782 for (; *c; c++) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
783 if (*c == '%')
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
784 switch(*++c) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
785 case 's':
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
786 dStr_append(ds, keys); break;;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
787 case '%':
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
788 dStr_append_c(ds, '%'); break;;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
789 case 0:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
790 MSG_WARN("search_url ends with '%%'\n"); c--; break;;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
791 default:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
792 MSG_WARN("illegal specifier '%%%c' in search_url\n", *c);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
793 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
794 else
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
795 dStr_append_c(ds, *c);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
796 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
797 dFree(keys);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
798
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
799 search_url = ds->str;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
800 dStr_free(ds, 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
801 return search_url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
802 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
803
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
804 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
805 * Get a query from a dialog and open it
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
806 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
807 void a_UIcmd_search_dialog(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
808 {
1088
8c7cf8e29325 Fix minor memory leak in a_UIcmd_search_dialog
Jorge Arellano Cid <jcid@dillo.org>
parents: 1053
diff changeset
809 const char *query;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
810
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
811 if ((query = a_Dialog_input("Search the Web:"))) {
1088
8c7cf8e29325 Fix minor memory leak in a_UIcmd_search_dialog
Jorge Arellano Cid <jcid@dillo.org>
parents: 1053
diff changeset
812 char *url_str = UIcmd_make_search_str(query);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
813 a_UIcmd_open_urlstr(vbw, url_str);
1088
8c7cf8e29325 Fix minor memory leak in a_UIcmd_search_dialog
Jorge Arellano Cid <jcid@dillo.org>
parents: 1053
diff changeset
814 dFree(url_str);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
815 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
816 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
817
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
818 /*
241
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
819 * Get password for user
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
820 */
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
821 const char *a_UIcmd_get_passwd(const char *user)
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
822 {
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
823 const char *passwd;
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
824 char *prompt = dStrconcat("Password for user \"", user, "\"", NULL);
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
825 passwd = a_Dialog_passwd(prompt);
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
826 dFree(prompt);
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
827 return passwd;
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
828 }
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
829
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
830 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
831 * Save link URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
832 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
833 void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
834 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
835 const char *name;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
836 char *SuggestedName;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
837
42
42bc9637b93d Fixed a bug in the save_dir patch
jcid
parents: 40
diff changeset
838 a_UIcmd_set_save_dir(prefs.save_dir);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
839
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
840 SuggestedName = UIcmd_make_save_filename(URL_STR(url));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
841 name = a_Dialog_save_file("Save Link as File", NULL, SuggestedName);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
842 MSG("a_UIcmd_save_link: %s\n", name);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
843 dFree(SuggestedName);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
844
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
845 if (name) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
846 a_Nav_save_url(bw, url, name);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
847 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
848 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
849
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
850 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
851 * Request the bookmarks page
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
852 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
853 void a_UIcmd_book(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
854 {
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
855 DilloUrl *url = a_Url_new("dpi:/bm/", NULL);
1594
f27e5fed2e6b hide temporarily shown panel on a_UIcmd_open_url()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1591
diff changeset
856 a_UIcmd_open_url((BrowserWindow*)vbw, url);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
857 a_Url_free(url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
858 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
859
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
860 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
861 * Add a bookmark for a certain URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
862 */
11
4a5942beffdf Added some "const" qualifiers.
jcid
parents: 8
diff changeset
863 void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
864 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
865 a_Bookmarks_add(bw, url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
866 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
867
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
868
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
869 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
870 * Popup the page menu
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
871 */
958
1a26b2bd7138 [mq]: view-stylesheets
Jorge Arellano Cid <jcid@dillo.org>
parents: 942
diff changeset
872 void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, void *v_cssUrls)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
873 {
827
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 776
diff changeset
874 BrowserWindow *bw = (BrowserWindow*)vbw;
1661
0c5d982c92a0 Add const qualifier to a_History_get_url()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1644
diff changeset
875 const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
958
1a26b2bd7138 [mq]: view-stylesheets
Jorge Arellano Cid <jcid@dillo.org>
parents: 942
diff changeset
876 a_Menu_page_popup(bw, url, has_bugs, v_cssUrls);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
877 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
878
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
879 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
880 * Popup the link menu
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
881 */
11
4a5942beffdf Added some "const" qualifiers.
jcid
parents: 8
diff changeset
882 void a_UIcmd_link_popup(void *vbw, const DilloUrl *url)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
883 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
884 a_Menu_link_popup((BrowserWindow*)vbw, url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
885 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
886
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
887 /*
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
888 * Pop up the image menu
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
889 */
356
81338758c3dd - Added a workaround for segfaulting popup menus.
jcid
parents: 352
diff changeset
890 void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
926
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 908
diff changeset
891 DilloUrl *page_url, DilloUrl *link_url)
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
892 {
926
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 908
diff changeset
893 a_Menu_image_popup((BrowserWindow*)vbw, url, loaded_img, page_url,link_url);
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
894 }
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
895
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
896 /*
477
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
897 * Pop up the form menu
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
898 */
484
cdfdb006f193 Added a right-click menu to the form submit button (allows to show hiddens)
Jorge Arellano Cid <jcid@dillo.org>
parents: 477
diff changeset
899 void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
cdfdb006f193 Added a right-click menu to the form submit button (allows to show hiddens)
Jorge Arellano Cid <jcid@dillo.org>
parents: 477
diff changeset
900 bool_t showing_hiddens)
477
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
901 {
484
cdfdb006f193 Added a right-click menu to the form submit button (allows to show hiddens)
Jorge Arellano Cid <jcid@dillo.org>
parents: 477
diff changeset
902 a_Menu_form_popup((BrowserWindow*)vbw, url, vform, showing_hiddens);
477
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
903 }
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
904
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
905 /*
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
906 * Pop up the file menu
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
907 */
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
908 void a_UIcmd_file_popup(void *vbw, void *v_wid)
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
909 {
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
910 a_Menu_file_popup((BrowserWindow*)vbw, v_wid);
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
911 }
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
912
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
913 /*
55
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
914 * Copy url string to paste buffer
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
915 */
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
916 void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr)
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
917 {
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
918 Layout *layout = (Layout*)bw->render_layout;
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
919 layout->copySelection(urlstr);
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
920 }
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
921
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
922 /*
1577
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
923 * Ask the vsource dpi to show this URL's source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
924 */
1569
24a5d37b09e1 Add the a_Capi_dpi_send_data() function
Jorge Arellano Cid <jcid@dillo.org>
parents: 1468
diff changeset
925 void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
926 {
1577
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
927 char *buf;
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
928 int buf_size;
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
929 Dstr *dstr_url;
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
930 DilloUrl *vs_url;
1600
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
931 static int post_id = 0;
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
932 char tag[8];
1577
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
933
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
934 if (a_Nav_get_buf(url, &buf, &buf_size)) {
1600
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
935 a_Nav_set_vsource_url(url);
1577
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
936 dstr_url = dStr_new("dpi:/vsource/:");
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
937 dStr_append(dstr_url, URL_STR(url));
1600
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
938 if (URL_FLAGS(url) & URL_Post) {
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
939 /* append a custom string to differentiate POST URLs */
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
940 post_id = (post_id < 9999) ? post_id + 1 : 0;
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
941 snprintf(tag, 8, "_%.4d", post_id);
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
942 dStr_append(dstr_url, tag);
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
943 }
1577
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
944 vs_url = a_Url_new(dstr_url->str, NULL);
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
945 a_UIcmd_open_url_nt(bw, vs_url, 1);
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
946 a_Url_free(vs_url);
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
947 dStr_free(dstr_url, 1);
1600
f50835ca545e Fix "view source" for POST URLs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1594
diff changeset
948 a_Nav_unref_buf(url);
1577
404899a37226 Handle vsource dpi inside a_Capi_open_url(); more orthogonality.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1572
diff changeset
949 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
950 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
951
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
952 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
953 * Show a text window with the URL's source
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
954 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
955 void a_UIcmd_view_page_bugs(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
956 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
957 BrowserWindow *bw = (BrowserWindow*)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
958
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
959 if (bw->num_page_bugs > 0) {
1572
2307d3f8e41b dialog recombine make/show_text_window
corvid <corvid@lavabit.com>
parents: 1571
diff changeset
960 a_Dialog_text_window(bw->page_bugs->str, "Detected HTML errors");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
961 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
962 a_Dialog_msg("Zero detected HTML errors!");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
963 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
964 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
965
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
966 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
967 * Popup the bug meter menu
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
968 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
969 void a_UIcmd_bugmeter_popup(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
970 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
971 BrowserWindow *bw = (BrowserWindow*)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
972
19
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
973 a_Menu_bugmeter_popup(bw, a_History_get_url(NAV_TOP_UIDX(bw)));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
974 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
975
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
976 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
977 * Make a list of URL indexes for the history popup
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
978 * based on direction (-1 = back, 1 = forward)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
979 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
980 int *a_UIcmd_get_history(BrowserWindow *bw, int direction)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
981 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
982 int i, j, n;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
983 int *hlist;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
984
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
985 // Count the number of URLs
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
986 i = a_Nav_stack_ptr(bw) + direction;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
987 for (n = 0 ; i >= 0 && i < a_Nav_stack_size(bw); i+=direction)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
988 ++n;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
989 hlist = dNew(int, n + 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
990
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
991 // Fill the list
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
992 i = a_Nav_stack_ptr(bw) + direction;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
993 for (j = 0 ; i >= 0 && i < a_Nav_stack_size(bw); i+=direction, j += 1) {
19
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
994 hlist[j] = NAV_UIDX(bw,i);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
995 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
996 hlist[j] = -1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
997
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
998 return hlist;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
999 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1000
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1001 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1002 * Jump to a certain URL in the navigation stack.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1003 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1004 void a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1005 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1006 a_Nav_jump(bw, offset, new_bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1007 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1008
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1009 // UI binding functions -------------------------------------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1010
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1011 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1012 * Return browser window width and height
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1013 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1014 void a_UIcmd_get_wh(BrowserWindow *bw, int *w, int *h)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1015 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1016 *w = BW2UI(bw)->w();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1017 *h = BW2UI(bw)->h();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1018 _MSG("a_UIcmd_wh: w=%d, h=%d\n", *w, *h);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1019 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1020
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1021 /*
15
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1022 * Get the scroll position (x, y offset pair)
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1023 */
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1024 void a_UIcmd_get_scroll_xy(BrowserWindow *bw, int *x, int *y)
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1025 {
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1026 Layout *layout = (Layout*)bw->render_layout;
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1027
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1028 if (layout) {
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1029 *x = layout->getScrollPosX();
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1030 *y = layout->getScrollPosY();
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1031 }
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1032 }
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1033
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1034 /*
19
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1035 * Set the scroll position ({x, y} offset pair)
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1036 */
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1037 void a_UIcmd_set_scroll_xy(BrowserWindow *bw, int x, int y)
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1038 {
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1039 Layout *layout = (Layout*)bw->render_layout;
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1040
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1041 if (layout) {
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1042 layout->scrollTo(HPOS_LEFT, VPOS_TOP, x, y, 0, 0);
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1043 }
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1044 }
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1045
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1046 /*
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1047 * Set the scroll position by fragment (from URL)
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1048 */
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1049 void a_UIcmd_set_scroll_by_fragment(BrowserWindow *bw, const char *f)
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1050 {
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1051 Layout *layout = (Layout*)bw->render_layout;
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1052
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1053 if (layout && f) {
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1054 layout->setAnchor(f);
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1055 }
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1056 }
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1057
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1058 /*
1209
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1059 * Pass scrolling command to dw.
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1060 */
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1061 void a_UIcmd_scroll(BrowserWindow *bw, int icmd)
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1062 {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1063 Layout *layout = (Layout*)bw->render_layout;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1064
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1065 if (layout) {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1066 typedef struct {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1067 KeysCommand_t keys_cmd;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1068 ScrollCommand dw_cmd;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1069 } mapping_t;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1070
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1071 const mapping_t map[] = {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1072 {KEYS_SCREEN_UP, SCREEN_UP_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1073 {KEYS_SCREEN_DOWN, SCREEN_DOWN_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1074 {KEYS_LINE_UP, LINE_UP_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1075 {KEYS_LINE_DOWN, LINE_DOWN_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1076 {KEYS_LEFT, LEFT_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1077 {KEYS_RIGHT, RIGHT_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1078 {KEYS_TOP, TOP_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1079 {KEYS_BOTTOM, BOTTOM_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1080 };
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1081 KeysCommand_t keycmd = (KeysCommand_t)icmd;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1082
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1083 for (uint_t i = 0; i < (sizeof(map)/sizeof(mapping_t)); i++) {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1084 if (keycmd == map[i].keys_cmd) {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1085 layout->scroll(map[i].dw_cmd);
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1086 break;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1087 }
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1088 }
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1089 }
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1090 }
1326
02ef25700865 trim some spaces
corvid <corvid@lavabit.com>
parents: 1275
diff changeset
1091
1209
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1092 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1093 * Get location's text
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1094 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1095 char *a_UIcmd_get_location_text(BrowserWindow *bw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1096 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1097 return dStrdup(BW2UI(bw)->get_location());
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1098 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1099
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1100 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1101 * Set location's text
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1102 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1103 void a_UIcmd_set_location_text(void *vbw, const char *text)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1104 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1105 BrowserWindow *bw = (BrowserWindow*)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1106 BW2UI(bw)->set_location(text);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1107 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1108
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1109 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1110 * Set the page progress bar
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1111 * cmd: 0 Deactivate, 1 Update, 2 Clear
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1112 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1113 void a_UIcmd_set_page_prog(BrowserWindow *bw, size_t nbytes, int cmd)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1114 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1115 BW2UI(bw)->set_page_prog(nbytes, cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1116 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1117
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1118 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1119 * Set the images progress bar
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1120 * cmd: 0 Deactivate, 1 Update, 2 Clear
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1121 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1122 void a_UIcmd_set_img_prog(BrowserWindow *bw, int n_img, int t_img, int cmd)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1123 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1124 BW2UI(bw)->set_img_prog(n_img, t_img, cmd);
291
f8ec5a664371 - Updated AUTHORS
jcid
parents: 260
diff changeset
1125 #if 0
293
8b9684badb34 - Added a minor debug feature.
jcid
parents: 291
diff changeset
1126 if (!cmd)
291
f8ec5a664371 - Updated AUTHORS
jcid
parents: 260
diff changeset
1127 a_UIcmd_close_bw(bw);
f8ec5a664371 - Updated AUTHORS
jcid
parents: 260
diff changeset
1128 #endif
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1129 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1130
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1131 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1132 * Set the bug meter progress label
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1133 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1134 void a_UIcmd_set_bug_prog(BrowserWindow *bw, int n_bug)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1135 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1136 BW2UI(bw)->set_bug_prog(n_bug);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1137 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1138
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1139 /*
1101
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1140 * Set the page title in the window titlebar and tab label.
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1141 * (Update window titlebar for the current tab only)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1142 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1143 void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1144 {
1126
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1145 const int size = 128;
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1146 char title[size];
1101
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1147
1926
5a0a49770247 Made a brand new CustTabs class (to allow fine control of tabs).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1923
diff changeset
1148 if (a_UIcmd_get_bw_by_widget(BW2UI(bw)->tabs()->wizard()->value()) == bw) {
1101
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1149 // This is the focused bw, set window title
1126
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1150 if (snprintf(title, size, "Dillo: %s", label) >= size) {
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1151 uint_t i = MIN(size - 4, 1 + a_Utf8_end_of_char(title, size - 8));
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1152 snprintf(title + i, 4, "...");
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1153 }
1101
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1154 BW2UI(bw)->window()->copy_label(title);
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1155 }
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
1156 BW2UI(bw)->tabs()->set_tab_label(BW2UI(bw), label);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1157 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1158
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1159 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1160 * Set a printf-like status string on the bottom of the dillo window.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1161 * Beware: The safe way to set an arbitrary string is
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1162 * a_UIcmd_set_msg(bw, "%s", str)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1163 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1164 void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1165 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1166 va_list argp;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1167 Dstr *ds = dStr_sized_new(128);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1168 va_start(argp, format);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1169 dStr_vsprintf(ds, format, argp);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1170 va_end(argp);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1171 BW2UI(bw)->set_status(ds->str);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1172 dStr_free(ds, 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1173 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1174
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1175 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1176 * Set the sensitivity of back/forw/stop buttons.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1177 */
371
898e6ca77d7e - Removed the button sensitivity timeout.
jcid
parents: 367
diff changeset
1178 void a_UIcmd_set_buttons_sens(BrowserWindow *bw)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1179 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1180 int sens;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1181
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1182 // Stop
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1183 sens = (dList_length(bw->ImageClients) || dList_length(bw->RootClients));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1184 BW2UI(bw)->button_set_sens(UI_STOP, sens);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1185 // Back
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1186 sens = (a_Nav_stack_ptr(bw) > 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1187 BW2UI(bw)->button_set_sens(UI_BACK, sens);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1188 // Forward
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1189 sens = (a_Nav_stack_ptr(bw) < a_Nav_stack_size(bw) - 1 &&
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1190 !bw->nav_expecting);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1191 BW2UI(bw)->button_set_sens(UI_FORW, sens);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1192 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1193
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1194 /*
438
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1195 * Keep track of mouse pointer over a link.
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1196 */
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1197 void a_UIcmd_set_pointer_on_link(BrowserWindow *bw, int flag)
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1198 {
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1199 BW2UI(bw)->pointerOnLink(flag);
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1200 }
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1201
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1202 /*
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1203 * Is the mouse pointer over a link?
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1204 */
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1205 int a_UIcmd_pointer_on_link(BrowserWindow *bw)
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1206 {
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1207 return BW2UI(bw)->pointerOnLink();
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1208 }
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1209
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1210 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1211 * Toggle control panel (aka. fullscreen)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1212 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1213 void a_UIcmd_fullscreen_toggle(BrowserWindow *bw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1214 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1215 BW2UI(bw)->fullscreen_toggle();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1216 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1217
56
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1218 /*
908
40bc2df4de7a Implemented "search previous" in string searches
João Ricardo Lourenço <jorl17.8@gmail.com>
parents: 907
diff changeset
1219 * Search for next/previous occurrence of key.
56
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1220 */
941
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1221 void a_UIcmd_findtext_search(BrowserWindow *bw, const char *key,
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1222 int case_sens, int backwards)
56
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1223 {
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1224 Layout *l = (Layout *)bw->render_layout;
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
1225
908
40bc2df4de7a Implemented "search previous" in string searches
João Ricardo Lourenço <jorl17.8@gmail.com>
parents: 907
diff changeset
1226 switch (l->search(key, case_sens, backwards)) {
941
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1227 case FindtextState::RESTART:
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1228 a_UIcmd_set_msg(bw, "No further occurrences of \"%s\". "
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1229 "Restarting from the top.", key);
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1230 break;
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1231 case FindtextState::NOT_FOUND:
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1232 a_UIcmd_set_msg(bw, "\"%s\" not found.", key);
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1233 break;
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1234 case FindtextState::SUCCESS:
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1235 default:
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1236 a_UIcmd_set_msg(bw, "");
56
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1237 }
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1238 }
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1239
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1240 /*
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1241 * Reset text search state.
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1242 */
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1243 void a_UIcmd_findtext_reset(BrowserWindow *bw)
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1244 {
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1245 Layout *l = (Layout *)bw->render_layout;
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1246 l->resetSearch();
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1247
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1248 a_UIcmd_set_msg(bw, "");
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1249 }
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1250
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1251 /*
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1252 * Tell the UI to hide/show the findbar
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1253 */
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1254 void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on)
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1255 {
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1256 BW2UI(bw)->findbar_toggle(on);
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1257 }
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1258
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1259 /*
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1260 * Focus the rendered area.
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1261 */
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1262 void a_UIcmd_focus_main_area(BrowserWindow *bw)
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1263 {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1264 BW2UI(bw)->focus_main();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1265 }
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1266
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1267 /*
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1268 * Focus the location bar.
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1269 */
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1270 void a_UIcmd_focus_location(void *vbw)
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1271 {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1272 BrowserWindow *bw = (BrowserWindow*)vbw;
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1273 BW2UI(bw)->focus_location();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1274 }
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1275