SF.net SVN: geany:[4713] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Feb 28 14:57:06 UTC 2010


Revision: 4713
          http://geany.svn.sourceforge.net/geany/?rev=4713&view=rev
Author:   eht16
Date:     2010-02-28 14:57:06 +0000 (Sun, 28 Feb 2010)

Log Message:
-----------
Make Space on the compiler and messages widgets not focus the editor widget while Enter does (patch by Can Koy, thanks).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/msgwindow.c
    trunk/src/msgwindow.h
    trunk/src/ui_utils.c
    trunk/src/ui_utils.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-02-28 14:32:38 UTC (rev 4712)
+++ trunk/ChangeLog	2010-02-28 14:57:06 UTC (rev 4713)
@@ -16,6 +16,9 @@
  * src/document.c, src/document.h:
    Fix document_try_focus() to make it work with the sidebar document
    list as well.
+ * src/msgwindow.c, src/msgwindow.h, src/ui_utils.c, src/ui_utils.h:
+   Make Space on the compiler and messages widgets not focus the editor
+   widget while Enter does (patch by Can Koy, thanks).
 
 
 2010-02-28  Frank Lanitz  <frank(at)frank(dot)uvena(dot)de>

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2010-02-28 14:32:38 UTC (rev 4712)
+++ trunk/src/msgwindow.c	2010-02-28 14:57:06 UTC (rev 4713)
@@ -111,18 +111,29 @@
 }
 
 
+static gboolean is_keyval_enter_or_return(guint keyval)
+{
+	return (keyval == GDK_Return || keyval == GDK_ISO_Enter || keyval == GDK_KP_Enter);
+}
+
+
 static gboolean on_msgwin_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-	if (event->keyval == GDK_Return ||
-		event->keyval == GDK_ISO_Enter ||
-		event->keyval == GDK_KP_Enter ||
-		event->keyval == GDK_space)
+	if (is_keyval_enter_or_return(event->keyval) || event->keyval == GDK_space)
 	{
-		GdkEventButton button_event;
-
-		button_event.button = 1;
-		button_event.time = event->time;
-		on_msgwin_button_press_event(NULL, &button_event, data);
+		switch (GPOINTER_TO_INT(data))
+		{
+			case MSG_COMPILER:
+			{	/* single click in the compiler treeview */
+				msgwin_goto_compiler_file_line(event->keyval);
+				break;
+			}
+			case MSG_MESSAGE:
+			{	/* single click in the message treeview (results of 'Find usage') */
+				msgwin_goto_messages_file_line(event->keyval);
+				break;
+			}
+		}
 	}
 	return FALSE;
 }
@@ -582,7 +593,7 @@
 }
 
 
-static gboolean goto_compiler_file_line(const gchar *filename, gint line)
+static gboolean goto_compiler_file_line(const gchar *filename, gint line, guint keyval)
 {
 	if (!filename || line <= -1)
 		return FALSE;
@@ -626,17 +637,23 @@
 
 		if (doc != NULL)
 		{
+			gboolean ret;
+
 			if (! doc->changed)	/* if modified, line may be wrong */
 				editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_ERROR, line - 1);
 
-			return navqueue_goto_line(old_doc, doc, line);
+			ret = navqueue_goto_line(old_doc, doc, line);
+			if (ret && is_keyval_enter_or_return(keyval))
+				gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
+
+			return ret;
 		}
 	}
 	return FALSE;
 }
 
 
-gboolean msgwin_goto_compiler_file_line(void)
+gboolean msgwin_goto_compiler_file_line(guint keyval)
 {
 	GtkTreeIter iter;
 	GtkTreeModel *model;
@@ -672,7 +689,7 @@
 			g_free(string);
 			g_free(dir);
 
-			ret = goto_compiler_file_line(filename, line);
+			ret = goto_compiler_file_line(filename, line, keyval);
 			g_free(filename);
 			return ret;
 		}
@@ -949,7 +966,7 @@
 }
 
 
-gboolean msgwin_goto_messages_file_line(void)
+gboolean msgwin_goto_messages_file_line(guint keyval)
 {
 	GtkTreeIter iter;
 	GtkTreeModel *model;
@@ -969,6 +986,8 @@
 		if (line >= 0 && DOC_VALID(doc))
 		{
 			ret = navqueue_goto_line(old_doc, doc, line);
+			if (ret && is_keyval_enter_or_return(keyval))
+				gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
 		}
 		else if (line < 0 && string != NULL)
 		{
@@ -979,7 +998,11 @@
 				/* use document_open_file to find an already open file, or open it in place */
 				doc = document_open_file(filename, FALSE, NULL, NULL);
 				if (doc != NULL)
+				{
 					ret = navqueue_goto_line(old_doc, doc, line);
+					if (ret && is_keyval_enter_or_return(keyval))
+						gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
+				}
 			}
 			g_free(filename);
 		}
@@ -1027,12 +1050,12 @@
 		{
 			case MSG_COMPILER:
 			{	/* single click in the compiler treeview */
-				msgwin_goto_compiler_file_line();
+				msgwin_goto_compiler_file_line(0);
 				break;
 			}
 			case MSG_MESSAGE:
 			{	/* single click in the message treeview (results of 'Find usage') */
-				msgwin_goto_messages_file_line();
+				msgwin_goto_messages_file_line(0);
 				break;
 			}
 		}

Modified: trunk/src/msgwindow.h
===================================================================
--- trunk/src/msgwindow.h	2010-02-28 14:32:38 UTC (rev 4712)
+++ trunk/src/msgwindow.h	2010-02-28 14:57:06 UTC (rev 4713)
@@ -101,11 +101,11 @@
 
 void msgwin_menu_add_common_items(GtkMenu *menu);
 
-gboolean msgwin_goto_compiler_file_line(void);
+gboolean msgwin_goto_compiler_file_line(guint keyval);
 
 void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir,
 									  gchar **filename, gint *line);
 
-gboolean msgwin_goto_messages_file_line(void);
+gboolean msgwin_goto_messages_file_line(guint keyval);
 
 #endif

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2010-02-28 14:32:38 UTC (rev 4712)
+++ trunk/src/ui_utils.c	2010-02-28 14:57:06 UTC (rev 4713)
@@ -1492,7 +1492,7 @@
 	while (TRUE)
 	{
 		gtk_tree_selection_select_iter(treesel, &iter);
-		if (cb())
+		if (cb(0))
 			break;	/* found next message */
 
 		if (! tree_model_iter_get_next(model, &iter, down))

Modified: trunk/src/ui_utils.h
===================================================================
--- trunk/src/ui_utils.h	2010-02-28 14:32:38 UTC (rev 4712)
+++ trunk/src/ui_utils.h	2010-02-28 14:57:06 UTC (rev 4713)
@@ -283,7 +283,7 @@
 void ui_update_tab_status(GeanyDocument *doc);
 
 
-typedef gboolean TVMatchCallback(void);
+typedef gboolean TVMatchCallback(guint);
 
 gboolean ui_tree_view_find_next(GtkTreeView *treeview, TVMatchCallback cb);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list