From ed7795be783b4f49314834b9c71813ce37f17280 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Wed, 26 Nov 2003 17:58:50 +0000 Subject: Make PDM dialogue a singleton. 2003-11-26 Christian Persch * src/ephy-shell.c: (ephy_shell_init), (ephy_shell_finalize), (ephy_shell_get_history_window), (ephy_shell_get_pdm_dialog): * src/ephy-shell.h: * src/pdm-dialog.c: (pdm_dialog_response_cb): * src/pdm-dialog.h: * src/window-commands.c: (window_cmd_edit_personal_data): Make PDM dialogue a singleton. --- src/ephy-shell.c | 23 +++++++++++++++++++++++ src/ephy-shell.h | 2 ++ src/pdm-dialog.c | 8 -------- src/pdm-dialog.h | 8 +++----- src/window-commands.c | 12 ++++++------ 5 files changed, 34 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ephy-shell.c b/src/ephy-shell.c index a0d14b4f6..a759d0133 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -32,6 +32,7 @@ #include "ephy-bookmarks-import.h" #include "ephy-bookmarks-editor.h" #include "ephy-history-window.h" +#include "pdm-dialog.h" #include "ephy-debug.h" #include "ephy-extensions-manager.h" #include "toolbar.h" @@ -71,6 +72,7 @@ struct EphyShellPrivate EphyExtensionsManager *extensions_manager; GtkWidget *bme; GtkWidget *history_window; + GObject *pdm_dialog; GList *del_on_exit; guint server_timeout; }; @@ -205,6 +207,7 @@ ephy_shell_init (EphyShell *gs) gs->priv->bookmarks = NULL; gs->priv->bme = NULL; gs->priv->history_window = NULL; + gs->priv->pdm_dialog = NULL; gs->priv->toolbars_model = NULL; gs->priv->fs_toolbars_model = NULL; gs->priv->extensions_manager = NULL; @@ -494,6 +497,12 @@ ephy_shell_finalize (GObject *object) gtk_widget_destroy (GTK_WIDGET (gs->priv->history_window)); } + LOG ("Unref PDM Dialog") + if (gs->priv->pdm_dialog) + { + g_object_unref (gs->priv->pdm_dialog); + } + LOG ("Unref bookmarks") if (gs->priv->bookmarks) { @@ -787,6 +796,20 @@ ephy_shell_get_history_window (EphyShell *gs) return gs->priv->history_window; } +GObject * +ephy_shell_get_pdm_dialog (EphyShell *shell) +{ + if (shell->priv->pdm_dialog == NULL) + { + shell->priv->pdm_dialog = g_object_new (EPHY_TYPE_PDM_DIALOG, NULL); + + g_object_add_weak_pointer (shell->priv->pdm_dialog, + (gpointer *) &shell->priv->pdm_dialog); + } + + return shell->priv->pdm_dialog; +} + void ephy_shell_delete_on_exit (EphyShell *gs, const char *path) { diff --git a/src/ephy-shell.h b/src/ephy-shell.h index d086beb4d..219942f41 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -135,6 +135,8 @@ GtkWidget *ephy_shell_get_bookmarks_editor (EphyShell *gs); GtkWidget *ephy_shell_get_history_window (EphyShell *gs); +GObject *ephy_shell_get_pdm_dialog (EphyShell *shell); + void ephy_shell_delete_on_exit (EphyShell *gs, const char *path); diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c index 137da4837..d1534de15 100755 --- a/src/pdm-dialog.c +++ b/src/pdm-dialog.c @@ -1000,11 +1000,3 @@ pdm_dialog_response_cb (GtkDialog *widget, break; } } - -EphyDialog * -pdm_dialog_new (GtkWidget *window) -{ - return EPHY_DIALOG (g_object_new (EPHY_TYPE_PDM_DIALOG, - "ParentWindow", window, - NULL)); -} diff --git a/src/pdm-dialog.h b/src/pdm-dialog.h index d476c714c..9dd7a3183 100644 --- a/src/pdm-dialog.h +++ b/src/pdm-dialog.h @@ -34,9 +34,9 @@ G_BEGIN_DECLS #define EPHY_IS_PDM_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_PDM_DIALOG)) #define EPHY_PDM_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_PDM_DIALOG, PdmDialogClass)) -typedef struct PdmDialog PdmDialog; -typedef struct PdmDialogClass PdmDialogClass; -typedef struct PdmDialogPrivate PdmDialogPrivate; +typedef struct PdmDialog PdmDialog; +typedef struct PdmDialogClass PdmDialogClass; +typedef struct PdmDialogPrivate PdmDialogPrivate; struct PdmDialog { @@ -53,8 +53,6 @@ struct PdmDialogClass GType pdm_dialog_get_type (void); -EphyDialog *pdm_dialog_new (GtkWidget *window); - G_END_DECLS #endif diff --git a/src/window-commands.c b/src/window-commands.c index f545747fb..b86db7377 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti + * Copyright (C) 2000-2003 Marco Pesenti Gritti * * 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 @@ -31,7 +31,7 @@ #include "print-dialog.h" #include "eel-gconf-extensions.h" #include "ephy-prefs.h" -#include "pdm-dialog.h" +#include "ephy-dialog.h" #include "ephy-bookmarks-editor.h" #include "ephy-history-window.h" #include "ephy-new-bookmark.h" @@ -46,16 +46,16 @@ #include "egg-editable-toolbar.h" #include "egg-toolbar-editor.h" -#include #include +#include #include #include -#include -#include #include #include #include #include +#include +#include enum { @@ -796,7 +796,7 @@ window_cmd_edit_personal_data (GtkAction *action, { EphyDialog *dialog; - dialog = pdm_dialog_new (GTK_WIDGET(window)); + dialog = EPHY_DIALOG (ephy_shell_get_pdm_dialog (ephy_shell)); ephy_dialog_show (dialog); } -- cgit