Commit 1f609bc6 authored by Michael Catanzaro's avatar Michael Catanzaro
Browse files

Stop using gd-notification

It has been obsoleted by the app-notification style class
parent 0658dc86
......@@ -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);
}
......@@ -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);
......
......@@ -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 {
......@@ -109,18 +112,52 @@ 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
......
......@@ -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);
......
......@@ -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')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment