~ubuntu-branches/ubuntu/precise/rhythmbox/precise-201203091205

« back to all changes in this revision

Viewing changes to plugins/rb-plugins-engine.c

Tags: upstream-0.9.5
ImportĀ upstreamĀ versionĀ 0.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Plugin manager for Rhythmbox, based heavily on the code from gedit.
 
3
 *
 
4
 * Copyright (C) 2002-2005 Paolo Maggi 
 
5
 *               2006 James Livingston  <jrl@ids.org.au>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, 
 
20
 * Boston, MA 02110-1301  USA. 
 
21
 */
 
22
 
 
23
 
 
24
#ifdef HAVE_CONFIG_H
 
25
#include <config.h>
 
26
#endif
 
27
 
 
28
#include <string.h>
 
29
 
 
30
#include <glib/gi18n.h>
 
31
#include <glib/gkeyfile.h>
 
32
#include <libgnome/gnome-util.h>
 
33
 
 
34
#include "eel-gconf-extensions.h"
 
35
#include "rb-file-helpers.h"
 
36
#include "rb-preferences.h"
 
37
#include "rb-util.h"
 
38
#include "rb-plugin.h"
 
39
#include "rb-debug.h"
 
40
#include "rb-dialog.h"
 
41
 
 
42
#include "rb-module.h"
 
43
#ifdef ENABLE_PYTHON
 
44
#include "rb-python-module.h"
 
45
#endif
 
46
 
 
47
#include "rb-plugins-engine.h"
 
48
 
 
49
#define USER_RB_PLUGINS_LOCATION "rhythmbox/plugins/"
 
50
#define UNINSTALLED_PLUGINS_LOCATION "plugins"
 
51
 
 
52
#define RB_PLUGINS_ENGINE_BASE_KEY CONF_PREFIX "/plugins"
 
53
#define RB_PLUGINS_ENGINE_KEY RB_PLUGINS_ENGINE_BASE_KEY "/active-plugins"
 
54
 
 
55
#define PLUGIN_EXT      ".rb-plugin"
 
56
 
 
57
typedef enum
 
58
{
 
59
        RB_PLUGIN_LOADER_C,
 
60
        RB_PLUGIN_LOADER_PY,
 
61
} RBPluginLang;
 
62
 
 
63
struct _RBPluginInfo
 
64
{
 
65
        gchar        *file;
 
66
        
 
67
        gchar        *location;
 
68
        RBPluginLang lang;
 
69
        GTypeModule  *module;
 
70
 
 
71
        gchar        *name;
 
72
        gchar        *desc;
 
73
        gchar        **authors;
 
74
        gchar        *copyright;
 
75
        gchar        *website;
 
76
 
 
77
        gchar        *icon_name;
 
78
        GdkPixbuf    *icon_pixbuf;
 
79
         
 
80
        RBPlugin     *plugin;
 
81
        
 
82
        gboolean     active;
 
83
        guint        notification_id;
 
84
};
 
85
 
 
86
static void rb_plugin_info_free (RBPluginInfo *info);
 
87
static void rb_plugins_engine_plugin_active_cb (GConfClient *client,
 
88
                                                guint cnxn_id,
 
89
                                                GConfEntry *entry,
 
90
                                                RBPluginInfo *info);
 
91
static gboolean rb_plugins_engine_activate_plugin_real (RBPluginInfo *info,
 
92
                                                        RBShell *shell);
 
93
static void rb_plugins_engine_deactivate_plugin_real (RBPluginInfo *info,
 
94
                                                      RBShell *shell);
 
95
 
 
96
 
 
97
static GHashTable *rb_plugins = NULL;
 
98
guint garbage_collect_id = 0;
 
99
RBShell *rb_plugins_shell = NULL;
 
100
 
 
101
static RBPluginInfo *
 
102
rb_plugins_engine_load (const gchar *file)
 
