[epiphany/wip/bookmarks: 4/76] bookmarks-popover: Define a custom type for bookmarks button



commit 0244efa27113611bd6f8895d42021d95201815d4
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Sat Jul 16 00:21:40 2016 +0300

    bookmarks-popover: Define a custom type for bookmarks button

 src/Makefile.am                        |    5 +++
 src/ephy-bookmarks-popover.c           |   47 ++++++++++++++++++++++++++++++++
 src/ephy-bookmarks-popover.h           |   33 ++++++++++++++++++++++
 src/ephy-header-bar.c                  |    3 ++
 src/epiphany.gresource.xml             |    1 +
 src/resources/gtk/bookmarks-popover.ui |   43 +++++++++++++++++++++++++++++
 6 files changed, 132 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index d392db7..4a9bae0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,6 +21,8 @@ libephymain_la_SOURCES = \
        cookies-dialog.h                        \
        ephy-action-helper.c                    \
        ephy-action-helper.h                    \
+       ephy-bookmarks-popover.c                \
+       ephy-bookmarks-popover.h                \
        ephy-completion-model.c                 \
        ephy-completion-model.h                 \
        ephy-encoding-dialog.c                  \
@@ -127,6 +129,9 @@ RESOURCE_FILES = \
        resources/prism.css                       \
        resources/prism.js                        \
        resources/shortcuts-dialog.ui
+       resources/gtk/bookmarks-popover.ui        \
+       resources/gtk/menus.ui                    \
+       $(NULL)
 
 epiphany-resources.c: epiphany.gresource.xml $(RESOURCE_FILES)
        $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir)/resources --generate-source 
--c-name epiphany $(srcdir)/epiphany.gresource.xml
diff --git a/src/ephy-bookmarks-popover.c b/src/ephy-bookmarks-popover.c
new file mode 100644
index 0000000..a38e047
--- /dev/null
+++ b/src/ephy-bookmarks-popover.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 Iulian-Gabriel Radu <iulian radu67 gmail com>
+ *
+ * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "ephy-bookmarks-popover.h"
+
+struct _EphyBookmarksPopover {
+  GtkPopover      parent_instance;
+};
+
+G_DEFINE_TYPE (EphyBookmarksPopover, ephy_bookmarks_popover, GTK_TYPE_POPOVER)
+
+static void
+ephy_bookmarks_popover_class_init (EphyBookmarksPopoverClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/gtk/bookmarks-popover.ui");
+}
+
+static void
+ephy_bookmarks_popover_init (EphyBookmarksPopover *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+EphyBookmarksPopover *
+ephy_bookmarks_popover_new (void)
+{
+  return g_object_new (EPHY_TYPE_BOOKMARKS_POPOVER,
+                       NULL);
+}
diff --git a/src/ephy-bookmarks-popover.h b/src/ephy-bookmarks-popover.h
new file mode 100644
index 0000000..f7be1c4
--- /dev/null
+++ b/src/ephy-bookmarks-popover.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 Iulian-Gabriel Radu <iulian radu67 gmail com>
+ *
+ * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef EPHY_BOOKMARKS_POPOVER_H
+#define EPHY_BOOKMARKS_POPOVER_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_BOOKMARKS_POPOVER (ephy_bookmarks_popover_get_type())
+
+G_DECLARE_FINAL_TYPE (EphyBookmarksPopover, ephy_bookmarks_popover, EPHY, BOOKMARKS_POPOVER, GtkPopover)
+
+EphyBookmarksPopover*       ephy_bookmarks_popover_new      (void);
+
+G_END_DECLS
+
+#endif /* EPHY_BOOMARKS_POPOVER_H */
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 7c86fc7..1ac35c8 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -22,6 +22,7 @@
 #include "ephy-header-bar.h"
 
 #include "ephy-action-helper.h"
+#include "ephy-bookmarks-popover.h"
 #include "ephy-downloads-popover.h"
 #include "ephy-downloads-progress-icon.h"
 #include "ephy-embed.h"
@@ -660,6 +661,8 @@ ephy_header_bar_constructed (GObject *object)
   gtk_button_set_image (GTK_BUTTON (button),
                         gtk_image_new_from_icon_name ("user-bookmarks-symbolic", GTK_ICON_SIZE_BUTTON));
   gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+  gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), GTK_WIDGET (ephy_bookmarks_popover_new ()));
+
   gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), button);
 
   /* Downloads */
diff --git a/src/epiphany.gresource.xml b/src/epiphany.gresource.xml
index 0391977..4dd799e 100644
--- a/src/epiphany.gresource.xml
+++ b/src/epiphany.gresource.xml
@@ -12,6 +12,7 @@
     <file preprocess="xml-stripblanks" compressed="true">history-dialog.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">passwords-dialog.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">shortcuts-dialog.ui</file>
+    <file preprocess="xml-stripblanks" compressed="true">gtk/bookmarks-popover.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/menus.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/page-menu-popover.ui</file>
     <file preprocess="xml-stripblanks">epiphany-application-menu.ui</file>
diff --git a/src/resources/gtk/bookmarks-popover.ui b/src/resources/gtk/bookmarks-popover.ui
new file mode 100644
index 0000000..64a1dd0
--- /dev/null
+++ b/src/resources/gtk/bookmarks-popover.ui
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.16 -->
+  <template class="EphyBookmarksPopover" parent="GtkPopover">
+    <child>
+      <object class="GtkBox">
+        <property name="border-width">12</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
+        <property name="visible">true</property>
+        <child>
+          <object class="GtkStackSwitcher">
+            <property name="stack">stack</property>
+            <property name="visible">true</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkStack" id="stack">
+            <property name="visible">true</property>
+            <child>
+              <object class="GtkListBox" id="bookmarks_list_box">
+                <property name="visible">true</property>
+              </object>
+              <packing>
+                <property name="name">all</property>
+                <property name="title" translatable="yes">All</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkListBox" id="tags_list_box">
+                <property name="visible">true</property>
+              </object>
+              <packing>
+                <property name="name">tags</property>
+                <property name="title" translatable="yes">Tags</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>


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