[epiphany] bookmarks-popover: Drop window construct param
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] bookmarks-popover: Drop window construct param
- Date: Fri, 22 Jun 2018 04:39:57 +0000 (UTC)
commit 8e75d98af7c4c8a36741dd26b8e361b1539a89b5
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon May 7 14:10:32 2018 +0200
bookmarks-popover: Drop window construct param
Drop the EphyWindow parameter from the constructor to instead get the
window by getting the ancestor. This implies that all
EphyBookmarksPopover must be put into an EphyWindow for them to work.
src/bookmarks/ephy-bookmarks-popover.c | 47 ++++++----------------------------
src/bookmarks/ephy-bookmarks-popover.h | 4 +--
src/ephy-header-bar.c | 2 +-
3 files changed, 10 insertions(+), 43 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmarks-popover.c b/src/bookmarks/ephy-bookmarks-popover.c
index d221e18f8..e49a48d89 100644
--- a/src/bookmarks/ephy-bookmarks-popover.c
+++ b/src/bookmarks/ephy-bookmarks-popover.c
@@ -27,6 +27,7 @@
#include "ephy-bookmarks-manager.h"
#include "ephy-debug.h"
#include "ephy-shell.h"
+#include "ephy-window.h"
#include <glib/gi18n.h>
@@ -42,7 +43,6 @@ struct _EphyBookmarksPopover {
char *tag_detail_tag;
EphyBookmarksManager *manager;
- EphyWindow *window;
};
G_DEFINE_TYPE (EphyBookmarksPopover, ephy_bookmarks_popover, GTK_TYPE_POPOVER)
@@ -50,14 +50,6 @@ G_DEFINE_TYPE (EphyBookmarksPopover, ephy_bookmarks_popover, GTK_TYPE_POPOVER)
#define EPHY_LIST_BOX_ROW_TYPE_BOOKMARK "bookmark"
#define EPHY_LIST_BOX_ROW_TYPE_TAG "tag"
-enum {
- PROP_0,
- PROP_WINDOW,
- LAST_PROP
-};
-
-static GParamSpec *obj_properties[LAST_PROP];
-
static GtkWidget *create_bookmark_row (gpointer item, gpointer user_data);
static GtkWidget *create_tag_row (const char *tag);
@@ -446,12 +438,17 @@ ephy_bookmarks_popover_list_box_row_activated_cb (EphyBookmarksPopover *self,
type = g_object_get_data (G_OBJECT (row), "type");
if (g_strcmp0 (type, EPHY_LIST_BOX_ROW_TYPE_BOOKMARK) == 0) {
+ GtkWidget *window;
GActionGroup *action_group;
GAction *action;
const char *url;
- action_group = gtk_widget_get_action_group (GTK_WIDGET (self->window), "win");
+ window = gtk_widget_get_ancestor (GTK_WIDGET (self), EPHY_TYPE_WINDOW);
+ g_assert (EPHY_IS_WINDOW (window));
+ action_group = gtk_widget_get_action_group (window, "win");
+ g_assert (action_group != NULL);
action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "open-bookmark");
+ g_assert (action != NULL);
url = ephy_bookmark_row_get_bookmark_url (EPHY_BOOKMARK_ROW (row));
g_action_activate (action, g_variant_new_string (url));
@@ -471,23 +468,6 @@ ephy_bookmarks_popover_finalize (GObject *object)
G_OBJECT_CLASS (ephy_bookmarks_popover_parent_class)->finalize (object);
}
-static void
-ephy_bookmarks_popover_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyBookmarksPopover *self = EPHY_BOOKMARKS_POPOVER (object);
-
- switch (prop_id) {
- case PROP_WINDOW:
- self->window = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
static void
ephy_bookmarks_popover_class_init (EphyBookmarksPopoverClass *klass)
{
@@ -495,16 +475,6 @@ ephy_bookmarks_popover_class_init (EphyBookmarksPopoverClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = ephy_bookmarks_popover_finalize;
- object_class->set_property = ephy_bookmarks_popover_set_property;
-
- obj_properties[PROP_WINDOW] =
- g_param_spec_object ("window",
- "An EphyWindow object",
- "The popover's parent EphyWindow",
- EPHY_TYPE_WINDOW,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/gtk/bookmarks-popover.ui");
gtk_widget_class_bind_template_child (widget_class, EphyBookmarksPopover, toplevel_stack);
@@ -609,9 +579,8 @@ ephy_bookmarks_popover_init (EphyBookmarksPopover *self)
}
EphyBookmarksPopover *
-ephy_bookmarks_popover_new (EphyWindow *window)
+ephy_bookmarks_popover_new (void)
{
return g_object_new (EPHY_TYPE_BOOKMARKS_POPOVER,
- "window", window,
NULL);
}
diff --git a/src/bookmarks/ephy-bookmarks-popover.h b/src/bookmarks/ephy-bookmarks-popover.h
index cb155ff17..816d622bc 100644
--- a/src/bookmarks/ephy-bookmarks-popover.h
+++ b/src/bookmarks/ephy-bookmarks-popover.h
@@ -20,8 +20,6 @@
#pragma once
-#include "ephy-window.h"
-
#include <gtk/gtk.h>
G_BEGIN_DECLS
@@ -30,7 +28,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EphyBookmarksPopover, ephy_bookmarks_popover, EPHY, BOOKMARKS_POPOVER, GtkPopover)
-EphyBookmarksPopover* ephy_bookmarks_popover_new (EphyWindow *window);
+EphyBookmarksPopover* ephy_bookmarks_popover_new (void);
G_END_DECLS
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 3f529813d..c2fa2f304 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -753,7 +753,7 @@ ephy_header_bar_constructed (GObject *object)
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
/* Translators: tooltip for the bookmarks popover button */
gtk_widget_set_tooltip_text (button, _("View and manage your bookmarks"));
- gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), GTK_WIDGET (ephy_bookmarks_popover_new
(header_bar->window)));
+ 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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]