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

« back to all changes in this revision

Viewing changes to plugins/brasero-disc-recorder/rb-disc-recorder-plugin.c

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2011-07-29 16:41:38 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: james.westby@ubuntu.com-20110729164138-wwicy8nqalm18ck7
Tags: upstream-2.90.1~20110802
ImportĀ upstreamĀ versionĀ 2.90.1~20110802

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include <libxml/uri.h>
51
51
#include <libxml/xmlsave.h>
52
52
 
53
 
#include "rb-plugin.h"
 
53
#include "rb-plugin-macros.h"
54
54
#include "rb-debug.h"
55
55
#include "rb-shell.h"
56
56
#include "rb-source.h"
67
67
 
68
68
typedef struct
69
69
{
70
 
        RBPlugin        parent;
 
70
        PeasExtensionBase parent;
71
71
 
72
 
        RBShell        *shell;
73
72
        GtkActionGroup *action_group;
74
73
        guint           ui_merge_id;
75
74
 
79
78
 
80
79
typedef struct
81
80
{
82
 
        RBPluginClass parent_class;
 
81
        PeasExtensionBaseClass parent_class;
83
82
} RBDiscRecorderPluginClass;
84
83
 
85
 
G_MODULE_EXPORT GType register_rb_plugin (GTypeModule *module);
86
 
GType   rb_disc_recorder_plugin_get_type                (void) G_GNUC_CONST;
 
84
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
 
85
 
 
86
RB_DEFINE_PLUGIN(RB_TYPE_DISC_RECORDER_PLUGIN, RBDiscRecorderPlugin, rb_disc_recorder_plugin,)
87
87
 
88
88
static void rb_disc_recorder_plugin_init (RBDiscRecorderPlugin *plugin);
89
 
static void rb_disc_recorder_plugin_finalize (GObject *object);
90
 
static void impl_activate (RBPlugin *plugin, RBShell *shell);
91
 
static void impl_deactivate (RBPlugin *plugin, RBShell *shell);
92
89
static void cmd_burn_source (GtkAction          *action,
93
90
                             RBDiscRecorderPlugin *pi);
94
91
static void cmd_duplicate_cd (GtkAction          *action,
103
100
          G_CALLBACK (cmd_duplicate_cd) },
104
101
};
105
102
 
106
 
RB_PLUGIN_REGISTER(RBDiscRecorderPlugin, rb_disc_recorder_plugin)
107
 
 
108
103
#define RB_RECORDER_ERROR rb_disc_recorder_error_quark ()
109
104
 
110
105
GQuark rb_disc_recorder_error_quark (void);
127
122
} RBRecorderError;
128
123
 
129
124
static void
130
 
rb_disc_recorder_plugin_class_init (RBDiscRecorderPluginClass *klass)
131
 
{
132
 
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
133
 
        RBPluginClass *plugin_class = RB_PLUGIN_CLASS (klass);
134
 
 
135
 
        object_class->finalize = rb_disc_recorder_plugin_finalize;
136
 
 
137
 
        plugin_class->activate = impl_activate;
138
 
        plugin_class->deactivate = impl_deactivate;
139
 
}
140
 
 
141
 
static void
142
125
rb_disc_recorder_plugin_init (RBDiscRecorderPlugin *pi)
143
126
{
144
127
        rb_debug ("RBDiscRecorderPlugin initialized");
145
128
}
146
129
 
147
 
static void
148
 
rb_disc_recorder_plugin_finalize (GObject *object)
149
 
