summaryrefslogtreecommitdiff
path: root/src/totem-menu.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-04-03 20:53:14 +0200
committerBastien Nocera <hadess@hadess.net>2013-04-10 14:09:14 +0200
commit5cf4f4b78038a22eb5e287699adeabdf27afd096 (patch)
treea82a6e31146898eda30bfa34964861fe4821284d /src/totem-menu.c
parentc4684437a4e5076847c7ba54bf49756571c2219a (diff)
downloadtotem-5cf4f4b78038a22eb5e287699adeabdf27afd096.tar.gz
main: Remove recent menu entries
They're now in the browse section of the Grilo plugin. https://bugzilla.gnome.org/show_bug.cgi?id=697237
Diffstat (limited to 'src/totem-menu.c')
-rw-r--r--src/totem-menu.c173
1 files changed, 0 insertions, 173 deletions
diff --git a/src/totem-menu.c b/src/totem-menu.c
index 3a9479087..1c045eddd 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -444,179 +444,6 @@ totem_sublang_exit (Totem *totem)
g_list_free_full (totem->language_list, g_free);
}
-/* Recent files */
-static void
-connect_proxy_cb (GtkActionGroup *action_group,
- GtkAction *action,
- GtkWidget *proxy,
- gpointer data)
-{
- GtkLabel *label;
-
- if (!GTK_IS_MENU_ITEM (proxy))
- return;
-
- label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));
-
- gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_MIDDLE);
- gtk_label_set_max_width_chars (label,TOTEM_MAX_RECENT_ITEM_LEN);
-}
-
-static void
-on_recent_file_item_activated (GtkAction *action,
- Totem *totem)
-{
- GtkRecentInfo *recent_info;
- const gchar *uri, *display_name;
-
- recent_info = g_object_get_data (G_OBJECT (action), "recent-info");
- uri = gtk_recent_info_get_uri (recent_info);
- display_name = gtk_recent_info_get_display_name (recent_info);
-
- totem_object_add_to_playlist_and_play (totem, uri, display_name);
-}
-
-static gint
-totem_compare_recent_items (GtkRecentInfo *a, GtkRecentInfo *b)
-{
- gboolean has_totem_a, has_totem_b;
-
- has_totem_a = gtk_recent_info_has_group (a, "Totem");
- has_totem_b = gtk_recent_info_has_group (b, "Totem");
-
- if (has_totem_a && has_totem_b) {
- time_t time_a, time_b;
-
- time_a = gtk_recent_info_get_modified (a);
- time_b = gtk_recent_info_get_modified (b);
-
- return (time_b - time_a);
- } else if (has_totem_a) {
- return -1;
- } else if (has_totem_b) {
- return 1;
- }
-
- return 0;
-}
-
-static void
-totem_recent_manager_changed_callback (GtkRecentManager *recent_manager, Totem *totem)
-{
- GList *items, *totem_items, *l;
- guint n_items = 0;
-
- if (totem->recent_ui_id != 0) {
- gtk_ui_manager_remove_ui (totem->ui_manager, totem->recent_ui_id);
- gtk_ui_manager_ensure_update (totem->ui_manager);
- }
-
- if (totem->recent_action_group) {
- gtk_ui_manager_remove_action_group (totem->ui_manager,
- totem->recent_action_group);
- }
-
- totem->recent_action_group = gtk_action_group_new ("recent-action-group");
- g_signal_connect (totem->recent_action_group, "connect-proxy",
- G_CALLBACK (connect_proxy_cb), NULL);
- gtk_ui_manager_insert_action_group (totem->ui_manager,
- totem->recent_action_group, -1);
- g_object_unref (totem->recent_action_group);
-
- totem->recent_ui_id = gtk_ui_manager_new_merge_id (totem->ui_manager);
- items = gtk_recent_manager_get_items (recent_manager);
-
- /* Remove the non-Totem items */
- totem_items = NULL;
- for (l = items; l && l->data; l = l->next) {
- GtkRecentInfo *info;
-
- info = (GtkRecentInfo *) l->data;
-
- if (gtk_recent_info_has_group (info, "Totem")) {
- gtk_recent_info_ref (info);
- totem_items = g_list_prepend (totem_items, info);
- }
- }
- g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
-
- totem_items = g_list_sort (totem_items, (GCompareFunc) totem_compare_recent_items);
-
- for (l = totem_items; l && l->data; l = l->next) {
- GtkRecentInfo *info;
- GtkAction *action;
- char action_name[32];
- const char *display_name;
- char *label;
- char *escaped_label;
- const gchar *mime_type;
- gchar *content_type;
- GIcon *icon = NULL;
-
- info = (GtkRecentInfo *) l->data;
-
- if (!gtk_recent_info_has_group (info, "Totem"))
- continue;
-
- g_snprintf (action_name, sizeof (action_name), "RecentFile%u", n_items);
-
- display_name = gtk_recent_info_get_display_name (info);
- escaped_label = escape_label_for_menu (display_name);
-
- label = g_strdup_printf ("_%d. %s", n_items + 1, escaped_label);
- g_free (escaped_label);
-
- action = gtk_action_new (action_name, label, NULL, NULL);
- g_object_set_data_full (G_OBJECT (action), "recent-info",
- gtk_recent_info_ref (info),
- (GDestroyNotify) gtk_recent_info_unref);
- g_signal_connect (G_OBJECT (action), "activate",
- G_CALLBACK (on_recent_file_item_activated),
- totem);
-
- mime_type = gtk_recent_info_get_mime_type (info);
- content_type = g_content_type_from_mime_type (mime_type);
- if (content_type != NULL) {
- icon = g_content_type_get_icon (content_type);
- g_free (content_type);
- }
- if (icon != NULL) {
- gtk_action_set_gicon (action, icon);
- gtk_action_set_always_show_image (action, TRUE);
- g_object_unref (icon);
- }
-
- gtk_action_group_add_action (totem->recent_action_group,
- action);
- g_object_unref (action);
-
- gtk_ui_manager_add_ui (totem->ui_manager, totem->recent_ui_id,
- "/tmw-menubar/movie/recent-placeholder",
- label, action_name, GTK_UI_MANAGER_MENUITEM,
- FALSE);
- g_free (label);
-
- if (++n_items == 5)
- break;
- }
-
- g_list_free_full (totem_items, (GDestroyNotify) gtk_recent_info_unref);
-}
-
-void
-totem_setup_recent (Totem *totem)
-{
- totem->recent_manager = gtk_recent_manager_get_default ();
- totem->recent_action_group = NULL;
- totem->recent_ui_id = 0;
-
- g_signal_connect (G_OBJECT (totem->recent_manager), "changed",
- G_CALLBACK (totem_recent_manager_changed_callback),
- totem);
-
- totem_recent_manager_changed_callback (totem->recent_manager, totem);
-}
-
void
eject_action_callback (GtkAction *action, Totem *totem)
{