James Vega wrote:
> I've given it a shot and it's working well for me.  One thing I did
> notice is that the files Vim edits aren't added to Gtk's recently used
> list.  Based on the patch, this doesn't look like it's a regression in
> behavior from the last time Vim was using GtkFileChooser.
>
> I think it'd be good to get the patch as is included so Vim is no longer
> using a deprecated (and as of Gtk3 removed) widget.  Also,
> GtkFileChooser is more intuitive to use than GtkFileSelection (where
> it's non-obvious how to select hidden files).
>
> It would be interesting to look into how (and whether) Vim should make
> use of Gtk's recently used list, especially since not all of Vim's
> buffers directly relate to an actual file.
>
>   

I imagine it would be done in a manner along the lines of the attached
patch file. It was briefly tested.

I'm not a big fan of #ifdef so I added a function called
gui_mch_file_opened() which allows any GUI module to perform tasks on
file open. I put it near similar #ifdef-based notifications for Sun
Workshop and Netbeans.

My knowledge of the vim source is rudimentary. Some more callers might
have to be added, such as when saving a new file.

-- Tim Starling

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

diff -ru vim7-svn/src/ex_cmds.c vim7-svn.p2/src/ex_cmds.c
--- vim7-svn/src/ex_cmds.c	2009-11-12 16:54:22.000000000 +1100
+++ vim7-svn.p2/src/ex_cmds.c	2009-11-17 18:23:18.000000000 +1100
@@ -3813,9 +3813,11 @@
     /* Change directories when the 'acd' option is set. */
     DO_AUTOCHDIR
 
-#if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG)
+    /* Notify the GUI */
+# ifdef FEAT_GUI
     if (gui.in_use && curbuf->b_ffname != NULL)
     {
+	gui_mch_file_opened(curbuf);
 # ifdef FEAT_SUN_WORKSHOP
 	if (usingSunWorkShop)
 	    workshop_file_opened((char *)curbuf->b_ffname, curbuf->b_p_ro);
diff -ru vim7-svn/src/gui_gtk_x11.c vim7-svn.p2/src/gui_gtk_x11.c
--- vim7-svn/src/gui_gtk_x11.c	2009-11-13 08:55:55.000000000 +1100
+++ vim7-svn.p2/src/gui_gtk_x11.c	2009-11-17 18:40:04.000000000 +1100
@@ -83,6 +83,7 @@
 # endif
 
 # include <gtk/gtk.h>
+# include <gio/gio.h>
 # include "gui_gtk_f.h"
 #endif
 
@@ -7262,3 +7263,19 @@
 # endif /* !HAVE_GTK2 */
 
 #endif /* FEAT_SIGN_ICONS */
+
+    void
+gui_mch_file_opened(buf_T *buf)
+{
+    /* Register the newly-opened file in GtkRecentManager */
+    GtkRecentManager *manager = gtk_recent_manager_get_default();
+    char *uri;
+    GFile *file;
+
+    file = g_file_new_for_path((const char*)buf->b_ffname);
+    uri = g_file_get_uri(file);
+    gtk_recent_manager_add_item(manager, (const gchar *)uri);
+    g_free(uri);
+    g_object_unref(file);
+}
+
diff -ru vim7-svn/src/gui_mac.c vim7-svn.p2/src/gui_mac.c
--- vim7-svn/src/gui_mac.c	2009-04-26 10:01:45.000000000 +1000
+++ vim7-svn.p2/src/gui_mac.c	2009-11-17 18:23:58.000000000 +1100
@@ -6897,3 +6897,8 @@
 }
 
 #endif // FEAT_GUI_TABLINE
+
+    void
+gui_mch_file_opened(buf_T *buf)
+{
+}
diff -ru vim7-svn/src/gui_photon.c vim7-svn.p2/src/gui_photon.c
--- vim7-svn/src/gui_photon.c	2009-11-12 16:54:22.000000000 +1100
+++ vim7-svn.p2/src/gui_photon.c	2009-11-17 18:25:19.000000000 +1100
@@ -3096,3 +3096,8 @@
     vim_free( font );
 }
 
+    void
+gui_mch_file_opened(buf_T *buf)
+{
+}
+
diff -ru vim7-svn/src/gui_riscos.c vim7-svn.p2/src/gui_riscos.c
--- vim7-svn/src/gui_riscos.c	2009-04-26 10:01:45.000000000 +1000
+++ vim7-svn.p2/src/gui_riscos.c	2009-11-17 18:26:29.000000000 +1100
@@ -3556,3 +3556,8 @@
     }
     return NULL;
 }
+
+    void
+gui_mch_file_opened(buf_T *buf)
+{
+}
diff -ru vim7-svn/src/gui_w16.c vim7-svn.p2/src/gui_w16.c
--- vim7-svn/src/gui_w16.c	2009-04-26 10:01:45.000000000 +1000
+++ vim7-svn.p2/src/gui_w16.c	2009-11-17 18:27:12.000000000 +1100
@@ -1554,3 +1554,4 @@
     SetActiveWindow(s_hwnd);
 }
 #endif
+
diff -ru vim7-svn/src/gui_w48.c vim7-svn.p2/src/gui_w48.c
--- vim7-svn/src/gui_w48.c	2009-04-26 10:01:45.000000000 +1000
+++ vim7-svn.p2/src/gui_w48.c	2009-11-17 18:27:36.000000000 +1100
@@ -3907,3 +3907,9 @@
     *argvp = argv;
     return argc;
 }
+
+    void
+gui_mch_file_opened(buf_T *buf)
+{
+}
+
diff -ru vim7-svn/src/gui_x11.c vim7-svn.p2/src/gui_x11.c
--- vim7-svn/src/gui_x11.c	2009-11-12 16:54:22.000000000 +1100
+++ vim7-svn.p2/src/gui_x11.c	2009-11-17 18:28:26.000000000 +1100
@@ -3585,3 +3585,8 @@
     }
 }
 #endif
+
+    void
+gui_mch_file_opened(buf_T *buf)
+{
+}
diff -ru vim7-svn/src/proto/gui_gtk_x11.pro vim7-svn.p2/src/proto/gui_gtk_x11.pro
--- vim7-svn/src/proto/gui_gtk_x11.pro	2009-11-12 16:54:14.000000000 +1100
+++ vim7-svn.p2/src/proto/gui_gtk_x11.pro	2009-11-17 18:45:33.000000000 +1100
@@ -72,4 +72,5 @@
 void gui_mch_drawsign __ARGS((int row, int col, int typenr));
 void *gui_mch_register_sign __ARGS((char_u *signfile));
 void gui_mch_destroy_sign __ARGS((void *sign));
+void gui_mch_file_opened __ARGS((buf_T *buf));
 /* vim: set ft=c : */
diff -ru vim7-svn/src/proto/gui_mac.pro vim7-svn.p2/src/proto/gui_mac.pro
--- vim7-svn/src/proto/gui_mac.pro	2009-04-26 10:01:34.000000000 +1000
+++ vim7-svn.p2/src/proto/gui_mac.pro	2009-11-17 19:08:01.000000000 +1100
@@ -143,5 +143,6 @@
 int C2PascalString (char_u *CString, Str255 *PascalString);
 int GetFSSpecFromPath ( char_u *file, FSSpec *fileFSSpec);
 char_u *FullPathFromFSSpec_save (FSSpec file);
+void gui_mch_file_opened __ARGS((buf_T *buf));
 
 /* vim: set ft=c : */
diff -ru vim7-svn/src/proto/gui_photon.pro vim7-svn.p2/src/proto/gui_photon.pro
--- vim7-svn/src/proto/gui_photon.pro	2009-04-26 10:01:34.000000000 +1000
+++ vim7-svn.p2/src/proto/gui_photon.pro	2009-11-17 18:45:35.000000000 +1100
@@ -64,4 +64,5 @@
 char_u *gui_mch_get_fontname __ARGS((GuiFont font, char_u *name));
 void gui_mch_set_font __ARGS((GuiFont font));
 void gui_mch_free_font __ARGS((GuiFont font));
+void gui_mch_file_opened __ARGS((buf_T *buf));
 /* vim: set ft=c : */
diff -ru vim7-svn/src/proto/gui_riscos.pro vim7-svn.p2/src/proto/gui_riscos.pro
--- vim7-svn/src/proto/gui_riscos.pro	2009-04-26 10:01:34.000000000 +1000
+++ vim7-svn.p2/src/proto/gui_riscos.pro	2009-11-17 19:06:42.000000000 +1100
@@ -63,4 +63,5 @@
 
 void ro_redraw_title __ARGS((int window));
 int ro_ok_to_quit __ARGS((void));
+void gui_mch_file_opened __ARGS((buf_T *buf));
 /* vim: set ft=c : */
diff -ru vim7-svn/src/proto/gui_w16.pro vim7-svn.p2/src/proto/gui_w16.pro
--- vim7-svn/src/proto/gui_w16.pro	2009-04-26 10:01:34.000000000 +1000
+++ vim7-svn.p2/src/proto/gui_w16.pro	2009-11-17 18:45:34.000000000 +1100
@@ -57,6 +57,7 @@
 char_u *gui_mch_browsedir __ARGS((char_u *title, char_u *initdir));
 char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter));
 int get_cmd_args __ARGS((char *prog, char *cmdline, char ***argvp, char **tofree));
+void gui_mch_file_opened __ARGS((buf_T *buf));
 void gui_mch_prepare __ARGS((int *argc, char **argv));
 int gui_mch_init __ARGS((void));
 void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction));
diff -ru vim7-svn/src/proto/gui_w32.pro vim7-svn.p2/src/proto/gui_w32.pro
--- vim7-svn/src/proto/gui_w32.pro	2009-04-26 10:01:34.000000000 +1000
+++ vim7-svn.p2/src/proto/gui_w32.pro	2009-11-17 18:45:34.000000000 +1100
@@ -57,6 +57,7 @@
 char_u *gui_mch_browsedir __ARGS((char_u *title, char_u *initdir));
 char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter));
 int get_cmd_args __ARGS((char *prog, char *cmdline, char ***argvp, char **tofree));
+void gui_mch_file_opened __ARGS((buf_T *buf));
 int gui_is_win32s __ARGS((void));
 void gui_mch_set_parent __ARGS((char *title));
 void gui_mch_prepare __ARGS((int *argc, char **argv));
diff -ru vim7-svn/src/proto/gui_x11.pro vim7-svn.p2/src/proto/gui_x11.pro
--- vim7-svn/src/proto/gui_x11.pro	2009-04-26 10:01:34.000000000 +1000
+++ vim7-svn.p2/src/proto/gui_x11.pro	2009-11-17 18:45:33.000000000 +1100
@@ -67,4 +67,5 @@
 void gui_mch_mousehide __ARGS((int hide));
 void mch_set_mouse_shape __ARGS((int shape));
 void gui_mch_menu_set_tip __ARGS((vimmenu_T *menu));
+void gui_mch_file_opened __ARGS((buf_T *buf));
 /* vim: set ft=c : */

Raspunde prin e-mail lui