[epiphany] Stop using gd-notification
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Stop using gd-notification
- Date: Fri, 28 Apr 2017 01:12:13 +0000 (UTC)
commit 1f609bc6c77da393493462f14eceea4a42a89b6d
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Thu Apr 27 12:43:56 2017 -0500
Stop using gd-notification
It has been obsoleted by the app-notification style class
embed/ephy-notification-container.c | 11 ++++----
embed/ephy-notification-container.h | 17 +------------
lib/widgets/ephy-notification.c | 45 +++++++++++++++++++++++++++++++---
lib/widgets/ephy-notification.h | 2 +-
meson.build | 3 +-
5 files changed, 49 insertions(+), 29 deletions(-)
---
diff --git a/embed/ephy-notification-container.c b/embed/ephy-notification-container.c
index 846d953..8d29dbc 100644
--- a/embed/ephy-notification-container.c
+++ b/embed/ephy-notification-container.c
@@ -22,16 +22,16 @@
#include "ephy-notification-container.h"
struct _EphyNotificationContainer {
- GdNotification parent_instance;
+ GtkRevealer parent_instance;
- GtkWidget *grid;
+ GtkWidget *grid;
};
struct _EphyNotificationContainerClass {
- GdNotificationClass parent_class;
+ GtkRevealerClass parent_class;
};
-G_DEFINE_TYPE (EphyNotificationContainer, ephy_notification_container, GD_TYPE_NOTIFICATION);
+G_DEFINE_TYPE (EphyNotificationContainer, ephy_notification_container, GTK_TYPE_REVEALER);
static EphyNotificationContainer *notification_container = NULL;
@@ -65,8 +65,6 @@ ephy_notification_container_get_default (void)
return notification_container;
return g_object_new (EPHY_TYPE_NOTIFICATION_CONTAINER,
- "show-close-button", TRUE,
- "timeout", -1,
NULL);
}
@@ -79,4 +77,5 @@ ephy_notification_container_add_notification (EphyNotificationContainer *self,
gtk_container_add (GTK_CONTAINER (self->grid), notification);
gtk_widget_show_all (GTK_WIDGET (self));
+ gtk_revealer_set_reveal_child (GTK_REVEALER (self), TRUE);
}
diff --git a/embed/ephy-notification-container.h b/embed/ephy-notification-container.h
index 79657a9..faffc5f 100644
--- a/embed/ephy-notification-container.h
+++ b/embed/ephy-notification-container.h
@@ -26,22 +26,7 @@ G_BEGIN_DECLS
#define EPHY_TYPE_NOTIFICATION_CONTAINER (ephy_notification_container_get_type ())
-/* FIXME: Replace this boilerplate with G_DECLARE_FINAL_TYPE. This won't prove
- * trivial, since G_DECLARE_FINAL_TYPE requires that an autocleanup function
- * has been declared for the parent type, and libgd doesn't have one yet.
- */
-#define EPHY_NOTIFICATION_CONTAINER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- EPHY_TYPE_NOTIFICATION_CONTAINER, EphyNotificationContainer))
-
-#define EPHY_IS_NOTIFICATION_CONTAINER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- EPHY_TYPE_NOTIFICATION_CONTAINER))
-
-typedef struct _EphyNotificationContainer EphyNotificationContainer;
-typedef struct _EphyNotificationContainerClass EphyNotificationContainerClass;
-
-GType ephy_notification_container_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (EphyNotificationContainer, ephy_notification_container, EPHY, NOTIFICATION_CONTAINER,
GtkRevealer)
EphyNotificationContainer *ephy_notification_container_get_default (void);
diff --git a/lib/widgets/ephy-notification.c b/lib/widgets/ephy-notification.c
index 35740a6..6c808c0 100644
--- a/lib/widgets/ephy-notification.c
+++ b/lib/widgets/ephy-notification.c
@@ -24,17 +24,20 @@
#include "ephy-notification-container.h"
struct _EphyNotification {
- GtkGrid parent_instance;
+ GtkFrame parent_instance;
+
+ GtkWidget *grid;
GtkWidget *head;
GtkWidget *body;
+ GtkWidget *close_button;
char *head_msg;
char *body_msg;
};
struct _EphyNotificationClass {
- GtkGridClass parent_class;
+ GtkFrameClass parent_class;
};
enum {
@@ -110,17 +113,51 @@ ephy_notification_get_property (GObject *object,
}
static void
+close_button_clicked_cb (GtkButton *button,
+ EphyNotification *self)
+{
+ EphyNotificationContainer *container = ephy_notification_container_get_default ();
+
+ gtk_widget_hide (GTK_WIDGET (container));
+ gtk_revealer_set_reveal_child (GTK_REVEALER (container), FALSE);
+}
+
+static void
ephy_notification_init (EphyNotification *self)
{
+ GtkWidget *image;
+ GtkStyleContext *context;
+
+ self->grid = gtk_grid_new ();
+ context = gtk_widget_get_style_context (self->grid);
+ gtk_style_context_add_class (context, "app-notification");
+ gtk_container_add (GTK_CONTAINER (self), self->grid);
+
self->head = gtk_label_new (NULL);
gtk_widget_set_halign (self->head, GTK_ALIGN_CENTER);
gtk_widget_set_hexpand (self->head, TRUE);
- gtk_grid_attach (GTK_GRID (self), self->head, 0, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (self->grid), self->head, 0, 0, 1, 1);
self->body = gtk_label_new (NULL);
gtk_widget_set_halign (self->body, GTK_ALIGN_CENTER);
gtk_widget_set_hexpand (self->body, TRUE);
- gtk_grid_attach (GTK_GRID (self), self->body, 0, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (self->grid), self->body, 0, 1, 1, 1);
+
+ self->close_button = gtk_button_new ();
+ g_object_set (self->close_button,
+ "relief", GTK_RELIEF_NONE,
+ "focus-on-click", FALSE,
+ "margin", 6,
+ NULL);
+ gtk_grid_attach (GTK_GRID (self->grid), self->close_button, 1, 0, 1, 2);
+
+ image = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image (GTK_BUTTON (self->close_button), image);
+
+ g_signal_connect (self->close_button,
+ "clicked",
+ G_CALLBACK (close_button_clicked_cb),
+ self);
}
static void
diff --git a/lib/widgets/ephy-notification.h b/lib/widgets/ephy-notification.h
index 0d7e492..af08a64 100644
--- a/lib/widgets/ephy-notification.h
+++ b/lib/widgets/ephy-notification.h
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
#define EPHY_TYPE_NOTIFICATION (ephy_notification_get_type ())
-G_DECLARE_FINAL_TYPE (EphyNotification, ephy_notification, EPHY, NOTIFICATION, GtkGrid)
+G_DECLARE_FINAL_TYPE (EphyNotification, ephy_notification, EPHY, NOTIFICATION, GtkFrame)
EphyNotification *ephy_notification_new (const char *head,
const char *body);
diff --git a/meson.build b/meson.build
index 41de3ca..69e5317 100644
--- a/meson.build
+++ b/meson.build
@@ -47,8 +47,7 @@ gvdb_dep = gvdb.get_variable('gvdb_dep')
libgd = subproject('libgd',
default_options: [
- 'with-main-view=true',
- 'with-notification=true'
+ 'with-main-view=true'
]
)
libgd_dep = libgd.get_variable('libgd_dep')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]