103
{
 
104
        RBPluginInfo *info;
 
105
        GKeyFile *plugin_file = NULL;
 
106
        gchar *str;
 
107
 
 
108
        g_return_val_if_fail (file != NULL, NULL);
 
109
 
 
110
        rb_debug ("Loading plugin: %s", file);
 
111
 
 
112
        info = g_new0 (RBPluginInfo, 1);
 
113
        info->file = g_strdup (file);
 
114
 
 
115
        plugin_file = g_key_file_new ();
 
116
        if (!g_key_file_load_from_file (plugin_file, file, G_KEY_FILE_NONE, NULL))
 
117
        {
 
118
                g_warning ("Bad plugin file: %s", file);
 
119
                goto error;
 
120
        }
 
121
 
 
122
        if (!g_key_file_has_key (plugin_file,
 
123
                                 "RB Plugin",
 
124
                                 "IAge",
 
125
                                 NULL))
 
126
        {
 
127
                rb_debug ("IAge key does not exist in file: %s", file);
 
128
                goto error;
 
129
        }
 
130
        
 
131
        /* Check IAge=1 */
 
132
        if (g_key_file_get_integer (plugin_file,
 
133
                                    "RB Plugin",
 
134
                                    "IAge",
 
135
                                    NULL) != 1)
 
136
        {
 
137
                rb_debug ("Wrong IAge in file: %s", file);
 
138
                goto error;
 
139
        }
 
140
                                    
 
141
        /* Get Location */
 
142
        str = g_key_file_get_string (plugin_file,
 
143
                                     "RB Plugin",
 
144
                                     "Module",
 
145
                                     NULL);
 
146
        if (str)
 
147
        {
 
148
                info->location = str;
 
149
        }
 
150
        else
 
151
        {
 
152
                g_warning ("Could not find 'Module' in %s", file);
 
153
                goto error;
 
154
        }
 
155
        
 
156
        /* Get the loader for this plugin */
 
157
        str = g_key_file_get_string (plugin_file,
 
158
                                     "RB Plugin",
 
159
                                     "Loader",
 
160
                                     NULL);
 
161
        if (str && strcmp(str, "python") == 0)
 
162
        {
 
163
                info->lang = RB_PLUGIN_LOADER_PY;
 
164
#ifndef ENABLE_PYTHON
 
165
                rb_debug ("Cannot load python extension '%s', Rhythmbox was not "
 
166
                                        "compiled with python support", file);
 
167
                goto error;
 
168
#endif
 
169
        }
 
170
        else
 
171
        {
 
172
                info->lang = RB_PLUGIN_LOADER_C;
 
173
        }
 
174
        g_free (str);
 
175
 
 
176
        /* Get Name */
 
177
        str = g_key_file_get_locale_string (plugin_file,
 
178
                                            "RB Plugin",
 
179
                                            "Name",
 
180
                                            NULL, NULL);
 
181
        if (str)
 
182
                info->name = str;
 
183
        else
 
184
        {
 
185
                g_warning ("Could not find 'Name' in %s", file);
 
186
                goto error;
 
187
        }
 
188
 
 
189
        /* Get Description */
 
190
        str = g_key_file_get_locale_string (plugin_file,
 
191
                                            "RB Plugin",
 
192
                                            "Description",
 
193
                                            NULL, NULL);
 
194
        if (str)
 
195
                info->desc = str;
 
196
        else
 
197
                rb_debug ("Could not find 'Description' in %s", file);
 
198
 
 
199
        /* Get icon name */
 
200
        str = g_key_file_get_string (plugin_file,
 
201
                                     "RB Plugin",
 
202
                                     "Icon",
 
203
                                     NULL);
 
204
        if (str)
 
205
                info->icon_name = str;
 
206
        else
 
207
                rb_debug ("Could not find 'Description' in %s", file);
 
208
 
 
209
 
 
210
        /* Get Authors */
 
211
        info->authors = g_key_file_get_string_list (plugin_file,
 
212
                                                    "RB Plugin",
 
213
                                                    "Authors",
 
214
                                                    NULL, NULL);
 
215
        if (info->authors == NULL)
 
216
                rb_debug ("Could not find 'Authors' in %s", file);
 
217
 
 
218
 
 
219
        /* Get Copyright */
 
220
        str = g_key_file_get_string (plugin_file,
 
221
                                     "RB Plugin",
 
222
                                     "Copyright",
 
223
                                     NULL);
 
224
        if (str)
 
225
                info->copyright = str;
 
226
        else
 
227
                rb_debug ("Could not find 'Copyright' in %s", file);
 
228
 
 
229
        /* Get Copyright */
 
230
        str = g_key_file_get_string (plugin_file,
 
231
                                     "RB Plugin",
 
232
                                     "Website",
 
233
                                     NULL);
 
234
        if (str)
 
235
                info->website = str;
 
236
        else
 
237
                rb_debug ("Could not find 'Website' in %s", file);
 
238
                
 
239
        g_key_file_free (plugin_file);
 
240
        
 
241
        return info;
 
242
 
 
243
error:
 
244
        g_free (info->file);
 
245
        g_free (info->location);
 
246
        g_free (info->name);
 
247
        g_free (info);
 
248
        g_key_file_free (plugin_file);
 
249
 
 
250
        return NULL;
 
251
}
 
