[anjuta] document-manager: bgo#680555 - Escape key does not dismiss Find in Files panel



commit 63840510bd5ccfa0d745b408d1c12c6b5c0079f1
Author: Johannes Schmid <jhs gnome org>
Date:   Thu Jul 26 12:54:47 2012 +0200

    document-manager: bgo#680555 - Escape key does not dismiss Find in Files panel

 plugins/document-manager/anjuta-docman.c           |    5 +--
 .../document-manager/anjuta-document-manager.ui    |    4 ++
 plugins/document-manager/search-files.c            |   34 ++++++++++++++++++++
 3 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/plugins/document-manager/anjuta-docman.c b/plugins/document-manager/anjuta-docman.c
index 67a574f..693acfa 100644
--- a/plugins/document-manager/anjuta-docman.c
+++ b/plugins/document-manager/anjuta-docman.c
@@ -1407,9 +1407,8 @@ anjuta_docman_present_notebook_page (AnjutaDocman *docman, IAnjutaDocument *doc)
 			{
 				if (curindx != gtk_notebook_get_current_page (GTK_NOTEBOOK (docman)))
 					gtk_notebook_set_current_page (GTK_NOTEBOOK (docman), curindx);
-				else
-					/* Make sure current page is visible */
-					anjuta_docman_grab_text_focus (docman);
+				/* Make sure current page is visible */
+				anjuta_docman_grab_text_focus (docman);
 			}
 			break;
 		}
diff --git a/plugins/document-manager/anjuta-document-manager.ui b/plugins/document-manager/anjuta-document-manager.ui
index 0fe6092..2dc0fae 100644
--- a/plugins/document-manager/anjuta-document-manager.ui
+++ b/plugins/document-manager/anjuta-document-manager.ui
@@ -372,6 +372,7 @@
             <property name="primary_icon_stock">gtk-find</property>
             <signal name="changed" handler="search_files_update_ui" swapped="yes"/>
             <signal name="activate" handler="search_files_search_clicked" swapped="yes"/>
+            <signal name="key-press-event" handler="search_files_key_pressed" swapped="no"/>
           </object>
           <packing>
             <property name="left_attach">0</property>
@@ -389,6 +390,7 @@
             <property name="invisible_char">â</property>
             <property name="invisible_char_set">True</property>
             <property name="primary_icon_stock">gtk-find-and-replace</property>
+            <signal name="key-press-event" handler="search_files_key_pressed" swapped="no"/>
           </object>
           <packing>
             <property name="left_attach">0</property>
@@ -526,6 +528,7 @@
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
+                <signal name="key-press-event" handler="search_files_key_pressed" swapped="no"/>
                 <signal name="clicked" handler="search_files_search_clicked" swapped="yes"/>
               </object>
               <packing>
@@ -541,6 +544,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <signal name="key-press-event" handler="search_files_key_pressed" swapped="no"/>
                 <signal name="clicked" handler="search_files_replace_clicked" swapped="yes"/>
               </object>
               <packing>
diff --git a/plugins/document-manager/search-files.c b/plugins/document-manager/search-files.c
index 348d9db..4a7382b 100644
--- a/plugins/document-manager/search-files.c
+++ b/plugins/document-manager/search-files.c
@@ -97,6 +97,8 @@ G_DEFINE_TYPE (SearchFiles, search_files, G_TYPE_OBJECT);
 G_MODULE_EXPORT void search_files_search_clicked (SearchFiles* sf);
 G_MODULE_EXPORT void search_files_replace_clicked (SearchFiles* sf);
 G_MODULE_EXPORT void search_files_update_ui (SearchFiles* sf);
+G_MODULE_EXPORT gboolean search_files_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+
 
 void
 search_files_update_ui (SearchFiles* sf)
@@ -882,6 +884,38 @@ search_files_new (AnjutaDocman* docman, SearchBox* search_box)
 	return sf;
 }
 
+gboolean
+search_files_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+	SearchFiles* sf = SEARCH_FILES(user_data);
+	IAnjutaDocument* doc;
+	
+	g_return_val_if_fail (widget != NULL, FALSE);
+	g_return_val_if_fail (event != NULL, FALSE);
+	g_return_val_if_fail (sf != NULL, FALSE);
+
+	switch (event->keyval)
+	{
+		case GDK_KEY_Escape:
+		{
+			anjuta_shell_hide_dockable_widget (sf->priv->docman->shell,
+			                                   sf->priv->main_box,
+			                                   NULL);
+			/* Check if document is open */
+			doc = anjuta_docman_get_current_document(sf->priv->docman);
+
+			if (doc)
+			{
+				anjuta_docman_present_notebook_page(sf->priv->docman,
+				                                    doc);
+			}
+			return TRUE;
+		}
+		default:
+			return FALSE;
+	}
+}
+
 void search_files_present (SearchFiles* sf)
 {
 	g_return_if_fail (sf != NULL && SEARCH_IS_FILES(sf));



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