Revision: 3529 http://geany.svn.sourceforge.net/geany/?rev=3529&view=rev Author: eht16 Date: 2009-01-30 16:12:25 +0000 (Fri, 30 Jan 2009)
Log Message: ----------- Add utils_string_replace_first() to the plugin API. Allow entering paths prefixed with '~' in the filebrowser path entry. Show the full path for files and folders in the filebrowser plugin as tooltips.
Modified Paths: -------------- trunk/ChangeLog trunk/plugins/filebrowser.c trunk/plugins/geanyfunctions.h trunk/src/plugindata.h trunk/src/plugins.c trunk/src/utils.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-01-30 15:39:08 UTC (rev 3528) +++ trunk/ChangeLog 2009-01-30 16:12:25 UTC (rev 3529) @@ -1,3 +1,13 @@ +2009-01-30 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * src/plugins.c, src/plugindata.h, src/utils.c, plugins/filebrowser.c, + plugins/geanyfunctions.h: + Add utils_string_replace_first() to the plugin API. + Allow entering paths prefixed with '~' in the filebrowser path entry. + Show the full path for files and folders in the filebrowser plugin + as tooltips. + + 2009-01-29 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* autogen.sh:
Modified: trunk/plugins/filebrowser.c =================================================================== --- trunk/plugins/filebrowser.c 2009-01-30 15:39:08 UTC (rev 3528) +++ trunk/plugins/filebrowser.c 2009-01-30 16:12:25 UTC (rev 3529) @@ -45,7 +45,7 @@ GeanyFunctions *geany_functions;
-PLUGIN_VERSION_CHECK(69) +PLUGIN_VERSION_CHECK(131)
PLUGIN_SET_INFO(_("File Browser"), _("Adds a file browser tab to the sidebar."), VERSION, _("The Geany developer team")) @@ -66,6 +66,7 @@ { FILEVIEW_COLUMN_ICON = 0, FILEVIEW_COLUMN_NAME, + FILEVIEW_COLUMN_FILENAME, /* the full filename, including path for display as tooltip */ FILEVIEW_N_COLUMNS };
@@ -146,7 +147,7 @@ static void add_item(const gchar *name) { GtkTreeIter iter; - gchar *fname, *utf8_name; + gchar *fname, *utf8_name, *utf8_fullname, *sep; gboolean dir;
if (! show_hidden_files && check_hidden(name)) @@ -155,8 +156,10 @@ if (check_filtered(name)) return;
- fname = g_strconcat(current_dir, G_DIR_SEPARATOR_S, name, NULL); + sep = (utils_str_equal(current_dir, "/")) ? "" : G_DIR_SEPARATOR_S; + fname = g_strconcat(current_dir, sep, name, NULL); dir = g_file_test(fname, G_FILE_TEST_IS_DIR); + utf8_fullname = utils_get_locale_from_utf8(fname); g_free(fname);
if (dir) @@ -177,8 +180,11 @@
gtk_list_store_set(file_store, &iter, FILEVIEW_COLUMN_ICON, (dir) ? GTK_STOCK_DIRECTORY : GTK_STOCK_FILE, - FILEVIEW_COLUMN_NAME, utf8_name, -1); + FILEVIEW_COLUMN_NAME, utf8_name, + FILEVIEW_COLUMN_FILENAME, utf8_fullname, + -1); g_free(utf8_name); + g_free(utf8_fullname); }
@@ -186,15 +192,23 @@ static void add_top_level_entry(void) { GtkTreeIter iter; + gchar *utf8_dir;
if (! NZV(g_path_skip_root(current_dir))) return; /* ignore 'C:' or '/' */
+ utf8_dir = g_path_get_dirname(current_dir); + setptr(utf8_dir, utils_get_utf8_from_locale(utf8_dir)); + gtk_list_store_prepend(file_store, &iter); last_dir_iter = gtk_tree_iter_copy(&iter);
gtk_list_store_set(file_store, &iter, - FILEVIEW_COLUMN_ICON, GTK_STOCK_DIRECTORY, FILEVIEW_COLUMN_NAME, "..", -1); + FILEVIEW_COLUMN_ICON, GTK_STOCK_DIRECTORY, + FILEVIEW_COLUMN_NAME, "..", + FILEVIEW_COLUMN_FILENAME, utf8_dir, + -1); + g_free(utf8_dir); }
@@ -336,17 +350,9 @@ gchar *name, *fname;
gtk_tree_model_get_iter(model, &iter, treepath); - gtk_tree_model_get(model, &iter, FILEVIEW_COLUMN_NAME, &name, -1); + gtk_tree_model_get(model, &iter, FILEVIEW_COLUMN_FILENAME, &name, -1);
- if (utils_str_equal(name, "..")) - { - fname = g_path_get_dirname(current_dir); - } - else - { - setptr(name, utils_get_locale_from_utf8(name)); - fname = g_build_filename(current_dir, name, NULL); - } + fname = utils_get_locale_from_utf8(name); g_free(name);
return fname; @@ -637,7 +643,14 @@ on_go_up(); return; } - new_dir = utils_get_locale_from_utf8(new_dir); + else if (new_dir[0] == '~') + { + GString *str = g_string_new(new_dir); + utils_string_replace_first(str, "~", g_get_home_dir()); + new_dir = g_string_free(str, FALSE); + } + else + new_dir = utils_get_locale_from_utf8(new_dir); } else new_dir = g_strdup(g_get_home_dir()); @@ -668,7 +681,7 @@ GtkTreeSelection *select; PangoFontDescription *pfd;
- file_store = gtk_list_store_new(FILEVIEW_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING); + file_store = gtk_list_store_new(FILEVIEW_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
gtk_tree_view_set_model(GTK_TREE_VIEW(file_view), GTK_TREE_MODEL(file_store)); g_object_unref(file_store); @@ -690,6 +703,10 @@ gtk_widget_modify_font(file_view, pfd); pango_font_description_free(pfd);
+ /* GTK 2.12 tooltips */ + if (gtk_check_version(2, 12, 0) == NULL) + g_object_set(file_view, "has-tooltip", TRUE, "tooltip-column", FILEVIEW_COLUMN_FILENAME, NULL); + /* selection handling */ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(file_view)); gtk_tree_selection_set_mode(select, GTK_SELECTION_MULTIPLE);
Modified: trunk/plugins/geanyfunctions.h =================================================================== --- trunk/plugins/geanyfunctions.h 2009-01-30 15:39:08 UTC (rev 3528) +++ trunk/plugins/geanyfunctions.h 2009-01-30 16:12:25 UTC (rev 3529) @@ -166,6 +166,8 @@ geany_functions->p_utils->get_date_time #define utils_open_browser \ geany_functions->p_utils->open_browser +#define utils_string_replace_first \ + geany_functions->p_utils->string_replace_first #define ui_dialog_vbox_new \ geany_functions->p_ui->dialog_vbox_new #define ui_frame_new_with_alignment \
Modified: trunk/src/plugindata.h =================================================================== --- trunk/src/plugindata.h 2009-01-30 15:39:08 UTC (rev 3528) +++ trunk/src/plugindata.h 2009-01-30 16:12:25 UTC (rev 3529) @@ -45,7 +45,7 @@ enum { /** The Application Programming Interface (API) version, incremented * whenever any plugin data types are modified or appended to. */ - GEANY_API_VERSION = 130, + GEANY_API_VERSION = 131,
/** The Application Binary Interface (ABI) version, incremented whenever * existing fields in the plugin data types have to be changed or reordered. */ @@ -354,6 +354,8 @@ gint (*str_casecmp) (const gchar *s1, const gchar *s2); gchar* (*get_date_time) (const gchar *format, time_t *time_to_use); void (*open_browser) (const gchar *uri); + guint (*string_replace_first) (GString *haystack, const gchar *needle, + const gchar *replace); } UtilsFuncs;
Modified: trunk/src/plugins.c =================================================================== --- trunk/src/plugins.c 2009-01-30 15:39:08 UTC (rev 3528) +++ trunk/src/plugins.c 2009-01-30 16:12:25 UTC (rev 3529) @@ -214,7 +214,8 @@ &utils_spawn_async, &utils_str_casecmp, &utils_get_date_time, - &utils_open_browser + &utils_open_browser, + &utils_string_replace_first };
static UIUtilsFuncs uiutils_funcs = {
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2009-01-30 15:39:08 UTC (rev 3528) +++ trunk/src/utils.c 2009-01-30 16:12:25 UTC (rev 3529) @@ -1333,10 +1333,9 @@ }
-/* - * Replaces the first occurrence of @c needle in @c haystack with @c replace. - * As of Geany 0.16, @a replace can match @a needle, so the following will work: - * @code utils_string_replace_all(text, "\n", "\r\n"); @endcode +/** + * Convenience function to replace only the occurrence of @c needle in @c haystack with @c. + * For details, see utils_string_replace_all(). * * @param haystack The input string to operate on. This string is modified in place. * @param needle The string which should be replaced.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.