diff options
author | Bastien Nocera <hadess@hadess.net> | 2012-04-05 17:17:41 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2012-04-12 17:18:39 +0100 |
commit | d9fa4d22c9b75ff063f6cf8c0672fcee240efbfe (patch) | |
tree | 90cc830d88d09ec873f91dfd50316e8019d01c00 | |
parent | c9d112f54731de03ad9346e76be232abf7bc1b96 (diff) | |
download | totem-d9fa4d22c9b75ff063f6cf8c0672fcee240efbfe.tar.gz |
main: Use grilo to list DVDs and co.
https://bugzilla.gnome.org/show_bug.cgi?id=673591
-rw-r--r-- | data/totem.ui | 1 | ||||
-rw-r--r-- | src/totem-menu.c | 386 | ||||
-rw-r--r-- | src/totem-menu.h | 2 | ||||
-rw-r--r-- | src/totem.c | 1 |
4 files changed, 0 insertions, 390 deletions
diff --git a/data/totem.ui b/data/totem.ui index 8914c7c7e..dc3a166e9 100644 --- a/data/totem.ui +++ b/data/totem.ui @@ -386,7 +386,6 @@ <menubar name="tmw-menubar"> <menu name="movie" action="movie-menu"> <placeholder name="save-placeholder"/> - <placeholder name="devices-placeholder"/> <separator name="recent-separator"/> <placeholder name="recent-placeholder"/> <separator/> diff --git a/src/totem-menu.c b/src/totem-menu.c index 05ab405e6..84219352d 100644 --- a/src/totem-menu.c +++ b/src/totem-menu.c @@ -712,392 +712,6 @@ totem_action_add_recent (Totem *totem, G_FILE_QUERY_INFO_NONE, 0, NULL, (GAsyncReadyCallback) recent_info_cb, totem); } -/* Play Disc menu items */ - -static void -on_play_disc_activate (GtkAction *action, Totem *totem) -{ - char *device_path; - - device_path = g_object_get_data (G_OBJECT (action), "device_path"); - totem_action_play_media_device (totem, device_path); -} - -static const char * -get_icon_name_for_gicon (GtkIconTheme *theme, - GIcon *icon) -{ - const char * const *icon_names; - const char *icon_name; - guint j; - - icon_name = NULL; - - if (G_IS_EMBLEMED_ICON (icon) != FALSE) { - GIcon *new_icon; - new_icon = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (icon)); - g_object_unref (icon); - icon = g_object_ref (new_icon); - } - - if (G_IS_THEMED_ICON (icon)) { - icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon)); - - for (j = 0; icon_names[j] != NULL; j++) { - icon_name = icon_names[j]; - if (gtk_icon_theme_has_icon (theme, icon_name) != FALSE) - break; - } - } - - return icon_name; -} - -static char * -unescape_archive_name (GFile *root) -{ - char *uri; - guint len; - char *escape1, *escape2; - - uri = g_file_get_uri (root); - - /* Remove trailing slash */ - len = strlen (uri); - if (uri[len - 1] == '/') - uri[len - 1] = '\0'; - - /* Unescape the path */ - escape1 = g_uri_unescape_string (uri + strlen ("archive://"), NULL); - escape2 = g_uri_unescape_string (escape1, NULL); - g_free (escape1); - g_free (uri); - - return escape2; -} - -static void -add_mount_to_menu (GMount *mount, - GtkIconTheme *theme, - guint position, - Totem *totem) -{ - char *name, *escaped_name, *label; - GtkAction *action; - GIcon *icon; - const char *icon_name; - char *device_path; - - GVolume *volume; - GFile *root, *iso; - char **content_types; - gboolean has_content; - guint i; - - /* Check whether we have an archive mount */ - volume = g_mount_get_volume (mount); - if (volume != NULL) { - g_object_unref (volume); - return; - } - - root = g_mount_get_root (mount); - if (g_file_has_uri_scheme (root, "archive") == FALSE) { - g_object_unref (root); - return; - } - - /* Check whether it's a DVD or VCD image */ - content_types = g_content_type_guess_for_tree (root); - if (content_types == NULL || - g_strv_length (content_types) == 0) { - g_strfreev (content_types); - g_object_unref (root); - return; - } - - has_content = FALSE; - for (i = 0; content_types[i] != NULL; i++) { - /* XXX: Keep in sync with mime-type-list.txt */ - if (g_str_equal (content_types[i], "x-content/video-dvd") || - g_str_equal (content_types[i], "x-content/video-vcd") || - g_str_equal (content_types[i], "x-content/video-svcd")) { - has_content = TRUE; - break; - } - } - g_strfreev (content_types); - - if (has_content == FALSE) { - g_object_unref (root); - return; - } - - device_path = unescape_archive_name (root); - g_object_unref (root); - - /* And ensure it's a local path */ - iso = g_file_new_for_uri (device_path); - g_free (device_path); - device_path = g_file_get_path (iso); - g_object_unref (iso); - - /* Work out an icon to display */ - icon = g_mount_get_icon (mount); - icon_name = get_icon_name_for_gicon (theme, icon); - - /* Get the mount's pretty name for the menu label */ - name = g_mount_get_name (mount); - g_strstrip (name); - escaped_name = escape_label_for_menu (name); - g_free (name); - /* Translators: - * This is not a JPEG image, but a disc image, for example, - * an ISO file */ - label = g_strdup_printf (_("Play Image '%s'"), escaped_name); - g_free (escaped_name); - - name = g_strdup_printf ("device%d", position); - - action = gtk_action_new (name, label, NULL, NULL); - g_object_set (G_OBJECT (action), - "icon-name", icon_name, NULL); - gtk_action_set_always_show_image (action, TRUE); - gtk_action_group_add_action (totem->devices_action_group, action); - g_object_unref (action); - - gtk_ui_manager_add_ui (totem->ui_manager, totem->devices_ui_id, - "/tmw-menubar/movie/devices-placeholder", name, name, - GTK_UI_MANAGER_MENUITEM, FALSE); - - g_free (name); - g_free (label); - g_object_unref (icon); - - g_object_set_data_full (G_OBJECT (action), - "device_path", device_path, - (GDestroyNotify) g_free); - - g_signal_connect (G_OBJECT (action), "activate", - G_CALLBACK (on_play_disc_activate), totem); -} - -static void -add_volume_to_menu (GVolume *volume, - GDrive *drive, - GtkIconTheme *theme, - guint position, - Totem *totem) -{ - char *name, *escaped_name, *label; - GtkAction *action; - gboolean disabled; - GIcon *icon; - const char *icon_name; - char *device_path; - GtkWidget *menu_item; - char *menu_item_path; - - disabled = FALSE; - device_path = NULL; - - /* Add devices with blank CDs and audio CDs in them, but disable them */ - if (drive != NULL) { - device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); - if (device_path == NULL) - return; - } - - /* Check whether we have a media... */ - if (drive != NULL && - g_drive_has_media (drive) == FALSE) { - disabled = TRUE; - } else { - /* ... Or an audio CD or a blank media */ - GMount *mount; - GFile *root; - - mount = g_volume_get_mount (volume); - if (mount != NULL) { - root = g_mount_get_root (mount); - g_object_unref (mount); - - if (g_file_has_uri_scheme (root, "burn") != FALSE || g_file_has_uri_scheme (root, "cdda") != FALSE) - disabled = TRUE; - g_object_unref (root); - } - } - - /* Work out an icon to display */ - icon = g_volume_get_icon (volume); - icon_name = get_icon_name_for_gicon (theme, icon); - - /* Get the volume's pretty name for the menu label */ - name = g_volume_get_name (volume); - g_strstrip (name); - escaped_name = escape_label_for_menu (name); - g_free (name); - label = g_strdup_printf (_("Play Disc '%s'"), escaped_name); - g_free (escaped_name); - - name = g_strdup_printf ("device%d", position); - - action = gtk_action_new (name, label, NULL, NULL); - g_object_set (G_OBJECT (action), - "icon-name", icon_name, - "sensitive", !disabled, NULL); - gtk_action_group_add_action (totem->devices_action_group, action); - g_object_unref (action); - - gtk_ui_manager_add_ui (totem->ui_manager, totem->devices_ui_id, - "/tmw-menubar/movie/devices-placeholder", name, name, - GTK_UI_MANAGER_MENUITEM, FALSE); - - /* TODO: This can be made cleaner once bug #589842 is fixed */ - menu_item_path = g_strdup_printf ("/tmw-menubar/movie/devices-placeholder/%s", name); - menu_item = gtk_ui_manager_get_widget (totem->ui_manager, menu_item_path); - g_free (menu_item_path); - - if (menu_item != NULL) - gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menu_item), TRUE); - - g_free (name); - g_free (label); - g_object_unref (icon); - - if (disabled != FALSE) { - g_free (device_path); - return; - } - - g_object_set_data_full (G_OBJECT (action), - "device_path", device_path, - (GDestroyNotify) g_free); - - g_signal_connect (G_OBJECT (action), "activate", - G_CALLBACK (on_play_disc_activate), totem); -} - -static void -add_drive_to_menu (GDrive *drive, - GtkIconTheme *theme, - guint position, - Totem *totem) -{ - GList *volumes, *i; - - /* FIXME: We used to explicitly check whether it was a CD/DVD drive - * Use: - * udi = g_volume_get_identifier (i->data, G_VOLUME_IDENTIFIER_KIND_HAL_UDI); */ - if (g_drive_can_eject (drive) == FALSE) - return; - - /* Repeat for all the drive's volumes */ - volumes = g_drive_get_volumes (drive); - - for (i = volumes; i != NULL; i = i->next) { - GVolume *volume = i->data; - add_volume_to_menu (volume, drive, theme, position, totem); - g_object_unref (volume); - } - - g_list_free (volumes); -} - -static void -update_drive_menu_items (GtkMenuItem *movie_menuitem, Totem *totem) -{ - GList *drives, *mounts, *i; - GtkIconTheme *theme; - guint position; - - /* Add any suitable devices to the menu */ - position = 0; - - theme = gtk_icon_theme_get_default (); - - drives = g_volume_monitor_get_connected_drives (totem->monitor); - for (i = drives; i != NULL; i = i->next) { - GDrive *drive = i->data; - - position++; - add_drive_to_menu (drive, theme, position, totem); - g_object_unref (drive); - } - g_list_free (drives); - - /* Look for mounted archives */ - mounts = g_volume_monitor_get_mounts (totem->monitor); - for (i = mounts; i != NULL; i = i->next) { - GMount *mount = i->data; - - position++; - add_mount_to_menu (mount, theme, position, totem); - g_object_unref (mount); - } - g_list_free (mounts); - - totem->drives_changed = FALSE; -} - -static void -on_movie_menu_select (GtkMenuItem *movie_menuitem, Totem *totem) -{ - if (totem->drives_changed == FALSE) - return; - - /* Remove old UI */ - gtk_ui_manager_remove_ui (totem->ui_manager, totem->devices_ui_id); - gtk_ui_manager_ensure_update (totem->ui_manager); - - /* Create new ActionGroup */ - if (totem->devices_action_group) { - gtk_ui_manager_remove_action_group (totem->ui_manager, - totem->devices_action_group); - g_object_unref (totem->devices_action_group); - } - totem->devices_action_group = gtk_action_group_new ("devices-action-group"); - gtk_ui_manager_insert_action_group (totem->ui_manager, - totem->devices_action_group, -1); - - update_drive_menu_items (movie_menuitem, totem); - - gtk_ui_manager_ensure_update (totem->ui_manager); -} - -static void -on_g_volume_monitor_event (GVolumeMonitor *monitor, - gpointer device, - Totem *totem) -{ - totem->drives_changed = TRUE; -} - -void -totem_setup_play_disc (Totem *totem) -{ - GtkWidget *item; - - item = gtk_ui_manager_get_widget (totem->ui_manager, "/tmw-menubar/movie"); - g_signal_connect (G_OBJECT (item), "select", - G_CALLBACK (on_movie_menu_select), totem); - - g_signal_connect (G_OBJECT (totem->monitor), - "volume-added", - G_CALLBACK (on_g_volume_monitor_event), totem); - g_signal_connect (G_OBJECT (totem->monitor), - "volume-removed", - G_CALLBACK (on_g_volume_monitor_event), totem); - g_signal_connect (G_OBJECT (totem->monitor), - "mount-added", - G_CALLBACK (on_g_volume_monitor_event), totem); - g_signal_connect (G_OBJECT (totem->monitor), - "mount-removed", - G_CALLBACK (on_g_volume_monitor_event), totem); - - totem->drives_changed = TRUE; -} - void eject_action_callback (GtkAction *action, Totem *totem) { diff --git a/src/totem-menu.h b/src/totem-menu.h index f3b74baf7..32df81199 100644 --- a/src/totem-menu.h +++ b/src/totem-menu.h @@ -34,8 +34,6 @@ void totem_ui_manager_setup (Totem *totem); void totem_sublang_update (Totem *totem); void totem_sublang_exit (Totem *totem); -void totem_setup_play_disc (Totem *totem); - void totem_setup_recent (Totem *totem); void totem_action_add_recent (Totem *totem, const char *uri, diff --git a/src/totem.c b/src/totem.c index 8b4cf5605..c232fa4bc 100644 --- a/src/totem.c +++ b/src/totem.c @@ -109,7 +109,6 @@ app_init (Totem *totem, char **argv) totem_session_setup (totem, argv); totem_setup_file_monitoring (totem); totem_setup_file_filters (); - totem_setup_play_disc (totem); totem_app_menu_setup (totem); totem_callback_connect (totem); |