Hello,
Attached is a small and very preliminary patch for a file browser/chooser
side pane for vim-gtk. The patch just adds a gtk file chooser widget on the
left side of vim-gtk; when a file is selected, it is opened in a new tab.
Its a preliminary patch and would require additional work which I'd be
willing to do if there is interest in such a thing. Specifically,
1. Because selected files are opened in a new tab, a [No Name] remains.
2. The gtk file chooser widget is too large and takes up too much space.
It would have to be replace with something smaller.
3. The panes (file chooser and vim window) are (randomly?) resized when
the first new tab is opened.
If there is interest in such a thing and any chance at all of it being
merged, I would address the above issues.
Cheers,
axel.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: src/gui_gtk_x11.c
===================================================================
--- src/gui_gtk_x11.c (revision 1421)
+++ src/gui_gtk_x11.c (working copy)
@@ -3401,6 +3401,19 @@
#endif /* FEAT_GUI_TABLINE */
+void
+file_chooser_on_file_activated (GtkFileChooser *chooser, gpointer data) {
+ gchar *file_name = gtk_file_chooser_get_filename (chooser);
+
+ exarg_T ea;
+ vim_memset(&ea, 0, sizeof(ea));
+ ea.cmdidx = CMD_tabedit;
+ ea.cmd = (char_u *)"tabedit";
+ ea.arg = (char_u *)file_name;
+ ex_splitview(&ea);
+ g_free(file_name);
+}
+
/*
* Initialize the GUI. Create all the windows, set up all the callbacks etc.
* Returns OK for success, FAIL when the GUI can't be started.
@@ -3409,6 +3422,8 @@
gui_mch_init(void)
{
GtkWidget *vbox;
+ GtkWidget *vbox2;
+ GtkWidget *hpane;
#ifdef FEAT_GUI_GNOME
/* Initialize the GNOME libraries. gnome_program_init()/gnome_init()
@@ -3543,6 +3558,7 @@
/* A vertical box holds the menubar, toolbar and main text window. */
vbox = gtk_vbox_new(FALSE, 0);
+ vbox2 = gtk_vbox_new(FALSE, 0);
#ifdef FEAT_GUI_GNOME
if (using_gnome)
@@ -3615,6 +3631,19 @@
* disabled in gui_init() later. */
gtk_widget_show(gui.menubar);
gtk_box_pack_start(GTK_BOX(vbox), gui.menubar, FALSE, FALSE, 0);
+
+ hpane = gtk_hpaned_new();
+ gtk_box_pack_start(GTK_BOX(vbox), hpane, TRUE, TRUE, 0);
+
+ GtkWidget *file_chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
+ g_signal_connect(G_OBJECT(file_chooser),
+ "file_activated",
+ G_CALLBACK(file_chooser_on_file_activated),
+ NULL);
+ gtk_paned_add1(GTK_PANED(hpane), file_chooser);
+ gtk_paned_add2(GTK_PANED(hpane), vbox2);
+ gtk_widget_show_all(hpane);
+
}
#endif /* FEAT_MENU */
@@ -3693,7 +3722,7 @@
*/
gui.tabline = gtk_notebook_new();
gtk_widget_show(gui.tabline);
- gtk_box_pack_start(GTK_BOX(vbox), gui.tabline, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox2), gui.tabline, FALSE, FALSE, 0);
gtk_notebook_set_show_border(GTK_NOTEBOOK(gui.tabline), FALSE);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gui.tabline), FALSE);
gtk_notebook_set_scrollable(GTK_NOTEBOOK(gui.tabline), TRUE);
@@ -3752,7 +3781,7 @@
gtk_widget_show(gui.drawarea);
gtk_form_put(GTK_FORM(gui.formwin), gui.drawarea, 0, 0);
gtk_widget_show(gui.formwin);
- gtk_box_pack_start(GTK_BOX(vbox), gui.formwin, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox2), gui.formwin, TRUE, TRUE, 0);
/* For GtkSockets, key-presses must go to the focus widget (drawarea)
* and not the window. */