[epiphany] Add EphyActionBar



commit b3fdf128f08643aab37448ac46a1f26ccd81d367
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Apr 26 13:34:42 2018 +0200

    Add EphyActionBar
    
    This will be used to display actions at the bottom of the window when it
    is narrow.

 po/POTFILES.in                       |  1 +
 src/ephy-action-bar.c                | 92 ++++++++++++++++++++++++++++++++++++
 src/ephy-action-bar.h                | 42 ++++++++++++++++
 src/meson.build                      |  1 +
 src/resources/epiphany.gresource.xml |  1 +
 src/resources/gtk/action-bar.ui      | 27 +++++++++++
 6 files changed, 164 insertions(+)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a98b37e08..d9a213822 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -55,6 +55,7 @@ src/prefs-dialog.c
 src/profile-migrator/ephy-profile-migrator.c
 src/resources/gtk/action-bar-end.ui
 src/resources/gtk/action-bar-start.ui
+src/resources/gtk/action-bar.ui
 src/resources/gtk/application-menu.ui
 src/resources/gtk/bookmark-properties-grid.ui
 src/resources/gtk/bookmarks-popover.ui
diff --git a/src/ephy-action-bar.c b/src/ephy-action-bar.c
new file mode 100644
index 000000000..12ac1a788
--- /dev/null
+++ b/src/ephy-action-bar.c
@@ -0,0 +1,92 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ *  Copyright © 2018 Purism SPC
+ *  Copyright © 2018 Adrien Plazas <kekun plazas laposte net>
+ *
+ *  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-action-bar.h"
+
+struct _EphyActionBar {
+  GtkRevealer parent_instance;
+
+  EphyActionBarStart *action_bar_start;
+  EphyActionBarEnd *action_bar_end;
+};
+
+G_DEFINE_TYPE (EphyActionBar, ephy_action_bar, GTK_TYPE_REVEALER)
+
+static void
+ephy_action_bar_class_init (EphyActionBarClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class,
+                                               "/org/gnome/epiphany/gtk/action-bar.ui");
+
+  gtk_widget_class_bind_template_child (widget_class,
+                                        EphyActionBar,
+                                        action_bar_start);
+  gtk_widget_class_bind_template_child (widget_class,
+                                        EphyActionBar,
+                                        action_bar_end);
+}
+
+static void
+ephy_action_bar_init (EphyActionBar *action_bar)
+{
+  /* Ensure the types used by the template have been initialized. */
+  EPHY_TYPE_ACTION_BAR_END;
+  EPHY_TYPE_ACTION_BAR_START;
+
+  gtk_widget_init_template (GTK_WIDGET (action_bar));
+}
+
+EphyActionBar *
+ephy_action_bar_new (void)
+{
+  return g_object_new (EPHY_TYPE_ACTION_BAR,
+                       NULL);
+}
+
+EphyActionBarStart *
+ephy_action_bar_get_action_bar_start (EphyActionBar *action_bar)
+{
+  return action_bar->action_bar_start;
+}
+
+EphyActionBarEnd *
+ephy_action_bar_get_action_bar_end (EphyActionBar *action_bar)
+{
+  return action_bar->action_bar_end;
+}
+
+void
+ephy_action_bar_set_adaptive_mode (EphyActionBar    *action_bar,
+                                   EphyAdaptiveMode  adaptive_mode)
+{
+  switch (adaptive_mode) {
+  case EPHY_ADAPTIVE_MODE_NORMAL:
+    gtk_revealer_set_reveal_child (GTK_REVEALER (action_bar), FALSE);
+
+    break;
+  case EPHY_ADAPTIVE_MODE_NARROW:
+    gtk_revealer_set_reveal_child (GTK_REVEALER (action_bar), TRUE);
+
+    break;
+  }
+}
diff --git a/src/ephy-action-bar.h b/src/ephy-action-bar.h
new file mode 100644
index 000000000..312227a0b
--- /dev/null
+++ b/src/ephy-action-bar.h
@@ -0,0 +1,42 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ *  Copyright © 2018 Purism SPC
+ *  Copyright © 2018 Adrien Plazas <kekun plazas laposte net>
+ *
+ *  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/>.
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "ephy-action-bar-end.h"
+#include "ephy-action-bar-start.h"
+#include "ephy-adaptive-mode.h"
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_ACTION_BAR (ephy_action_bar_get_type ())
+
+G_DECLARE_FINAL_TYPE (EphyActionBar, ephy_action_bar, EPHY, ACTION_BAR, GtkRevealer);
+
+EphyActionBar      *ephy_action_bar_new                  (void);
+EphyActionBarStart *ephy_action_bar_get_action_bar_start (EphyActionBar *action_bar);
+EphyActionBarEnd   *ephy_action_bar_get_action_bar_end   (EphyActionBar *action_bar);
+void                ephy_action_bar_set_adaptive_mode    (EphyActionBar    *action_bar,
+                                                          EphyAdaptiveMode  adaptive_mode);
+
+G_END_DECLS
diff --git a/src/meson.build b/src/meson.build
index c27f46c4e..cf8a17b60 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -21,6 +21,7 @@ libephymain_sources = [
   'bookmarks/ephy-bookmarks-popover.c',
   'clear-data-dialog.c',
   'cookies-dialog.c',
+  'ephy-action-bar.c',
   'ephy-action-bar-end.c',
   'ephy-action-bar-start.c',
   'ephy-action-helper.c',
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index 6bddbad94..c797d2a53 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -14,6 +14,7 @@
     <file preprocess="xml-stripblanks" compressed="true">mime-types-permissions.xml</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/action-bar-end.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/action-bar-start.ui</file>
+    <file preprocess="xml-stripblanks" compressed="true">gtk/action-bar.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/application-menu.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/bookmark-properties-grid.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/bookmark-row.ui</file>
diff --git a/src/resources/gtk/action-bar.ui b/src/resources/gtk/action-bar.ui
new file mode 100644
index 000000000..f11a9c879
--- /dev/null
+++ b/src/resources/gtk/action-bar.ui
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="EphyActionBar" parent="GtkRevealer">
+    <property name="transition-type">slide-up</property>
+    <child>
+      <object class="GtkActionBar" id="action_bar">
+        <property name="visible">True</property>
+        <child>
+            <object class="EphyActionBarStart" id="action_bar_start">
+              <property name="visible">True</property>
+            </object>
+          <packing>
+            <property name="pack-type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="EphyActionBarEnd" id="action_bar_end">
+            <property name="visible">True</property>
+          </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]