SF.net SVN: geany: [2444] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Apr 3 16:07:10 UTC 2008


Revision: 2444
          http://geany.svn.sourceforge.net/geany/?rev=2444&view=rev
Author:   ntrel
Date:     2008-04-03 09:06:41 -0700 (Thu, 03 Apr 2008)

Log Message:
-----------
Add configurable keybindings for focusing the Path Entry and File
List.
Refactor load_settings() from init().

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/NEWS
    trunk/plugins/filebrowser.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-04-03 15:45:23 UTC (rev 2443)
+++ trunk/ChangeLog	2008-04-03 16:06:41 UTC (rev 2444)
@@ -5,6 +5,10 @@
    so that clicking cancel keeps all documents open.
    This also prevents the UI from not being updated after cancelling
    Close All.
+ * NEWS, plugins/filebrowser.c:
+   Add configurable keybindings for focusing the Path Entry and File
+   List.
+   Refactor load_settings() from init().
 
 
 2008-04-03  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2008-04-03 15:45:23 UTC (rev 2443)
+++ trunk/NEWS	2008-04-03 16:06:41 UTC (rev 2444)
@@ -34,6 +34,7 @@
     Plugins:
     * Add configurable plugin keybindings support.
     * Add a HTML Characters keybinding to show the dialog.
+    * Add File Browser keybindings to focus the Path Entry and File List
     * Rename VCDiff plugin Version Diff.
 
     Plugin API:

Modified: trunk/plugins/filebrowser.c
===================================================================
--- trunk/plugins/filebrowser.c	2008-04-03 15:45:23 UTC (rev 2443)
+++ trunk/plugins/filebrowser.c	2008-04-03 16:06:41 UTC (rev 2444)
@@ -49,6 +49,17 @@
 	_("The Geany developer team"))
 
 
+/* Keybinding(s) */
+enum
+{
+	KB_FOCUS_FILE_LIST,
+	KB_FOCUS_PATH_ENTRY,
+	KB_COUNT
+};
+
+PLUGIN_KEY_GROUP(file_browser, KB_COUNT)
+
+
 /* number of characters to skip the root of an absolute path("c:" or "d:" on Windows) */
 #ifdef G_OS_WIN32
 # define ROOT_OFFSET 2
@@ -785,13 +796,49 @@
 	else \
 		(var) = (tmp);
 
-void init(GeanyData *data)
+static void load_settings(void)
 {
-	GtkWidget *scrollwin, *toolbar;
 	GKeyFile *config = g_key_file_new();
 	GError *error = NULL;
 	gboolean tmp;
 
+	config_file = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
+		"filebrowser", G_DIR_SEPARATOR_S, "filebrowser.conf", NULL);
+	g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
+	open_cmd = g_key_file_get_string(config, "filebrowser", "open_command", &error);
+	if (error != NULL)
+	{
+		open_cmd = g_strdup("nautilus \"%d\"");
+		g_error_free(error);
+		error = NULL;
+	}
+	tmp = g_key_file_get_boolean(config, "filebrowser", "show_hidden_files", &error);
+	CHECK_READ_SETTING(show_hidden_files, error, tmp);
+	tmp = g_key_file_get_boolean(config, "filebrowser", "hide_object_files", &error);
+	CHECK_READ_SETTING(hide_object_files, error, tmp);
+
+	g_key_file_free(config);
+}
+
+
+static void kb_activate(guint key_id)
+{
+	switch (key_id)
+	{
+		case KB_FOCUS_FILE_LIST:
+			gtk_widget_grab_focus(file_view);
+			break;
+		case KB_FOCUS_PATH_ENTRY:
+			gtk_widget_grab_focus(path_entry);
+			break;
+	}
+}
+
+
+void init(GeanyData *data)
+{
+	GtkWidget *scrollwin, *toolbar;
+
 	file_view_vbox = gtk_vbox_new(FALSE, 0);
 	toolbar = make_toolbar();
 	gtk_box_pack_start(GTK_BOX(file_view_vbox), toolbar, FALSE, FALSE, 0);
@@ -815,22 +862,13 @@
 	gtk_notebook_append_page(GTK_NOTEBOOK(app->treeview_notebook), file_view_vbox,
 		gtk_label_new(_("Files")));
 
-	config_file = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
-		"filebrowser", G_DIR_SEPARATOR_S, "filebrowser.conf", NULL);
-	g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
-	open_cmd = g_key_file_get_string(config, "filebrowser", "open_command", &error);
-	if (error != NULL)
-	{
-		open_cmd = g_strdup("nautilus \"%d\"");
-		g_error_free(error);
-		error = NULL;
-	}
-	tmp = g_key_file_get_boolean(config, "filebrowser", "show_hidden_files", &error);
-	CHECK_READ_SETTING(show_hidden_files, error, tmp);
-	tmp = g_key_file_get_boolean(config, "filebrowser", "hide_object_files", &error);
-	CHECK_READ_SETTING(hide_object_files, error, tmp);
+	load_settings();
 
-	g_key_file_free(config);
+	/* setup keybindings */
+	p_keybindings->set_item(plugin_key_group, KB_FOCUS_FILE_LIST, kb_activate,
+		0, 0, "focus_file_list", _("Focus File List"), NULL);
+	p_keybindings->set_item(plugin_key_group, KB_FOCUS_PATH_ENTRY, kb_activate,
+		0, 0, "focus_path_entry", _("Focus Path Entry"), NULL);
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list