[gedit] Focus on view when opening files from the File Browser or Documents Panel (fixes bug #544092)



commit 139db33451057858f196be29f567b7c37140c70b
Author: Garrett Regier <alias301 gmail com>
Date:   Thu Apr 29 12:45:16 2010 -0700

    Focus on view when opening files from the File Browser or Documents Panel (fixes bug #544092)

 gedit/gedit-commands-file.c                   |    3 +++
 gedit/gedit-documents-panel.c                 |    8 ++++++++
 gedit/gedit-window.c                          |    3 +++
 plugins/filebrowser/gedit-file-browser-view.c |    7 ++++---
 4 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index 77f1bd7..5c409be 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -199,6 +199,9 @@ load_file_list (GeditWindow         *window,
 					 line_pos,
 					 column_pos,
 					 create);
+			
+			/* make sure the view has focus */
+			gtk_widget_grab_focus (GTK_WIDGET (gedit_tab_get_view (tab)));
 
 			l = g_slist_next (l);
 			jump_to = FALSE;
diff --git a/gedit/gedit-documents-panel.c b/gedit/gedit-documents-panel.c
index 9660753..cfd9c2b 100644
--- a/gedit/gedit-documents-panel.c
+++ b/gedit/gedit-documents-panel.c
@@ -776,6 +776,14 @@ gedit_documents_panel_init (GeditDocumentsPanel *panel)
 	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (panel->priv->treeview), FALSE);
 	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (panel->priv->treeview), TRUE);
 
+	/* Disable search because each time the selection is changed, the
+	   active tab is changed which focusses the view, and thus would remove
+	   the search entry, rendering it useless */
+	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (panel->priv->treeview), FALSE);
+
+	/* Disable focus so it doesn't steel focus each time from the view */
+	gtk_widget_set_can_focus (panel->priv->treeview, FALSE);
+
 	g_object_set (panel->priv->treeview, "has-tooltip", TRUE, NULL);
 
 	gtk_widget_show (panel->priv->treeview);
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 5f002af..ac8e7ba 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -4441,6 +4441,9 @@ gedit_window_set_active_tab (GeditWindow *window,
 	
 	gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook),
 				       page_num);
+
+	/* Make sure to grab focus if the page didn't change */
+	gtk_widget_grab_focus (GTK_WIDGET (gedit_tab_get_view (tab)));
 }
 
 /**
diff --git a/plugins/filebrowser/gedit-file-browser-view.c b/plugins/filebrowser/gedit-file-browser-view.c
index 9e0634e..342a7a6 100644
--- a/plugins/filebrowser/gedit-file-browser-view.c
+++ b/plugins/filebrowser/gedit-file-browser-view.c
@@ -551,12 +551,13 @@ button_press_event (GtkWidget      *widget,
 
 		if (event->type == GDK_2BUTTON_PRESS)
 		{
+			/* Chain up, must be before activating the selected
+			   items because this will cause the view to grab focus */
+			widget_parent->button_press_event (widget, event);
+			
 			if (view->priv->double_click_path[1] &&
 			    gtk_tree_path_compare (view->priv->double_click_path[0], view->priv->double_click_path[1]) == 0)
 				activate_selected_items (view);
-			
-			/* Chain up */
-			widget_parent->button_press_event (widget, event);
 		}
 		else
 		{



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]