Commit a8a56a21 authored by Gabriel Ivașcu's avatar Gabriel Ivașcu Committed by Michael Catanzaro

ephy-notification-manager: Rename to ephy-notification-container

parent 7fa32421
......@@ -42,8 +42,8 @@ libephyembed_la_SOURCES = \
ephy-find-toolbar.h \
ephy-hosts-manager.c \
ephy-hosts-manager.h \
ephy-notification-manager.c \
ephy-notification-manager.h \
ephy-notification-container.c \
ephy-notification-container.h \
ephy-view-source-handler.c \
ephy-view-source-handler.h \
ephy-web-view.c \
......
......@@ -28,7 +28,7 @@
#include "ephy-embed-shell.h"
#include "ephy-embed-utils.h"
#include "ephy-find-toolbar.h"
#include "ephy-notification-manager.h"
#include "ephy-notification-container.h"
#include "ephy-prefs.h"
#include "ephy-settings.h"
#include "ephy-string.h"
......@@ -949,26 +949,27 @@ ephy_embed_inspector_is_loaded (EphyEmbed *embed)
}
void
ephy_embed_attach_notification_manager (EphyEmbed *embed)
ephy_embed_attach_notification_container (EphyEmbed *embed)
{
EphyNotificationManager *manager;
EphyNotificationContainer *container;
g_return_if_fail (EPHY_IS_EMBED (embed));
manager = ephy_notification_manager_dup_singleton ();
gtk_overlay_add_overlay (GTK_OVERLAY (embed->overlay), GTK_WIDGET (manager));
if (ephy_notification_manager_get_children_num (manager) == 0)
gtk_widget_hide (GTK_WIDGET (manager));
container = ephy_notification_container_get_default ();
gtk_overlay_add_overlay (GTK_OVERLAY (embed->overlay), GTK_WIDGET (container));
}
void
ephy_embed_detach_notification_manager (EphyEmbed *embed)
ephy_embed_detach_notification_container (EphyEmbed *embed)
{
EphyNotificationManager *manager;
EphyNotificationContainer *container;
g_return_if_fail (EPHY_IS_EMBED (embed));
manager = ephy_notification_manager_dup_singleton ();
gtk_container_remove (GTK_CONTAINER (embed->overlay), GTK_WIDGET (manager));
container = ephy_notification_container_get_default ();
/* Since the overlay container will own the one and only reference to the
* notification widget, removing it from the container will destroy the
* singleton. To prevent this, add a reference to it before removing it
* from the container. */
gtk_container_remove (GTK_CONTAINER (embed->overlay), g_object_ref (container));
}
......@@ -30,22 +30,22 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EphyEmbed, ephy_embed, EPHY, EMBED, GtkBox)
EphyWebView* ephy_embed_get_web_view (EphyEmbed *embed);
EphyFindToolbar* ephy_embed_get_find_toolbar (EphyEmbed *embed);
void ephy_embed_add_top_widget (EphyEmbed *embed,
GtkWidget *widget,
gboolean destroy_on_transition);
void ephy_embed_remove_top_widget (EphyEmbed *embed,
GtkWidget *widget);
void ephy_embed_entering_fullscreen (EphyEmbed *embed);
void ephy_embed_leaving_fullscreen (EphyEmbed *embed);
void ephy_embed_set_delayed_load_request (EphyEmbed *embed,
WebKitURIRequest *request,
WebKitWebViewSessionState *state);
gboolean ephy_embed_has_load_pending (EphyEmbed *embed);
gboolean ephy_embed_inspector_is_loaded (EphyEmbed *embed);
const char *ephy_embed_get_title (EphyEmbed *embed);
void ephy_embed_attach_notification_manager (EphyEmbed *embed);
void ephy_embed_detach_notification_manager (EphyEmbed *embed);
EphyWebView* ephy_embed_get_web_view (EphyEmbed *embed);
EphyFindToolbar* ephy_embed_get_find_toolbar (EphyEmbed *embed);
void ephy_embed_add_top_widget (EphyEmbed *embed,
GtkWidget *widget,
gboolean destroy_on_transition);
void ephy_embed_remove_top_widget (EphyEmbed *embed,
GtkWidget *widget);
void ephy_embed_entering_fullscreen (EphyEmbed *embed);
void ephy_embed_leaving_fullscreen (EphyEmbed *embed);
void ephy_embed_set_delayed_load_request (EphyEmbed *embed,
WebKitURIRequest *request,
WebKitWebViewSessionState *state);
gboolean ephy_embed_has_load_pending (EphyEmbed *embed);
gboolean ephy_embed_inspector_is_loaded (EphyEmbed *embed);
const char *ephy_embed_get_title (EphyEmbed *embed);
void ephy_embed_attach_notification_container (EphyEmbed *embed);
void ephy_embed_detach_notification_container (EphyEmbed *embed);
G_END_DECLS
......@@ -17,52 +17,30 @@
*/
#include "config.h"
#include "ephy-notification-manager.h"
#include "ephy-notification-container.h"
struct _EphyNotificationManager {
struct _EphyNotificationContainer {
GdNotification parent_instance;
GtkWidget *grid;
};
struct _EphyNotificationManagerClass {
struct _EphyNotificationContainerClass {
GdNotificationClass parent_class;
};
G_DEFINE_TYPE (EphyNotificationManager, ephy_notification_manager, GD_TYPE_NOTIFICATION);
G_DEFINE_TYPE (EphyNotificationContainer, ephy_notification_container, GD_TYPE_NOTIFICATION);
static GObject *
ephy_notification_manager_constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
static GObject *self = NULL;
if (self == NULL) {
self = G_OBJECT_CLASS (ephy_notification_manager_parent_class)->constructor (type,
n_construct_params,
construct_params);
g_object_add_weak_pointer (self, (gpointer) &self);
}
return g_object_ref_sink (self);
}
static void
ephy_notification_manager_dispose (GObject *object)
{
EphyNotificationManager *self = EPHY_NOTIFICATION_MANAGER (object);
if (ephy_notification_manager_get_children_num (self) > 0)
g_list_free (gtk_container_get_children (GTK_CONTAINER (self->grid)));
G_OBJECT_CLASS (ephy_notification_manager_parent_class)->dispose (object);
}
static EphyNotificationContainer *notification_container = NULL;
static void
ephy_notification_manager_init (EphyNotificationManager *self)
ephy_notification_container_init (EphyNotificationContainer *self)
{
g_return_if_fail (EPHY_IS_NOTIFICATION_MANAGER (self));
/* Globally accessible singleton */
g_assert (notification_container == NULL);
notification_container = self;
g_object_add_weak_pointer (G_OBJECT (notification_container),
(gpointer *)&notification_container);
gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_START);
......@@ -75,38 +53,29 @@ ephy_notification_manager_init (EphyNotificationManager *self)
}
static void
ephy_notification_manager_class_init (EphyNotificationManagerClass *klass)
ephy_notification_container_class_init (EphyNotificationContainerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructor = ephy_notification_manager_constructor;
object_class->dispose = ephy_notification_manager_dispose;
}
EphyNotificationManager *
ephy_notification_manager_dup_singleton (void)
EphyNotificationContainer *
ephy_notification_container_get_default (void)
{
return g_object_new (EPHY_TYPE_NOTIFICATION_MANAGER,
if (notification_container != NULL)
return notification_container;
return g_object_new (EPHY_TYPE_NOTIFICATION_CONTAINER,
"show-close-button", TRUE,
"timeout", -1,
NULL);
}
void
ephy_notification_manager_add_notification (EphyNotificationManager *self,
GtkWidget *notification)
ephy_notification_container_add_notification (EphyNotificationContainer *self,
GtkWidget *notification)
{
g_return_if_fail (EPHY_IS_NOTIFICATION_MANAGER (self));
g_return_if_fail (EPHY_IS_NOTIFICATION_CONTAINER (self));
g_return_if_fail (GTK_IS_WIDGET (notification));
gtk_container_add (GTK_CONTAINER (self->grid), notification);
gtk_widget_show_all (GTK_WIDGET (self));
}
guint
ephy_notification_manager_get_children_num (EphyNotificationManager *self)
{
g_return_val_if_fail (EPHY_IS_NOTIFICATION_MANAGER (self), 0);
return g_list_length (gtk_container_get_children (GTK_CONTAINER (self->grid)));
}
......@@ -16,34 +16,36 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EPHY_NOTIFICATION_MANAGER_H
#define EPHY_NOTIFICATION_MANAGER_H
#ifndef EPHY_NOTIFICATION_CONTAINER_H
#define EPHY_NOTIFICATION_CONTAINER_H
#include <libgd/gd.h>
G_BEGIN_DECLS
#define EPHY_TYPE_NOTIFICATION_MANAGER (ephy_notification_manager_get_type ())
#define EPHY_TYPE_NOTIFICATION_CONTAINER (ephy_notification_container_get_type ())
#define EPHY_NOTIFICATION_MANAGER(obj) \
/* 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_MANAGER, EphyNotificationManager))
EPHY_TYPE_NOTIFICATION_CONTAINER, EphyNotificationContainer))
#define EPHY_IS_NOTIFICATION_MANAGER(obj) \
#define EPHY_IS_NOTIFICATION_CONTAINER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
EPHY_TYPE_NOTIFICATION_MANAGER))
typedef struct _EphyNotificationManager EphyNotificationManager;
typedef struct _EphyNotificationManagerClass EphyNotificationManagerClass;
EPHY_TYPE_NOTIFICATION_CONTAINER))
GType ephy_notification_manager_get_type (void) G_GNUC_CONST;
typedef struct _EphyNotificationContainer EphyNotificationContainer;
typedef struct _EphyNotificationContainerClass EphyNotificationContainerClass;
EphyNotificationManager *ephy_notification_manager_dup_singleton (void);
GType ephy_notification_container_get_type (void) G_GNUC_CONST;
void ephy_notification_manager_add_notification (EphyNotificationManager *self,
GtkWidget *notification);
EphyNotificationContainer *ephy_notification_container_get_default (void);
guint ephy_notification_manager_get_children_num (EphyNotificationManager *self);
void ephy_notification_container_add_notification (EphyNotificationContainer *self,
GtkWidget *notification);
G_END_DECLS
......
......@@ -19,7 +19,7 @@
#include "config.h"
#include "ephy-password-notification.h"
#include "ephy-notification-manager.h"
#include "ephy-notification-container.h"
#include <glib/gi18n.h>
......@@ -160,6 +160,6 @@ ephy_password_notification_show (EphyPasswordNotification *self)
{
g_return_if_fail (EPHY_IS_PASSWORD_NOTIFICATION (self));
ephy_notification_manager_add_notification (ephy_notification_manager_dup_singleton (),
GTK_WIDGET (self));
ephy_notification_container_add_notification (ephy_notification_container_get_default (),
GTK_WIDGET (self));
}
......@@ -2078,7 +2078,7 @@ ephy_window_connect_active_embed (EphyWindow *window)
view = ephy_embed_get_web_view (embed);
web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
ephy_embed_attach_notification_manager (window->active_embed);
ephy_embed_attach_notification_container (window->active_embed);
sync_tab_security (view, NULL, window);
sync_tab_document_type (view, NULL, window);
......@@ -2160,7 +2160,7 @@ ephy_window_disconnect_active_embed (EphyWindow *window)
web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
view = EPHY_WEB_VIEW (web_view);
ephy_embed_detach_notification_manager (window->active_embed);
ephy_embed_detach_notification_container (window->active_embed);
g_signal_handlers_disconnect_by_func (web_view,
G_CALLBACK (sync_tab_zoom),
......
Markdown is supported
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