]> git.0d.be Git - empathy.git/blob - src/cc-empathy-accounts-panel.c
Updated Polish translation
[empathy.git] / src / cc-empathy-accounts-panel.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2010 Red Hat, Inc.
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include "config.h"
21
22 #include <stdlib.h>
23 #include <stdio.h>
24
25 #include <gtk/gtk.h>
26 #include <gio/gio.h>
27 #include <glib/gi18n-lib.h>
28
29 #include <gconf/gconf-client.h>
30
31 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
32 #include <libempathy/empathy-debug.h>
33
34 #include "cc-empathy-accounts-panel.h"
35 #include "cc-empathy-accounts-page.h"
36
37 #define CC_EMPATHY_ACCOUNTS_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_EMPATHY_ACCOUNTS_PANEL, CcEmpathyAccountsPanelPrivate))
38
39 struct CcEmpathyAccountsPanelPrivate
40 {
41   CcPage *empathy_accounts_page;
42 };
43
44 G_DEFINE_DYNAMIC_TYPE (CcEmpathyAccountsPanel, cc_empathy_accounts_panel, CC_TYPE_PANEL)
45
46 static void
47 setup_panel (CcEmpathyAccountsPanel *panel)
48 {
49   panel->priv->empathy_accounts_page = cc_empathy_accounts_page_new ();
50
51   gtk_container_add (GTK_CONTAINER (panel),
52       GTK_WIDGET (panel->priv->empathy_accounts_page));
53
54   gtk_widget_show (GTK_WIDGET (panel->priv->empathy_accounts_page));
55
56   g_object_set (panel,
57       "current-page", panel->priv->empathy_accounts_page,
58       NULL);
59 }
60
61 static void
62 cc_empathy_accounts_panel_active_changed (CcPanel *self,
63     gboolean is_active)
64 {
65   DEBUG ("%s: active = %i", G_STRLOC, is_active);
66
67   if (!is_active)
68     {
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));
73     }
74
75   CC_PANEL_CLASS (cc_empathy_accounts_panel_parent_class)->active_changed (
76       self, is_active);
77 }
78
79 static GObject *
80 cc_empathy_accounts_panel_constructor (GType type,
81     guint n_construct_properties,
82     GObjectConstructParam *construct_properties)
83 {
84   CcEmpathyAccountsPanel *empathy_accounts_panel;
85
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));
89
90   g_object_set (empathy_accounts_panel,
91       "display-name", _("Messaging and VoIP Accounts"),
92       "id", "empathy-accounts.desktop",
93       NULL);
94
95   setup_panel (empathy_accounts_panel);
96
97   return G_OBJECT (empathy_accounts_panel);
98 }
99
100 static void
101 cc_empathy_accounts_panel_finalize (GObject *object)
102 {
103   CcEmpathyAccountsPanel *empathy_accounts_panel;
104
105   g_return_if_fail (object != NULL);
106   g_return_if_fail (CC_IS_EMPATHY_ACCOUNTS_PANEL (object));
107
108   empathy_accounts_panel = CC_EMPATHY_ACCOUNTS_PANEL (object);
109
110   g_return_if_fail (empathy_accounts_panel->priv != NULL);
111
112   g_object_unref (empathy_accounts_panel->priv->empathy_accounts_page);
113
114   G_OBJECT_CLASS (cc_empathy_accounts_panel_parent_class)->finalize (object);
115 }
116
117 static void
118 cc_empathy_accounts_panel_class_init (CcEmpathyAccountsPanelClass *klass)
119 {
120   CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
121   GObjectClass *object_class = G_OBJECT_CLASS (klass);
122
123   panel_class->active_changed = cc_empathy_accounts_panel_active_changed;
124
125   object_class->constructor = cc_empathy_accounts_panel_constructor;
126   object_class->finalize = cc_empathy_accounts_panel_finalize;
127
128   g_type_class_add_private (klass, sizeof (CcEmpathyAccountsPanelPrivate));
129 }
130
131 static void
132 cc_empathy_accounts_panel_class_finalize (CcEmpathyAccountsPanelClass *klass)
133 {
134 }
135
136 static void
137 cc_empathy_accounts_panel_init (CcEmpathyAccountsPanel *panel)
138 {
139   GConfClient *client;
140
141   panel->priv = CC_EMPATHY_ACCOUNTS_PANEL_GET_PRIVATE (panel);
142
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);
149 }
150
151 void
152 cc_empathy_accounts_panel_register (GIOModule *module)
153 {
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);
157 }