[epiphany/wip/bookmarks: 2/9] bookmarks-popover: Define a custom type for bookmarks button
- From: Iulian Radu <iulianradu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/bookmarks: 2/9] bookmarks-popover: Define a custom type for bookmarks button
- Date: Sat, 23 Jul 2016 21:30:09 +0000 (UTC)
commit 8c636727936a0c94ccc9e63ac0a82aa2e1620672
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 | 3 ++
src/ephy-bookmarks-popover.c | 47 ++++++++++++++++++++++++++++++++
src/ephy-bookmarks-popover.h | 33 ++++++++++++++++++++++
src/ephy-toolbar.c | 3 ++
src/epiphany.gresource.xml | 1 +
src/resources/gtk/bookmarks-popover.ui | 43 +++++++++++++++++++++++++++++
6 files changed, 130 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a3c300a..f965245 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,6 +30,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 \
@@ -113,6 +115,7 @@ RESOURCE_FILES = \
resources/prefs-dialog.ui \
resources/prefs-lang-dialog.ui \
resources/shortcuts-dialog.ui \
+ resources/gtk/bookmarks-popover.ui \
resources/gtk/menus.ui \
$(NULL)
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-toolbar.c b/src/ephy-toolbar.c
index 45027ab..cf59d09 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -21,6 +21,7 @@
#include "ephy-toolbar.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"
@@ -672,6 +673,8 @@ ephy_toolbar_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 (toolbar), button);
/* Downloads */
diff --git a/src/epiphany.gresource.xml b/src/epiphany.gresource.xml
index d3bc0bb..5b5c32a 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">epiphany-application-menu.ui</file>
<file preprocess="xml-stripblanks">epiphany-bookmark-editor-ui.xml</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]