1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3 * Copyright (C) 2010 Red Hat, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <glib/gi18n-lib.h>
29 #include <gconf/gconf-client.h>
31 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
32 #include <libempathy/empathy-debug.h>
34 #include "cc-empathy-accounts-panel.h"
35 #include "cc-empathy-accounts-page.h"
37 #define CC_EMPATHY_ACCOUNTS_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_EMPATHY_ACCOUNTS_PANEL, CcEmpathyAccountsPanelPrivate))
39 struct CcEmpathyAccountsPanelPrivate
41 CcPage *empathy_accounts_page;
44 G_DEFINE_DYNAMIC_TYPE (CcEmpathyAccountsPanel, cc_empathy_accounts_panel, CC_TYPE_PANEL)
47 setup_panel (CcEmpathyAccountsPanel *panel)
49 panel->priv->empathy_accounts_page = cc_empathy_accounts_page_new ();
51 gtk_container_add (GTK_CONTAINER (panel),
52 GTK_WIDGET (panel->priv->empathy_accounts_page));
54 gtk_widget_show (GTK_WIDGET (panel->priv->empathy_accounts_page));
57 "current-page", panel->priv->empathy_accounts_page,
62 cc_empathy_accounts_panel_active_changed (CcPanel *self,
65 DEBUG ("%s: active = %i", G_STRLOC, is_active);
69 /* why doesn't control-center call active-changed on the Page? */
70 cc_empathy_accounts_page_destroy_dialogs (
71 CC_EMPATHY_ACCOUNTS_PAGE (
72 CC_EMPATHY_ACCOUNTS_PANEL (self)->priv->empathy_accounts_page));
75 CC_PANEL_CLASS (cc_empathy_accounts_panel_parent_class)->active_changed (
80 cc_empathy_accounts_panel_constructor (GType type,
81 guint n_construct_properties,
82 GObjectConstructParam *construct_properties)
84 CcEmpathyAccountsPanel *empathy_accounts_panel;
86 empathy_accounts_panel = CC_EMPATHY_ACCOUNTS_PANEL (
87 G_OBJECT_CLASS (cc_empathy_accounts_panel_parent_class)->constructor (
88 type, n_construct_properties, construct_properties));
90 g_object_set (empathy_accounts_panel,
91 "display-name", _("Messaging and VoIP Accounts"),
92 "id", "empathy-accounts.desktop",
95 setup_panel (empathy_accounts_panel);
97 return G_OBJECT (empathy_accounts_panel);
101 cc_empathy_accounts_panel_finalize (GObject *object)
103 CcEmpathyAccountsPanel *empathy_accounts_panel;
105 g_return_if_fail (object != NULL);
106 g_return_if_fail (CC_IS_EMPATHY_ACCOUNTS_PANEL (object));
108 empathy_accounts_panel = CC_EMPATHY_ACCOUNTS_PANEL (object);
110 g_return_if_fail (empathy_accounts_panel->priv != NULL);
112 g_object_unref (empathy_accounts_panel->priv->empathy_accounts_page);
114 G_OBJECT_CLASS (cc_empathy_accounts_panel_parent_class)->finalize (object);
118 cc_empathy_accounts_panel_class_init (CcEmpathyAccountsPanelClass *klass)
120 CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
121 GObjectClass *object_class = G_OBJECT_CLASS (klass);
123 panel_class->active_changed = cc_empathy_accounts_panel_active_changed;
125 object_class->constructor = cc_empathy_accounts_panel_constructor;
126 object_class->finalize = cc_empathy_accounts_panel_finalize;
128 g_type_class_add_private (klass, sizeof (CcEmpathyAccountsPanelPrivate));
132 cc_empathy_accounts_panel_class_finalize (CcEmpathyAccountsPanelClass *klass)
137 cc_empathy_accounts_panel_init (CcEmpathyAccountsPanel *panel)
141 panel->priv = CC_EMPATHY_ACCOUNTS_PANEL_GET_PRIVATE (panel);
143 client = gconf_client_get_default ();
144 gconf_client_add_dir (client, "/desktop/gnome/peripherals/empathy_accounts",
145 GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
146 gconf_client_add_dir (client, "/desktop/gnome/interface",
147 GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
148 g_object_unref (client);
152 cc_empathy_accounts_panel_register (GIOModule *module)
154 cc_empathy_accounts_panel_register_type (G_TYPE_MODULE (module));
155 g_io_extension_point_implement (CC_PANEL_EXTENSION_POINT_NAME,
156 CC_TYPE_EMPATHY_ACCOUNTS_PANEL, "empathy-accounts", 10);