{
150
 
        rb_debug ("RBDiscRecorderPlugin finalized");
151
 
 
152
 
        G_OBJECT_CLASS (rb_disc_recorder_plugin_parent_class)->finalize (object);
153
 
}
154
 
 
155
130
static gboolean
156
131
rb_disc_recorder_plugin_start_burning (RBDiscRecorderPlugin *pi,
157
132
                                          const char *path,
163
138
        char **args, *xid_str;
164
139
        GError *error = NULL;
165
140
        gboolean ret;
 
141
        RBShell *shell;
166
142
        
167
143
        array = g_ptr_array_new ();
168
144
        g_ptr_array_add (array, "brasero");
172
148
                g_ptr_array_add (array, "-r");
173
149
        g_ptr_array_add (array, (gpointer) path);
174
150
 
175
 
        g_object_get (pi->shell, "window", &main_window, NULL);
 
151
        g_object_get (pi, "object", &shell, NULL);
 
152
        g_object_get (shell, "window", &main_window, NULL);
 
153
        g_object_unref (shell);
 
154
 
176
155
        window = gtk_widget_get_window (main_window);
177
156
        if (window) {
178
157
                int xid;
606
585
        /* for now restrict to playlist sources */
607
586
        playlist_active = RB_IS_PLAYLIST_SOURCE (selected_page);
608
587
 
609
 
        page_type = G_OBJECT_TYPE_NAME (selected_page);
610
 
        is_audiocd_active = g_str_equal (page_type, "RBAudioCdSource");
 
588
        if (selected_page != NULL) {
 
589
                page_type = G_OBJECT_TYPE_NAME (selected_page);
 
590
                is_audiocd_active = g_str_equal (page_type, "RBAudioCdSource");
 
591
        } else {
 
592
                is_audiocd_active = FALSE;
 
593
        }
611
594
 
612
595
        burn_action = gtk_action_group_get_action (pi->action_group,
613
596
                                                   "MusicPlaylistBurnToDiscPlaylist");
671
654
};
672
655
 
673
656
static void
674
 
impl_activate (RBPlugin *plugin,
675
 
               RBShell  *shell)
 
657
impl_activate (PeasActivatable *plugin)
676
658
{
677
659
        RBDiscRecorderPlugin *pi = RB_DISC_RECORDER_PLUGIN (plugin);
678
660
        GtkUIManager         *uimanager = NULL;
679
661
        GtkAction            *action;
 
662
        RBShell              *shell;
680
663
        int                   i;
681
664
 
 
665
        g_object_get (pi, "object", &shell, NULL);
 
666
 
682
667
        pi->enabled = TRUE;
683
668
 
684
669
        rb_debug ("RBDiscRecorderPlugin activating");
685
670
 
686
671
        brasero_media_library_start ();
687
672
 
688
 
        pi->shell = shell;
689
 
 
690
673
        g_object_get (shell,
691
674
                      "ui-manager", &uimanager,
692
675
                      NULL);
737
720
        g_object_set (action, "short-label", _("Copy CD"), NULL);
738
721
 
739
722
        update_source (pi, shell);
 
723
 
 
724
        g_object_unref (shell);
740
725
}
741
726
 
742
727
static void
743
 
impl_deactivate (RBPlugin *plugin,
744
 
                 RBShell  *shell)
 
728
impl_deactivate (PeasActivatable *plugin)
745
729
{
746
730
        RBDiscRecorderPlugin *pi = RB_DISC_RECORDER_PLUGIN (plugin);
747
 
        GtkUIManager       *uimanager = NULL;
 
731
        GtkUIManager         *uimanager = NULL;
 
732
        RBShell              *shell;
 
733
 
 
734
        g_object_get (pi, "object", &shell, NULL);
748
735
 
749
736
        pi->enabled = FALSE;
750
737
 
769
756
        g_object_unref (uimanager);
770
757
 
771
758
        /* NOTE: don't deactivate libbrasero-media as it could be in use somewhere else */
772
 
}
773
 
 
 
759
 
 
760
        g_object_unref (shell);
 
761
}
 
762
 
 
763
G_MODULE_EXPORT void
 
764
peas_register_types (PeasObjectModule *module)
 
765
{
 
766
        rb_disc_recorder_plugin_register_type (G_TYPE_MODULE (module));
 
767
        peas_object_module_register_extension_type (module,
 
768
                                                    PEAS_TYPE_ACTIVATABLE,
 
769
                                                    RB_TYPE_DISC_RECORDER_PLUGIN);
 
770
}