Revision: 1262
http://geeqie.svn.sourceforge.net/geeqie/?rev=1262&view=rev
Author: zas_
Date: 2008-11-22 16:24:23 +0000 (Sat, 22 Nov 2008)
Log Message:
-----------
Add a back button in the toolbar: it allows to go back and forth between two
directories. Experimental, please test and comment on ml.
Modified Paths:
--------------
trunk/src/layout.c
trunk/src/layout_util.c
trunk/src/typedefs.h
trunk/src/ui_tabcomp.c
trunk/src/ui_tabcomp.h
Modified: trunk/src/layout.c
===================================================================
--- trunk/src/layout.c 2008-11-20 17:28:34 UTC (rev 1261)
+++ trunk/src/layout.c 2008-11-22 16:24:23 UTC (rev 1262)
@@ -183,6 +183,25 @@
layout_set_path(lw, path);
}
+static void layout_path_entry_tab_append_cb(const gchar *path, gpointer data,
gint n)
+{
+ LayoutWindow *lw = data;
+
+ if (!lw || !lw->back_button) return;
+ if (!layout_valid(&lw)) return;
+
+ if (n >= 2)
+ {
+ /* Enable back button */
+ gtk_widget_set_sensitive(lw->back_button, TRUE);
+ }
+ else
+ {
+ /* Disable back button */
+ gtk_widget_set_sensitive(lw->back_button, FALSE);
+ }
+}
+
static GtkWidget *layout_tool_setup(LayoutWindow *lw)
{
GtkWidget *box;
@@ -202,6 +221,7 @@
tabcomp = tab_completion_new_with_history(&lw->path_entry, NULL,
"path_list", -1,
layout_path_entry_cb, lw);
tab_completion_add_tab_func(lw->path_entry, layout_path_entry_tab_cb,
lw);
+ tab_completion_add_append_func(lw->path_entry,
layout_path_entry_tab_append_cb, lw);
gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0);
gtk_widget_show(tabcomp);
Modified: trunk/src/layout_util.c
===================================================================
--- trunk/src/layout_util.c 2008-11-20 17:28:34 UTC (rev 1261)
+++ trunk/src/layout_util.c 2008-11-22 16:24:23 UTC (rev 1262)
@@ -1556,6 +1556,34 @@
layout_thumb_set(lw,
gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget)));
}
+/* Back button callback */
+static void layout_button_back_cb(GtkWidget *widget, gpointer data)
+{
+ LayoutWindow *lw = data;
+ FileData *dir_fd;
+ gchar *path = NULL;
+ GList *list = history_list_get_by_key("path_list");
+ gint n = 0;
+
+ while (list)
+ {
+ if (n == 1) {
+ /* Previous path from history */
+ path = (gchar *)list->data;
+ break;
+ }
+ list = list->next;
+ n++;
+ }
+
+ if (!path) return;
+
+ /* Open previous path */
+ dir_fd = file_data_new_simple(path);
+ layout_set_fd(lw, dir_fd);
+ file_data_unref(dir_fd);
+}
+
static void layout_button_home_cb(GtkWidget *widget, gpointer data)
{
const gchar *path;
@@ -1647,6 +1675,10 @@
_("Show thumbnails"),
G_CALLBACK(layout_button_thumb_cb), lw);
layout_button_custom_icon(button, PIXBUF_INLINE_ICON_THUMB);
lw->thumb_button = button;
+
+ lw->back_button = pref_toolbar_button(box, GTK_STOCK_GO_BACK, NULL,
FALSE,
+ _("Back to previous folder"),
G_CALLBACK(layout_button_back_cb), lw);
+ gtk_widget_set_sensitive(lw->back_button, FALSE);
pref_toolbar_button(box, GTK_STOCK_HOME, NULL, FALSE,
_("Change to home folder"),
G_CALLBACK(layout_button_home_cb), lw);
Modified: trunk/src/typedefs.h
===================================================================
--- trunk/src/typedefs.h 2008-11-20 17:28:34 UTC (rev 1261)
+++ trunk/src/typedefs.h 2008-11-22 16:24:23 UTC (rev 1262)
@@ -493,6 +493,8 @@
gint thumbs_enabled;
gint marks_enabled;
+ GtkWidget *back_button;
+
/* dir view */
LayoutLocation dir_location;
Modified: trunk/src/ui_tabcomp.c
===================================================================
--- trunk/src/ui_tabcomp.c 2008-11-20 17:28:34 UTC (rev 1261)
+++ trunk/src/ui_tabcomp.c 2008-11-22 16:24:23 UTC (rev 1262)
@@ -63,9 +63,12 @@
GList *file_list;
void (*enter_func)(const gchar *, gpointer);
void (*tab_func)(const gchar *, gpointer);
+ void (*tab_append_func)(const gchar *, gpointer, gint);
+
gpointer enter_data;
gpointer tab_data;
-
+ gpointer tab_append_data;
+
GtkWidget *combo;
gint has_history;
gchar *history_key;
@@ -733,6 +736,7 @@
TabCompData *td;
GtkTreeModel *store;
GList *work;
+ gint n = 0;
td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
@@ -752,7 +756,12 @@
{
gtk_combo_box_append_text(GTK_COMBO_BOX(td->combo), (gchar
*)work->data);
work = work->next;
+ n++;
}
+
+ if (td->tab_append_func) {
+ td->tab_append_func(path, td->tab_append_data, n);
+ }
}
GtkWidget *tab_completion_new(GtkWidget **entry, const gchar *text,
@@ -819,6 +828,17 @@
td->tab_data = data;
}
+/* Add a callback function called when a new entry is appended to the list */
+void tab_completion_add_append_func(GtkWidget *entry, void
(*tab_append_func)(const gchar *, gpointer, gint), gpointer data)
+{
+ TabCompData *td = g_object_get_data(G_OBJECT(entry),
"tab_completion_data");
+
+ if (!td) return;
+
+ td->tab_append_func = tab_append_func;
+ td->tab_append_data = data;
+}
+
gchar *remove_trailing_slash(const gchar *path)
{
gint l;
Modified: trunk/src/ui_tabcomp.h
===================================================================
--- trunk/src/ui_tabcomp.h 2008-11-20 17:28:34 UTC (rev 1261)
+++ trunk/src/ui_tabcomp.h 2008-11-22 16:24:23 UTC (rev 1262)
@@ -27,6 +27,7 @@
gchar *remove_trailing_slash(const gchar *path);
void tab_completion_add_select_button(GtkWidget *entry, const gchar *title,
gint folders_only);
+void tab_completion_add_append_func(GtkWidget *entry, void
(*tab_append_func)(const gchar *, gpointer, gint), gpointer data);
#endif
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn