1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
|
/*
* Copyright © 2000-2004 Marco Pesenti Gritti
* Copyright © 2001, 2002 Jorn Baayen
* Copyright © 2003, 2004, 2005 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $Id$
*/
#include "config.h"
#include "ephy-toolbar.h"
#include "ephy-link.h"
#include "ephy-go-action.h"
#include "ephy-home-action.h"
#include "ephy-location-entry.h"
#include "ephy-location-action.h"
#include "ephy-navigation-action.h"
#include "ephy-topic-action.h"
#include "ephy-zoom-action.h"
#include "ephy-spinner-tool-item.h"
#include "ephy-dnd.h"
#include "ephy-shell.h"
#include "ephy-stock-icons.h"
#include "ephy-action-helper.h"
#include "window-commands.h"
#include "ephy-debug.h"
#include <glib/gi18n.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkuimanager.h>
#include <gtk/gtktoolitem.h>
#include <gtk/gtktoolbutton.h>
#include <gtk/gtkseparatortoolitem.h>
#include <gtk/gtktoolbar.h>
#include <string.h>
enum
{
BACK_ACTION,
FORWARD_ACTION,
UP_ACTION,
LOCATION_ACTION,
ZOOM_ACTION,
LAST_ACTION
};
enum
{
SENS_FLAG = 1 << 0
};
#define EPHY_TOOLBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOOLBAR, EphyToolbarPrivate))
struct _EphyToolbarPrivate
{
EphyWindow *window;
GtkActionGroup *action_group;
GtkAction *actions[LAST_ACTION];
GtkWidget *fixed_toolbar;
EphySpinnerToolItem *spinner;
GtkToolItem *sep_item;
GtkToolItem *exit_button;
gulong set_focus_handler;
guint updating_address : 1;
guint show_lock : 1;
guint is_secure : 1;
guint leave_fullscreen_visible : 1;
guint spinning : 1;
};
static const GtkTargetEntry drag_targets [] =
{
{ EGG_TOOLBAR_ITEM_TYPE, GTK_TARGET_SAME_APP, 0 },
{ EPHY_DND_TOPIC_TYPE, 0, 1 },
{ EPHY_DND_URL_TYPE, 0, 2 }
};
enum
{
PROP_0,
PROP_WINDOW
};
enum
{
ACTIVATION_FINISHED,
EXIT_CLICKED,
LOCK_CLICKED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
static GObjectClass *parent_class = NULL;
/* helper functions */
static void
exit_button_clicked_cb (GtkWidget *button,
EphyToolbar *toolbar)
{
g_signal_emit (toolbar, signals[EXIT_CLICKED], 0);
}
static void
ephy_toolbar_update_fixed_visibility (EphyToolbar *toolbar)
{
EphyToolbarPrivate *priv = toolbar->priv;
gboolean show;
show = priv->leave_fullscreen_visible;
g_object_set (priv->sep_item, "visible", show, NULL);
g_object_set (priv->exit_button, "visible", show,
"sensitive", show, NULL);
}
static void
ephy_toolbar_update_spinner (EphyToolbar *toolbar)
{
EphyToolbarPrivate *priv = toolbar->priv;
ephy_spinner_tool_item_set_spinning (priv->spinner, priv->spinning);
}
static void
maybe_finish_activation_cb (EphyWindow *window,
GtkWidget *widget,
EphyToolbar *toolbar)
{
EphyToolbarPrivate *priv = toolbar->priv;
GtkWidget *wtoolbar = GTK_WIDGET (toolbar);
while (widget != NULL && widget != wtoolbar)
{
widget = widget->parent;
}
/* if widget == toolbar, the new focus widget is in the toolbar, so we
* don't deactivate.
*/
if (widget != wtoolbar)
{
g_signal_handler_disconnect (window, priv->set_focus_handler);
toolbar->priv->set_focus_handler = 0;
g_signal_emit (toolbar, signals[ACTIVATION_FINISHED], 0);
}
}
static void
sync_user_input_cb (EphyLocationAction *action,
GParamSpec *pspec,
EphyToolbar *toolbar)
{
EphyToolbarPrivate *priv = toolbar->priv;
EphyEmbed *embed;
const char *address;
LOG ("sync_user_input_cb");
if (priv->updating_address) return;
embed = ephy_window_get_active_tab (priv->window);
g_assert (EPHY_IS_EMBED (embed));
address = ephy_location_action_get_address (action);
priv->updating_address = TRUE;
ephy_embed_set_typed_address (embed, address,
EPHY_EMBED_ADDRESS_EXPIRE_CURRENT);
priv->updating_address = FALSE;
}
static void
lock_clicked_cb (EphyLocationAction *action,
EphyToolbar *toolbar)
{
g_signal_emit (toolbar, signals[LOCK_CLICKED], 0);
}
static void
zoom_to_level_cb (GtkAction *action,
float zoom,
EphyToolbar *toolbar)
{
ephy_window_set_zoom (toolbar->priv->window, zoom);
}
static void
ephy_toolbar_set_window (EphyToolbar *toolbar,
EphyWindow *window)
{
EphyToolbarPrivate *priv = toolbar->priv;
GtkUIManager *manager;
GtkAction *action;
priv->window = window;
manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
priv->action_group = gtk_action_group_new ("SpecialToolbarActions");
gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
g_object_unref (priv->action_group);
action = priv->actions[BACK_ACTION] =
g_object_new (EPHY_TYPE_NAVIGATION_ACTION,
"name", "NavigationBack",
"label", _("_Back"),
"stock_id", GTK_STOCK_GO_BACK,
"tooltip", _("Go to the previous visited page"),
/* this is the tooltip on the Back button's drop-down arrow, which will show
* a menu with all sites you can go 'back' to
*/
"arrow-tooltip", _("Back history"),
"window", priv->window,
"direction", EPHY_NAVIGATION_DIRECTION_BACK,
"is_important", TRUE,
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);
gtk_action_group_add_action_with_accel (priv->action_group, action,
"<alt>Left");
g_object_unref (action);
action = priv->actions[FORWARD_ACTION] =
g_object_new (EPHY_TYPE_NAVIGATION_ACTION,
"name", "NavigationForward",
"label", _("_Forward"),
"stock_id", GTK_STOCK_GO_FORWARD,
"tooltip", _("Go to the next visited page"),
/* this is the tooltip on the Forward button's drop-down arrow, which will show
* a menu with all sites you can go 'forward' to
*/
"arrow-tooltip", _("Forward history"),
"window", priv->window,
"direction", EPHY_NAVIGATION_DIRECTION_FORWARD,
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);
gtk_action_group_add_action_with_accel (priv->action_group, action,
"<alt>Right");
g_object_unref (action);
action = priv->actions[UP_ACTION] =
g_object_new (EPHY_TYPE_NAVIGATION_ACTION,
"name", "NavigationUp",
"label", _("_Up"),
"stock_id", GTK_STOCK_GO_UP,
"tooltip", _("Go up one level"),
/* this is the tooltip on the Up button's drop-down arrow, which will show
* a menu with al sites you can go 'up' to
*/
"arrow-tooltip", _("List of upper levels"),
"window", priv->window,
"direction", EPHY_NAVIGATION_DIRECTION_UP,
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);
gtk_action_group_add_action_with_accel (priv->action_group, action,
"<alt>Up");
g_object_unref (action);
/* FIXME: I'm still waiting for the exact term to
* user here from the docs team.
*/
action = priv->actions[LOCATION_ACTION] =
g_object_new (EPHY_TYPE_LOCATION_ACTION,
"name", "Location",
"label", _("Address Entry"),
"stock_id", EPHY_STOCK_ENTRY,
"tooltip", _("Enter a web address to open, or a phrase to search for"),
"visible-overflown", FALSE,
"window", priv->window,
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);
g_signal_connect (action, "notify::address",
G_CALLBACK (sync_user_input_cb), toolbar);
g_signal_connect (action, "lock-clicked",
G_CALLBACK (lock_clicked_cb), toolbar);
gtk_action_group_add_action (priv->action_group, action);
g_object_unref (action);
action = priv->actions[ZOOM_ACTION] =
g_object_new (EPHY_TYPE_ZOOM_ACTION,
"name", "Zoom",
"label", _("Zoom"),
"stock_id", GTK_STOCK_ZOOM_IN,
"tooltip", _("Adjust the text size"),
"zoom", 1.0,
NULL);
g_signal_connect (action, "zoom_to_level",
G_CALLBACK (zoom_to_level_cb), toolbar);
gtk_action_group_add_action (priv->action_group, action);
g_object_unref (action);
action = g_object_new (EPHY_TYPE_GO_ACTION,
"name", "ToolbarGo",
"label", _("Go"),
"stock_id", GTK_STOCK_JUMP_TO,
"tooltip", _("Go to the address entered in the address entry"),
NULL);
g_signal_connect (action, "activate",
G_CALLBACK (window_cmd_load_location), priv->window);
gtk_action_group_add_action (priv->action_group, action);
g_object_unref (action);
action = g_object_new (EPHY_TYPE_HOME_ACTION,
"name", "GoHome",
"label", _("_Home"),
"stock_id", GTK_STOCK_HOME,
"tooltip", _("Go to the home page"),
"is_important", TRUE,
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);
gtk_action_group_add_action_with_accel (priv->action_group, action, "<alt>Home");
g_object_unref (action);
action = g_object_new (EPHY_TYPE_HOME_ACTION,
"name", "FileNewTab",
"label", _("New _Tab"),
"stock_id", STOCK_NEW_TAB,
"tooltip", _("Open a new tab"),
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);
gtk_action_group_add_action_with_accel (priv->action_group, action, "<control>T");
g_object_unref (action);
action = g_object_new (EPHY_TYPE_HOME_ACTION,
"name", "FileNewWindow",
"label", _("_New Window"),
"stock_id", STOCK_NEW_WINDOW,
"tooltip", _("Open a new window"),
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);
gtk_action_group_add_action_with_accel (priv->action_group, action, "<control>N");
g_object_unref (action);
}
/* public functions */
GtkActionGroup *
ephy_toolbar_get_action_group (EphyToolbar *toolbar)
{
return toolbar->priv->action_group;
}
void
ephy_toolbar_set_favicon (EphyToolbar *toolbar,
GdkPixbuf *icon)
{
EphyToolbarPrivate *priv = toolbar->priv;
g_object_set (priv->actions[LOCATION_ACTION], "icon", icon, NULL);
}
void
ephy_toolbar_set_show_leave_fullscreen (EphyToolbar *toolbar,
gboolean show)
{
EphyToolbarPrivate *priv = toolbar->priv;
priv->leave_fullscreen_visible = show != FALSE;
ephy_toolbar_update_fixed_visibility (toolbar);
}
void
ephy_toolbar_activate_location (EphyToolbar *toolbar)
{
EphyToolbarPrivate *priv = toolbar->priv;
GSList *proxies;
GtkWidget *entry = NULL;
gboolean visible;
proxies = gtk_action_get_proxies (priv->actions[LOCATION_ACTION]);
if (proxies != NULL && EPHY_IS_LOCATION_ENTRY (proxies->data))
{
entry = GTK_WIDGET (proxies->data);
}
if (entry == NULL)
{
/* happens when the user has removed the location entry from
* the toolbars.
*/
return;
}
g_object_get (G_OBJECT (toolbar), "visible", &visible, NULL);
if (visible == FALSE)
{
gtk_widget_show (GTK_WIDGET (toolbar));
toolbar->priv->set_focus_handler =
g_signal_connect (toolbar->priv->window, "set-focus",
G_CALLBACK (maybe_finish_activation_cb),
toolbar);
}
ephy_location_entry_activate (EPHY_LOCATION_ENTRY (entry));
}
const char *
ephy_toolbar_get_location (EphyToolbar *toolbar)
{
EphyToolbarPrivate *priv = toolbar->priv;
EphyLocationAction *action = EPHY_LOCATION_ACTION (priv->actions[LOCATION_ACTION]);
return ephy_location_action_get_address (action);
}
void
ephy_toolbar_set_location (EphyToolbar *toolbar,
const char *address,
const char *typed_address)
{
EphyToolbarPrivate *priv = toolbar->priv;
EphyLocationAction *action = EPHY_LOCATION_ACTION (priv->actions[LOCATION_ACTION]);
if (priv->updating_address) return;
priv->updating_address = TRUE;
ephy_location_action_set_address (action, address, typed_address);
priv->updating_address = FALSE;
}
void
ephy_toolbar_set_navigation_actions (EphyToolbar *toolbar,
gboolean back,
gboolean forward,
gboolean up)
{
EphyToolbarPrivate *priv = toolbar->priv;
ephy_action_change_sensitivity_flags (priv->actions[BACK_ACTION], SENS_FLAG, !back);
ephy_action_change_sensitivity_flags (priv->actions[FORWARD_ACTION], SENS_FLAG, !forward);
ephy_action_change_sensitivity_flags (priv->actions[UP_ACTION], SENS_FLAG, !up);
}
void
ephy_toolbar_set_navigation_tooltips (EphyToolbar *toolbar,
const char *back_title,
const char *forward_title)
{
EphyToolbarPrivate *priv = toolbar->priv;
GValue value = { 0 };
g_value_init (&value, G_TYPE_STRING);
g_value_set_static_string (&value, back_title);
g_object_set_property (G_OBJECT (priv->actions[BACK_ACTION]),
"tooltip", &value);
g_value_set_static_string (&value, forward_title);
g_object_set_property (G_OBJECT (priv->actions[FORWARD_ACTION]),
"tooltip", &value);
g_value_unset (&value);
}
void
ephy_toolbar_set_security_state (EphyToolbar *toolbar,
gboolean is_secure,
gboolean show_lock,
const char *stock_id,
const char *tooltip)
{
EphyToolbarPrivate *priv = toolbar->priv;
priv->show_lock = show_lock != FALSE;
priv->is_secure = is_secure != FALSE;
g_object_set (priv->actions[LOCATION_ACTION],
"lock-stock-id", stock_id,
"lock-tooltip", tooltip,
"show-lock", priv->show_lock,
"secure", is_secure,
NULL);
}
void
ephy_toolbar_set_spinning (EphyToolbar *toolbar,
gboolean spinning)
{
EphyToolbarPrivate *priv = toolbar->priv;
priv->spinning = spinning != FALSE;
ephy_toolbar_update_spinner (toolbar);
}
void
ephy_toolbar_set_zoom (EphyToolbar *toolbar,
gboolean can_zoom,
float zoom)
{
EphyToolbarPrivate *priv = toolbar->priv;
gtk_action_set_sensitive (priv->actions[ZOOM_ACTION], can_zoom);
g_object_set (priv->actions[ZOOM_ACTION], "zoom", can_zoom ? zoom : 1.0, NULL);
}
/* Class implementation */
static void
ephy_toolbar_realize (GtkWidget *widget)
{
GTK_WIDGET_CLASS (parent_class)->realize (widget);
}
static void
ephy_toolbar_unrealize (GtkWidget *widget)
{
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static void
ephy_toolbar_show (GtkWidget *widget)
{
EphyToolbar *toolbar = EPHY_TOOLBAR (widget);
GTK_WIDGET_CLASS (parent_class)->show (widget);
ephy_toolbar_update_spinner (toolbar);
}
static void
ephy_toolbar_hide (GtkWidget *widget)
{
EphyToolbar *toolbar = EPHY_TOOLBAR (widget);
GTK_WIDGET_CLASS (parent_class)->hide (widget);
ephy_toolbar_update_spinner (toolbar);
}
static void
ephy_toolbar_init (EphyToolbar *toolbar)
{
EphyToolbarPrivate *priv;
priv = toolbar->priv = EPHY_TOOLBAR_GET_PRIVATE (toolbar);
}
static GObject *
ephy_toolbar_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_params)
{
GObject *object;
EphyToolbar *toolbar;
EphyToolbarPrivate *priv;
GtkToolbar *gtoolbar;
object = parent_class->constructor (type, n_construct_properties,
construct_params);
toolbar = EPHY_TOOLBAR (object);
priv = toolbar->priv;
priv->fixed_toolbar = gtk_toolbar_new ();
gtoolbar = GTK_TOOLBAR (priv->fixed_toolbar);
gtk_toolbar_set_show_arrow (gtoolbar, FALSE);
priv->spinner = EPHY_SPINNER_TOOL_ITEM (ephy_spinner_tool_item_new ());
gtk_toolbar_insert (gtoolbar, GTK_TOOL_ITEM (priv->spinner), -1);
gtk_widget_show (GTK_WIDGET (priv->spinner));
priv->sep_item = gtk_separator_tool_item_new ();
gtk_toolbar_insert (gtoolbar, priv->sep_item, -1);
priv->exit_button = gtk_tool_button_new_from_stock (GTK_STOCK_LEAVE_FULLSCREEN);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->exit_button), _("Leave Fullscreen"));
gtk_tool_item_set_is_important (priv->exit_button, TRUE);
g_signal_connect (priv->exit_button, "clicked",
G_CALLBACK (exit_button_clicked_cb), toolbar);
gtk_toolbar_insert (gtoolbar, priv->exit_button, -1);
egg_editable_toolbar_set_fixed (EGG_EDITABLE_TOOLBAR (toolbar), gtoolbar);
ephy_toolbar_update_fixed_visibility (toolbar);
return object;
}
static void
ephy_toolbar_finalize (GObject *object)
{
EphyToolbar *toolbar = EPHY_TOOLBAR (object);
EphyToolbarPrivate *priv = toolbar->priv;
if (priv->set_focus_handler != 0)
{
g_signal_handler_disconnect (priv->window,
priv->set_focus_handler);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
ephy_toolbar_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
/* no readable properties */
g_assert_not_reached ();
}
static void
ephy_toolbar_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
EphyToolbar *toolbar = EPHY_TOOLBAR (object);
switch (prop_id)
{
case PROP_WINDOW:
ephy_toolbar_set_window (toolbar, g_value_get_object (value));
break;
}
}
static void
ephy_toolbar_class_init (EphyToolbarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = ephy_toolbar_constructor;
object_class->finalize = ephy_toolbar_finalize;
object_class->set_property = ephy_toolbar_set_property;
object_class->get_property = ephy_toolbar_get_property;
widget_class->realize = ephy_toolbar_realize;
widget_class->unrealize = ephy_toolbar_unrealize;
widget_class->show = ephy_toolbar_show;
widget_class->hide = ephy_toolbar_hide;
signals[ACTIVATION_FINISHED] =
g_signal_new ("activation-finished",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EphyToolbarClass, activation_finished),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
signals[EXIT_CLICKED] =
g_signal_new
("exit-clicked",
EPHY_TYPE_TOOLBAR,
G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EphyToolbarClass, exit_clicked),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
signals[LOCK_CLICKED] =
g_signal_new
("lock-clicked",
EPHY_TYPE_TOOLBAR,
G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EphyToolbarClass, lock_clicked),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
g_object_class_install_property (object_class,
PROP_WINDOW,
g_param_spec_object ("window",
"Window",
"Parent window",
EPHY_TYPE_WINDOW,
G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
G_PARAM_CONSTRUCT_ONLY));
g_type_class_add_private (object_class, sizeof(EphyToolbarPrivate));
}
GType
ephy_toolbar_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0))
{
const GTypeInfo our_info =
{
sizeof (EphyToolbarClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) ephy_toolbar_class_init,
NULL,
NULL, /* class_data */
sizeof (EphyToolbar),
0, /* n_preallocs */
(GInstanceInitFunc) ephy_toolbar_init
};
const GInterfaceInfo link_info =
{
NULL,
NULL,
NULL
};
type = g_type_register_static (EGG_TYPE_EDITABLE_TOOLBAR,
"EphyToolbar",
&our_info, 0);
g_type_add_interface_static (type,
EPHY_TYPE_LINK,
&link_info);
}
return type;
}
EphyToolbar *
ephy_toolbar_new (EphyWindow *window)
{
EggEditableToolbar *etoolbar;
etoolbar = EGG_EDITABLE_TOOLBAR
(g_object_new (EPHY_TYPE_TOOLBAR,
"window", window,
"ui-manager", ephy_window_get_ui_manager (window),
"popup-path", "/ToolbarPopup",
NULL));
egg_editable_toolbar_add_visibility
(etoolbar, "/menubar/ViewMenu/ViewTogglesGroup/ToolbarMenu/ViewToolbarsGroup");
egg_editable_toolbar_add_visibility
(etoolbar, "/ToolbarPopup/ViewToolbarsGroup");
return EPHY_TOOLBAR (etoolbar);
}
|