~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to libwindow-settings/gnome-window-manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2
 
 
3
 
/* gnome-window-manager.h
4
 
 * Copyright (C) 2002 Seth Nickell
5
 
 * Copyright (C) 2002 Red Hat, Inc.
6
 
 *
7
 
 * Written by: Seth Nickell <snickell@stanford.edu>,
8
 
 *             Havoc Pennington <hp@redhat.com>
9
 
 *
10
 
 * This program is free software; you can redistribute it and/or modify
11
 
 * it under the terms of the GNU General Public License as published by
12
 
 * the Free Software Foundation; either version 2, or (at your option)
13
 
 * any later version.
14
 
 *
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU General Public License
21
 
 * along with this program; if not, write to the Free Software
22
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23
 
 * 02111-1307, USA.
24
 
 */
25
 
 
26
 
#include "gnome-window-manager.h"
27
 
 
28
 
#include <gmodule.h>
29
 
 
30
 
static GObjectClass *parent_class;
31
 
 
32
 
struct _GnomeWindowManagerPrivate {
33
 
        char *window_manager_name;
34
 
        GnomeDesktopItem *ditem;
35
 
};
36
 
 
37
 
GObject *
38
 
gnome_window_manager_new (GnomeDesktopItem *it)
39
 
{
40
 
        const char *settings_lib;
41
 
        char *module_name;
42
 
        GnomeWindowManagerNewFunc wm_new_func = NULL;
43
 
        GObject *wm;
44
 
        GModule *module;
45
 
        gboolean success;
46
 
 
47
 
        settings_lib = gnome_desktop_item_get_string (it, "X-GNOME-WMSettingsModule");
48
 
 
49
 
        module_name = g_module_build_path (GNOME_WINDOW_MANAGER_MODULE_PATH,
50
 
                                           settings_lib);
51
 
 
52
 
        module = g_module_open (module_name, G_MODULE_BIND_LAZY);
53
 
        if (module == NULL) {
54
 
                g_warning ("Couldn't load window manager settings module `%s' (%s)", module_name, g_module_error ());
55
 
                g_free (module_name);
56
 
                return NULL;
57
 
        }
58
 
 
59
 
        success = g_module_symbol (module, "window_manager_new",
60
 
                                   (gpointer *) &wm_new_func);  
61
 
  
62
 
        if ((!success) || wm_new_func == NULL) {
63
 
                g_warning ("Couldn't load window manager settings module `%s`, couldn't find symbol \'window_manager_new\'", module_name);
64
 
                g_free (module_name);
65
 
                return NULL;
66
 
        }
67
 
 
68
 
        g_free (module_name);
69
 
 
70
 
        wm = (* wm_new_func) (GNOME_WINDOW_MANAGER_INTERFACE_VERSION);
71
 
 
72
 
        if (wm == NULL)
73
 
                return NULL;
74
 
        
75
 
        (GNOME_WINDOW_MANAGER (wm))->p->window_manager_name = g_strdup (gnome_desktop_item_get_string (it, GNOME_DESKTOP_ITEM_NAME));
76
 
        (GNOME_WINDOW_MANAGER (wm))->p->ditem = gnome_desktop_item_ref (it);
77
 
  
78
 
        return wm;
79
 
}
80
 
 
81
 
const char * 
82
 
gnome_window_manager_get_name (GnomeWindowManager *wm)
83
 
{
84
 
        return wm->p->window_manager_name;
85
 
}
86
 
 
87
 
GnomeDesktopItem *
88
 
gnome_window_manager_get_ditem (GnomeWindowManager *wm)
89
 
{
90
 
        return gnome_desktop_item_ref (wm->p->ditem);
91
 
}
92
 
 
93
 
GList *
94
 
gnome_window_manager_get_theme_list (GnomeWindowManager *wm)
95
 
{
96
 
        GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
97
 
        if (klass->get_theme_list)
98
 
                return klass->get_theme_list (wm);
99
 
        else
100
 
                return NULL;
101
 
}
102
 
 
103
 
char *
104
 
gnome_window_manager_get_user_theme_folder (GnomeWindowManager *wm)
105
 
{
106
 
        GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
107
 
        if (klass->get_user_theme_folder)
108
 
                return klass->get_user_theme_folder (wm);
109
 
        else
110
 
                return NULL;
111
 
}
112
 
 
113
 
void
114
 
gnome_window_manager_get_double_click_actions (GnomeWindowManager              *wm,
115
 
                                               const GnomeWMDoubleClickAction **actions,
116
 
                                               int                             *n_actions)
117
 
{
118
 
        GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
119
 
 
120
 
        *actions = NULL;
121
 
        *n_actions = 0;
122
 
        
123
 
        if (klass->get_double_click_actions)
124
 
                klass->get_double_click_actions (wm, actions, n_actions);
125
 
}
126
 
 
127
 
void
128
 
gnome_window_manager_change_settings  (GnomeWindowManager    *wm,
129
 
                                       const GnomeWMSettings *settings)
130
 
{
131
 
        GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
132
 
        
133
 
        (* klass->change_settings) (wm, settings);
134
 
}
135
 
 
136
 
void
137
 
gnome_window_manager_get_settings (GnomeWindowManager *wm,
138
 
                                   GnomeWMSettings    *settings)
139
 
