93
81
GtkWindow *main_window;
96
char **args, *xid_str;
86
GdkAppLaunchContext *context;
97
87
GError *error = NULL;
101
array = g_ptr_array_new ();
102
g_ptr_array_add (array, (gpointer) "brasero");
104
g_ptr_array_add (array, (gpointer) "-c");
106
g_ptr_array_add (array, (gpointer) "-r");
107
g_ptr_array_add (array, (gpointer) path);
109
main_window = totem_get_main_window (pi->totem);
90
/* Build a command line to use */
91
main_window = totem_get_main_window (pi->priv->totem);
110
92
screen = gtk_widget_get_screen (GTK_WIDGET (main_window));
111
xid = gdk_x11_drawable_get_xid (GDK_DRAWABLE (gtk_widget_get_window (GTK_WIDGET (main_window))));
112
xid_str = g_strdup_printf ("%d", xid);
113
g_ptr_array_add (array, (gpointer) "-x");
114
g_ptr_array_add (array, xid_str);
116
g_ptr_array_add (array, NULL);
117
args = (char **) g_ptr_array_free (array, FALSE);
120
if (gdk_spawn_on_screen (screen, NULL, args, NULL,
121
G_SPAWN_SEARCH_PATH | G_SPAWN_FILE_AND_ARGV_ZERO,
122
NULL, NULL, NULL, &error) == FALSE) {
124
totem_interface_error (_("The video disc could not be duplicated."),
126
totem_get_main_window (pi->totem));
128
totem_interface_error (_("The movie could not be recorded."),
130
totem_get_main_window (pi->totem));
133
g_error_free (error);
93
xid = gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (main_window)));
94
g_object_unref (main_window);
97
command_line = g_strdup_printf ("brasero -x %d -c", xid);
99
command_line = g_strdup_printf ("brasero -x %d -r", xid);
101
/* Build the app info */
102
info = g_app_info_create_from_commandline (command_line, NULL,
103
G_APP_INFO_CREATE_SUPPORTS_URIS | G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION, &error);
104
g_free (command_line);
109
/* Create a launch context and launch it */
110
context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (main_window)));
111
gdk_app_launch_context_set_screen (context, screen);
113
uris = g_list_prepend (NULL, (gpointer) path);
114
g_app_info_launch_uris (info, uris, G_APP_LAUNCH_CONTEXT (context), &error);
117
g_object_unref (info);
118
g_object_unref (context);
126
main_window = totem_get_main_window (pi->priv->totem);
129
totem_interface_error (_("The video disc could not be duplicated."), error->message, main_window);
131
totem_interface_error (_("The movie could not be recorded."), error->message, main_window);
133
g_error_free (error);
134
g_object_unref (main_window);
325
322
TotemDiscRecorderPlugin *pi)
324
TotemDiscRecorderPluginPrivate *priv = pi->priv;
327
325
GtkAction *action;
329
327
/* Check if that stream is supported by brasero */
330
328
if (g_str_has_prefix (mrl, "file:")) {
331
329
/* If the file is supported we can always burn, even if there
332
330
* aren't any burner since we can still create an image. */
333
action = gtk_action_group_get_action (pi->action_group, "VideoBurnToDisc");
331
action = gtk_action_group_get_action (priv->action_group, "VideoBurnToDisc");
334
332
gtk_action_set_visible (action, TRUE);
335
action = gtk_action_group_get_action (pi->action_group, "VideoDVDCopy");
333
action = gtk_action_group_get_action (priv->action_group, "VideoDVDCopy");
336
334
gtk_action_set_visible (action, FALSE);
337
action = gtk_action_group_get_action (pi->action_group, "VideoVCDCopy");
335
action = gtk_action_group_get_action (priv->action_group, "VideoVCDCopy");
338
336
gtk_action_set_visible (action, FALSE);
340
338
else if (g_str_has_prefix (mrl, "dvd:")) {
341
action = gtk_action_group_get_action (pi->action_group, "VideoBurnToDisc");
339
action = gtk_action_group_get_action (priv->action_group, "VideoBurnToDisc");
342
340
gtk_action_set_visible (action, FALSE);
343
action = gtk_action_group_get_action (pi->action_group, "VideoDVDCopy");
341
action = gtk_action_group_get_action (priv->action_group, "VideoDVDCopy");
344
342
gtk_action_set_visible (action, TRUE);
345
action = gtk_action_group_get_action (pi->action_group, "VideoVCDCopy");
343
action = gtk_action_group_get_action (priv->action_group, "VideoVCDCopy");
346
344
gtk_action_set_visible (action, FALSE);
348
346
else if (g_str_has_prefix (mrl, "vcd:")) {
349
action = gtk_action_group_get_action (pi->action_group, "VideoBurnToDisc");
350
gtk_action_set_visible (action, FALSE);
351
action = gtk_action_group_get_action (pi->action_group, "VideoDVDCopy");
352
gtk_action_set_visible (action, FALSE);
353
action = gtk_action_group_get_action (pi->action_group, "VideoVCDCopy");
347
action = gtk_action_group_get_action (priv->action_group, "VideoBurnToDisc");
348
gtk_action_set_visible (action, FALSE);
349
action = gtk_action_group_get_action (priv->action_group, "VideoDVDCopy");
350
gtk_action_set_visible (action, FALSE);
351
action = gtk_action_group_get_action (priv->action_group, "VideoVCDCopy");
354
352
gtk_action_set_visible (action, TRUE);
357
action = gtk_action_group_get_action (pi->action_group, "VideoBurnToDisc");
358
gtk_action_set_visible (action, FALSE);
359
action = gtk_action_group_get_action (pi->action_group, "VideoDVDCopy");
360
gtk_action_set_visible (action, FALSE);
361
action = gtk_action_group_get_action (pi->action_group, "VideoVCDCopy");
355
action = gtk_action_group_get_action (priv->action_group, "VideoBurnToDisc");
356
gtk_action_set_visible (action, FALSE);
357
action = gtk_action_group_get_action (priv->action_group, "VideoDVDCopy");
358
gtk_action_set_visible (action, FALSE);
359
action = gtk_action_group_get_action (priv->action_group, "VideoVCDCopy");
362
360
gtk_action_set_visible (action, FALSE);
367
impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error)
365
impl_activate (PeasActivatable *plugin)
369
367
TotemDiscRecorderPlugin *pi = TOTEM_DISC_RECORDER_PLUGIN (plugin);
368
TotemDiscRecorderPluginPrivate *priv = pi->priv;
370
369
GtkUIManager *uimanager = NULL;
371
370
GtkAction *action;
387
priv->totem = g_object_get_data (G_OBJECT (plugin), "object");
390
g_signal_connect (totem,
389
g_signal_connect (priv->totem,
392
391
G_CALLBACK (totem_disc_recorder_file_opened),
394
g_signal_connect (totem,
393
g_signal_connect (priv->totem,
396
395
G_CALLBACK (totem_disc_recorder_file_closed),
400
pi->action_group = gtk_action_group_new ("DiscRecorderActions");
401
gtk_action_group_set_translation_domain (pi->action_group, GETTEXT_PACKAGE);
402
gtk_action_group_add_actions (pi->action_group,
399
priv->action_group = gtk_action_group_new ("DiscRecorderActions");
400
gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE);
401
gtk_action_group_add_actions (priv->action_group,
403
402
totem_disc_recorder_plugin_actions,
404
403
G_N_ELEMENTS (totem_disc_recorder_plugin_actions),
407
uimanager = totem_get_ui_manager (totem);
408
gtk_ui_manager_insert_action_group (uimanager, pi->action_group, -1);
409
g_object_unref (pi->action_group);
411
pi->ui_merge_id = gtk_ui_manager_new_merge_id (uimanager);
413
gtk_ui_manager_add_ui (uimanager,
415
"/ui/tmw-menubar/movie/burn-placeholder",
418
GTK_UI_MANAGER_MENUITEM,
420
gtk_ui_manager_add_ui (uimanager,
422
"/ui/totem-main-popup/burn-placeholder",
425
GTK_UI_MANAGER_MENUITEM,
428
gtk_ui_manager_add_ui (uimanager,
430
"/ui/tmw-menubar/movie/burn-placeholder",
433
GTK_UI_MANAGER_MENUITEM,
435
gtk_ui_manager_add_ui (uimanager,
437
"/ui/totem-main-popup/burn-placeholder",
440
GTK_UI_MANAGER_MENUITEM,
443
gtk_ui_manager_add_ui (uimanager,
445
"/ui/tmw-menubar/movie/burn-placeholder",
448
GTK_UI_MANAGER_MENUITEM,
450
gtk_ui_manager_add_ui (uimanager,
452
"/ui/totem-main-popup/burn-placeholder",
455
GTK_UI_MANAGER_MENUITEM,
458
if (!totem_is_paused (totem) && !totem_is_playing (totem)) {
459
action = gtk_action_group_get_action (pi->action_group, "VideoBurnToDisc");
460
gtk_action_set_visible (action, FALSE);
461
action = gtk_action_group_get_action (pi->action_group, "VideoDVDCopy");
462
gtk_action_set_visible (action, FALSE);
463
action = gtk_action_group_get_action (pi->action_group, "VideoVCDCopy");
406
uimanager = totem_get_ui_manager (priv->totem);
407
gtk_ui_manager_insert_action_group (uimanager, priv->action_group, -1);
408
g_object_unref (priv->action_group);
410
priv->ui_merge_id = gtk_ui_manager_new_merge_id (uimanager);
412
gtk_ui_manager_add_ui (uimanager,
414
"/ui/tmw-menubar/movie/burn-placeholder",
417
GTK_UI_MANAGER_MENUITEM,
420
gtk_ui_manager_add_ui (uimanager,
422
"/ui/tmw-menubar/movie/burn-placeholder",
425
GTK_UI_MANAGER_MENUITEM,
428
gtk_ui_manager_add_ui (uimanager,
430
"/ui/tmw-menubar/movie/burn-placeholder",
433
GTK_UI_MANAGER_MENUITEM,
436
if (!totem_is_paused (priv->totem) && !totem_is_playing (priv->totem)) {
437
action = gtk_action_group_get_action (priv->action_group, "VideoBurnToDisc");
438
gtk_action_set_visible (action, FALSE);
439
action = gtk_action_group_get_action (priv->action_group, "VideoDVDCopy");
440
gtk_action_set_visible (action, FALSE);
441
action = gtk_action_group_get_action (priv->action_group, "VideoVCDCopy");
464
442
gtk_action_set_visible (action, FALSE); }
468
mrl = totem_get_current_mrl (totem);
469
totem_disc_recorder_file_opened (totem, mrl, pi);
446
mrl = totem_get_current_mrl (priv->totem);
447
totem_disc_recorder_file_opened (priv->totem, mrl, pi);
477
impl_deactivate (TotemPlugin *plugin, TotemObject *totem)
453
impl_deactivate (PeasActivatable *plugin)
479
455
TotemDiscRecorderPlugin *pi = TOTEM_DISC_RECORDER_PLUGIN (plugin);
456
TotemDiscRecorderPluginPrivate *priv = pi->priv;
480
457
GtkUIManager *uimanager = NULL;
484
g_signal_handlers_disconnect_by_func (totem, totem_disc_recorder_file_opened, plugin);
485
g_signal_handlers_disconnect_by_func (totem, totem_disc_recorder_file_closed, plugin);
487
uimanager = totem_get_ui_manager (totem);
488
gtk_ui_manager_remove_ui (uimanager, pi->ui_merge_id);
489
gtk_ui_manager_remove_action_group (uimanager, pi->action_group);
495
totem_disc_recorder_plugin_finalize (GObject *object)
497
G_OBJECT_CLASS (totem_disc_recorder_plugin_parent_class)->finalize (object);
501
totem_disc_recorder_plugin_class_init (TotemDiscRecorderPluginClass *klass)
503
GObjectClass *object_class = G_OBJECT_CLASS (klass);
504
TotemPluginClass *plugin_class = TOTEM_PLUGIN_CLASS (klass);
506
object_class->finalize = totem_disc_recorder_plugin_finalize;
508
plugin_class->activate = impl_activate;
509
plugin_class->deactivate = impl_deactivate;
513
totem_disc_recorder_plugin_init (TotemDiscRecorderPlugin *pi)
459
g_signal_handlers_disconnect_by_func (priv->totem, totem_disc_recorder_file_opened, plugin);
460
g_signal_handlers_disconnect_by_func (priv->totem, totem_disc_recorder_file_closed, plugin);
462
uimanager = totem_get_ui_manager (priv->totem);
463
gtk_ui_manager_remove_ui (uimanager, priv->ui_merge_id);
464
gtk_ui_manager_remove_action_group (uimanager, priv->action_group);