Commit aa22566e authored by Federico Mena Quintero's avatar Federico Mena Quintero Committed by Federico Mena Quintero

Connect to "row_activated" on the file list. (list_row_activated): New

2003-09-10  Federico Mena Quintero  <federico@ximian.com>

	* gtkfilechooserimpldefault.c (create_file_list): Connect to
	"row_activated" on the file list.
	(list_row_activated): New function.  Changes to folders or emits
	the "file-activated" signal depending on what type of row was
	activated.
	(create_folder_tree): Renamed from create_directory_tree(), since
	"folder" is the new politically-correct name.

	* gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added a
	file-activated signal.

	* gtkfilechooser.c (gtk_file_chooser_class_init): Register the
	signal.

	* gtkfilechooserutils.c (_gtk_file_chooser_set_delegate): Connect
	to "file-activated" on the delegate.
	(delegate_file_activated): New function.

	* TODO: Added an API item about Clipart-like folders provided by
	applications.
parent e23ed607
......@@ -80,6 +80,13 @@ gtk_file_chooser_class_init (gpointer g_iface)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_new ("file-activated",
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_object_interface_install_property (g_iface,
g_param_spec_enum ("action",
......
......@@ -141,6 +141,10 @@ static void tree_selection_changed (GtkTreeSelection *tree_selectio
GtkFileChooserImplDefault *impl);
static void list_selection_changed (GtkTreeSelection *tree_selection,
GtkFileChooserImplDefault *impl);
static void list_row_activated (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
GtkFileChooserImplDefault *impl);
static void entry_activate (GtkEntry *entry,
GtkFileChooserImplDefault *impl);
......@@ -333,9 +337,9 @@ create_filter (GtkFileChooserImplDefault *impl)
return impl->filter_alignment;
}
/* Creates the widgets for the directory tree */
/* Creates the widgets for the folder tree */
static GtkWidget *
create_directory_tree (GtkFileChooserImplDefault *impl)
create_folder_tree (GtkFileChooserImplDefault *impl)
{
GtkTreeSelection *selection;
......@@ -381,7 +385,7 @@ create_directory_tree (GtkFileChooserImplDefault *impl)
return impl->tree_scrollwin;
}
/* Creates the widgets for the directory tree */
/* Creates the widgets for the folder tree */
static GtkWidget *
create_file_list (GtkFileChooserImplDefault *impl)
{
......@@ -403,6 +407,8 @@ create_file_list (GtkFileChooserImplDefault *impl)
impl->list = gtk_tree_view_new ();
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (impl->list), TRUE);
gtk_container_add (GTK_CONTAINER (impl->list_scrollwin), impl->list);
g_signal_connect (impl->list, "row_activated",
G_CALLBACK (list_row_activated), impl);
gtk_widget_show (impl->list);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
......@@ -531,9 +537,9 @@ gtk_file_chooser_impl_default_constructor (GType type,
gtk_paned_set_position (GTK_PANED (hpaned), 200); /* FIXME: this sucks */
gtk_widget_show (hpaned);
/* Directory tree */
/* Folder tree */
widget = create_directory_tree (impl);
widget = create_folder_tree (impl);
gtk_paned_add1 (GTK_PANED (hpaned), widget);
/* File list */
......@@ -1395,6 +1401,41 @@ list_selection_changed (GtkTreeSelection *selection,
g_signal_emit_by_name (impl, "selection-changed", 0);
}
/* Callback used when a row in the file list is activated */
static void
list_row_activated (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
GtkFileChooserImplDefault *impl)
{
GtkTreeIter iter, child_iter;
const GtkFileInfo *info;
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->sort_model), &iter, path))
return;
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &iter);
info = _gtk_file_system_model_get_info (impl->list_model, &child_iter);
if (gtk_file_info_get_is_folder (info))
{
const GtkFilePath *file_path;
char *uri;
file_path = _gtk_file_system_model_get_path (impl->list_model, &child_iter);
uri = gtk_file_system_path_to_uri (impl->file_system, file_path);
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (impl), uri);
g_free (uri);
return;
}
g_signal_emit_by_name (impl, "file-activated");
}
static void
entry_activate (GtkEntry *entry,
GtkFileChooserImplDefault *impl)
......
......@@ -62,6 +62,7 @@ struct _GtkFileChooserIface
void (*current_folder_changed) (GtkFileChooser *chooser);
void (*selection_changed) (GtkFileChooser *chooser);
void (*update_preview) (GtkFileChooser *chooser);
void (*file_activated) (GtkFileChooser *chooser);
};
GtkFileSystem *_gtk_file_chooser_get_file_system (GtkFileChooser *chooser);
......
......@@ -52,6 +52,8 @@ static void delegate_selection_changed (GtkFileChooser *choose
gpointer data);
static void delegate_update_preview (GtkFileChooser *chooser,
gpointer data);
static void delegate_file_activated (GtkFileChooser *chooser,
gpointer data);
/**
* _gtk_file_chooser_install_properties:
......@@ -156,6 +158,8 @@ _gtk_file_chooser_set_delegate (GtkFileChooser *receiver,
G_CALLBACK (delegate_selection_changed), receiver);
g_signal_connect (delegate, "update-preview",
G_CALLBACK (delegate_update_preview), receiver);
g_signal_connect (delegate, "file-activated",
G_CALLBACK (delegate_file_activated), receiver);
}
static GtkFileChooser *
......@@ -280,3 +284,10 @@ delegate_update_preview (GtkFileChooser *chooser,
{
g_signal_emit_by_name (data, "update-preview");
}
static void
delegate_file_activated (GtkFileChooser *chooser,
gpointer data)
{
g_signal_emit_by_name (data, "file-activated");
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment