[epiphany] Add EphyTitleWidget interface
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Add EphyTitleWidget interface
- Date: Thu, 22 Sep 2016 05:02:24 +0000 (UTC)
commit 01e6a4ba12ba9f02c154c32a8f2e7bf87851e043
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Sep 20 22:55:53 2016 -0500
Add EphyTitleWidget interface
The goal is to only ever create an EphyLocationEntry *or* an
EphyTitleBox, depending on whether or not we're in app mode. To aid in
this, add an interface for them both to implement.
lib/widgets/Makefile.am | 2 +
lib/widgets/ephy-title-widget.c | 96 +++++++++++++++++++++++++++++++++++++++
lib/widgets/ephy-title-widget.h | 53 +++++++++++++++++++++
3 files changed, 151 insertions(+), 0 deletions(-)
---
diff --git a/lib/widgets/Makefile.am b/lib/widgets/Makefile.am
index 5236046..0decde1 100644
--- a/lib/widgets/Makefile.am
+++ b/lib/widgets/Makefile.am
@@ -78,6 +78,8 @@ libephywidgets_la_SOURCES = \
ephy-security-popover.h \
ephy-title-box.c \
ephy-title-box.h \
+ ephy-title-widget.c \
+ ephy-title-widget.h \
ephy-tree-model-node.c \
ephy-tree-model-node.h \
ephy-tree-model-sort.c \
diff --git a/lib/widgets/ephy-title-widget.c b/lib/widgets/ephy-title-widget.c
new file mode 100644
index 0000000..6a33947
--- /dev/null
+++ b/lib/widgets/ephy-title-widget.c
@@ -0,0 +1,96 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2016 Igalia S.L.
+ *
+ * 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 2, 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 "config.h"
+#include "ephy-lib-type-builtins.h"
+#include "ephy-title-widget.h"
+
+G_DEFINE_INTERFACE (EphyTitleWidget, ephy_title_widget, GTK_TYPE_WIDGET);
+
+static void
+ephy_title_widget_default_init (EphyTitleWidgetInterface *iface)
+{
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("address",
+ "Address",
+ "The current address",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_enum ("security-level",
+ "Security level",
+ "State of the security icon",
+ EPHY_TYPE_SECURITY_LEVEL,
+ EPHY_SECURITY_LEVEL_TO_BE_DETERMINED,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+const char *
+ephy_title_widget_get_address (EphyTitleWidget *widget)
+{
+ EphyTitleWidgetInterface *iface;
+
+ g_return_val_if_fail (EPHY_IS_TITLE_WIDGET (widget), NULL);
+
+ iface = EPHY_TITLE_WIDGET_GET_IFACE (widget);
+
+ g_return_val_if_fail (iface->get_address, NULL);
+ return iface->get_address (widget);
+}
+
+void
+ephy_title_widget_set_address (EphyTitleWidget *widget,
+ const char *address)
+{
+ EphyTitleWidgetInterface *iface;
+
+ g_return_if_fail (EPHY_IS_TITLE_WIDGET (widget));
+
+ iface = EPHY_TITLE_WIDGET_GET_IFACE (widget);
+
+ g_return_if_fail (iface->set_address);
+ iface->set_address (widget, address);
+}
+
+EphySecurityLevel
+ephy_title_widget_get_security_level (EphyTitleWidget *widget)
+{
+ EphyTitleWidgetInterface *iface;
+
+ g_return_val_if_fail (EPHY_IS_TITLE_WIDGET (widget), EPHY_SECURITY_LEVEL_TO_BE_DETERMINED);
+
+ iface = EPHY_TITLE_WIDGET_GET_IFACE (widget);
+
+ g_return_val_if_fail (iface->get_security_level, EPHY_SECURITY_LEVEL_TO_BE_DETERMINED);
+ return iface->get_security_level (widget);
+}
+
+void
+ephy_title_widget_set_security_level (EphyTitleWidget *widget,
+ EphySecurityLevel security_level)
+{
+ EphyTitleWidgetInterface *iface;
+
+ g_return_if_fail (EPHY_IS_TITLE_WIDGET (widget));
+
+ iface = EPHY_TITLE_WIDGET_GET_IFACE (widget);
+
+ g_return_if_fail (iface->set_security_level);
+ iface->set_security_level (widget, security_level);
+}
diff --git a/lib/widgets/ephy-title-widget.h b/lib/widgets/ephy-title-widget.h
new file mode 100644
index 0000000..3a26499
--- /dev/null
+++ b/lib/widgets/ephy-title-widget.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2016 Igalia S.L.
+ *
+ * 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 2, 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/>.
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "ephy-security-levels.h"
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_TITLE_WIDGET (ephy_title_widget_get_type ())
+
+G_DECLARE_INTERFACE (EphyTitleWidget, ephy_title_widget, EPHY, TITLE_WIDGET, GtkWidget)
+
+struct _EphyTitleWidgetInterface
+{
+ GTypeInterface parent_iface;
+
+ const char *(*get_address) (EphyTitleWidget *widget);
+ void (*set_address) (EphyTitleWidget *widget,
+ const char *address);
+ EphySecurityLevel (*get_security_level) (EphyTitleWidget *widget);
+ void (*set_security_level) (EphyTitleWidget *widget,
+ EphySecurityLevel security_level);
+};
+
+const char *ephy_title_widget_get_address (EphyTitleWidget *widget);
+
+void ephy_title_widget_set_address (EphyTitleWidget *widget,
+ const char *address);
+
+EphySecurityLevel ephy_title_widget_get_security_level (EphyTitleWidget *widget);
+
+void ephy_title_widget_set_security_level (EphyTitleWidget *widget,
+ EphySecurityLevel security_level);
+
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]