Revision: 1627 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1627&view=re... Author: dimitrov-adrian Date: 2010-10-08 15:07:25 +0000 (Fri, 08 Oct 2010)
Log Message: ----------- Treebrowser: added keybindings, fixed possible segfault
Modified Paths: -------------- trunk/geany-plugins/treebrowser/ChangeLog trunk/geany-plugins/treebrowser/src/treebrowser.c
Modified: trunk/geany-plugins/treebrowser/ChangeLog =================================================================== --- trunk/geany-plugins/treebrowser/ChangeLog 2010-10-05 19:19:20 UTC (rev 1626) +++ trunk/geany-plugins/treebrowser/ChangeLog 2010-10-08 15:07:25 UTC (rev 1627) @@ -8,7 +8,7 @@ "CRITICAL : g_object_ref: assertion `object->ref_count > 0' failed" (FIXED) Double click on bookmarks, do nothing (FIXED) show/hide hidden files not working on Windows - (FIXED) "Go Up" not working if the current path ends with slash // thanks to <dmaphy> for report + (FIXED) "Go Up" not working if the current path ends with slash // thanks to <dmaphy> for the report
+---------------------------+ @@ -18,7 +18,7 @@ (DONE) codestyle improve to be same as other parts as geany`s (DONE) configuration dialog (DONE) tracking path to current focused document (work only for refreshed directories) - * Better tracking for files, open path to them + * Better tracking for files, when they are not cached, open path to them * In windows can choice between devices (C:, D:,...) * Language files (DONE) Saving state of Showbars in config file everytime where is changed @@ -29,7 +29,7 @@ (DONE) Hide object files as native filebroser (*.o;*.a;*.so;*.dll;*.lib..) (DONE) Using font from geany settings for sidebar * Migrating to stash - * Adding keybindings for renaming/deleting/refreshing + (DONE) Adding keybindings for renaming/deleting/refreshing (DONE) Add option to change bars position // requested by <dmaphy> (DONE) Add option to autorename point the newest created objects by the Treebrowser
@@ -41,6 +41,16 @@ 05-10-2010 Adrian Dimitrov dimitrov.adrian@gmail.com
* src/treebrowser.c + Added keybindings for renaming/deleting/refreshing + (from the todo list) + Fixed possible segfault when option "Hidding object files" is enabled + (idea from native filebrowser plugin) + + + +05-10-2010 Adrian Dimitrov dimitrov.adrian@gmail.com + + * src/treebrowser.c Fixed wrong english message for not existing directory (thanks to Dimitar Zhekov (dimitar.zhekov@gmail.com)) Added option to autorename point the newest created objects by the Treebrowser
Modified: trunk/geany-plugins/treebrowser/src/treebrowser.c =================================================================== --- trunk/geany-plugins/treebrowser/src/treebrowser.c 2010-10-05 19:19:20 UTC (rev 1626) +++ trunk/geany-plugins/treebrowser/src/treebrowser.c 2010-10-08 15:07:25 UTC (rev 1627) @@ -80,6 +80,19 @@ };
+/* Keybinding(s) */ +enum +{ + KB_FOCUS_FILE_LIST, + KB_FOCUS_PATH_ENTRY, + KB_RENAME_OBJECT, + KB_REFRESH, + KB_COUNT +}; + +PLUGIN_KEY_GROUP(file_browser, KB_COUNT) + + /* ------------------ * PLUGIN INFO * ------------------ */ @@ -114,6 +127,7 @@ static void treebrowser_bookmarks_set_state(); static void treebrowser_load_bookmarks(); static void gtk_tree_store_iter_clear_nodes(gpointer iter, gboolean delete_root); +static gboolean treebrowser_rename_current(); static void load_settings(); static gboolean save_settings();
@@ -143,11 +157,17 @@ const gchar *exts[] = {".o", ".obj", ".so", ".dll", ".a", ".lib"};
if (CONFIG_HIDE_OBJECT_FILES) - for (i = 0; exts[i]; i++) + { + guint i, exts_len; + exts_len = G_N_ELEMENTS(exts); + for (i = 0; i < exts_len; i++) { - if (g_str_has_suffix(base_name, exts[i])) + const gchar *ext = exts[i]; + + if (g_str_has_suffix(base_name, ext)) return FALSE; } + }
if (! NZV(gtk_entry_get_text(GTK_ENTRY(filter)))) return TRUE; @@ -175,6 +195,9 @@ if (CONFIG_SHOW_HIDDEN_FILES) return TRUE;
+ if (uri[strlen(uri) - 1] == '~') + return FALSE; + #ifdef G_OS_WIN32 #ifdef HAVE_GIO_2_0 GError *error; @@ -206,10 +229,9 @@ #endif
#else - if (g_path_get_basename(uri) [0] == '.') + if (g_path_get_basename(uri)[0] == '.') return FALSE; - else - return TRUE; + return TRUE; #endif }
@@ -255,7 +277,7 @@
gtk_entry_set_text(GTK_ENTRY(addressbar), directory);
- if (strlen(directory) == 0) + if (!directory || strlen(directory) == 0) directory = "/";
if (! g_file_test(directory, G_FILE_TEST_IS_DIR)) @@ -627,6 +649,17 @@ return FALSE; }
+static gboolean +treebrowser_rename_current() +{ + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); + GtkTreeIter iter; + GtkTreeModel *model; + + if (gtk_tree_selection_get_selected(selection, &model, &iter)) + treebrowser_iter_rename(&iter); +} + /* ------------------ * RIGHTCLICK MENU EVENTS * ------------------*/ @@ -749,23 +782,13 @@ }
if (treebrowser_search(uri_new, NULL)) - { - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); - if (gtk_tree_selection_get_selected(selection, &model, &iter)) - treebrowser_iter_rename(&iter); - } - + treebrowser_rename_current(); }
static void on_menu_rename(GtkMenuItem *menuitem, gpointer *user_data) { - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); - GtkTreeIter iter; - GtkTreeModel *model; - - if (gtk_tree_selection_get_selected(selection, &model, &iter)) - treebrowser_iter_rename(&iter); + treebrowser_rename_current(); }
static void @@ -1574,6 +1597,29 @@ treebrowser_chroot(get_default_dir()); }
+static void kb_activate(guint key_id) +{ + gtk_notebook_set_current_page(GTK_NOTEBOOK(geany->main_widgets->sidebar_notebook), page_number); + switch (key_id) + { + case KB_FOCUS_FILE_LIST: + gtk_widget_grab_focus(treeview); + break; + + case KB_FOCUS_PATH_ENTRY: + gtk_widget_grab_focus(addressbar); + break; + + case KB_RENAME_OBJECT: + treebrowser_rename_current(); + break; + + case KB_REFRESH: + on_menu_refresh(NULL, NULL); + break; + } +} + void plugin_init(GeanyData *data) { @@ -1586,6 +1632,16 @@ create_sidebar(); treebrowser_chroot(get_default_dir());
+ /* setup keybindings */ + keybindings_set_item(plugin_key_group, KB_FOCUS_FILE_LIST, kb_activate, + 0, 0, "focus_file_list", _("Focus File List"), NULL); + keybindings_set_item(plugin_key_group, KB_FOCUS_PATH_ENTRY, kb_activate, + 0, 0, "focus_path_entry", _("Focus Path Entry"), NULL); + keybindings_set_item(plugin_key_group, KB_RENAME_OBJECT, kb_activate, + 0, 0, "rename_object", _("Rename Object"), NULL); + keybindings_set_item(plugin_key_group, KB_REFRESH, kb_activate, + 0, 0, "rename_refresh", _("Refresh"), NULL); + plugin_signal_connect(geany_plugin, NULL, "document-activate", TRUE, (GCallback)&treebrowser_track_current_cb, NULL); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org