2 * ThemeLoaders for libpurple
4 * Pidgin is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
24 #include "glibcompat.h"
25 #include "theme-loader.h"
27 void purple_theme_loader_set_type_string(PurpleThemeLoader
*loader
, const gchar
*type
);
29 /******************************************************************************
31 *****************************************************************************/
34 } PurpleThemeLoaderPrivate
;
36 /******************************************************************************
38 *****************************************************************************/
46 /******************************************************************************
48 *****************************************************************************/
50 static GParamSpec
*properties
[PROP_LAST
];
52 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(PurpleThemeLoader
, purple_theme_loader
,
55 /******************************************************************************
57 *****************************************************************************/
60 purple_theme_loader_get_property(GObject
*obj
, guint param_id
, GValue
*value
,
63 PurpleThemeLoader
*theme_loader
= PURPLE_THEME_LOADER(obj
);
67 g_value_set_string(value
, purple_theme_loader_get_type_string(theme_loader
));
70 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj
, param_id
, psec
);
76 purple_theme_loader_set_property(GObject
*obj
, guint param_id
, const GValue
*value
,
79 PurpleThemeLoader
*loader
= PURPLE_THEME_LOADER(obj
);
83 purple_theme_loader_set_type_string(loader
, g_value_get_string(value
));
86 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj
, param_id
, psec
);
92 purple_theme_loader_probe_directory(PurpleThemeLoader
*loader
, const gchar
*dir
)
94 const gchar
*type
= purple_theme_loader_get_type_string(loader
);
98 /* Checks for directory as $root/purple/$type */
99 themedir
= g_build_filename(dir
, "purple", type
, NULL
);
100 result
= g_file_test(themedir
, G_FILE_TEST_IS_DIR
);
107 purple_theme_loader_init(PurpleThemeLoader
*loader
)
112 purple_theme_loader_finalize(GObject
*obj
)
114 PurpleThemeLoader
*loader
= PURPLE_THEME_LOADER(obj
);
115 PurpleThemeLoaderPrivate
*priv
=
116 purple_theme_loader_get_instance_private(loader
);
120 G_OBJECT_CLASS(purple_theme_loader_parent_class
)->finalize(obj
);
124 purple_theme_loader_class_init(PurpleThemeLoaderClass
*klass
)
126 GObjectClass
*obj_class
= G_OBJECT_CLASS(klass
);
128 obj_class
->get_property
= purple_theme_loader_get_property
;
129 obj_class
->set_property
= purple_theme_loader_set_property
;
130 obj_class
->finalize
= purple_theme_loader_finalize
;
132 /* TYPE STRING (read only) */
133 properties
[PROP_TYPE
] = g_param_spec_string("type", "Type",
134 "The string representing the type of the theme",
136 G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY
|
137 G_PARAM_STATIC_STRINGS
);
139 g_object_class_install_properties(obj_class
, PROP_LAST
, properties
);
142 /*****************************************************************************
143 * Public API functions
144 *****************************************************************************/
147 purple_theme_loader_get_type_string(PurpleThemeLoader
*theme_loader
)
149 PurpleThemeLoaderPrivate
*priv
= NULL
;
151 g_return_val_if_fail(PURPLE_IS_THEME_LOADER(theme_loader
), NULL
);
153 priv
= purple_theme_loader_get_instance_private(theme_loader
);
159 purple_theme_loader_set_type_string(PurpleThemeLoader
*loader
, const gchar
*type
)
161 PurpleThemeLoaderPrivate
*priv
;
163 g_return_if_fail(PURPLE_IS_THEME_LOADER(loader
));
165 priv
= purple_theme_loader_get_instance_private(loader
);
168 priv
->type
= g_strdup(type
);
170 g_object_notify_by_pspec(G_OBJECT(loader
), properties
[PROP_TYPE
]);
174 purple_theme_loader_build(PurpleThemeLoader
*loader
, const gchar
*dir
)
176 return PURPLE_THEME_LOADER_GET_CLASS(loader
)->purple_theme_loader_build(dir
);
180 purple_theme_loader_probe(PurpleThemeLoader
*loader
, const gchar
*dir
)
182 if (PURPLE_THEME_LOADER_GET_CLASS(loader
)->probe_directory
!= NULL
)
183 return PURPLE_THEME_LOADER_GET_CLASS(loader
)->probe_directory(dir
);
185 return purple_theme_loader_probe_directory(loader
, dir
);