This fixes single click activation in the list view, bug 76197.

2002-03-30  David Emory Watson  <dwatson@cs.ucr.edu>

	This fixes single click activation in the list view, bug 76197.

	* src/file-manager/fm-list-view.c:
	(list_activate_callback): only do this if the double click activation
	preference is set.
	(event_after_callback): handle single click activation preference.
	(click_policy_changed): new function to handle whether file names
	are underlined or not.
	(create_and_set_up_tree_view): connect click policy preference callback
	(fm_list_view_finalize): disconnect.
This commit is contained in:
David Emory Watson 2002-04-05 18:25:57 +00:00 committed by David Emory Watson
parent c2a199be3c
commit 6c7f6cd689
2 changed files with 70 additions and 15 deletions

View file

@ -1,3 +1,16 @@
2002-03-30 David Emory Watson <dwatson@cs.ucr.edu>
This fixes single click activation in the list view, bug 76197.
* src/file-manager/fm-list-view.c:
(list_activate_callback): only do this if the double click activation
preference is set.
(event_after_callback): handle single click activation preference.
(click_policy_changed): new function to handle whether file names
are underlined or not.
(create_and_set_up_tree_view): connect click policy preference callback
(fm_list_view_finalize): disconnect.
2002-04-05 David Emory Watson <dwatson@cs.ucr.edu>
* src/nautilus-sidebar.c:

View file

@ -45,7 +45,8 @@ struct FMListViewDetails {
GtkTreeView *tree_view;
FMListModel *model;
GtkTreeViewColumn *file_name_column;
GtkTreeViewColumn *file_name_column;
GtkCellRendererText *file_name_cell;
};
static GtkTargetEntry drag_types [] = {
@ -86,10 +87,12 @@ list_activate_callback (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewCo
GList *file_list;
view = FM_DIRECTORY_VIEW (user_data);
file_list = fm_list_view_get_selection (view);
fm_directory_view_activate_files (view, file_list);
nautilus_file_list_free (file_list);
if (eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_DOUBLE) {
file_list = fm_list_view_get_selection (view);
fm_directory_view_activate_files (view, file_list);
nautilus_file_list_free (file_list);
}
}
/* Move these to eel? */
@ -124,16 +127,26 @@ tree_view_has_selection (GtkTreeView *view)
static void
event_after_callback (GtkWidget *widget, GdkEventAny *event, gpointer callback_data)
{
/* Put up the right kind of menu if we right click in the tree view. */
FMDirectoryView *view;
GList *file_list;
view = FM_DIRECTORY_VIEW (callback_data);
if (event->type == GDK_BUTTON_PRESS
&& event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))
&& ((GdkEventButton *) event)->button == 3) {
if (tree_view_has_selection (GTK_TREE_VIEW (widget))) {
fm_directory_view_pop_up_selection_context_menu
(FM_DIRECTORY_VIEW (callback_data), (GdkEventButton *) event);
} else {
fm_directory_view_pop_up_background_context_menu
(FM_DIRECTORY_VIEW (callback_data), (GdkEventButton *) event);
&& event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))) {
if (((GdkEventButton *) event)->button == 1
&& eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_SINGLE) {
/* Handle single click activation preference. */
file_list = fm_list_view_get_selection (view);
fm_directory_view_activate_files (view, file_list);
nautilus_file_list_free (file_list);
} else if (((GdkEventButton *) event)->button == 3) {
/* Put up the right kind of menu if we right click in the tree view. */
if (tree_view_has_selection (GTK_TREE_VIEW (widget))) {
fm_directory_view_pop_up_selection_context_menu (view, (GdkEventButton *) event);
} else {
fm_directory_view_pop_up_background_context_menu (view, (GdkEventButton *) event);
}
}
}
}
@ -179,6 +192,24 @@ cell_renderer_edited (GtkCellRendererText *cell,
nautilus_file_unref (file);
}
static void
click_policy_changed (gpointer callback_data)
{
FMListView *view;
view = FM_LIST_VIEW (callback_data);
if (eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_SINGLE) {
g_object_set (G_OBJECT (view->details->file_name_cell),
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
} else {
g_object_set (G_OBJECT (view->details->file_name_cell),
"underline", PANGO_UNDERLINE_NONE,
NULL);
}
}
static void
create_and_set_up_tree_view (FMListView *view)
{
@ -221,7 +252,7 @@ create_and_set_up_tree_view (FMListView *view)
cell = gtk_cell_renderer_text_new ();
g_signal_connect (cell, "edited", G_CALLBACK (cell_renderer_edited), view);
gtk_tree_view_column_pack_start (view->details->file_name_column, cell, TRUE);
gtk_tree_view_column_set_attributes (view->details->file_name_column, cell,
"text", FM_LIST_MODEL_NAME_COLUMN,
@ -229,6 +260,13 @@ create_and_set_up_tree_view (FMListView *view)
NULL);
gtk_tree_view_append_column (view->details->tree_view, view->details->file_name_column);
/* Set up underline of file name. */
view->details->file_name_cell = (GtkCellRendererText *)cell;
eel_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed,
view);
click_policy_changed (view);
/* Create the size column */
cell = gtk_cell_renderer_text_new ();
g_object_set (G_OBJECT (cell),
@ -492,6 +530,10 @@ fm_list_view_finalize (GObject *object)
list_view = FM_LIST_VIEW (object);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed,
list_view->details->file_name_cell);
g_free (list_view->details);
G_OBJECT_CLASS (parent_class)->finalize (object);