Revision: 5787
http://geany.svn.sourceforge.net/geany/?rev=5787&view=rev
Author: colombanw
Date: 2011-05-09 17:39:11 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Fix the sidebar popup menu to popup for the correct selection
Fix the sidebar popup menu to properly use the currently selected item
rather than the previous one.
Also change the hack used for the selection to be updated in the input
handlers (key and mouse button) to call the GtkTreeView's handler
manually rather than doing the actual job in IDLE callbacks for the
TreeView's handler to have run.
This prevents from having several different handlers but removes the
need to work in IDLE time and then possible have a lag, as well as
simplifying the code.
Modified Paths:
--------------
branches/0.20.1/ChangeLog
branches/0.20.1/src/sidebar.c
Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog 2011-05-09 17:38:45 UTC (rev 5786)
+++ branches/0.20.1/ChangeLog 2011-05-09 17:39:11 UTC (rev 5787)
@@ -18,6 +18,12 @@
Update forced indent settings when setting the filetype. This makes
documents created or set to a filetype with forced indent setting
(Makefile, F77) to have the correct setting right away.
+ * src/sidebar.c:
+ Fix the sidebar popup menu to properly use the currently selected item
+ rather than the previous one.
+ Also change the hack used for the selection to be updated in the input
+ handlers to call the GtkTreeView's handler manually rather than doing
+ the actual job in IDLE callbacks for the TreeView's handler to have run.
2011-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: branches/0.20.1/src/sidebar.c
===================================================================
--- branches/0.20.1/src/sidebar.c 2011-05-09 17:38:45 UTC (rev 5786)
+++ branches/0.20.1/src/sidebar.c 2011-05-09 17:39:11 UTC (rev 5787)
@@ -62,12 +62,6 @@
}
doc_items = {NULL, NULL, NULL, NULL, NULL};
-static struct
-{
- GtkTreeSelection *selection;
- guint keyval;
-} selection_change = {NULL, 0};
-
enum
{
TREEVIEW_SYMBOL = 0,
@@ -97,9 +91,7 @@
static GtkWidget *tag_window; /* scrolled window that holds the symbol list GtkTreeView */
/* callback prototypes */
-static gboolean on_openfiles_tree_selection_changed(gpointer data);
static void on_openfiles_document_action(GtkMenuItem *menuitem, gpointer user_data);
-static gboolean on_taglist_tree_selection_changed(gpointer data);
static gboolean sidebar_button_press_cb(GtkWidget *widget, GdkEventButton *event,
gpointer user_data);
static gboolean sidebar_key_press_cb(GtkWidget *widget, GdkEventKey *event,
@@ -716,6 +708,7 @@
gtk_container_add(GTK_CONTAINER(openfiles_popup_menu), item);
doc_items.show_paths = gtk_check_menu_item_new_with_mnemonic(_("Show _Paths"));
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(doc_items.show_paths), documents_show_paths);
gtk_widget_show(doc_items.show_paths);
gtk_container_add(GTK_CONTAINER(openfiles_popup_menu), doc_items.show_paths);
g_signal_connect(doc_items.show_paths, "activate",
@@ -836,14 +829,14 @@
}
-static gboolean on_openfiles_tree_selection_changed(gpointer data)
+static gboolean openfiles_go_to_selection(GtkTreeSelection *selection, guint keyval)
{
GtkTreeIter iter;
GtkTreeModel *model;
GeanyDocument *doc = NULL;
/* use switch_notebook_page to ignore changing the notebook page because it is already done */
- if (gtk_tree_selection_get_selected(selection_change.selection, &model, &iter) && ! ignore_callback)
+ if (gtk_tree_selection_get_selected(selection, &model, &iter) && ! ignore_callback)
{
gtk_tree_model_get(model, &iter, DOCUMENTS_DOCUMENT, &doc, -1);
if (! doc)
@@ -853,20 +846,20 @@
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
(GtkWidget*) doc->editor->sci));
- if (selection_change.keyval != GDK_space)
+ if (keyval != GDK_space)
change_focus_to_editor(doc, tv.tree_openfiles);
}
return FALSE;
}
-static gboolean on_taglist_tree_selection_changed(gpointer data)
+static gboolean taglist_go_to_selection(GtkTreeSelection *selection, guint keyval)
{
GtkTreeIter iter;
GtkTreeModel *model;
gint line = 0;
- if (gtk_tree_selection_get_selected(selection_change.selection, &model, &iter))
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
const TMTag *tag;
@@ -882,7 +875,7 @@
if (doc != NULL)
{
navqueue_goto_line(doc, doc, line);
- if (selection_change.keyval != GDK_space)
+ if (keyval != GDK_space)
change_focus_to_editor(doc, NULL);
}
}
@@ -891,29 +884,28 @@
}
-static void update_selection_change(GtkTreeSelection *selection, guint keyval)
-{
- selection_change.selection = selection;
- selection_change.keyval = keyval;
-}
-
-
static gboolean sidebar_key_press_cb(GtkWidget *widget, GdkEventKey *event,
gpointer user_data)
{
may_steal_focus = FALSE;
if (ui_is_keyval_enter_or_return(event->keyval) || event->keyval == GDK_space)
{
+ GtkWidgetClass *widget_class = GTK_WIDGET_GET_CLASS(widget);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
may_steal_focus = TRUE;
- /* delay the query of selection state because this callback is executed before GTK
- * changes the selection (g_signal_connect_after would be better but it doesn't work) */
- update_selection_change(selection, event->keyval);
- if (widget == tv.tree_openfiles) /* tag and doc list have separate handlers */
- g_idle_add(on_openfiles_tree_selection_changed, NULL);
+ /* force the TreeView handler to run before us for it to do its job (selection & stuff).
+ * doing so will prevent further handlers to be run in most cases, but the only one is our
+ * own, so guess it's fine. */
+ if (widget_class->key_press_event)
+ widget_class->key_press_event(widget, event);
+
+ if (widget == tv.tree_openfiles) /* tag and doc list have separate handlers */
+ openfiles_go_to_selection(selection, event->keyval);
else
- g_idle_add(on_taglist_tree_selection_changed, NULL);
+ taglist_go_to_selection(selection, event->keyval);
+
+ return TRUE;
}
return FALSE;
}
@@ -923,7 +915,15 @@
G_GNUC_UNUSED gpointer user_data)
{
GtkTreeSelection *selection;
+ GtkWidgetClass *widget_class = GTK_WIDGET_GET_CLASS(widget);
+ gboolean handled = FALSE;
+ /* force the TreeView handler to run before us for it to do its job (selection & stuff).
+ * doing so will prevent further handlers to be run in most cases, but the only one is our own,
+ * so guess it's fine. */
+ if (widget_class->button_press_event)
+ handled = widget_class->button_press_event(widget, event);
+
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
may_steal_focus = TRUE;
@@ -950,14 +950,11 @@
}
else if (event->button == 1)
{ /* allow reclicking of taglist treeview item */
- /* delay the query of selection state because this callback is executed before GTK
- * changes the selection (g_signal_connect_after would be better but it doesn't work) */
- update_selection_change(selection, 0);
-
if (widget == tv.tree_openfiles)
- g_idle_add(on_openfiles_tree_selection_changed, NULL);
+ openfiles_go_to_selection(selection, 0);
else
- g_idle_add(on_taglist_tree_selection_changed, NULL);
+ taglist_go_to_selection(selection, 0);
+ handled = TRUE;
}
else if (event->button == 3)
{
@@ -976,8 +973,9 @@
gtk_menu_popup(GTK_MENU(tv.popup_taglist), NULL, NULL, NULL, NULL,
event->button, event->time);
}
+ handled = TRUE;
}
- return FALSE;
+ return handled;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5784
http://geany.svn.sourceforge.net/geany/?rev=5784&view=rev
Author: colombanw
Date: 2011-05-09 17:38:02 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Update forced indent settings when setting the filetype
This makes documents created or set to a filetype with forced indent
setting (Makefile, F77) to have the correct setting right away.
Modified Paths:
--------------
branches/0.20.1/ChangeLog
branches/0.20.1/src/document.c
Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog 2011-05-09 17:37:39 UTC (rev 5783)
+++ branches/0.20.1/ChangeLog 2011-05-09 17:38:02 UTC (rev 5784)
@@ -14,6 +14,10 @@
* src/callbacks.c:
Create a new undo action when inserting templates, making sure the user
can undo the template insertion without also undoing a previous action.
+ * src/document.c:
+ Update forced indent settings when setting the filetype. This makes
+ documents created or set to a filetype with forced indent setting
+ (Makefile, F77) to have the correct setting right away.
2011-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: branches/0.20.1/src/document.c
===================================================================
--- branches/0.20.1/src/document.c 2011-05-09 17:37:39 UTC (rev 5783)
+++ branches/0.20.1/src/document.c 2011-05-09 17:38:02 UTC (rev 5784)
@@ -1152,24 +1152,33 @@
}
-void document_apply_indent_settings(GeanyDocument *doc)
+static gboolean apply_forced_indent_settings(GeanyDocument *doc)
{
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(NULL);
- GeanyIndentType type = iprefs->type;
switch (doc->file_type->id)
{
case GEANY_FILETYPES_MAKE:
/* force using tabs for indentation for Makefiles */
editor_set_indent(doc->editor, GEANY_INDENT_TYPE_TABS, iprefs->width);
- return;
+ return TRUE;
case GEANY_FILETYPES_F77:
/* force using spaces for indentation for Fortran 77 */
editor_set_indent(doc->editor, GEANY_INDENT_TYPE_SPACES, iprefs->width);
- return;
- default:
- break;
+ return TRUE;
}
+
+ return FALSE;
+}
+
+
+void document_apply_indent_settings(GeanyDocument *doc)
+{
+ const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(NULL);
+ GeanyIndentType type = iprefs->type;
+
+ if (apply_forced_indent_settings(doc))
+ return;
if (iprefs->detect_type)
{
type = detect_indent_type(doc->editor);
@@ -2585,6 +2594,8 @@
if (ft_changed)
{
+ if (apply_forced_indent_settings(doc)) /* update forced indents, like Makefiles and F77 */
+ ui_document_show_hide(doc);
sidebar_openfiles_update(doc); /* to update the icon */
g_signal_emit_by_name(geany_object, "document-filetype-set", doc, old_ft);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5783
http://geany.svn.sourceforge.net/geany/?rev=5783&view=rev
Author: colombanw
Date: 2011-05-09 17:37:39 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Create a new undo action when inserting templates
This makes sure the user can undo the template insertion without also
undoing a previous action.
Modified Paths:
--------------
branches/0.20.1/ChangeLog
branches/0.20.1/src/callbacks.c
Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog 2011-05-09 17:37:17 UTC (rev 5782)
+++ branches/0.20.1/ChangeLog 2011-05-09 17:37:39 UTC (rev 5783)
@@ -11,6 +11,9 @@
* src/toolbar.c:
Correctly expand the menubar if the toolbar is appended to it but
not visible (closes #3204955).
+ * src/callbacks.c:
+ Create a new undo action when inserting templates, making sure the user
+ can undo the template insertion without also undoing a previous action.
2011-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: branches/0.20.1/src/callbacks.c
===================================================================
--- branches/0.20.1/src/callbacks.c 2011-05-09 17:37:17 UTC (rev 5782)
+++ branches/0.20.1/src/callbacks.c 2011-05-09 17:37:39 UTC (rev 5783)
@@ -1299,7 +1299,9 @@
text = templates_get_template_function(doc, cur_tag);
+ sci_start_undo_action(doc->editor->sci);
sci_insert_text(doc->editor->sci, pos, text);
+ sci_end_undo_action(doc->editor->sci);
g_free(text);
}
@@ -1339,7 +1341,9 @@
verify_click_pos(doc); /* make sure that the click_pos is valid */
+ sci_start_undo_action(doc->editor->sci);
sci_insert_text(doc->editor->sci, editor_info.click_pos, text);
+ sci_end_undo_action(doc->editor->sci);
g_free(text);
}
@@ -1358,7 +1362,9 @@
verify_click_pos(doc); /* make sure that the click_pos is valid */
+ sci_start_undo_action(doc->editor->sci);
sci_insert_text(doc->editor->sci, editor_info.click_pos, text);
+ sci_end_undo_action(doc->editor->sci);
g_free(text);
}
@@ -1374,10 +1380,12 @@
g_return_if_fail(doc != NULL);
text = templates_get_template_changelog(doc);
+ sci_start_undo_action(doc->editor->sci);
sci_insert_text(doc->editor->sci, 0, text);
/* sets the cursor to the right position to type the changelog text,
* the template has 21 chars + length of name and email */
sci_goto_pos(doc->editor->sci, 21 + strlen(template_prefs.developer) + strlen(template_prefs.mail), TRUE);
+ sci_end_undo_action(doc->editor->sci);
g_free(text);
}
@@ -1398,8 +1406,10 @@
fname = doc->file_name;
text = templates_get_template_fileheader(FILETYPE_ID(ft), fname);
+ sci_start_undo_action(doc->editor->sci);
sci_insert_text(doc->editor->sci, 0, text);
sci_goto_pos(doc->editor->sci, 0, FALSE);
+ sci_end_undo_action(doc->editor->sci);
g_free(text);
}
@@ -1451,8 +1461,10 @@
{
verify_click_pos(doc); /* make sure that the click_pos is valid */
+ sci_start_undo_action(doc->editor->sci);
sci_insert_text(doc->editor->sci, editor_info.click_pos, time_str);
sci_goto_pos(doc->editor->sci, editor_info.click_pos + strlen(time_str), FALSE);
+ sci_end_undo_action(doc->editor->sci);
g_free(time_str);
}
else
@@ -1487,7 +1499,9 @@
text = g_strconcat("#include <", user_data, ">\n", NULL);
}
+ sci_start_undo_action(doc->editor->sci);
sci_insert_text(doc->editor->sci, editor_info.click_pos, text);
+ sci_end_undo_action(doc->editor->sci);
g_free(text);
if (pos >= 0)
sci_goto_pos(doc->editor->sci, pos, FALSE);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5781
http://geany.svn.sourceforge.net/geany/?rev=5781&view=rev
Author: colombanw
Date: 2011-05-09 17:36:59 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Correctly expand the menubar if the toolbar is appended to it but not visible (closes #3204955)
Modified Paths:
--------------
branches/0.20.1/ChangeLog
branches/0.20.1/src/toolbar.c
Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog 2011-05-09 17:36:39 UTC (rev 5780)
+++ branches/0.20.1/ChangeLog 2011-05-09 17:36:59 UTC (rev 5781)
@@ -8,6 +8,9 @@
When sorting tags by line, also sort by scope if line is the same, avoiding
wrong sorting if a parent tag is on the same line than its children, and one
of it's children would be sorted before alphabetically (closes #3193982).
+ * src/toolbar.c:
+ Correctly expand the menubar if the toolbar is appended to it but
+ not visible (closes #3204955).
2011-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: branches/0.20.1/src/toolbar.c
===================================================================
--- branches/0.20.1/src/toolbar.c 2011-05-09 17:36:39 UTC (rev 5780)
+++ branches/0.20.1/src/toolbar.c 2011-05-09 17:36:59 UTC (rev 5781)
@@ -479,7 +479,8 @@
/* we need to adjust the packing flags for the menubar to expand it if it is alone in the
* hbox and not expand it if the toolbar is appended */
gtk_box_set_child_packing(GTK_BOX(hbox_menubar), menubar,
- ! toolbar_prefs.append_to_menu, ! toolbar_prefs.append_to_menu, 0, GTK_PACK_START);
+ ! (toolbar_prefs.visible && toolbar_prefs.append_to_menu),
+ ! (toolbar_prefs.visible && toolbar_prefs.append_to_menu), 0, GTK_PACK_START);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5780
http://geany.svn.sourceforge.net/geany/?rev=5780&view=rev
Author: colombanw
Date: 2011-05-09 17:36:39 +0000 (Mon, 09 May 2011)
Log Message:
-----------
When sorting tags by line, also sort by scope if line is the same
This avoids wrong sorting, and then wrong display in the symbols list,
if a parent tag is on the same line than its children, and one of it's
children would be sorted before alphabetically (closes #3193982).
Modified Paths:
--------------
branches/0.20.1/ChangeLog
branches/0.20.1/src/symbols.c
Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog 2011-05-09 17:36:20 UTC (rev 5779)
+++ branches/0.20.1/ChangeLog 2011-05-09 17:36:39 UTC (rev 5780)
@@ -4,6 +4,10 @@
Don't remove and add the symbols tree view if we re-add the same one.
* tagmanager/c.c:
Plug a memory leak.
+ * src/symbols.c:
+ When sorting tags by line, also sort by scope if line is the same, avoiding
+ wrong sorting if a parent tag is on the same line than its children, and one
+ of it's children would be sorted before alphabetically (closes #3193982).
2011-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: branches/0.20.1/src/symbols.c
===================================================================
--- branches/0.20.1/src/symbols.c 2011-05-09 17:36:20 UTC (rev 5779)
+++ branches/0.20.1/src/symbols.c 2011-05-09 17:36:39 UTC (rev 5780)
@@ -451,16 +451,27 @@
}
-/* sort by line only */
+/* sort by line, then scope */
static gint compare_symbol_lines(gconstpointer a, gconstpointer b)
{
const TMTag *tag_a = TM_TAG(a);
const TMTag *tag_b = TM_TAG(b);
+ gint ret;
if (a == NULL || b == NULL)
return 0;
- return tag_a->atts.entry.line - tag_b->atts.entry.line;
+ ret = tag_a->atts.entry.line - tag_b->atts.entry.line;
+ if (ret == 0)
+ {
+ if (tag_a->atts.entry.scope == NULL)
+ return -(tag_a->atts.entry.scope != tag_b->atts.entry.scope);
+ if (tag_b->atts.entry.scope == NULL)
+ return tag_a->atts.entry.scope != tag_b->atts.entry.scope;
+ else
+ return strcmp(tag_a->atts.entry.scope, tag_b->atts.entry.scope);
+ }
+ return ret;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.