252
 
 
253
static void
 
254
rb_plugins_engine_load_cb (const char *uri, gpointer userdata)
 
255
{
 
256
        gchar *plugin_file;
 
257
        RBPluginInfo *info;
 
258
        char *key_name;
 
259
        gboolean activate;
 
260
                        
 
261
        if (!g_str_has_suffix (uri, PLUGIN_EXT))
 
262
                return;
 
263
 
 
264
        plugin_file = gnome_vfs_get_local_path_from_uri (uri);
 
265
        info = rb_plugins_engine_load (plugin_file);
 
266
        g_free (plugin_file);
 
267
 
 
268
        if (info == NULL)
 
269
                return;
 
270
 
 
271
        if (g_hash_table_lookup (rb_plugins, info->location)) {
 
272
                rb_plugin_info_free (info);
 
273
                return;
 
274
        }
 
275
 
 
276
        g_hash_table_insert (rb_plugins, info->location, info);
 
277
        rb_debug ("Plugin %s loaded", info->name);
 
278
        
 
279
        key_name = g_strdup_printf (CONF_PLUGIN_ACTIVE_KEY, info->location);
 
280
        info->notification_id = eel_gconf_notification_add (key_name,
 
281
                                                            (GConfClientNotifyFunc)rb_plugins_engine_plugin_active_cb,
 
282
                                                            info);
 
283
        activate = eel_gconf_get_boolean (key_name);
 
284
        g_free (key_name);
 
285
 
 
286
        if (activate)
 
287
                rb_plugins_engine_activate_plugin (info);
 
288
}
 
289
 
 
290
static void
 
291
rb_plugins_engine_load_dir (const gchar *path)
 
292
{
 
293
        char *uri;
 
294
 
 
295
        uri = rb_uri_resolve_relative (path);
 
296
        rb_uri_handle_recursively (uri, (GFunc)rb_plugins_engine_load_cb, NULL, NULL);
 
297
        g_free (uri);
 
298
}
 
299
 
 
300
static void
 
301
rb_plugins_engine_load_all (void)
 
302
{
 
303
        gchar *pdir;
 
304
 
 
305
        /* load user's plugins */
 
306
        pdir = gnome_util_home_file (USER_RB_PLUGINS_LOCATION);
 
307
        rb_plugins_engine_load_dir (pdir);
 
308
        g_free (pdir);
 
309
 
 
310
#ifdef SHARE_UNINSTALLED_DIR
 
311
        /* load plugins when running uninstalled */
 
312
        rb_plugins_engine_load_dir (UNINSTALLED_PLUGINS_LOCATION);
 
313
        rb_plugins_engine_load_dir ("../" UNINSTALLED_PLUGINS_LOCATION);
 
314
#endif
 
315
        
 
316
        /* load system-wide plugins */
 
317
        rb_plugins_engine_load_dir (RB_PLUGIN_DIR);
 
318
}
 
319
 
 
320
static gboolean
 
321
garbage_collect_cb (gpointer data)
 
322
{
 
323
        rb_plugins_engine_garbage_collect ();
 
324
        return TRUE;
 
325
}
 
326
 
 
327
gboolean
 
328
rb_plugins_engine_init (RBShell *shell)
 
329
{
 
330
        g_return_val_if_fail (rb_plugins == NULL, FALSE);
 
331
        
 
332
        if (!g_module_supported ())
 
333
        {
 
334
                g_warning ("rb is not able to initialize the plugins engine.");
 
335
                return FALSE;
 
336
        }
 
337
        rb_profile_start ("plugins engine init");
 
338
 
 
339
        rb_plugins = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)rb_plugin_info_free);
 
340
 
 
341
        rb_plugins_shell = shell;
 
342
        g_object_ref (G_OBJECT (rb_plugins_shell));
 
343
 
 
344
        rb_plugins_engine_load_all ();
 
345
 
 
346
        garbage_collect_id = g_timeout_add_full (G_PRIORITY_LOW, 20000, garbage_collect_cb, NULL, NULL);
 
