annotate src/uicmd.cc @ 1449:6d248ac9f54b

adjust focus handling with new tabs and windows (suggested by furaisanjin) When opening a new BrowserWindow (tab or real window) we focus Location if we don't yet have an URL, main otherwise.
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Fri, 27 Nov 2009 19:38:06 +0100
parents d2ee0ca5eb34
children 7fc6e6dca086
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
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
19 #include <fltk/draw.h>
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
20 #include <fltk/damage.h>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 #include <fltk/Widget.h>
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
22 #include <fltk/TabGroup.h>
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
23 #include <fltk/Tooltip.h>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24
1053
64e078b7a711 Refactor the preferences parser
Tim Nieradzik, Jorge Arellano Cid
parents: 1037
diff changeset
25 #include "paths.hh"
1209
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
26 #include "keys.hh"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 #include "ui.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 #include "uicmd.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 #include "timeout.hh"
1126
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
30 #include "utf8.hh"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 #include "menu.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32 #include "dialog.hh"
1109
39febe63d2c9 add support for --xid command line option
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1101
diff changeset
33 #include "xembed.hh"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 #include "bookmark.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 #include "history.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 #include "msg.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 #include "prefs.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39 #include "dw/fltkviewport.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 #include "nav.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42
433
jcid
parents: 404
diff changeset
43 #define DEFAULT_TAB_LABEL "Dillo"
jcid
parents: 404
diff changeset
44
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
45 // Handy macro
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
46 #define BW2UI(bw) ((UI*)((bw)->ui))
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
47
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 // Platform idependent part
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 using namespace dw::core;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 // FLTK related
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 using namespace dw::fltk;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 * Local data
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 static char *save_dir = NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
59 using namespace fltk;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
60
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
61
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
62 //----------------------------------------------------------------------------
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 #define BTN_W 25
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
64 #define BTN_H 20
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 static int btn_x;
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 /*
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
69 * Adds a tab-close button at the rightmost part
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 */
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
71 class CustShrinkTabPager : public TabGroupPager {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
72 bool btn_hl;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
73 TabGroup *tg;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
74 public:
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
75 int update_positions(
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
76 TabGroup *g, int numchildren, int &selected,
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 int &cumulated_width, int &available_width,
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
78 int *tab_pos, int *tab_width);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
79 virtual int which(TabGroup* g, int m_x,int m_y);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
80 virtual TabGroupPager* clone() const;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
81 virtual const char * mode_name() const {return "Shrink";}
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
82 virtual int id() const {return PAGER_SHRINK;}
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
83 virtual int available_width(TabGroup *g) const;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
84 virtual bool draw_tabs(TabGroup* g, int selected, int* tab_pos,
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
85 int* tab_width) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
86 if (!tg) tg = g;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
87 if (g->children() > 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
88 fltk::Rectangle r(btn_x,0,BTN_W,BTN_H);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
89 setcolor(btn_hl ? 206 : GRAY75);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
90 fillrect(r);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
91 if (btn_hl) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
92 setcolor(WHITE);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
93 strokerect(r);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
94 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
95 setcolor(GRAY10);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
96 //fltk::setfont(fltk::getfont()->bold(), fltk::getsize());
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
97 r.h(r.h()-2);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
98 drawtext("X", r, ALIGN_CENTER);
976
d14bddcad83d add workaround for fltk bug 2062
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 973
diff changeset
99 return false;
d14bddcad83d add workaround for fltk bug 2062
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 973
diff changeset
100 } else {
979
b3987cabf220 Minor comment correction
Jorge Arellano Cid <jcid@dillo.org>
parents: 976
diff changeset
101 // WORKAROUND: for http://fltk.org/str.php?L2062
976
d14bddcad83d add workaround for fltk bug 2062
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 973
diff changeset
102 // By returning true we avoid a call to TabGroup::draw_tab()
d14bddcad83d add workaround for fltk bug 2062
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 973
diff changeset
103 // in TabGroup::draw() in case we don't show the tabs.
d14bddcad83d add workaround for fltk bug 2062
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 973
diff changeset
104 return true;
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
105 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
106 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
107
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
108 void btn_highlight(bool flag) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
109 if (btn_hl != flag) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
110 btn_hl = flag;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
111 if (tg)
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
112 tg->redraw(DAMAGE_VALUE);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
113 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
114 };
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
115 bool btn_highlight() { return btn_hl; };
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
116
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
117 CustShrinkTabPager() : TabGroupPager() {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
118 noclip(true);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
119 btn_hl = false;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
120 tg = NULL;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
121 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
122 };
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
123
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
124 int CustShrinkTabPager::available_width(TabGroup *g) const
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
125 {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
126 _MSG("CustShrinkTabPager::available_width\n");
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
127 int w = MAX (g->w() - this->slope()-1 - BTN_W, 0);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
128 btn_x = w + 6;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
129 return w;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
130 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
131
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
132 int CustShrinkTabPager::which(TabGroup* g, int event_x,int event_y)
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
133 {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
134 int H = g->tab_height();
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
135 if (!H) 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
136 if (H < 0) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
137 if (event_y > g->h() || event_y < g->h()+H) 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
138 } else {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
139 if (event_y > H || event_y < 0) 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
140 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
141 if (event_x < 0) 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
142 int p[128], w[128];
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
143 int selected = g->tab_positions(p, w);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
144 int d = (event_y-(H>=0?0:g->h()))*slope()/H;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
145 for (int i=0; i<g->children(); i++) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
146 if (event_x < p[i+1]+(i<selected ? slope() - d : d)) return i;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
147 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
148 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
149 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
150
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
151 /*
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
152 * Prevents tabs from going over the close-tab button.
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
153 * Modified from fltk-2.0.x-r6525.
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
154 */
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
155 int CustShrinkTabPager::update_positions(
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
156 TabGroup *g, int numchildren, int &selected,
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
157 int &cumulated_width, int &available_width,
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
158 int *tab_pos, int *tab_width)
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
159 {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
160 available_width-=BTN_W;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
161
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
162 // uh oh, they are too big, we must move them:
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
163 // special case when the selected tab itself is too big, make it fill
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
164 // cumulated_width:
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
165 int i;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
166
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
167 if (tab_width[selected] >= available_width) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
168 tab_width[selected] = available_width;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
169 for (i = 0; i <= selected; i++)
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
170 tab_pos[i] = 0;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
171 for (i = selected + 1; i <= numchildren; i++)
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
172 tab_pos[i] = available_width;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
173 return selected;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
174 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
175
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
176 int w2[128];
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
177
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
178 for (i = 0; i < numchildren; i++)
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
179 w2[i] = tab_width[i];
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
180 i = numchildren - 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
181 int j = 0;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
182
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
183 int minsize = 5;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
184
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
185 bool right = true;
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 while (cumulated_width > available_width) {
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 int n; // which one to shrink
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
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
190 if (j < selected && (!right || i <= selected)) { // shrink a left one
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 n = j++;
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 right = true;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
193 } else if (i > selected) { // shrink a right one
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
194 n = i--;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
195 right = false;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
196 } else { // no more space, start making them zero
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 minsize = 0;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
198 i = numchildren - 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
199 j = 0;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
200 right = true;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
201 continue;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
202 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
203 cumulated_width -= w2[n] - minsize;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
204 w2[n] = minsize;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
205 if (cumulated_width < available_width) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
206 w2[n] = available_width - cumulated_width + minsize;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
207 cumulated_width = available_width;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
208 break;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
209 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
210 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
211 // re-sum the positions:
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
212 cumulated_width = 0;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
213 for (i = 0; i < numchildren; i++) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
214 cumulated_width += w2[i];
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
215 tab_pos[i+1] = cumulated_width;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
216 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
217 return selected;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
218 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
219
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
220 TabGroupPager* CustShrinkTabPager::clone() const {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
221 return new CustShrinkTabPager(*this);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
222 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
223
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
224 //----------------------------------------------------------------------------
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
225
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
226 /*
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
227 * For custom handling of keyboard
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
228 */
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
229 class CustTabGroup : public fltk::TabGroup {
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
230 Tooltip *toolTip;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
231 bool tooltipEnabled;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
232 bool buttonPushed;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
233 public:
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
234 CustTabGroup (int x, int y, int ww, int wh, const char *lbl=0) :
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
235 TabGroup(x,y,ww,wh,lbl) {
973
4355018cc2af Fixed a minor memory leak with CustShrinkTabPager()
Hofmann Johannes <Johannes.Hofmann@gmx.de>
parents: 958
diff changeset
236 // The parameter pager is cloned, so free it.
4355018cc2af Fixed a minor memory leak with CustShrinkTabPager()
Hofmann Johannes <Johannes.Hofmann@gmx.de>
parents: 958
diff changeset
237 CustShrinkTabPager *cp = new CustShrinkTabPager();
4355018cc2af Fixed a minor memory leak with CustShrinkTabPager()
Hofmann Johannes <Johannes.Hofmann@gmx.de>
parents: 958
diff changeset
238 this->pager(cp);
4355018cc2af Fixed a minor memory leak with CustShrinkTabPager()
Hofmann Johannes <Johannes.Hofmann@gmx.de>
parents: 958
diff changeset
239 delete cp;
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
240 toolTip = new Tooltip;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
241 tooltipEnabled = false;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
242 buttonPushed = false;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
243 };
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
244 ~CustTabGroup() { delete toolTip; }
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
245 int handle(int e) {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
246 // Don't focus with arrow keys
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
247 _MSG("CustTabGroup::handle %d\n", 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
248 fltk::Rectangle r(btn_x,0,BTN_W,BTN_H);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
249 if (e == KEY) {
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
250 int k = event_key();
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
251 // We're only interested in some flags
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
252 unsigned modifier = event_state() & (SHIFT | CTRL | ALT);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
253 if (k == UpKey || k == DownKey || k == TabKey) {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
254 return 0;
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
255 } else if (k == LeftKey || k == RightKey) {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
256 if (modifier == SHIFT) {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
257 int i = value();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
258 if (k == LeftKey) {i = i ? i-1 : children()-1;}
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
259 else {i++; if (i >= children()) i = 0;}
378
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
260 selected_child(child(i));
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
261 return 1;
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
262 }
388
dfd25e7990be - Avoided focus change with {Left, Right} in CustTabGroup
jcid
parents: 386
diff changeset
263 // Avoid focus change.
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
264 return 0;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
265 }
1097
4be83aec27bd Sync window title with current tab
Jorge Arellano Cid <jcid@dillo.org>
parents: 1096
diff changeset
266 } else if (e == FOCUS_CHANGE) {
4be83aec27bd Sync window title with current tab
Jorge Arellano Cid <jcid@dillo.org>
parents: 1096
diff changeset
267 // Update the window title
4be83aec27bd Sync window title with current tab
Jorge Arellano Cid <jcid@dillo.org>
parents: 1096
diff changeset
268 BrowserWindow *bw = a_UIcmd_get_bw_by_widget(selected_child());
1429
d2ee0ca5eb34 use macro
corvid <corvid@lavabit.com>
parents: 1343
diff changeset
269 const char *title = a_History_get_title(NAV_TOP_UIDX(bw), 1);
1101
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
270 a_UIcmd_set_page_title(bw, title ? title : "");
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 } else if (e == MOVE) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
272 CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager();
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
273 if (event_inside(r) && children() > 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
274 /* We're inside the button area */
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
275 cstp->btn_highlight(true);
1343
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
276 if (prefs.show_tooltip) {
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
277 /* Prepare the tooltip for pop-up */
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
278 tooltipEnabled = true;
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
279 /* We use parent() if available because we are returning 0.
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
280 * Returning without having TabGroup processing makes the
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
281 * popup event never reach 'this', but it reaches parent() */
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
282 toolTip->enter(parent() ?parent():this, r, "Close current Tab");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
283 }
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
284 return 0; // Change focus
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
285 } else {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
286 cstp->btn_highlight(false);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
287
1343
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
288 if (prefs.show_tooltip) {
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
289 /* Hide the tooltip or enable it again.*/
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
290 if (tooltipEnabled) {
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
291 tooltipEnabled = false;
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
292 toolTip->exit();
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
293 } else {
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
294 toolTip->enable();
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1326
diff changeset
295 }
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
296 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
297 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
298 } else if (e == PUSH && event_inside(r) &&
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
299 event_button() == 1 && children() > 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
300 buttonPushed = true;
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 return 1; /* non-zero */
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
302 } else if (e == RELEASE) {
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 if (event_inside(r) && event_button() == 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
304 children() > 1 && buttonPushed) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
305 a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(selected_child()));
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
306 } else {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
307 CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager();
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
308 cstp->btn_highlight(false);
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
309 }
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
310 buttonPushed = false;
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
311 } else if (e == DRAG) {
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
312 /* Ignore this event */
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
313 return 1;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
314 }
1265
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
315 int ret = TabGroup::handle(e);
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
316
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
317 if (e == PUSH) {
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
318 /* WORKAROUND: FLTK raises the window on unhandled clicks,
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
319 * which we do not want.
1326
02ef25700865 trim some spaces
corvid <corvid@lavabit.com>
parents: 1275
diff changeset
320 */
1265
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
321 ret = 1;
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
322 }
b4df6dadb093 leave the decision of raising a window to the WM (BUG 916)
corvid <corvid@lavabit.com>
parents: 1209
diff changeset
323 return ret;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
324 }
343
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
325
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
326 void remove (Widget *w) {
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
327 TabGroup::remove (w);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
328 /* fixup resizable in case we just removed it */
442
68639eb89297 - Reduced warnings with gcc-4.3.
jcid
parents: 438
diff changeset
329 if (resizable () == w) {
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
330 if (children () > 0)
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
331 resizable (child (children () - 1));
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
332 else
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
333 resizable (NULL);
442
68639eb89297 - Reduced warnings with gcc-4.3.
jcid
parents: 438
diff changeset
334 }
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
335
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
336 if (children () < 2)
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
337 hideLabels ();
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
338 }
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
339
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
340 void add (Widget *w) {
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
341 TabGroup::add (w);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
342 if (children () > 1)
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
343 showLabels ();
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
344 }
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
345
343
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
346 void hideLabels() {
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
347 for (int i = children () - 1; i >= 0; i--)
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
348 child(i)->resize(x(), y(), w(), h());
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
349 }
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
350
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
351 void showLabels() {
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
352 for (int i = children () - 1; i >= 0; i--)
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
353 child(i)->resize(x(), y() + 20, w(), h() - 20);
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
354 }
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
355 };
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
356
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
357 //----------------------------------------------------------------------------
0dd5f290caa4 Implemented a close-tab button for the GUI
João Ricardo <jorl17.8@gmail.com>, Jorge <jcid@dillo.org
parents: 941
diff changeset
358
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
359 static void win_cb (fltk::Widget *w, void *cb_data) {
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
360 CustTabGroup *tabs;
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
361 int choice = 0;
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
362
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
363 tabs = BW2UI((BrowserWindow*) cb_data)->tabs();
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
364 if (tabs->children () > 1)
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
365 choice = a_Dialog_choice3 ("Window contains more than one tab.",
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
366 "Close all tabs", "Cancel", NULL);
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
367 if (choice == 0)
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
368 while (tabs->children())
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
369 a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->child(0)));
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
370 }
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
371
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
372 /*
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
373 * 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
374 */
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
375 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
376 {
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
377 BrowserWindow *bw;
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
378 for (int i = 0; i < a_Bw_num(); ++i) {
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
379 bw = a_Bw_get(i);
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
380 if (((fltk::Widget*)bw->ui)->contains((fltk::Widget*)v_wid))
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
381 return bw;
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
382 }
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
383 return NULL;
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
384 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
385
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
386 /*
378
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
387 * FLTK regards SHIFT + {LeftKey, Right} as navigation keys.
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
388 * 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
389 * these events directly to the recipient.
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
390 * TODO: focus is not remembered correctly.
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
391 */
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
392 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
393 {
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
394 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
395 UI *ui = (UI*)bw->ui;
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
396 if (ui->tabs())
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
397 ui->tabs()->handle(e);
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
398 }
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
399
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 376
diff changeset
400 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
401 * 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
402 * Use style from v_ui. If non-NULL it must be of type UI*.
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
403 */
1149
d76ff9ca5658 line length
Jorge Arellano Cid <jcid@dillo.org>
parents: 1137
diff changeset
404 BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh,
d76ff9ca5658 line length
Jorge Arellano Cid <jcid@dillo.org>
parents: 1137
diff changeset
405 uint32_t xid, const void *vbw)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
406 {
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
407 BrowserWindow *old_bw = (BrowserWindow*)vbw;
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
408 BrowserWindow *new_bw = NULL;
1137
f10904ac58b4 more xembed work
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1126
diff changeset
409 Window *win;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
410
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
411 if (ww <= 0 || wh <= 0) {
8
ab2998c07f18 enabled geometry in preferences
jcid
parents: 0
diff changeset
412 // Set default geometry from dillorc.
ab2998c07f18 enabled geometry in preferences
jcid
parents: 0
diff changeset
413 ww = prefs.width;
ab2998c07f18 enabled geometry in preferences
jcid
parents: 0
diff changeset
414 wh = prefs.height;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
415 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
416
1137
f10904ac58b4 more xembed work
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1126
diff changeset
417 if (xid)
f10904ac58b4 more xembed work
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1126
diff changeset
418 win = new Xembed(xid, ww, wh);
f10904ac58b4 more xembed work
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1126
diff changeset
419 else
f10904ac58b4 more xembed work
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1126
diff changeset
420 win = new Window(ww, wh);
1109
39febe63d2c9 add support for --xid command line option
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1101
diff changeset
421
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
422 win->shortcut(0); // Ignore Escape
399
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 392
diff changeset
423 if (prefs.buffered_drawing != 2)
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 392
diff changeset
424 win->clear_double_buffer();
352
44a801a15c88 - Set the ::fltk::RAW_LABEL flag for widgets getting labels from html.
jcid
parents: 350
diff changeset
425 win->set_flag(RAW_LABEL);
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
426 CustTabGroup *DilloTabs = new CustTabGroup(0, 0, ww, wh);
388
dfd25e7990be - Avoided focus change with {Left, Right} in CustTabGroup
jcid
parents: 386
diff changeset
427 DilloTabs->clear_tab_to_focus();
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
428 DilloTabs->selection_color(156);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
429 win->add(DilloTabs);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
430
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
431 // Create and set the UI
453
817c15b79ca7 - dillorc comment change.
jcid
parents: 446
diff changeset
432 UI *new_ui = new UI(0, 0, ww, wh, DEFAULT_TAB_LABEL,
817c15b79ca7 - dillorc comment change.
jcid
parents: 446
diff changeset
433 old_bw ? BW2UI(old_bw) : NULL);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
434 new_ui->set_status("http://www.dillo.org/");
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
435 new_ui->tabs(DilloTabs);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
436
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
437 DilloTabs->add(new_ui);
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
438 DilloTabs->resizable(new_ui);
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
439 DilloTabs->window()->resizable(new_ui);
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
440 DilloTabs->window()->show();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
441
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
442 if (old_bw == NULL && prefs.xpos >= 0 && prefs.ypos >= 0) {
91
950979eb5ead - Enabled the geometry offset part (dillorc2).
jcid
parents: 86
diff changeset
443 // position the first window according to preferences
950979eb5ead - Enabled the geometry offset part (dillorc2).
jcid
parents: 86
diff changeset
444 fltk::Rectangle r;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
445 new_ui->window()->borders(&r);
91
950979eb5ead - Enabled the geometry offset part (dillorc2).
jcid
parents: 86
diff changeset
446 // borders() gives x and y border sizes as negative values
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
447 new_ui->window()->position(prefs.xpos - r.x(), prefs.ypos - r.y());
91
950979eb5ead - Enabled the geometry offset part (dillorc2).
jcid
parents: 86
diff changeset
448 }
950979eb5ead - Enabled the geometry offset part (dillorc2).
jcid
parents: 86
diff changeset
449
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
450 // Now create the Dw render layout and viewport
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
451 FltkPlatform *platform = new FltkPlatform ();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
452 Layout *layout = new Layout (platform);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
453
86
c6cecbed4727 - Made TopGroup a PackedGroup, simplifying UI code and removing workarounds.
jcid
parents: 72
diff changeset
454 FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
399
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 392
diff changeset
455 if (prefs.buffered_drawing == 1)
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 392
diff changeset
456 viewport->setBufferedDrawing (true);
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 392
diff changeset
457 else
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 392
diff changeset
458 viewport->setBufferedDrawing (false);
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
459
86
c6cecbed4727 - Made TopGroup a PackedGroup, simplifying UI code and removing workarounds.
jcid
parents: 72
diff changeset
460 layout->attachView (viewport);
c6cecbed4727 - Made TopGroup a PackedGroup, simplifying UI code and removing workarounds.
jcid
parents: 72
diff changeset
461 new_ui->set_render_layout(*viewport);
50
22a3dedcb1a0 - s/camp/field/ s/CAMP/FIELD/
jcid
parents: 48
diff changeset
462
327
7d83c41d52b9 - Adjusted internal font sizes so the default font_factor is 1.0
jcid
parents: 293
diff changeset
463 viewport->setScrollStep((int) rint(14.0 * prefs.font_factor));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
464
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
465 // Now, create a new browser window structure
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
466 new_bw = a_Bw_new();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
467
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
468 // Reference the UI from the bw
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
469 new_bw->ui = (void *)new_ui;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
470 // Copy the layout pointer into the bw data
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
471 new_bw->render_layout = (void*)layout;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
472
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
473 win->callback(win_cb, new_bw);
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
474
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
475 new_ui->focus_location();
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
476
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
477 return new_bw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
478 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
479
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
480 /*
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
481 * Create a new Tab.
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
482 * i.e the new UI and its associated BrowserWindow data structure.
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
483 */
776
19b91909aa98 some consts
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 490
diff changeset
484 static BrowserWindow *UIcmd_tab_new(const void *vbw)
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
485 {
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
486 _MSG(" UIcmd_tab_new vbw=%p\n", vbw);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
487
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
488 dReturn_val_if_fail (vbw != NULL, NULL);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
489
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
490 BrowserWindow *new_bw = NULL;
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
491 BrowserWindow *old_bw = (BrowserWindow*)vbw;
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
492 UI *ui = BW2UI(old_bw);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
493
386
a8f7106d78ee - Workaround for TabGroup max 128 limit.
jcid
parents: 378
diff changeset
494 // WORKAROUND: limit the number of tabs because of a fltk bug
a8f7106d78ee - Workaround for TabGroup max 128 limit.
jcid
parents: 378
diff changeset
495 if (ui->tabs()->children() >= 127)
a8f7106d78ee - Workaround for TabGroup max 128 limit.
jcid
parents: 378
diff changeset
496 return a_UIcmd_browser_window_new(ui->window()->w(), ui->window()->h(),
1109
39febe63d2c9 add support for --xid command line option
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1101
diff changeset
497 0, vbw);
386
a8f7106d78ee - Workaround for TabGroup max 128 limit.
jcid
parents: 378
diff changeset
498
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
499 // Create and set the UI
433
jcid
parents: 404
diff changeset
500 UI *new_ui = new UI(0, 0, ui->w(), ui->h(), DEFAULT_TAB_LABEL, ui);
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
501 new_ui->tabs(ui->tabs());
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
502
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
503 new_ui->tabs()->add(new_ui);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
504 new_ui->tabs()->resizable(new_ui);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
505 new_ui->tabs()->window()->resizable(new_ui);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
506 new_ui->tabs()->window()->show();
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
507
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
508 // Now create the Dw render layout and viewport
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
509 FltkPlatform *platform = new FltkPlatform ();
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
510 Layout *layout = new Layout (platform);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
511
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
512 FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
513
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
514 layout->attachView (viewport);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
515 new_ui->set_render_layout(*viewport);
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
516
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
517 viewport->setScrollStep((int) rint(14.0 * prefs.font_factor));
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
518
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
519 // Now, create a new browser window structure
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
520 new_bw = a_Bw_new();
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
521
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
522 // Reference the UI from the bw
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
523 new_bw->ui = (void *)new_ui;
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
524 // Copy the layout pointer into the bw data
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
525 new_bw->render_layout = (void*)layout;
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
526
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
527 return new_bw;
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
528 }
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
529
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
530 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
531 * Close one browser window
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
532 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
533 void a_UIcmd_close_bw(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
534 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
535 BrowserWindow *bw = (BrowserWindow *)vbw;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
536 UI *ui = BW2UI(bw);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
537 Layout *layout = (Layout*)bw->render_layout;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
538
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
539 MSG("a_UIcmd_close_bw\n");
1275
be3365808be1 s/Bw_Force/BW_Force/g
Jorge Arellano Cid <jcid@dillo.org>
parents: 1265
diff changeset
540 a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
541 delete(layout);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
542 if (ui->tabs()) {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
543 ui->tabs()->remove(ui);
490
a7095f0cfc4f Set tab focus (after tab close) to the most recently opened one.
Jorge Arellano Cid <jcid@dillo.org>
parents: 484
diff changeset
544 ui->tabs()->value(ui->tabs()->children() - 1);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
545 if (ui->tabs()->value() != -1)
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
546 ui->tabs()->selected_child()->take_focus();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
547 else
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
548 ui->tabs()->window()->hide();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
549 }
213
9a62d31d6f8b - More switches from destroy() to delete() call for close window.
jcid
parents: 172
diff changeset
550 delete(ui);
343
de7f0e48470f - Implemented hide tab labels for tabs < 2
jcid
parents: 341
diff changeset
551
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
552 a_Bw_free(bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
553 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
554
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
555 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
556 * Close all the browser windows
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
557 */
392
966b9162527d - Made ALT+q work.
jcid
parents: 388
diff changeset
558 void a_UIcmd_close_all_bw(void *)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
559 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
560 BrowserWindow *bw;
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
561 int choice = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
562
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
563 if (a_Bw_num() > 1)
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
564 choice = a_Dialog_choice3 ("More than one open tab or Window.",
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
565 "Close all tabs and windows", "Cancel", NULL);
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
566 if (choice == 0)
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
567 while ((bw = a_Bw_get(0)))
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 364
diff changeset
568 a_UIcmd_close_bw((void*)bw);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
569 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
570
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
571 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
572 * Open a new URL in the given browser window.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
573 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
574 * our custom "file:" URIs are normalized here too.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
575 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
576 void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
577 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
578 char *new_urlstr;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
579 DilloUrl *url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
580 int ch;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
581 BrowserWindow *bw = (BrowserWindow*)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
582
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
583 if (urlstr && *urlstr) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
584 /* Filter URL string */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
585 new_urlstr = a_Url_string_strip_delimiters(urlstr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
586
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
587 if (!dStrncasecmp(new_urlstr, "file:", 5)) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
588 /* file URI */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
589 ch = new_urlstr[5];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
590 if (!ch || ch == '.') {
1053
64e078b7a711 Refactor the preferences parser
Tim Nieradzik, Jorge Arellano Cid
parents: 1037
diff changeset
591 url = a_Url_new(Paths::getOldWorkingDir(), "file:");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
592 } else if (ch == '~') {
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
593 url = a_Url_new(dGethomedir(), "file:");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
594 } else {
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
595 url = a_Url_new(new_urlstr, "file:");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
596 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
597
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
598 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
599 /* common case */
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
600 url = a_Url_new(new_urlstr, NULL);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
601 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
602 dFree(new_urlstr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
603
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
604 if (url) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
605 a_Nav_push(bw, url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
606 a_Url_free(url);
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 /* let the rendered area have focus */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
611 //gtk_widget_grab_focus(GTK_BIN(bw->render_main_scroll)->child);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
612 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
613
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
614 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
615 * Open a new URL in the given browser window
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
616 */
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
617 void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
618 {
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
619 a_Nav_push(bw, url);
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
620 }
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
621
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
622 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
623 {
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
624 /* 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
625 * 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
626 */
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
627 if (url) {
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
628 a_Nav_push(new_bw, url);
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
629 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
630 } else {
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
631 BW2UI(new_bw)->focus_location();
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
632 }
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
633 }
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
634
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
635 /*
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
636 * Open a new URL in a new browser window
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
637 */
11
4a5942beffdf Added some "const" qualifiers.
jcid
parents: 8
diff changeset
638 void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
639 {
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
640 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
641 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
642
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
643 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
644 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
645
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
646 UIcmd_open_url_nbw(new_bw, url);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
647 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
648
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
649 /*
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
650 * 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
651 */
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
652 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
653 {
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
654 BrowserWindow *new_bw = UIcmd_tab_new(vbw);
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
655
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
656 if (focus)
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
657 BW2UI(new_bw)->tabs()->selected_child(BW2UI(new_bw));
1449
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
658
6d248ac9f54b adjust focus handling with new tabs and windows (suggested by furaisanjin)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1429
diff changeset
659 UIcmd_open_url_nbw(new_bw, url);
350
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
660 }
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
661
118fe0444e08 - Added the "middle_click_opens_new_tab" option to dillo2rc.
jcid
parents: 343
diff changeset
662 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
663 * Send the browser back to previous page
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
664 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
665 void a_UIcmd_back(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
666 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
667 a_Nav_back((BrowserWindow*)vbw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
668 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
669
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
670 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
671 * Popup the navigation menu of the Back button
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
672 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
673 void a_UIcmd_back_popup(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
674 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
675 a_Menu_history_popup((BrowserWindow*)vbw, -1);
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 * Send the browser to next page in the history list
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
680 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
681 void a_UIcmd_forw(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
682 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
683 a_Nav_forw((BrowserWindow*)vbw);
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 * Popup the navigation menu of the Forward button
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
688 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
689 void a_UIcmd_forw_popup(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
690 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
691 a_Menu_history_popup((BrowserWindow*)vbw, 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
692 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
693
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
694 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
695 * Send the browser to home URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
696 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
697 void a_UIcmd_home(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
698 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
699 a_Nav_home((BrowserWindow*)vbw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
700 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
701
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
702 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
703 * Reload current URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
704 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
705 void a_UIcmd_reload(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
706 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
707 a_Nav_reload((BrowserWindow*)vbw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
708 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
709
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
710 /*
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
711 * 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
712 */
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
713 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
714 {
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
715 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
716 }
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
717
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
718 /*
1037
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
719 * 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
720 */
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
721 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
722 {
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
723 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
724 }
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
725
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 979
diff changeset
726 /*
40
b8319194f7da Added a save-directory preference (save_dir in dillorc2).
jcid
parents: 35
diff changeset
727 * Return a suitable filename for a given URL path.
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
728 */
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 50
diff changeset
729 static char *UIcmd_make_save_filename(const char *pathstr)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
730 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
731 size_t MaxLen = 64;
1120
corvid <corvid@lavabit.com>
parents: 1109
diff changeset
732 char *FileName, *newname, *o, *n;
corvid <corvid@lavabit.com>
parents: 1109
diff changeset
733 const char *name, *dir = a_UIcmd_get_save_dir();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
734
40
b8319194f7da Added a save-directory preference (save_dir in dillorc2).
jcid
parents: 35
diff changeset
735 if ((name = strrchr(pathstr, '/'))) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
736 if (strlen(++name) > MaxLen) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
737 name = name + strlen(name) - MaxLen;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
738 }
1090
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
739 /* 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
740 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
741 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
742 *n++ = (o[i] == ' ') ? '_' :
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
743 (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
744 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
745 }
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
746 *n = 0;
ea72d116c3e2 Replace %20 and ' ' with '_' in the suggested filename for saving
Jorge Arellano Cid <jcid@dillo.org>
parents: 1088
diff changeset
747 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
748 dFree(newname);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
749 } else {
40
b8319194f7da Added a save-directory preference (save_dir in dillorc2).
jcid
parents: 35
diff changeset
750 FileName = dStrconcat(dir ? dir : "", pathstr, NULL);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
751 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
752 return FileName;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
753 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
754
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
755 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
756 * Get the default directory for saving files.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
757 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
758 const char *a_UIcmd_get_save_dir()
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
759 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
760 return save_dir;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
761 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
762
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
763 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
764 * Set the default directory for saving files.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
765 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
766 void a_UIcmd_set_save_dir(const char *dir)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
767 {
1096
bd988ddb1251 add a couple of const
Jorge Arellano Cid <jcid@dillo.org>
parents: 1090
diff changeset
768 const char *p;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
769
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
770 if (dir && (p = strrchr(dir, '/'))) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
771 dFree(save_dir);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
772 // assert a trailing '/'
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
773 save_dir = dStrconcat(dir, (p[1] != 0) ? "/" : "", NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
774 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
775 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
776
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
777 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
778 * Save current URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
779 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
780 void a_UIcmd_save(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
781 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
782 const char *name;
446
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
783 char *SuggestedName;
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
784 BrowserWindow *bw = (BrowserWindow *)vbw;
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
785 const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
786
446
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
787 if (url) {
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
788 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
789 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
790 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
791 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
792 dFree(SuggestedName);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
793
446
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
794 if (name) {
1b0dabe4afa2 - Switched a_UIcmd_save() to take its URL from history (not location bar).
jcid
parents: 442
diff changeset
795 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
796 }
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
797 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
798 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
799
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
800 /*
172
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
801 * Select a file
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
802 */
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
803 const char *a_UIcmd_select_file()
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
804 {
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
805 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
806 }
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
807
765db4e71128 - Implemented the file input control for forms (work in progress).
jcid
parents: 95
diff changeset
808 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
809 * Stop network activity on this bw.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
810 * The stop button was pressed: stop page (and images) downloads.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
811 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
812 void a_UIcmd_stop(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
813 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
814 BrowserWindow *bw = (BrowserWindow *)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
815
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
816 MSG("a_UIcmd_stop()\n");
376
9be38a4a0b14 - Disallowed loading images when expecting is set.
jcid
parents: 372
diff changeset
817 a_Nav_cancel_expect(bw);
1275
be3365808be1 s/Bw_Force/BW_Force/g
Jorge Arellano Cid <jcid@dillo.org>
parents: 1265
diff changeset
818 a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
819 a_UIcmd_set_buttons_sens(bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
820 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
821
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
822 /*
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
823 * 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
824 */
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
825 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
826 {
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
827 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
828 }
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
829
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
830 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
831 * Open URL with dialog chooser
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
832 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
833 void a_UIcmd_open_file(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
834 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
835 char *name;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
836 DilloUrl *url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
837
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
838 name = a_Dialog_open_file("Open File", NULL, "");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
839
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
840 if (name) {
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
841 url = a_Url_new(name, "file:");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
842 a_Nav_push((BrowserWindow*)vbw, url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
843 a_Url_free(url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
844 dFree(name);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
845 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
846 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
847
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
848 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
849 * Returns a newly allocated string holding a search url generated from
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
850 * a string of keywords (separarated by blanks) and prefs.search_url.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
851 * The search string is urlencoded.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
852 */
51
6ff7b6758e0c Added the "static" qualifier where missing.
jcid
parents: 50
diff changeset
853 static char *UIcmd_make_search_str(const char *str)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
854 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
855 char *keys = a_Url_encode_hex_str(str), *c = prefs.search_url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
856 Dstr *ds = dStr_sized_new(128);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
857 char *search_url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
858
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
859 for (; *c; c++) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
860 if (*c == '%')
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
861 switch(*++c) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
862 case 's':
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
863 dStr_append(ds, keys); break;;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
864 case '%':
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
865 dStr_append_c(ds, '%'); break;;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
866 case 0:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
867 MSG_WARN("search_url ends with '%%'\n"); c--; break;;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
868 default:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
869 MSG_WARN("illegal specifier '%%%c' in search_url\n", *c);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
870 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
871 else
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
872 dStr_append_c(ds, *c);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
873 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
874 dFree(keys);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
875
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
876 search_url = ds->str;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
877 dStr_free(ds, 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
878 return search_url;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
879 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
880
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
881 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
882 * Get a query from a dialog and open it
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
883 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
884 void a_UIcmd_search_dialog(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
885 {
1088
8c7cf8e29325 Fix minor memory leak in a_UIcmd_search_dialog
Jorge Arellano Cid <jcid@dillo.org>
parents: 1053
diff changeset
886 const char *query;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
887
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
888 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
889 char *url_str = UIcmd_make_search_str(query);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
890 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
891 dFree(url_str);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
892 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
893 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
894
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
895 /*
241
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
896 * Get password for user
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
897 */
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
898 const char *a_UIcmd_get_passwd(const char *user)
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
899 {
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
900 const char *passwd;
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
901 char *prompt = dStrconcat("Password for user \"", user, "\"", NULL);
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
902 passwd = a_Dialog_passwd(prompt);
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
903 dFree(prompt);
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
904 return passwd;
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
905 }
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
906
78fa66a3ba64 - Enabled proxy_user in preferences.
jcid
parents: 224
diff changeset
907 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
908 * Save link URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
909 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
910 void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
911 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
912 const char *name;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
913 char *SuggestedName;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
914
42
42bc9637b93d Fixed a bug in the save_dir patch
jcid
parents: 40
diff changeset
915 a_UIcmd_set_save_dir(prefs.save_dir);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
916
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
917 SuggestedName = UIcmd_make_save_filename(URL_STR(url));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
918 name = a_Dialog_save_file("Save Link as File", NULL, SuggestedName);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
919 MSG("a_UIcmd_save_link: %s\n", name);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
920 dFree(SuggestedName);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
921
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
922 if (name) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
923 a_Nav_save_url(bw, url, name);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
924 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
925 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
926
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
927 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
928 * Request the bookmarks page
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
929 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
930 void a_UIcmd_book(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
931 {
334
619177c88430 - Forbid dpi GET and POST from non dpi-generated urls.
jcid
parents: 333
diff changeset
932 DilloUrl *url = a_Url_new("dpi:/bm/", NULL);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
933 a_Nav_push((BrowserWindow*)vbw, url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
934 a_Url_free(url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
935 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
936
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
937 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
938 * Add a bookmark for a certain URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
939 */
11
4a5942beffdf Added some "const" qualifiers.
jcid
parents: 8
diff changeset
940 void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
941 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
942 a_Bookmarks_add(bw, url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
943 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
944
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
945
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
946 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
947 * Popup the page menu
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
948 */
958
1a26b2bd7138 [mq]: view-stylesheets
Jorge Arellano Cid <jcid@dillo.org>
parents: 942
diff changeset
949 void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, void *v_cssUrls)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
950 {
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
951 BrowserWindow *bw = (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
952 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
953 a_Menu_page_popup(bw, url, has_bugs, v_cssUrls);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
954 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
955
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
956 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
957 * Popup the link menu
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
958 */
11
4a5942beffdf Added some "const" qualifiers.
jcid
parents: 8
diff changeset
959 void a_UIcmd_link_popup(void *vbw, const DilloUrl *url)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
960 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
961 a_Menu_link_popup((BrowserWindow*)vbw, url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
962 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
963
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
964 /*
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
965 * Pop up the image menu
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
966 */
356
81338758c3dd - Added a workaround for segfaulting popup menus.
jcid
parents: 352
diff changeset
967 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
968 DilloUrl *page_url, DilloUrl *link_url)
22
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
969 {
926
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 908
diff changeset
970 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
971 }
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
972
571f09e42ab6 - Hooked "Activate" to the form_receiver.
jcid
parents: 19
diff changeset
973 /*
477
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
974 * Pop up the form menu
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
975 */
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
976 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
977 bool_t showing_hiddens)
477
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
978 {
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
979 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
980 }
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
981
9a41a7db39f5 Added a popup menu to form's submit button
corvid <corvid@lavabit.com>
parents: 453
diff changeset
982 /*
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
983 * Pop up the file menu
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
984 */
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
985 void a_UIcmd_file_popup(void *vbw, void *v_wid)
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
986 {
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
987 a_Menu_file_popup((BrowserWindow*)vbw, v_wid);
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
988 }
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
989
31b866fdde87 - File menu as popup implementation.
jcid
parents: 399
diff changeset
990 /*
55
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
991 * Copy url string to paste buffer
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
992 */
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
993 void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr)
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
994 {
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
995 Layout *layout = (Layout*)bw->render_layout;
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
996 layout->copySelection(urlstr);
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
997 }
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
998
a1f38544fab6 copy image/link location
jcid
parents: 51
diff changeset
999 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1000 * Show a text window with the URL's source
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1001 */
11
4a5942beffdf Added some "const" qualifiers.
jcid
parents: 8
diff changeset
1002 void a_UIcmd_view_page_source(const DilloUrl *url)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1003 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1004 char *buf;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1005 int buf_size;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1006
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1007 if (a_Nav_get_buf(url, &buf, &buf_size)) {
260
81fc5011ea56 - Moved charset decoding into cache.
jcid
parents: 241
diff changeset
1008 void *vWindow = a_Dialog_make_text_window(buf, "View Page source");
81fc5011ea56 - Moved charset decoding into cache.
jcid
parents: 241
diff changeset
1009 a_Nav_unref_buf(url);
81fc5011ea56 - Moved charset decoding into cache.
jcid
parents: 241
diff changeset
1010 a_Dialog_show_text_window(vWindow);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1011 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1012 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1013
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1014 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1015 * Show a text window with the URL's source
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1016 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1017 void a_UIcmd_view_page_bugs(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1018 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1019 BrowserWindow *bw = (BrowserWindow*)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1020
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1021 if (bw->num_page_bugs > 0) {
260
81fc5011ea56 - Moved charset decoding into cache.
jcid
parents: 241
diff changeset
1022 void *vWindow = a_Dialog_make_text_window(bw->page_bugs->str,
81fc5011ea56 - Moved charset decoding into cache.
jcid
parents: 241
diff changeset
1023 "Detected HTML errors");
81fc5011ea56 - Moved charset decoding into cache.
jcid
parents: 241
diff changeset
1024 a_Dialog_show_text_window(vWindow);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1025 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1026 a_Dialog_msg("Zero detected HTML errors!");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1027 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1028 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1029
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1030 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1031 * Popup the bug meter menu
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1032 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1033 void a_UIcmd_bugmeter_popup(void *vbw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1034 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1035 BrowserWindow *bw = (BrowserWindow*)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1036
19
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1037 a_Menu_bugmeter_popup(bw, a_History_get_url(NAV_TOP_UIDX(bw)));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1038 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1039
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1040 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1041 * Make a list of URL indexes for the history popup
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1042 * based on direction (-1 = back, 1 = forward)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1043 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1044 int *a_UIcmd_get_history(BrowserWindow *bw, int direction)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1045 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1046 int i, j, n;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1047 int *hlist;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1048
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1049 // Count the number of URLs
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1050 i = a_Nav_stack_ptr(bw) + direction;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1051 for (n = 0 ; i >= 0 && i < a_Nav_stack_size(bw); i+=direction)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1052 ++n;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1053 hlist = dNew(int, n + 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1054
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1055 // Fill the list
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1056 i = a_Nav_stack_ptr(bw) + direction;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1057 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
1058 hlist[j] = NAV_UIDX(bw,i);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1059 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1060 hlist[j] = -1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1061
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1062 return hlist;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1063 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1064
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1065 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1066 * Jump to a certain URL in the navigation stack.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1067 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1068 void a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1069 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1070 a_Nav_jump(bw, offset, new_bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1071 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1072
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1073 // UI binding functions -------------------------------------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1074
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1075 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1076 * Return browser window width and height
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1077 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1078 void a_UIcmd_get_wh(BrowserWindow *bw, int *w, int *h)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1079 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1080 *w = BW2UI(bw)->w();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1081 *h = BW2UI(bw)->h();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1082 _MSG("a_UIcmd_wh: w=%d, h=%d\n", *w, *h);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1083 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1084
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1085 /*
15
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1086 * 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
1087 */
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1088 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
1089 {
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1090 Layout *layout = (Layout*)bw->render_layout;
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1091
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1092 if (layout) {
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1093 *x = layout->getScrollPosX();
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1094 *y = layout->getScrollPosY();
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1095 }
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1096 }
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1097
a15e6c075023 Fixed the problem of scrolling position (remember position in a page)
jcid
parents: 11
diff changeset
1098 /*
19
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1099 * 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
1100 */
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1101 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
1102 {
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1103 Layout *layout = (Layout*)bw->render_layout;
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1104
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1105 if (layout) {
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1106 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
1107 }
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1108 }
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1109
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1110 /*
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1111 * 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
1112 */
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1113 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
1114 {
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1115 Layout *layout = (Layout*)bw->render_layout;
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1116
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1117 if (layout && f) {
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1118 layout->setAnchor(f);
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1119 }
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1120 }
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1121
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 15
diff changeset
1122 /*
1209
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1123 * Pass scrolling command to dw.
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1124 */
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1125 void a_UIcmd_scroll(BrowserWindow *bw, int icmd)
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1126 {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1127 Layout *layout = (Layout*)bw->render_layout;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1128
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1129 if (layout) {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1130 typedef struct {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1131 KeysCommand_t keys_cmd;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1132 ScrollCommand dw_cmd;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1133 } mapping_t;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1134
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1135 const mapping_t map[] = {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1136 {KEYS_SCREEN_UP, SCREEN_UP_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1137 {KEYS_SCREEN_DOWN, SCREEN_DOWN_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1138 {KEYS_LINE_UP, LINE_UP_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1139 {KEYS_LINE_DOWN, LINE_DOWN_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1140 {KEYS_LEFT, LEFT_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1141 {KEYS_RIGHT, RIGHT_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1142 {KEYS_TOP, TOP_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1143 {KEYS_BOTTOM, BOTTOM_CMD},
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1144 };
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1145 KeysCommand_t keycmd = (KeysCommand_t)icmd;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1146
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1147 for (uint_t i = 0; i < (sizeof(map)/sizeof(mapping_t)); i++) {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1148 if (keycmd == map[i].keys_cmd) {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1149 layout->scroll(map[i].dw_cmd);
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1150 break;
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1151 }
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1152 }
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1153 }
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1154 }
1326
02ef25700865 trim some spaces
corvid <corvid@lavabit.com>
parents: 1275
diff changeset
1155
1209
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1150
diff changeset
1156 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1157 * Get location's text
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1158 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1159 char *a_UIcmd_get_location_text(BrowserWindow *bw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1160 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1161 return dStrdup(BW2UI(bw)->get_location());
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1162 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1163
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1164 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1165 * Set location's text
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1166 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1167 void a_UIcmd_set_location_text(void *vbw, const char *text)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1168 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1169 BrowserWindow *bw = (BrowserWindow*)vbw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1170 BW2UI(bw)->set_location(text);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1171 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1172
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1173 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1174 * Set the page progress bar
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1175 * cmd: 0 Deactivate, 1 Update, 2 Clear
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1176 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1177 void a_UIcmd_set_page_prog(BrowserWindow *bw, size_t nbytes, int cmd)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1178 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1179 BW2UI(bw)->set_page_prog(nbytes, cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1180 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1181
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1182 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1183 * Set the images progress bar
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1184 * cmd: 0 Deactivate, 1 Update, 2 Clear
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1185 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1186 void a_UIcmd_set_img_prog(BrowserWindow *bw, int n_img, int t_img, int cmd)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1187 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1188 BW2UI(bw)->set_img_prog(n_img, t_img, cmd);
291
f8ec5a664371 - Updated AUTHORS
jcid
parents: 260
diff changeset
1189 #if 0
293
8b9684badb34 - Added a minor debug feature.
jcid
parents: 291
diff changeset
1190 if (!cmd)
291
f8ec5a664371 - Updated AUTHORS
jcid
parents: 260
diff changeset
1191 a_UIcmd_close_bw(bw);
f8ec5a664371 - Updated AUTHORS
jcid
parents: 260
diff changeset
1192 #endif
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1193 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1194
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1195 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1196 * Set the bug meter progress label
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1197 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1198 void a_UIcmd_set_bug_prog(BrowserWindow *bw, int n_bug)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1199 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1200 BW2UI(bw)->set_bug_prog(n_bug);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1201 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1202
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1203 /*
1101
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1204 * 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
1205 * (Update window titlebar for the current tab only)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1206 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1207 void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1208 {
1126
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1209 const int size = 128;
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1210 char title[size];
1101
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1211
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1212 if (a_UIcmd_get_bw_by_widget(BW2UI(bw)->tabs()->selected_child()) == bw) {
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1213 // This is the focused bw, set window title
1126
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1214 if (snprintf(title, size, "Dillo: %s", label) >= size) {
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1215 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
1216 snprintf(title + i, 4, "...");
958903cf2733 properly truncate utf8 window titles
corvid <corvid@lavabit.com>
parents: 1120
diff changeset
1217 }
1101
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1218 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
1219 BW2UI(bw)->window()->redraw_label();
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1220 }
73a85563d3a9 Fix: don't update window title for background tabs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1097
diff changeset
1221 BW2UI(bw)->set_tab_title(label);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1222 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1223
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1224 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1225 * Set a printf-like status string on the bottom of the dillo window.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1226 * Beware: The safe way to set an arbitrary string is
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1227 * a_UIcmd_set_msg(bw, "%s", str)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1228 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1229 void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1230 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1231 va_list argp;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1232 Dstr *ds = dStr_sized_new(128);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1233 va_start(argp, format);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1234 dStr_vsprintf(ds, format, argp);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1235 va_end(argp);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1236 BW2UI(bw)->set_status(ds->str);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1237 dStr_free(ds, 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1238 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1239
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1240 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1241 * Set the sensitivity of back/forw/stop buttons.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1242 */
371
898e6ca77d7e - Removed the button sensitivity timeout.
jcid
parents: 367
diff changeset
1243 void a_UIcmd_set_buttons_sens(BrowserWindow *bw)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1244 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1245 int sens;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1246
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1247 // Stop
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1248 sens = (dList_length(bw->ImageClients) || dList_length(bw->RootClients));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1249 BW2UI(bw)->button_set_sens(UI_STOP, sens);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1250 // Back
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1251 sens = (a_Nav_stack_ptr(bw) > 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1252 BW2UI(bw)->button_set_sens(UI_BACK, sens);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1253 // Forward
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1254 sens = (a_Nav_stack_ptr(bw) < a_Nav_stack_size(bw) - 1 &&
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1255 !bw->nav_expecting);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1256 BW2UI(bw)->button_set_sens(UI_FORW, sens);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1257 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1258
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1259 /*
438
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1260 * Keep track of mouse pointer over a link.
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1261 */
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1262 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
1263 {
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1264 BW2UI(bw)->pointerOnLink(flag);
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1265 }
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1266
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1267 /*
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1268 * Is the mouse pointer over a link?
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1269 */
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1270 int a_UIcmd_pointer_on_link(BrowserWindow *bw)
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1271 {
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1272 return BW2UI(bw)->pointerOnLink();
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1273 }
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1274
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 433
diff changeset
1275 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1276 * Toggle control panel (aka. fullscreen)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1277 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1278 void a_UIcmd_fullscreen_toggle(BrowserWindow *bw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1279 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1280 BW2UI(bw)->fullscreen_toggle();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1281 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1282
56
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1283 /*
908
40bc2df4de7a Implemented "search previous" in string searches
João Ricardo Lourenço <jorl17.8@gmail.com>
parents: 907
diff changeset
1284 * Search for next/previous occurrence of key.
56
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1285 */
941
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1286 void a_UIcmd_findtext_search(BrowserWindow *bw, const char *key,
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1287 int case_sens, int backwards)
56
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1288 {
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1289 Layout *l = (Layout *)bw->render_layout;
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
1290
908
40bc2df4de7a Implemented "search previous" in string searches
João Ricardo Lourenço <jorl17.8@gmail.com>
parents: 907
diff changeset
1291 switch (l->search(key, case_sens, backwards)) {
941
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1292 case FindtextState::RESTART:
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1293 a_UIcmd_set_msg(bw, "No further occurrences of \"%s\". "
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1294 "Restarting from the top.", key);
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1295 break;
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1296 case FindtextState::NOT_FOUND:
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1297 a_UIcmd_set_msg(bw, "\"%s\" not found.", key);
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1298 break;
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1299 case FindtextState::SUCCESS:
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1300 default:
217470146a54 whitespace
Jorge Arellano Cid <jcid@dillo.org>
parents: 930
diff changeset
1301 a_UIcmd_set_msg(bw, "");
56
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1302 }
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1303 }
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1304
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1305 /*
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1306 * Reset text search state.
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1307 */
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1308 void a_UIcmd_findtext_reset(BrowserWindow *bw)
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1309 {
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1310 Layout *l = (Layout *)bw->render_layout;
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1311 l->resetSearch();
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1312
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1313 a_UIcmd_set_msg(bw, "");
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1314 }
7bf5884218c4 - Bound Ctrl+Space to fullscreen toggle.
jcid
parents: 55
diff changeset
1315
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1316 /*
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1317 * Focus the rendered area.
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1318 */
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1319 void a_UIcmd_focus_main_area(BrowserWindow *bw)
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1320 {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1321 BW2UI(bw)->focus_main();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1322 }
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1323
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1324 /*
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1325 * Focus the location bar.
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1326 */
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1327 void a_UIcmd_focus_location(void *vbw)
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1328 {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1329 BrowserWindow *bw = (BrowserWindow*)vbw;
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1330 BW2UI(bw)->focus_location();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1331 }
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 335
diff changeset
1332