{
140
 
        GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
141
 
        int mask;
142
 
 
143
 
        mask = (* klass->get_settings_mask) (wm);
144
 
        settings->flags &= mask; /* avoid back compat issues by not returning
145
 
                                  * fields to the caller that the WM module
146
 
                                  * doesn't know about
147
 
                                  */
148
 
        
149
 
        (* klass->get_settings) (wm, settings);
150
 
}
151
 
 
152
 
static void
153
 
gnome_window_manager_init (GnomeWindowManager *gnome_window_manager, GnomeWindowManagerClass *class)
154
 
{
155
 
        gnome_window_manager->p = g_new0 (GnomeWindowManagerPrivate, 1);
156
 
}
157
 
 
158
 
static void
159
 
gnome_window_manager_finalize (GObject *object) 
160
 
{
161
 
        GnomeWindowManager *gnome_window_manager;
162
 
 
163
 
        g_return_if_fail (object != NULL);
164
 
        g_return_if_fail (IS_GNOME_WINDOW_MANAGER (object));
165
 
 
166
 
        gnome_window_manager = GNOME_WINDOW_MANAGER (object);
167
 
 
168
 
        g_free (gnome_window_manager->p);
169
 
 
170
 
        parent_class->finalize (object);
171
 
}
172
 
 
173
 
enum {
174
 
  SETTINGS_CHANGED,
175
 
  LAST_SIGNAL
176
 
};
177
 
 
178
 
static guint signals[LAST_SIGNAL] = { 0 };
179
 
 
180
 
static void
181
 
gnome_window_manager_class_init (GnomeWindowManagerClass *class) 
182
 
{
183
 
        GObjectClass *object_class;
184
 
 
185
 
        object_class = G_OBJECT_CLASS (class);
186
 
 
187
 
        object_class->finalize = gnome_window_manager_finalize;
188
 
        
189
 
        parent_class = g_type_class_peek_parent (class);
190
 
 
191
 
        
192
 
        signals[SETTINGS_CHANGED] =
193
 
                g_signal_new ("settings_changed",
194
 
                              G_OBJECT_CLASS_TYPE (class),
195
 
                              G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
196
 
                              G_STRUCT_OFFSET (GnomeWindowManagerClass, settings_changed),
197
 
                              NULL, NULL,
198
 
                              g_cclosure_marshal_VOID__VOID,
199
 
                              G_TYPE_NONE, 0);
200
 
}
201
 
 
202
 
 
203
 
GType
204
 
gnome_window_manager_get_type (void)
205
 
{
206
 
        static GType gnome_window_manager_type = 0;
207
 
 
208
 
        if (!gnome_window_manager_type) {
209
 
                static GTypeInfo gnome_window_manager_info = {
210
 
                        sizeof (GnomeWindowManagerClass),
211
 
                        NULL, /* GBaseInitFunc */
212
 
                        NULL, /* GBaseFinalizeFunc */
213
 
                        (GClassInitFunc) gnome_window_manager_class_init,
214
 
                        NULL, /* GClassFinalizeFunc */
215
 
                        NULL, /* user-supplied data */
216
 
                        sizeof (GnomeWindowManager),
217
 
                        0, /* n_preallocs */
218
 
                        (GInstanceInitFunc) gnome_window_manager_init,
219
 
                        NULL
220
 
                };
221
 
 
222
 
                gnome_window_manager_type = 
223
 
                        g_type_register_static (G_TYPE_OBJECT, 
224
 
                                                "GnomeWindowManager",
225
 
                                                &gnome_window_manager_info, 0);                
226
 
        }
227
 
 
228
 
        return gnome_window_manager_type;
229
 
}
230
 
 
231
 
 
232
 
void
233
 
gnome_window_manager_settings_changed (GnomeWindowManager *wm)
234
 
{
235
 
        g_signal_emit (wm, signals[SETTINGS_CHANGED], 0);
236
 
}
237
 
 
238
 
/* Helper functions for GnomeWMSettings */
239
 
GnomeWMSettings *
240
 
gnome_wm_settings_copy (GnomeWMSettings *settings)
241
 
{
242
 
        GnomeWMSettings *retval;
243
 
 
244
 
        g_return_val_if_fail (settings != NULL, NULL);
245
 
 
246
 
        retval = g_new (GnomeWMSettings, 1);
247
 
        *retval = *settings;
248
 
 
249
 
        if (retval->flags & GNOME_WM_SETTING_FONT)
250
 
                retval->font = g_strdup (retval->font);
251
 
        if (retval->flags & GNOME_WM_SETTING_MOUSE_MOVE_MODIFIER)
252
 
                retval->mouse_move_modifier = g_strdup (retval->mouse_move_modifier);
253
 
        if (retval->flags & GNOME_WM_SETTING_THEME)
254
 
                retval->theme = g_strdup (retval->theme);
255
 
 
256
 
        return retval;
257
 
}
258
 
 
259
 
void
260
 
gnome_wm_settings_free (GnomeWMSettings *settings)
261
 
{
262
 
        g_return_if_fail (settings != NULL);
263
 
 
264
 
        if (settings->flags & GNOME_WM_SETTING_FONT)
265
 
                g_free ((void *) settings->font);
266
 
        if (settings->flags & GNOME_WM_SETTING_MOUSE_MOVE_MODIFIER)
267
 
                g_free ((void *) settings->mouse_move_modifier);
268
 
        if (settings->flags & GNOME_WM_SETTING_THEME)
269
 
                g_free ((void *)settings->theme);
270
 
 
271
 
        g_free (settings);
272
 
}
273