#include "gtksizegroup.h"
#include "gtkstock.h"
#include "gtktable.h"
+#include "gtktooltip.h"
#include "gtktreednd.h"
#include "gtktreeprivate.h"
#include "gtktreeselection.h"
gtk_tree_view_column_set_sort_column_id (impl->list_mtime_column, mtime_id);
}
+static gboolean
+file_list_query_tooltip_cb (GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_tip,
+ GtkTooltip *tooltip,
+ gpointer user_data)
+{
+ GtkFileChooserDefault *impl = user_data;
+ GtkTreeIter iter, child_iter;
+ GtkTreePath *path = NULL;
+ GtkFilePath *file_path = NULL;
+ gchar *filename;
+
+ if (impl->operation_mode == OPERATION_MODE_BROWSE)
+ return FALSE;
+
+
+ gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (impl->browse_files_tree_view),
+ &x, &y,
+ keyboard_tip,
+ NULL, &path, NULL);
+
+ if (!path)
+ return FALSE;
+
+ switch (impl->operation_mode)
+ {
+ case OPERATION_MODE_SEARCH:
+ if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->search_model_sort), &iter, path))
+ {
+ gtk_tree_path_free (path);
+ return FALSE;
+ }
+
+ search_get_valid_child_iter (impl, &child_iter, &iter);
+ gtk_tree_model_get (GTK_TREE_MODEL (impl->search_model), &child_iter,
+ SEARCH_MODEL_COL_PATH, &file_path,
+ -1);
+ break;
+
+ case OPERATION_MODE_RECENT:
+ if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->recent_model_sort), &iter, path))
+ {
+ gtk_tree_path_free (path);
+ return FALSE;
+ }
+
+ recent_get_valid_child_iter (impl, &child_iter, &iter);
+ gtk_tree_model_get (GTK_TREE_MODEL (impl->recent_model), &child_iter,
+ RECENT_MODEL_COL_PATH, &file_path,
+ -1);
+ break;
+
+ case OPERATION_MODE_BROWSE:
+ g_assert_not_reached ();
+ return FALSE;
+ }
+
+ if (!file_path)
+ {
+ gtk_tree_path_free (path);
+ return FALSE;
+ }
+
+ filename = gtk_file_system_path_to_filename (impl->file_system, file_path);
+ gtk_tooltip_set_text (tooltip, filename);
+ gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (impl->browse_files_tree_view),
+ tooltip,
+ path);
+
+ g_free (filename);
+ gtk_tree_path_free (path);
+
+ return TRUE;
+}
/* Creates the widgets for the file list */
static GtkWidget *
g_signal_connect (impl->browse_files_tree_view, "drag_motion",
G_CALLBACK (file_list_drag_motion_cb), impl);
+ g_object_set (impl->browse_files_tree_view, "has-tooltip", TRUE, NULL);
+ g_signal_connect (impl->browse_files_tree_view, "query-tooltip",
+ G_CALLBACK (file_list_query_tooltip_cb), impl);
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
gtk_tree_selection_set_select_function (selection,
list_select_func,
if (impl->operation_mode == OPERATION_MODE_SEARCH)
{
GtkTreeIter child_iter;
- GtkFilePath *file_path;
- gchar *display_name, *tmp;
- gchar *text;
+ gchar *display_name;
gboolean is_folder;
search_get_valid_child_iter (impl, &child_iter, iter);
gtk_tree_model_get (GTK_TREE_MODEL (impl->search_model), &child_iter,
- SEARCH_MODEL_COL_PATH, &file_path,
SEARCH_MODEL_COL_DISPLAY_NAME, &display_name,
SEARCH_MODEL_COL_IS_FOLDER, &is_folder,
-1);
- tmp = gtk_file_system_path_to_filename (impl->file_system, file_path);
- text = g_strdup_printf ("<b>%s</b>\n%s", display_name, tmp);
- g_free (tmp);
-
if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
{
}
g_object_set (cell,
- "markup", text,
+ "text", display_name,
"sensitive", sensitive,
"ellipsize", PANGO_ELLIPSIZE_END,
NULL);
- g_free (text);
-
return;
}
{
GtkTreeIter child_iter;
GtkRecentInfo *recent_info;
- gchar *tmp, *text;
+ gchar *display_name;
gboolean is_folder;
recent_get_valid_child_iter (impl, &child_iter, iter);
RECENT_MODEL_COL_IS_FOLDER, &is_folder,
-1);
- tmp = gtk_recent_info_get_short_name (recent_info);
- text = g_strdup_printf ("<b>%s</b>\n%s",
- tmp,
- gtk_recent_info_get_uri_display (recent_info));
- g_free (tmp);
+ display_name = gtk_recent_info_get_short_name (recent_info);
if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
}
g_object_set (cell,
- "markup", text,
+ "text", display_name,
"sensitive", sensitive,
"ellipsize", PANGO_ELLIPSIZE_END,
NULL);
- g_free (text);
+
+ g_free (display_name);
return;
}