~ubuntu-branches/ubuntu/oneiric/rhythmbox/oneiric

« back to all changes in this revision

Viewing changes to remote/bonobo/rb-nautilus-context-menu.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2006-06-26 19:06:10 UTC
  • mto: (2.1.1 lenny) (1.1.37 upstream)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20060626190610-08x8lgvvfs0gr619
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
 
 * arch-tag: Nautilus context menu main implementation
3
 
 * Copyright (C) 2003 Yann Rouillard
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU General Public License as
7
 
 * published by the Free Software Foundation; either version 2 of the
8
 
 * License, or (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 GNU
13
 
 * General Public License for more av.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public
16
 
 * License along with this program; if not, write to the
17
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
 
 * Boston, MA 02111-1307, USA.
19
 
 *
20
 
 * Author:  Yann Rouillard  <y.rouillard@laposte.net>
21
 
 */
22
 
 
23
 
#include <config.h>
24
 
 
25
 
#include <string.h>
26
 
#include <gtk/gtk.h>
27
 
#include <libgnomevfs/gnome-vfs-utils.h>
28
 
#include <libbonobo.h>
29
 
#include "rb-nautilus-context-menu.h"
30
 
#include "Rhythmbox.h"
31
 
 
32
 
#include <stdlib.h>
33
 
 
34
 
 
35
 
static void
36
 
impl_Bonobo_Listener_event (PortableServer_Servant servant,
37
 
                            const CORBA_char *event_name,
38
 
                            const CORBA_any *args,
39
 
                            CORBA_Environment *ev)
40
 
{
41
 
        RbNautilusContextMenu *rncm;
42
 
        const CORBA_sequence_CORBA_string *list;
43
 
        gint i;
44
 
        CORBA_Object obj;
45
 
 
46
 
        rncm = RB_NAUTILUS_CONTEXT_MENU (bonobo_object_from_servant (servant));
47
 
 
48
 
        if (!CORBA_TypeCode_equivalent (args->_type, TC_CORBA_sequence_CORBA_string, ev))
49
 
                return;
50
 
 
51
 
        list = (CORBA_sequence_CORBA_string *) args->_value;
52
 
 
53
 
        g_return_if_fail (rncm != NULL);
54
 
        g_return_if_fail (list != NULL);
55
 
 
56
 
        obj = bonobo_activation_activate ("repo_ids.has ('IDL:GNOME/Rhythmbox:1.0')", NULL, 0, NULL, ev);
57
 
 
58
 
        if (ev->_major != CORBA_NO_EXCEPTION)
59
 
                return;
60
 
 
61
 
        g_return_if_fail (obj != CORBA_OBJECT_NIL);
62
 
 
63
 
        for (i = 0; i < list->_length; i++) {
64
 
                GError *error = NULL;
65
 
                char *utf8 = g_filename_to_utf8 (list->_buffer[i], -1, NULL, NULL, &error);
66
 
                if (utf8 && error == NULL)
67
 
                        GNOME_Rhythmbox_addToLibrary(obj, utf8, ev);
68
 
        }
69
 
 
70
 
        CORBA_Object_release (obj, ev);
71
 
}
72
 
 
73
 
 
74
 
/* initialize the class */
75
 
static void
76
 
rb_nautilus_context_menu_class_init (RbNautilusContextMenuClass *class)
77
 
{
78
 
        POA_Bonobo_Listener__epv *epv = &class->epv;
79
 
        epv->event = impl_Bonobo_Listener_event;
80
 
}
81
 
 
82
 
 
83
 
static void
84
 
rb_nautilus_context_menu_init (RbNautilusContextMenu *rncm)
85
 
{
86
 
}
87
 
 
88
 
 
89
 
BONOBO_TYPE_FUNC_FULL (RbNautilusContextMenu,
90
 
                       Bonobo_Listener,
91
 
                       BONOBO_TYPE_OBJECT,
92
 
                       rb_nautilus_context_menu);