347
 
 
348
        rb_profile_end ("plugins engine init");
 
349
 
 
350
        return TRUE;
 
351
}
 
352
 
 
353
 
 
354
void
 
355
rb_plugins_engine_garbage_collect (void)
 
356
{
 
357
#ifdef ENABLE_PYTHON
 
358
        rb_python_garbage_collect ();
 
359
#endif
 
360
}
 
361
 
 
362
static void
 
363
rb_plugin_info_free (RBPluginInfo *info)
 
364
{
 
365
        if (info->active)
 
366
                rb_plugins_engine_deactivate_plugin_real (info, rb_plugins_shell);
 
367
        
 
368
        if (info->plugin != NULL) {
 
369
                rb_debug ("Unref plugin %s", info->name);
 
370
 
 
371
                g_object_unref (info->plugin);
 
372
                        
 
373
                /* info->module must not be unref since it is not possible to finalize 
 
374
                 * a type module */
 
375
        }
 
376
 
 
377
        eel_gconf_notification_remove (info->notification_id);
 
378
 
 
379
        g_free (info->file);
 
380
        g_free (info->location);
 
381
        g_free (info->name);
 
382
        g_free (info->desc);
 
383
        g_free (info->website);
 
384
        g_free (info->copyright);
 
385
        g_free (info->icon_name);
 
386
 
 
387
        if (info->icon_pixbuf)
 
388
                g_object_unref (info->icon_pixbuf);
 
389
        g_strfreev (info->authors);
 
390
 
 
391
        g_free (info);
 
392
}
 
393
 
 
394
void
 
395
rb_plugins_engine_shutdown (void)
 
396
{
 
397
        g_hash_table_destroy (rb_plugins);
 
398
        rb_plugins = NULL;
 
399
 
 
400
        g_object_unref (rb_plugins_shell);
 
401
        rb_plugins_shell = NULL;
 
402
 
 
403
        g_source_remove (garbage_collect_id);
 
404
        rb_plugins_engine_garbage_collect ();
 
405
 
 
406
#ifdef ENABLE_PYTHON
 
407
        rb_python_shutdown ();
 
408
#endif
 
409
}
 
410
 
 
411
GList *
 
412
rb_plugins_engine_get_plugins_list (void)
 
413
{
 
414
        return rb_collate_hash_table_values (rb_plugins);
 
415
}
 
416
 
 
417
static gboolean
 
418
load_plugin_module (RBPluginInfo *info)
 
419
{
 
420
        gchar *path;
 
421
        gchar *dirname;
 
422
 
 
423
        g_return_val_if_fail (info != NULL, FALSE);
 
424
        g_return_val_if_fail (info->file != NULL, FALSE);
 
425
        g_return_val_if_fail (info->location != NULL, FALSE);
 
426
        g_return_val_if_fail (info->plugin == NULL, FALSE);
 
427
        
 
428
        switch (info->lang)
 
429
        {
 
430
                case RB_PLUGIN_LOADER_C:
 
431
                        dirname = g_path_get_dirname (info->file);      
 
432
                        g_return_val_if_fail (dirname != NULL, FALSE);
 
433
 
 
434
                        path = g_module_build_path (dirname, info->location);
 
435
#ifdef SHARE_UNINSTALLED_DIR
 
436
                        if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
 
437
                                char *temp;
 
438
 
 
439
                                g_free (path);
 
440
                                temp = g_build_filename (dirname, ".libs", NULL);
 
441
                                
 
442
                                path = g_module_build_path (temp, info->location);
 
443
                                g_free (temp);
 
444
                        }
 
445
#endif
 
446
                        
 
447
                        g_free (dirname);
 
448
                        g_return_val_if_fail (path != NULL, FALSE);
 
449
        
 
450
                        info->module = G_TYPE_MODULE (rb_module_new (path));
 
451
                        g_free (path);
 
452
                        break;
 
453
                case RB_PLUGIN_LOADER_PY:
 
454
                {
 
455
#ifdef ENABLE_PYTHON
 
456
                        gchar *dir = g_path_get_dirname (info->file);
 
457
                        
 
458
                        info->module = G_TYPE_MODULE (
 
459
                                        rb_python_module_new (dir, info->location));
 
460
                                        
 
461
                        g_free (dir);
 
462
#endif
 
463
                        break;
 
464
                }
 
465
        }
 
