Revision: 1623 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1623&view=re... Author: dimitrov-adrian Date: 2010-10-05 16:45:11 +0000 (Tue, 05 Oct 2010)
Log Message: ----------- Add option to autorename point the newest created objects by the Treebrowser; Minnor fixes.
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 14:50:41 UTC (rev 1622) +++ trunk/geany-plugins/treebrowser/ChangeLog 2010-10-05 16:45:11 UTC (rev 1623) @@ -3,7 +3,7 @@ | KNOWN BUGS | +---------------------------+
- * http://sourceforge.net/tracker/?func=detail&aid=3034450&group_id=222... + (FIXED) http://sourceforge.net/tracker/?func=detail&aid=3034450&group_id=222... * CRYTICAL warning when unloading the plugin "CRITICAL : g_object_ref: assertion `object->ref_count > 0' failed" (FIXED) Double click on bookmarks, do nothing @@ -31,7 +31,7 @@ * Migrating to stash * Adding keybindings for renaming/deleting/refreshing (DONE) Add option to change bars position // requested by <dmaphy> - * Add option to autorename point the newest created objects by the Treebrowser + (DONE) Add option to autorename point the newest created objects by the Treebrowser
+-------------------------------+ @@ -41,6 +41,11 @@ 03-10-2010 Adrian Dimitrov dimitrov.adrian@gmail.com
* src/treebrowser.c + Added option to autorename point the newest created objects by the Treebrowser + Improved autorename focus while renamed is successful then close old and + open new file; + Improved dialog for nonexisting folder + (now apear only when toolbars is hidden) Fixed some warnings when compiling
03-10-2010 Adrian Dimitrov dimitrov.adrian@gmail.com
Modified: trunk/geany-plugins/treebrowser/src/treebrowser.c =================================================================== --- trunk/geany-plugins/treebrowser/src/treebrowser.c 2010-10-05 14:50:41 UTC (rev 1622) +++ trunk/geany-plugins/treebrowser/src/treebrowser.c 2010-10-05 16:45:11 UTC (rev 1623) @@ -43,7 +43,6 @@
static gboolean flag_on_expand_refresh = FALSE;
- /* ------------------ * CONFIG VARS * ------------------ */ @@ -261,7 +260,9 @@
if (! g_file_test(directory, G_FILE_TEST_IS_DIR)) { - dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Directory '%s' not exists."), directory); + if (CONFIG_SHOW_BARS == 0) + dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Directory '%s' not exists."), directory); + return; }
@@ -478,19 +479,17 @@ gtk_tree_model_get(GTK_TREE_MODEL(treestore), &iter, TREEBROWSER_COLUMN_URI, &uri_current, -1);
if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(treestore), &iter)) - { if (treebrowser_search(uri, &iter)) return TRUE; + + if (utils_str_equal(uri, uri_current) == TRUE) + { + path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), &iter); + gtk_tree_view_expand_to_path(GTK_TREE_VIEW(treeview), path); + gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview), path, TREEBROWSER_COLUMN_ICON, FALSE, 0, 0); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(treeview), path, treeview_column_text, FALSE); + return TRUE; } - else - if (utils_str_equal(uri, uri_current) == TRUE) - { - path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), &iter); - gtk_tree_view_expand_to_path(GTK_TREE_VIEW(treeview), path); - gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview), path, TREEBROWSER_COLUMN_ICON, FALSE, 0, 0); - gtk_tree_view_set_cursor(GTK_TREE_VIEW(treeview), path, treeview_column_text, FALSE); - return TRUE; - }
} while(gtk_tree_model_iter_next(GTK_TREE_MODEL(treestore), &iter));
@@ -599,7 +598,35 @@ return FALSE; }
+static gboolean +treebrowser_iter_rename(gpointer iter) +{ + GtkTreeModel *model; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreePath *path; + GList *renderers;
+ if (gtk_tree_store_iter_is_valid(treestore, iter)) + { + path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), iter); + if (G_LIKELY(path != NULL)) + { + column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), 0); + renderers = _gtk_cell_layout_get_cells(column); + renderer = g_list_nth_data(renderers, TREEBROWSER_RENDER_TEXT); + + g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL); + gtk_tree_view_set_cursor_on_cell(GTK_TREE_VIEW(treeview), path, column, renderer, TRUE); + + gtk_tree_path_free(path); + g_list_free(renderers); + return TRUE; + } + } + return FALSE; +} + /* ------------------ * RIGHTCLICK MENU EVENTS * ------------------*/ @@ -710,13 +737,24 @@ { if (g_mkdir(uri_new, 0755) == 0) treebrowser_browse(uri, refresh_root ? NULL : &iter); + else + return; } else { if (g_creat(uri_new, 0755) != -1) treebrowser_browse(uri, refresh_root ? NULL : &iter); + else + return; }
+ 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); + } + }
static void @@ -725,27 +763,9 @@ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); GtkTreeIter iter; GtkTreeModel *model; - GtkTreeViewColumn *column; - GtkCellRenderer *renderer; - GtkTreePath *path; - GList *renderers;
if (gtk_tree_selection_get_selected(selection, &model, &iter)) - { - path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), &iter); - if (G_LIKELY(path != NULL)) - { - column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), 0); - renderers = _gtk_cell_layout_get_cells(column); - renderer = g_list_nth_data(renderers, TREEBROWSER_RENDER_TEXT); - - g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL); - gtk_tree_view_set_cursor_on_cell(GTK_TREE_VIEW(treeview), path, column, renderer, TRUE); - - gtk_tree_path_free(path); - g_list_free(renderers); - } - } + treebrowser_iter_rename(&iter); }
static void @@ -765,7 +785,7 @@
if (dialogs_show_question(_("Do you really want to delete '%s' ?"), uri)) { - if (CONFIG_ON_DELETE_CLOSE_FILE && ! g_file_test(uri, G_FILE_TEST_IS_DIR)) + if (CONFIG_ON_DELETE_CLOSE_FILE && !g_file_test(uri, G_FILE_TEST_IS_DIR)) document_close(document_find_by_filename(uri));
fs_remove(uri, TRUE); @@ -1178,6 +1198,10 @@ } else treebrowser_browse(g_path_get_dirname(uri_new), NULL); + + if (!g_file_test(uri, G_FILE_TEST_IS_DIR)) + if (document_close(document_find_by_filename(uri))) + document_open_file(uri_new, FALSE, NULL, NULL); } } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org