GNOME Bugzilla – Bug 404877
using GtkRecentManager to replace eggRecent
Last modified: 2008-08-29 14:03:45 UTC
see http://live.gnome.org/BestPractices recommend to use GtkRecentManager to replace eggRencent Other information:
Created attachment 81983 [details] [review] patch I got most of this patch from totem source code.
I'll look at this after 2.18.0 is out. Thanks for the effort!
Comment on attachment 81983 [details] [review] patch <snip> >diff -uw srcold/gsr-window.c src/gsr-window.c >--- srcold/gsr-window.c 2007-02-06 15:27:20.378074000 +0800 >+++ src/gsr-window.c 2007-02-06 15:35:22.631766000 +0800 >@@ -2,7 +2,7 @@ > /* > * Authors: Iain Holmes <iain@prettypeople.org> > * Johan Dahlin <johan@gnome.org> >- * Tim-Philipp Müller <tim centricular net> >+ * Tim-Philipp M??ller <tim centricular net> Don't change strings like that. Use a proper text edit with UTF-8 support instead :) <snip> <snip> >- if (!g_file_test (filename, G_FILE_TEST_EXISTS)) { >- gchar *filename_utf8; >- GtkWidget *dlg; >- >- filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); >- dlg = gtk_message_dialog_new (GTK_WINDOW (window), >- GTK_DIALOG_MODAL, >- GTK_MESSAGE_ERROR, >- GTK_BUTTONS_OK, >- _("Unable to load file:\n%s"), filename_utf8); There seems to be no replacement for this dialogue. <snip> > static void >@@ -2106,6 +2083,7 @@ > g_signal_connect (priv->ui_manager, "disconnect_proxy", > G_CALLBACK (disconnect_proxy_cb), window); > >+ Spurious change. > priv->action_group = gtk_action_group_new ("GSRWindowActions"); > gtk_action_group_set_translation_domain (priv->action_group, NULL); > gtk_action_group_add_actions (priv->action_group, >@@ -2143,13 +2121,9 @@ > submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (file_menu)); > rec_menu = gtk_ui_manager_get_widget (priv->ui_manager, > "/MenuBar/FileMenu/FileRecentMenu"); >- priv->recent_view = egg_recent_view_gtk_new (submenu, rec_menu); >- egg_recent_view_gtk_show_icons (EGG_RECENT_VIEW_GTK (priv->recent_view), >- FALSE); >- egg_recent_view_gtk_set_trailing_sep (priv->recent_view, TRUE); >- egg_recent_view_set_model (EGG_RECENT_VIEW (priv->recent_view), recent_model); >- g_signal_connect (priv->recent_view, "activate", >- G_CALLBACK (file_open_recent_cb), window); >+ >+ >+ More spurious changes. <snip> >+/* Recent files */ >+static void >+on_recent_file_item_activated (GtkAction *action, >+ GSRWindow *window) >+{ >+ GtkRecentInfo *recent_info; >+ const gchar *uri; >+ const gchar *short_name; >+ const gchar *title; >+ >+ recent_info = g_object_get_data (G_OBJECT (action), "recent-info"); >+ uri = gtk_recent_info_get_uri (recent_info); >+ >+ >+ window->priv->filename = g_strdup (uri); >+ window->priv->working_file = g_strdup (window->priv->filename); >+ window->priv->len_secs = 0; >+ short_name = g_path_get_basename (window->priv->filename); >+ window->priv->has_file = TRUE; >+ title = g_strdup_printf ("%s - Sound Recorder", short_name); >+ gtk_window_set_title (GTK_WINDOW (window), title); >+ g_free (title); >+ g_free (short_name); >+ g_free (uri); >+ >+ set_action_sensitive (window, "Play", window->priv->has_file ? TRUE : FALSE); >+ set_action_sensitive (window, "Stop", FALSE); >+ set_action_sensitive (window, "Record", TRUE); >+ set_action_sensitive (window, "FileSave", window->priv->has_file ? TRUE : FALSE); >+ set_action_sensitive (window, "FileSaveAs", window->priv->has_file ? TRUE : FALSE); >+ >+ >+ >+} Spurious line feeds and mixed tabs and spaces in indentation. >+void >+gsr_add_recent (gchar *filename, GSRWindow *window) >+{ >+ >+ GtkRecentData data; More spurious line feeds. >+ char *groups[] = { "gnome-sound-record", NULL }; >+ char *display; >+ >+ >+ display = g_strdup(filename); Spurious line feeds. >+ if (display) { >+ data.display_name = g_filename_display_basename (display); >+ g_free (display); >+ } That's completely broken. data.display_name = g_filename_display_basename (display); is enough. >+ data.description = NULL; >+ data.mime_type = gnome_vfs_get_mime_type (filename); gnome_vfs_get_mime_type takes a URI, not a local filename. >+ data.app_name = g_strdup (g_get_application_name ()); >+ data.app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL); >+ data.groups = groups; >+ gtk_recent_manager_add_full (window->priv->recent_manager, >+ filename, &data); It's expecting a URI here as well. >+ g_free (data.display_name); >+ g_free (data.mime_type); >+ g_free (data.app_name); >+ g_free (data.app_exec); >+} >+ >+static void >+gsr_recent_manager_changed_callback (GtkRecentManager *recent_manager, GSRWindow *window) >+{ >+ GList *items, *l; >+ guint n_items = 0; >+ static guint i = 0; >+ >+ gtk_ui_manager_remove_ui (window->priv->ui_manager, window->priv->recent_ui_id); >+ gtk_ui_manager_ensure_update (window->priv->ui_manager); >+ >+ if (window->priv->recent_action_group) { >+ gtk_ui_manager_remove_action_group (window->priv->ui_manager, >+ window->priv->recent_action_group); >+ g_object_unref (window->priv->recent_action_group); >+ } >+ window->priv->recent_action_group = gtk_action_group_new ("recent-action-group"); >+ gtk_ui_manager_insert_action_group (window->priv->ui_manager, >+ window->priv->recent_action_group, -1); >+ >+ items = gtk_recent_manager_get_items (recent_manager);+ What's the '+' here for?
FI, I did some updates on the proposed patch, I'll post it soon, because I'd like bastien to review it, if it's ok :)
Can we get this going in the next weeks to fix bug 516090 too? Thanks!
Created attachment 113206 [details] [review] [PATCH] recent configure.in | 1 - grecord/src/Makefile.am | 5 +- grecord/src/gnome-recorder.c | 44 - grecord/src/gsr-window.c | 328 +++-- grecord/src/recent-files/.cvsignore | 2 - grecord/src/recent-files/Makefile.am | 26 - grecord/src/recent-files/egg-recent-item.c | 462 ------ grecord/src/recent-files/egg-recent-item.h | 80 -- grecord/src/recent-files/egg-recent-model.c | 1781 ------------------------ grecord/src/recent-files/egg-recent-model.h | 80 -- grecord/src/recent-files/egg-recent-util.c | 138 -- grecord/src/recent-files/egg-recent-util.h | 23 - grecord/src/recent-files/egg-recent-view-gtk.c | 820 ----------- grecord/src/recent-files/egg-recent-view-gtk.h | 64 - grecord/src/recent-files/egg-recent-view.c | 68 - grecord/src/recent-files/egg-recent-view.h | 43 - grecord/src/recent-files/egg-recent.h | 6 - 17 files changed, 225 insertions(+), 3746 deletions(-)
The last patch is not yet ready, but I did not progress for the past 3 weeks, so maybe someone else should continue. I tried to address most of the bastien comments. There are still some issues and bugs left when you want to open a recent file, or when you start a recording... Not sure if it was introduced by this patch.
2008-08-29 Bastien Nocera <hadess@hadess.net> * configure.in: Remove recent-files sub-directory 2008-08-29 Bastien Nocera <hadess@hadess.net> * src/Makefile.am: * src/gnome-recorder.c (gsr_add_recent), (main): * src/gsr-window.c (file_open_recent_cb), (gsr_window_init), (gsr_window_set_property): Port gnome-sound-recorder to using GtkRecent (Closes: #404877) * src/recent-files/*: Remove