466
 
 
467
        
 
468
        if (g_type_module_use (info->module) == FALSE)
 
469
        {
 
470
                switch (info->lang)
 
471
                {
 
472
                        case RB_PLUGIN_LOADER_C:
 
473
                                g_warning ("Could not load plugin file at %s\n",
 
474
                                   rb_module_get_path (RB_MODULE (info->module)));
 
475
                                break;
 
476
                        case RB_PLUGIN_LOADER_PY:
 
477
                                g_warning ("Could not load python module %s\n", info->location);
 
478
                                break;
 
479
                }
 
480
                           
 
481
                g_object_unref (G_OBJECT (info->module));
 
482
                info->module = NULL;
 
483
                
 
484
                return FALSE;
 
485
        }
 
486
        
 
487
        switch (info->lang)
 
488
        {
 
489
                case RB_PLUGIN_LOADER_C:
 
490
                        info->plugin = RB_PLUGIN (rb_module_new_object (RB_MODULE (info->module)));
 
491
                        break;
 
492
                case RB_PLUGIN_LOADER_PY:
 
493
#ifdef ENABLE_PYTHON
 
494
                        info->plugin = RB_PLUGIN (rb_python_module_new_object (RB_PYTHON_MODULE (info->module)));
 
495
#endif
 
496
                        break;
 
497
        }
 
498
        
 
499
        g_type_module_unuse (info->module);
 
500
 
 
501
        rb_debug ("End");
 
502
        
 
503
        return TRUE;
 
504
}
 
505
 
 
506
static gboolean          
 
507
rb_plugins_engine_activate_plugin_real (RBPluginInfo *info, RBShell *shell)
 
508
{
 
509
        gboolean res = TRUE;
 
510
 
 
511
        if (info->plugin == NULL)
 
512
                res = load_plugin_module (info);
 
513
 
 
514
        if (res)
 
515
                rb_plugin_activate (info->plugin, shell);
 
516
        else
 
517
                g_warning ("Error, impossible to activate plugin '%s'", info->name);
 
518
 
 
519
        return res;
 
520
}
 
521
 
 
522
gboolean         
 
523
rb_plugins_engine_activate_plugin (RBPluginInfo *info)
 
524
{
 
525
        g_return_val_if_fail (info != NULL, FALSE);
 
526
 
 
527
        if (info->active)
 
528
                return TRUE;
 
529
 
 
530
        if (rb_plugins_engine_activate_plugin_real (info, rb_plugins_shell)) {
 
531
                char *key_name;
 
532
 
 
533
                key_name = g_strdup_printf (CONF_PLUGIN_ACTIVE_KEY, info->location);
 
534
                eel_gconf_set_boolean (key_name, TRUE);
 
535
                g_free (key_name);
 
536
        
 
537
                info->active = TRUE;
 
538
 
 
539
                return TRUE;
 
540
        }
 
541
 
 
542
        rb_error_dialog (NULL, _("Plugin Error"), _("Unable to activate plugin %s"), info->name);
 
543
 
 
544
        return FALSE;
 
545
}
 
546
 
 
547
static void
 
548
rb_plugins_engine_deactivate_plugin_real (RBPluginInfo *info, RBShell *shell)
 
549
{
 
550
        rb_plugin_deactivate (info->plugin, rb_plugins_shell);
 
551
}
 
552
 
 
553
gboolean
 
554
rb_plugins_engine_deactivate_plugin (RBPluginInfo *info)
 
555
{
 
556
        char *key_name;
 
557
        
 
558
        g_return_val_if_fail (info != NULL, FALSE);
 
559
 
 
560
        if (!info->active)
 
561
                return TRUE;
 
562
 
 
563
        rb_plugins_engine_deactivate_plugin_real (info, rb_plugins_shell);
 
564
 
 
565
        /* Update plugin state */
 
566
        info->active = FALSE;
 
567
 
 
568
        key_name = g_strdup_printf (CONF_PLUGIN_ACTIVE_KEY, info->location);
 
569
        eel_gconf_set_boolean (key_name, FALSE);
 
570
        g_free (key_name);
 
571
 
 
572
        return TRUE;
 
573
}
 
574
 
 
575
gboolean
 
576
rb_plugins_engine_plugin_is_active (RBPluginInfo *info)
 
