summaryrefslogtreecommitdiff
path: root/src/ephy-tab-header-bar.c
blob: ea21eda6f0a3cf02abbf757cb76d10712cce9889 (plain)
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
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 *  Copyright © 2019 Christopher Davis <christopherdavis@gnome.org>
 *
 *  This file is part of Epiphany.
 *
 *  Epiphany 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 3 of the License, or
 *  (at your option) any later version.
 *
 *  Epiphany 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 Epiphany.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "ephy-tab-header-bar.h"

#include <gtk/gtk.h>
#include <glib/gi18n.h>

struct _EphyTabHeaderBar {
  GtkHeaderBar parent_instance;

  GtkWidget *back_button;
  GtkWidget *new_tab_button;
};

G_DEFINE_TYPE (EphyTabHeaderBar, ephy_tab_header_bar, GTK_TYPE_HEADER_BAR)

/**
 * ephy_tab_header_bar_new:
 *
 * Create a new #EphyTabHeaderBar.
 *
 * Returns: (transfer full): a newly created #EphyTabHeaderBar
 */
GtkWidget *
ephy_tab_header_bar_new (void)
{
  return GTK_WIDGET (g_object_new (EPHY_TYPE_TAB_HEADER_BAR, NULL));
}

static void
ephy_tab_header_bar_constructed (GObject *object)
{
  GtkWidget *back_button;
  GtkWidget *new_tab_button;
  EphyTabHeaderBar *self = EPHY_TAB_HEADER_BAR (object);

  G_OBJECT_CLASS (ephy_tab_header_bar_parent_class)->constructed (object);

  back_button = GTK_WIDGET (gtk_button_new_from_icon_name ("go-previous-symbolic", GTK_ICON_SIZE_BUTTON));
  new_tab_button = GTK_WIDGET (gtk_button_new_from_icon_name ("tab-new-symbolic", GTK_ICON_SIZE_BUTTON));

  self->back_button = back_button;
  self->new_tab_button = new_tab_button;
  gtk_actionable_set_action_name (GTK_ACTIONABLE (back_button), "win.content");
  gtk_actionable_set_action_name (GTK_ACTIONABLE (new_tab_button), "win.new-tab");

  gtk_header_bar_pack_start (GTK_HEADER_BAR (self), back_button);
  gtk_header_bar_pack_end (GTK_HEADER_BAR (self), new_tab_button);

  gtk_header_bar_set_title (GTK_HEADER_BAR (self), _("Tabs"));
  gtk_header_bar_set_has_subtitle (GTK_HEADER_BAR (self), FALSE);
  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE);

  gtk_widget_show_all (GTK_WIDGET (self));
}

static void
ephy_tab_header_bar_class_init (EphyTabHeaderBarClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  object_class->constructed = ephy_tab_header_bar_constructed;
}

static void
ephy_tab_header_bar_init (EphyTabHeaderBar *self)
{
}