1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
3
/* gnome-window-manager.h
4
* Copyright (C) 2002 Seth Nickell
5
* Copyright (C) 2002 Red Hat, Inc.
7
* Written by: Seth Nickell <snickell@stanford.edu>,
8
* Havoc Pennington <hp@redhat.com>
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)
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.
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
26
#include "gnome-window-manager.h"
30
static GObjectClass *parent_class;
32
struct _GnomeWindowManagerPrivate {
33
char *window_manager_name;
34
GnomeDesktopItem *ditem;
38
gnome_window_manager_new (GnomeDesktopItem *it)
40
const char *settings_lib;
42
GnomeWindowManagerNewFunc wm_new_func = NULL;
47
settings_lib = gnome_desktop_item_get_string (it, "X-GNOME-WMSettingsModule");
49
module_name = g_module_build_path (GNOME_WINDOW_MANAGER_MODULE_PATH,
52
module = g_module_open (module_name, G_MODULE_BIND_LAZY);
54
g_warning ("Couldn't load window manager settings module `%s' (%s)", module_name, g_module_error ());
59
success = g_module_symbol (module, "window_manager_new",
60
(gpointer *) &wm_new_func);
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);
70
wm = (* wm_new_func) (GNOME_WINDOW_MANAGER_INTERFACE_VERSION);
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);
82
gnome_window_manager_get_name (GnomeWindowManager *wm)
84
return wm->p->window_manager_name;
88
gnome_window_manager_get_ditem (GnomeWindowManager *wm)
90
return gnome_desktop_item_ref (wm->p->ditem);
94
gnome_window_manager_get_theme_list (GnomeWindowManager *wm)
96
GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
97
if (klass->get_theme_list)
98
return klass->get_theme_list (wm);
104
gnome_window_manager_get_user_theme_folder (GnomeWindowManager *wm)
106
GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
107
if (klass->get_user_theme_folder)
108
return klass->get_user_theme_folder (wm);
114
gnome_window_manager_get_double_click_actions (GnomeWindowManager *wm,
115
const GnomeWMDoubleClickAction **actions,
118
GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
123
if (klass->get_double_click_actions)
124
klass->get_double_click_actions (wm, actions, n_actions);
128
gnome_window_manager_change_settings (GnomeWindowManager *wm,
129
const GnomeWMSettings *settings)
131
GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
133
(* klass->change_settings) (wm, settings);
137
gnome_window_manager_get_settings (GnomeWindowManager *wm,
138
GnomeWMSettings *settings)
140
GnomeWindowManagerClass *klass = GNOME_WINDOW_MANAGER_GET_CLASS (wm);
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
149
(* klass->get_settings) (wm, settings);
153
gnome_window_manager_init (GnomeWindowManager *gnome_window_manager, GnomeWindowManagerClass *class)
155
gnome_window_manager->p = g_new0 (GnomeWindowManagerPrivate, 1);
159
gnome_window_manager_finalize (GObject *object)
161
GnomeWindowManager *gnome_window_manager;
163
g_return_if_fail (object != NULL);
164
g_return_if_fail (IS_GNOME_WINDOW_MANAGER (object));
166
gnome_window_manager = GNOME_WINDOW_MANAGER (object);
168
g_free (gnome_window_manager->p);
170
parent_class->finalize (object);
178
static guint signals[LAST_SIGNAL] = { 0 };
181
gnome_window_manager_class_init (GnomeWindowManagerClass *class)
183
GObjectClass *object_class;
185
object_class = G_OBJECT_CLASS (class);
187
object_class->finalize = gnome_window_manager_finalize;
189
parent_class = g_type_class_peek_parent (class);
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),
198
g_cclosure_marshal_VOID__VOID,
204
gnome_window_manager_get_type (void)
206
static GType gnome_window_manager_type = 0;
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),
218
(GInstanceInitFunc) gnome_window_manager_init,
222
gnome_window_manager_type =
223
g_type_register_static (G_TYPE_OBJECT,
224
"GnomeWindowManager",
225
&gnome_window_manager_info, 0);
228
return gnome_window_manager_type;
233
gnome_window_manager_settings_changed (GnomeWindowManager *wm)
235
g_signal_emit (wm, signals[SETTINGS_CHANGED], 0);
238
/* Helper functions for GnomeWMSettings */
240
gnome_wm_settings_copy (GnomeWMSettings *settings)
242
GnomeWMSettings *retval;
244
g_return_val_if_fail (settings != NULL, NULL);
246
retval = g_new (GnomeWMSettings, 1);
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);
260
gnome_wm_settings_free (GnomeWMSettings *settings)
262
g_return_if_fail (settings != NULL);
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);