@@ -21,26 +21,30 @@ class html_widget_notifier : public litebrowser::browser_notify_interface
21
21
using render_func = std::function<void ()>;
22
22
using update_state_func = std::function<void ()>;
23
23
using on_page_loaded_func = std::function<void (uint64_t )>;
24
+ using on_set_caption_func = std::function<void (const std::string&)>;
24
25
private:
25
26
enum func_type
26
27
{
27
28
func_type_none,
28
29
func_type_redraw,
29
30
func_type_render,
30
31
func_type_update_state,
31
- func_type_on_page_loaded
32
+ func_type_on_page_loaded,
33
+ func_type_on_set_caption
32
34
};
33
35
struct queue_item
34
36
{
35
37
func_type type;
36
38
uint64_t param;
39
+ std::string str_param;
37
40
};
38
41
39
42
Glib::Dispatcher m_dispatcher;
40
43
redraw_func m_redraw_func;
41
44
render_func m_render_func;
42
45
update_state_func m_update_state_func;
43
46
on_page_loaded_func m_on_page_loaded_func;
47
+ on_set_caption_func m_on_set_caption_func;
44
48
45
49
std::mutex m_lock;
46
50
bool m_disconnect = false ;
@@ -79,13 +83,18 @@ class html_widget_notifier : public litebrowser::browser_notify_interface
79
83
m_on_page_loaded_func = _on_page_loaded_func;
80
84
}
81
85
86
+ void connect_on_set_caption (on_set_caption_func _on_set_caption_func)
87
+ {
88
+ m_on_set_caption_func = _on_set_caption_func;
89
+ }
90
+
82
91
private:
83
92
84
93
void redraw () override
85
94
{
86
95
{
87
96
std::lock_guard lock (m_lock);
88
- m_queue.push (queue_item{func_type_redraw, 0 });
97
+ m_queue.push (queue_item{func_type_redraw, 0 , {} });
89
98
}
90
99
m_dispatcher.emit ();
91
100
}
@@ -94,7 +103,7 @@ class html_widget_notifier : public litebrowser::browser_notify_interface
94
103
{
95
104
{
96
105
std::lock_guard lock (m_lock);
97
- m_queue.push (queue_item{func_type_render, 0 });
106
+ m_queue.push (queue_item{func_type_render, 0 , {} });
98
107
}
99
108
m_dispatcher.emit ();
100
109
}
@@ -103,7 +112,7 @@ class html_widget_notifier : public litebrowser::browser_notify_interface
103
112
{
104
113
{
105
114
std::lock_guard lock (m_lock);
106
- m_queue.push (queue_item{func_type_update_state, 0 });
115
+ m_queue.push (queue_item{func_type_update_state, 0 , {} });
107
116
}
108
117
m_dispatcher.emit ();
109
118
}
@@ -112,7 +121,16 @@ class html_widget_notifier : public litebrowser::browser_notify_interface
112
121
{
113
122
{
114
123
std::lock_guard lock (m_lock);
115
- m_queue.push (queue_item{func_type_on_page_loaded, web_page_id});
124
+ m_queue.push (queue_item{func_type_on_page_loaded, web_page_id, {}});
125
+ }
126
+ m_dispatcher.emit ();
127
+ }
128
+
129
+ void on_set_caption (const std::string& caption) override
130
+ {
131
+ {
132
+ std::lock_guard lock (m_lock);
133
+ m_queue.push (queue_item{func_type_on_set_caption, 0 , caption});
116
134
}
117
135
m_dispatcher.emit ();
118
136
}
@@ -164,6 +182,12 @@ class html_widget_notifier : public litebrowser::browser_notify_interface
164
182
m_on_page_loaded_func (item.param );
165
183
}
166
184
break ;
185
+ case func_type_on_set_caption:
186
+ if (m_on_set_caption_func)
187
+ {
188
+ m_on_set_caption_func (item.str_param );
189
+ }
190
+ break ;
167
191
168
192
default :
169
193
break ;
@@ -452,7 +476,6 @@ class html_widget : public Gtk::Widget,
452
476
int get_render_width () override ;
453
477
void scroll_to (int x, int y) override ;
454
478
void get_client_rect (litehtml::position& client) const override ;
455
- void set_caption (const char * caption) override ;
456
479
cairo_surface_t * load_image (const std::string& path) override ;
457
480
458
481
void snapshot_vfunc (const Glib::RefPtr<Gtk::Snapshot>& snapshot) override ;
@@ -466,6 +489,7 @@ class html_widget : public Gtk::Widget,
466
489
void size_allocate_vfunc (int width, int height, int baseline) override ;
467
490
void allocate_scrollbars (int width, int height);
468
491
492
+ void set_caption (const std::string& caption);
469
493
void on_vadjustment_changed ();
470
494
void on_hadjustment_changed ();
471
495
void on_adjustments_changed ();
0 commit comments