577
{
 
578
        g_return_val_if_fail (info != NULL, FALSE);
 
579
        
 
580
        return info->active;
 
581
}
 
582
 
 
583
 
 
584
gboolean
 
585
rb_plugins_engine_plugin_is_configurable (RBPluginInfo *info)
 
586
{
 
587
        g_return_val_if_fail (info != NULL, FALSE);
 
588
 
 
589
        if ((info->plugin == NULL) || !info->active)
 
590
                return FALSE;
 
591
        
 
592
        return rb_plugin_is_configurable (info->plugin);
 
593
}
 
594
 
 
595
void     
 
596
rb_plugins_engine_configure_plugin (RBPluginInfo *info, 
 
597
                                       GtkWindow       *parent)
 
598
{
 
599
        GtkWidget *conf_dlg;
 
600
        
 
601
        GtkWindowGroup *wg;
 
602
        
 
603
        g_return_if_fail (info != NULL);
 
604
 
 
605
        conf_dlg = rb_plugin_create_configure_dialog (info->plugin);
 
606
        g_return_if_fail (conf_dlg != NULL);
 
607
        gtk_window_set_transient_for (GTK_WINDOW (conf_dlg),
 
608
                                      parent);
 
609
 
 
610
        wg = parent->group;                   
 
611
        if (wg == NULL)
 
612
        {
 
613
                wg = gtk_window_group_new ();
 
614
                gtk_window_group_add_window (wg, parent);
 
615
        }
 
616
                        
 
617
        gtk_window_group_add_window (wg,
 
618
                                     GTK_WINDOW (conf_dlg));
 
619
                
 
620
        gtk_window_set_modal (GTK_WINDOW (conf_dlg), TRUE);                  
 
621
        gtk_widget_show (conf_dlg);
 
622
}
 
623
 
 
624
static void
 
625
rb_plugins_engine_plugin_active_cb (GConfClient *client,
 
626
                                    guint cnxn_id,
 
627
                                    GConfEntry *entry,
 
628
                                    RBPluginInfo *info)
 
629
{
 
630
        if (gconf_value_get_bool (entry->value)) {
 
631
                rb_plugins_engine_activate_plugin (info);
 
632
        } else {
 
633
                rb_plugins_engine_deactivate_plugin (info);
 
634
        }
 
635
}
 
636
 
 
637
const gchar *
 
638
rb_plugins_engine_get_plugin_name (RBPluginInfo *info)
 
639
{
 
640
        g_return_val_if_fail (info != NULL, NULL);
 
641
        
 
642
        return info->name;
 
643
}
 
644
 
 
645
const gchar *
 
646
rb_plugins_engine_get_plugin_description (RBPluginInfo *info)
 
647
{
 
648
        g_return_val_if_fail (info != NULL, NULL);
 
649
        
 
650
        return info->desc;
 
651
}
 
652
 
 
653
const gchar **
 
654
rb_plugins_engine_get_plugin_authors (RBPluginInfo *info)
 
655
{
 
656
        g_return_val_if_fail (info != NULL, (const gchar **)NULL);
 
657
        
 
658
        return (const gchar **)info->authors;
 
659
}
 
660
 
 
661
const gchar *
 
662
rb_plugins_engine_get_plugin_website (RBPluginInfo *info)
 
663
{
 
664
        g_return_val_if_fail (info != NULL, NULL);
 
665
        
 
666
        return info->website;
 
667
}
 
668
 
 
669
const gchar *
 
670
rb_plugins_engine_get_plugin_copyright (RBPluginInfo *info)
 
671
{
 
672
        g_return_val_if_fail (info != NULL, NULL);
 
673
        
 
674
        return info->copyright;
 
675
}
 
676
 
 
677
GdkPixbuf *
 
678
rb_plugins_engine_get_plugin_icon (RBPluginInfo *info)
 
679
{
 
680
        if (info->icon_name == NULL)
 
681
                return NULL;
 
682
 
 
683
        if (info->icon_pixbuf == NULL) {
 
684
                char *filename = NULL;
 
685
                char *dirname;
 
686
 
 
687
                dirname = g_path_get_dirname (info->file);
 
688
                filename = g_build_filename (dirname, info->icon_name, NULL);
 
689
                g_free (dirname);
 
690
 
 
691
                info->icon_pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
 
692
                g_free (filename);
 
693
        }
 
694
 
 
695
        return info->icon_pixbuf;
 
696
}
 
697