[geany/geany] 62a823: Merge pull request #475 from techee/retval_refresh

Colomban Wendling git-noreply at xxxxx
Sun May 3 20:36:16 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 03 May 2015 20:36:16 UTC
Commit:      62a8232901a831c694109b491f60b35aeaa579cc
             https://github.com/geany/geany/commit/62a8232901a831c694109b491f60b35aeaa579cc

Log Message:
-----------
Merge pull request #475 from techee/retval_refresh

Reload tooltip in the symbol tree also on tag update


Modified Paths:
--------------
    src/sidebar.c
    src/symbols.c
    tagmanager/src/tm_tag.c
    tagmanager/src/tm_tag.h

Modified: src/sidebar.c
13 lines changed, 13 insertions(+), 0 deletions(-)
===================================================================
@@ -192,6 +192,9 @@ void sidebar_update_tag_list(GeanyDocument *doc, gboolean update)
 
 	g_return_if_fail(doc == NULL || doc->is_valid);
 
+	if (gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.sidebar_notebook)) != TREEVIEW_SYMBOL)
+		return; /* don't bother updating symbol tree if we don't see it */
+
 	/* changes the tree view to the given one, trying not to do useless changes */
 	#define CHANGE_TREE(new_child) \
 		G_STMT_START { \
@@ -1081,6 +1084,14 @@ static void on_save_settings(void)
 }
 
 
+static void on_sidebar_switch_page(GtkNotebook *notebook,
+	gpointer page, guint page_num, gpointer user_data)
+{
+	if (page_num == TREEVIEW_SYMBOL)
+		sidebar_update_tag_list(document_get_current(), TRUE);
+}
+
+
 void sidebar_init(void)
 {
 	StashGroup *group;
@@ -1103,6 +1114,8 @@ void sidebar_init(void)
 	/* tabs may have changed when sidebar is reshown */
 	g_signal_connect(main_widgets.sidebar_notebook, "show",
 		G_CALLBACK(sidebar_tabs_show_hide), NULL);
+	g_signal_connect_after(main_widgets.sidebar_notebook, "switch-page",
+		G_CALLBACK(on_sidebar_switch_page), NULL);
 
 	sidebar_tabs_show_hide(GTK_NOTEBOOK(main_widgets.sidebar_notebook), NULL, 0, NULL);
 }


Modified: src/symbols.c
27 lines changed, 17 insertions(+), 10 deletions(-)
===================================================================
@@ -1422,7 +1422,6 @@ static void update_tree_tags(GeanyDocument *doc, GList **tags)
 				cont = tree_store_remove_row(store, &iter);
 			else /* tag still exist, update it */
 			{
-				const gchar *name;
 				const gchar *parent_name;
 				TMTag *found = found_item->data;
 
@@ -1431,13 +1430,22 @@ static void update_tree_tags(GeanyDocument *doc, GList **tags)
 				if (parent_name && ! g_hash_table_lookup(parents_table, parent_name))
 					parent_name = NULL;
 
-				/* only update fields that (can) have changed (name that holds line
-				 * number, and the tag itself) */
-				name = get_symbol_name(doc, found, parent_name != NULL);
-				gtk_tree_store_set(store, &iter,
-						SYMBOLS_COLUMN_NAME, name,
-						SYMBOLS_COLUMN_TAG, found,
-						-1);
+				if (!tm_tags_equal(tag, found))
+				{
+					const gchar *name;
+					gchar *tooltip;
+
+					/* only update fields that (can) have changed (name that holds line
+					 * number, tooltip, and the tag itself) */
+					name = get_symbol_name(doc, found, parent_name != NULL);
+					tooltip = get_symbol_tooltip(doc, found);
+					gtk_tree_store_set(store, &iter,
+							SYMBOLS_COLUMN_NAME, name,
+							SYMBOLS_COLUMN_TOOLTIP, tooltip,
+							SYMBOLS_COLUMN_TAG, found,
+							-1);
+					g_free(tooltip);
+				}
 
 				update_parents_table(parents_table, found, parent_name, &iter);
 
@@ -1513,10 +1521,9 @@ static void update_tree_tags(GeanyDocument *doc, GList **tags)
 			expand = ! gtk_tree_model_iter_has_child(model, parent);
 
 			/* insert the new element */
-			gtk_tree_store_append(store, &iter, parent);
 			name = get_symbol_name(doc, tag, parent_name != NULL);
 			tooltip = get_symbol_tooltip(doc, tag);
-			gtk_tree_store_set(store, &iter,
+			gtk_tree_store_insert_with_values(store, &iter, parent, 0,
 					SYMBOLS_COLUMN_NAME, name,
 					SYMBOLS_COLUMN_TOOLTIP, tooltip,
 					SYMBOLS_COLUMN_ICON, icon,


Modified: tagmanager/src/tm_tag.c
20 lines changed, 20 insertions(+), 0 deletions(-)
===================================================================
@@ -734,6 +734,26 @@ static gint tm_tag_compare(gconstpointer ptr1, gconstpointer ptr2, gpointer user
 	return returnval;
 }
 
+gboolean tm_tags_equal(const TMTag *a, const TMTag *b)
+{
+	if (a == b)
+		return TRUE;
+
+	return (a->line == b->line &&
+			a->file == b->file /* ptr comparison */ &&
+			strcmp(FALLBACK(a->name, ""), FALLBACK(b->name, "")) == 0 &&
+			a->type == b->type &&
+			a->local == b->local &&
+			a->pointerOrder == b->pointerOrder &&
+			a->access == b->access &&
+			a->impl == b->impl &&
+			a->lang == b->lang &&
+			strcmp(FALLBACK(a->scope, ""), FALLBACK(b->scope, "")) == 0 &&
+			strcmp(FALLBACK(a->arglist, ""), FALLBACK(b->arglist, "")) == 0 &&
+			strcmp(FALLBACK(a->inheritance, ""), FALLBACK(b->inheritance, "")) == 0 &&
+			strcmp(FALLBACK(a->var_type, ""), FALLBACK(b->var_type, "")) == 0);
+}
+
 /*
  Removes NULL tag entries from an array of tags. Called after tm_tags_dedup() since 
  this function substitutes duplicate entries with NULL


Modified: tagmanager/src/tm_tag.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -189,6 +189,7 @@ void tm_tag_unref(TMTag *tag);
 
 TMTag *tm_tag_ref(TMTag *tag);
 
+gboolean tm_tags_equal(const TMTag *a, const TMTag *b);
 
 #ifdef TM_DEBUG /* various debugging functions */
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list