SF.net SVN: geany: [945] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Oct 29 13:48:52 UTC 2006


Revision: 945
          http://svn.sourceforge.net/geany/?rev=945&view=rev
Author:   eht16
Date:     2006-10-29 05:48:39 -0800 (Sun, 29 Oct 2006)

Log Message:
-----------
Moved all treeview related callback functions from callbacks.c to msgwindow.c and treeviews.c.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
    trunk/src/callbacks.h
    trunk/src/geany.h
    trunk/src/msgwindow.c
    trunk/src/msgwindow.h
    trunk/src/treeviews.c
    trunk/src/treeviews.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-10-29 13:03:13 UTC (rev 944)
+++ trunk/ChangeLog	2006-10-29 13:48:39 UTC (rev 945)
@@ -8,6 +8,10 @@
  * src/document.c, src/treeviews.c, src/treeviews.h:
    Colour also the open files list items according to their changed
    state.
+ * src/callbacks.c, src/callbacks.h, src/msgwindow.c, src/msgwindow.h,
+   src/treeviews.c, src/treeviews.h, src/geany.h:
+   Moved all treeview related callback functions from callbacks.c to
+   msgwindow.c and treeviews.c.
 
 
 2006-10-28  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-10-29 13:03:13 UTC (rev 944)
+++ trunk/src/callbacks.c	2006-10-29 13:48:39 UTC (rev 945)
@@ -1030,46 +1030,6 @@
 
 
 void
-on_taglist_tree_selection_changed      (GtkTreeSelection *selection,
-                                        gpointer data)
-{
-	GtkTreeIter iter;
-	GtkTreeModel *model;
-	gchar *string;
-
-	if (gtk_tree_selection_get_selected(selection, &model, &iter))
-	{
-		gtk_tree_model_get(model, &iter, 0, &string, -1);
-		if (string && (strlen(string) > 0))
-		{
-			gint idx = document_get_cur_idx();
-			utils_goto_line(idx, utils_get_local_tag(idx, string));
-			g_free(string);
-		}
-	}
-}
-
-
-void
-on_openfiles_tree_selection_changed    (GtkTreeSelection *selection,
-                                        gpointer data)
-{
-	GtkTreeIter iter;
-	GtkTreeModel *model;
-	gint idx = 0;
-
-	// use switch_notebook_page to ignore changing the notebook page because it is already done
-	if (gtk_tree_selection_get_selected(selection, &model, &iter) && ! app->ignore_callback)
-	{
-		gtk_tree_model_get(model, &iter, 1, &idx, -1);
-		gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook),
-					gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook),
-					(GtkWidget*) doc_list[idx].sci));
-	}
-}
-
-
-void
 on_filetype_change                     (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
@@ -1327,127 +1287,7 @@
 }
 
 
-/* callback function for all treeview widgets */
-gboolean
-on_tree_view_button_press_event        (GtkWidget *widget,
-                                        GdkEventButton *event,
-                                        gpointer user_data)
-{
-	// user_data might be NULL, GPOINTER_TO_INT returns 0 if called with NULL
-	
-	if (event->button == 1)
-	{
-		switch (GPOINTER_TO_INT(user_data))
-		{
-			case TREEVIEW_SYMBOL:
-			{	// allow reclicking of taglist treeview item
-				GtkTreeSelection *select =
-					gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
-				on_taglist_tree_selection_changed(select, NULL);
-				break;
-			}
-			case MSG_COMPILER:
-			{	// single click in the compiler treeview
-				msgwin_goto_compiler_file_line();
-				break;
-			}
-			case MSG_MESSAGE:
-			{	// single click in the message treeview (results of 'Find usage')
-				msgwin_goto_messages_file_line();
-				break;
-			}
-		}
-	}
-
-	if (event->button == 3)
-	{	// popupmenu to hide or clear the active treeview
-		if (GPOINTER_TO_INT(user_data) == MSG_STATUS)
-			gtk_menu_popup(GTK_MENU(msgwindow.popup_status_menu), NULL, NULL, NULL, NULL, event->button, event->time);
-		else if (GPOINTER_TO_INT(user_data) == MSG_MESSAGE)
-			gtk_menu_popup(GTK_MENU(msgwindow.popup_msg_menu), NULL, NULL, NULL, NULL, event->button, event->time);
-		else if (GPOINTER_TO_INT(user_data) == MSG_COMPILER)
-			gtk_menu_popup(GTK_MENU(msgwindow.popup_compiler_menu), NULL, NULL, NULL, NULL, event->button, event->time);
-		else if (GPOINTER_TO_INT(user_data) == TREEVIEW_OPENFILES)
-			gtk_menu_popup(GTK_MENU(tv.popup_openfiles), NULL, NULL, NULL, NULL, event->button, event->time);
-		else if (GPOINTER_TO_INT(user_data) == TREEVIEW_SYMBOL)
-			gtk_menu_popup(GTK_MENU(tv.popup_taglist), NULL, NULL, NULL, NULL, event->button, event->time);
-	}
-	return FALSE;
-}
-
-
 void
-on_openfiles_tree_popup_clicked        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	GtkTreeIter iter;
-	GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles));
-	GtkTreeModel *model;
-	gint idx = -1;
-
-	if (gtk_tree_selection_get_selected(selection, &model, &iter))
-	{
-		gtk_tree_model_get(model, &iter, 1, &idx, -1);
-		if (idx >= 0)
-		{
-			switch (GPOINTER_TO_INT(user_data))
-			{
-				case 0:
-				{
-					document_remove(gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook), GTK_WIDGET(doc_list[idx].sci)));
-					break;
-				}
-				case 1:
-				{
-					if (doc_list[idx].changed) document_save_file(idx, FALSE);
-					break;
-				}
-				case 2:
-				{
-					on_toolbutton23_clicked(NULL, NULL);
-					break;
-				}
-				case 3:
-				{
-					app->sidebar_openfiles_visible = FALSE;
-					ui_treeviews_show_hide(FALSE);
-					break;
-				}
-				case 4:
-				{
-					app->sidebar_visible = FALSE;
-					ui_treeviews_show_hide(TRUE);
-					break;
-				}
-			}
-		}
-	}
-}
-
-
-void
-on_taglist_tree_popup_clicked          (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	switch (GPOINTER_TO_INT(user_data))
-	{
-		case 0:
-		{
-			app->sidebar_symbol_visible = FALSE;
-			ui_treeviews_show_hide(FALSE);
-			break;
-		}
-		case 1:
-		{
-			app->sidebar_visible = FALSE;
-			ui_treeviews_show_hide(TRUE);
-			break;
-		}
-	}
-}
-
-
-void
 on_message_treeview_clear_activate     (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {

Modified: trunk/src/callbacks.h
===================================================================
--- trunk/src/callbacks.h	2006-10-29 13:03:13 UTC (rev 944)
+++ trunk/src/callbacks.h	2006-10-29 13:48:39 UTC (rev 945)
@@ -130,11 +130,6 @@
 on_close_all1_activate                 (GtkMenuItem     *menuitem,
                                         gpointer         user_data);
 
-gboolean
-on_tree_view_button_press_event        (GtkWidget *widget,
-                                        GdkEventButton *event,
-                                        gpointer user_data);
-
 void
 on_crlf_activate                       (GtkMenuItem     *menuitem,
                                         gpointer         user_data);
@@ -224,16 +219,7 @@
 on_entry1_changed                      (GtkEditable     *editable,
                                         gpointer         user_data);
 
-
 void
-on_openfiles_tree_selection_changed    (GtkTreeSelection *selection,
-                                        gpointer data);
-
-void
-on_taglist_tree_selection_changed      (GtkTreeSelection *selection,
-                                        gpointer data);
-
-void
 on_filetype_change                     (GtkMenuItem     *menuitem,
                                         gpointer         user_data);
 
@@ -459,14 +445,6 @@
                                         guint            page_num,
                                         gpointer         user_data);
 
-void
-on_openfiles_tree_popup_clicked        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_taglist_tree_popup_clicked          (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
 gboolean
 on_window_key_press_event              (GtkWidget *widget,
                                         GdkEventKey *event,

Modified: trunk/src/geany.h
===================================================================
--- trunk/src/geany.h	2006-10-29 13:03:13 UTC (rev 944)
+++ trunk/src/geany.h	2006-10-29 13:48:39 UTC (rev 945)
@@ -212,16 +212,6 @@
 	GIGABYTE = (MEGABYTE*1024)
 };
 
-enum
-{
-	MSG_STATUS = 0, // force it to start at 0 to keep in sync with the notebook page numbers
-	MSG_COMPILER,
-	MSG_MESSAGE,
-	MSG_SCRATCH,
-	MSG_VTE,
-	TREEVIEW_SYMBOL,
-	TREEVIEW_OPENFILES
-};
 
 
 // implementation in main.c; prototype is here so that all files can use it.

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2006-10-29 13:03:13 UTC (rev 944)
+++ trunk/src/msgwindow.c	2006-10-29 13:48:39 UTC (rev 945)
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 
 
+
 // used for parse_file_line
 typedef struct
 {
@@ -55,6 +56,8 @@
 
 
 static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line);
+static gboolean on_msgwin_button_press_event(GtkWidget *widget, GdkEventButton *event,
+																			gpointer user_data);
 
 
 void msgwin_init()
@@ -90,7 +93,7 @@
 
 	gtk_widget_modify_font(msgwindow.tree_status, pango_font_description_from_string(app->msgwin_font));
 	g_signal_connect(G_OBJECT(msgwindow.tree_status), "button-press-event",
-				G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(MSG_STATUS));
+				G_CALLBACK(on_msgwin_button_press_event), GINT_TO_POINTER(MSG_STATUS));
 
 }
 
@@ -115,7 +118,7 @@
 	gtk_widget_modify_font(msgwindow.tree_msg, pango_font_description_from_string(app->msgwin_font));
 	// use button-release-event so the selection has changed (connect_after button-press-event doesn't work)
 	g_signal_connect(G_OBJECT(msgwindow.tree_msg), "button-release-event",
-					G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(MSG_MESSAGE));
+					G_CALLBACK(on_msgwin_button_press_event), GINT_TO_POINTER(MSG_MESSAGE));
 
 	// selection handling
 	select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg));
@@ -143,7 +146,7 @@
 	gtk_widget_modify_font(msgwindow.tree_compiler, pango_font_description_from_string(app->msgwin_font));
 	// use button-release-event so the selection has changed (connect_after button-press-event doesn't work)
 	g_signal_connect(G_OBJECT(msgwindow.tree_compiler), "button-release-event",
-					G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(MSG_COMPILER));
+					G_CALLBACK(on_msgwin_button_press_event), GINT_TO_POINTER(MSG_COMPILER));
 
 	// selection handling
 	select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler));
@@ -589,3 +592,51 @@
 }
 
 
+static gboolean on_msgwin_button_press_event(GtkWidget *widget, GdkEventButton *event,
+																			gpointer user_data)
+{
+	// user_data might be NULL, GPOINTER_TO_INT returns 0 if called with NULL
+	
+	if (event->button == 1)
+	{
+		switch (GPOINTER_TO_INT(user_data))
+		{
+			case MSG_COMPILER:
+			{	// single click in the compiler treeview
+				msgwin_goto_compiler_file_line();
+				break;
+			}
+			case MSG_MESSAGE:
+			{	// single click in the message treeview (results of 'Find usage')
+				msgwin_goto_messages_file_line();
+				break;
+			}
+		}
+	}
+
+	if (event->button == 3)
+	{	// popupmenu to hide or clear the active treeview
+		switch (GPOINTER_TO_INT(user_data))
+		{
+			case MSG_STATUS:
+			{
+				gtk_menu_popup(GTK_MENU(msgwindow.popup_status_menu), NULL, NULL, NULL, NULL,
+																	event->button, event->time);
+				break;
+			}
+			case MSG_MESSAGE:
+			{
+				gtk_menu_popup(GTK_MENU(msgwindow.popup_msg_menu), NULL, NULL, NULL, NULL,
+																	event->button, event->time);
+				break;
+			}
+			case MSG_COMPILER:
+			{
+				gtk_menu_popup(GTK_MENU(msgwindow.popup_compiler_menu), NULL, NULL, NULL, NULL,
+																	event->button, event->time);
+				break;
+			}
+		}
+	}
+	return FALSE;
+}

Modified: trunk/src/msgwindow.h
===================================================================
--- trunk/src/msgwindow.h	2006-10-29 13:03:13 UTC (rev 944)
+++ trunk/src/msgwindow.h	2006-10-29 13:48:39 UTC (rev 945)
@@ -33,8 +33,17 @@
 	COLOR_BLUE
 };
 
+enum
+{
+	MSG_STATUS = 0, // force it to start at 0 to keep in sync with the notebook page numbers
+	MSG_COMPILER,
+	MSG_MESSAGE,
+	MSG_SCRATCH,
+	MSG_VTE,
+};
 
 
+
 typedef struct
 {
 	GtkListStore	*store_status;

Modified: trunk/src/treeviews.c
===================================================================
--- trunk/src/treeviews.c	2006-10-29 13:03:13 UTC (rev 944)
+++ trunk/src/treeviews.c	2006-10-29 13:48:39 UTC (rev 945)
@@ -27,8 +27,38 @@
 #include "callbacks.h"
 #include "treeviews.h"
 #include "document.h"
+#include "utils.h"
+#include "ui_utils.h"
 
 
+enum
+{
+	TREEVIEW_SYMBOL = 0,
+	TREEVIEW_OPENFILES
+};
+
+enum
+{
+	OPENFILES_ACTION_REMOVE = 0,
+	OPENFILES_ACTION_SAVE,
+	OPENFILES_ACTION_RELOAD,
+	OPENFILES_ACTION_HIDE,
+	OPENFILES_ACTION_HIDE_ALL,
+	SYMBOL_ACTION_HIDE,
+	SYMBOL_ACTION_HIDE_ALL
+};
+
+
+/* callback prototypes */
+static void on_taglist_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_data);
+static void on_openfiles_tree_selection_changed(GtkTreeSelection *selection, gpointer data);
+static void on_openfiles_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_data);
+static void on_taglist_tree_selection_changed(GtkTreeSelection *selection, gpointer data);
+static gboolean on_treeviews_button_press_event(GtkWidget *widget, GdkEventButton *event,
+																			gpointer user_data);
+
+
+
 /* the following two functions are document-related, but I think they fit better here than in document.c */
 void treeviews_prepare_taglist(GtkWidget *tree, GtkTreeStore *store)
 {
@@ -44,14 +74,15 @@
 	gtk_widget_modify_font(tree, pango_font_description_from_string(app->tagbar_font));
 	gtk_tree_view_set_model(GTK_TREE_VIEW(tree), GTK_TREE_MODEL(store));
 	g_signal_connect(G_OBJECT(tree), "button-press-event",
-						G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(TREEVIEW_SYMBOL));
+					G_CALLBACK(on_treeviews_button_press_event), GINT_TO_POINTER(TREEVIEW_SYMBOL));
 
 	gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE);
 
 	// selection handling
 	select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
 	gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
-	g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(on_taglist_tree_selection_changed), NULL);
+	g_signal_connect(G_OBJECT(select), "changed",
+				G_CALLBACK(on_taglist_tree_selection_changed), NULL);
 }
 
 
@@ -228,7 +259,7 @@
 
 
 /* does some preparing things to the open files list widget */
-void treeviews_prepare_openfiles(void)
+void treeviews_prepare_openfiles()
 {
 	GtkCellRenderer *renderer;
 	GtkTreeViewColumn *column;
@@ -255,7 +286,7 @@
 
 	gtk_widget_modify_font(tv.tree_openfiles, pango_font_description_from_string(app->tagbar_font));
 	g_signal_connect(G_OBJECT(tv.tree_openfiles), "button-press-event",
-						G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(TREEVIEW_OPENFILES));
+						G_CALLBACK(on_treeviews_button_press_event), GINT_TO_POINTER(TREEVIEW_OPENFILES));
 
 	// selection handling
 	select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles));
@@ -306,7 +337,7 @@
 }
 
 
-void treeviews_openfiles_update_all(void)
+void treeviews_openfiles_update_all()
 {
 	guint i;
 	gint idx;
@@ -329,7 +360,7 @@
 }
 
 
-void treeviews_create_taglist_popup_menu(void)
+void treeviews_create_taglist_popup_menu()
 {
 	GtkWidget *item;
 
@@ -341,7 +372,7 @@
 	gtk_widget_show(item);
 	gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item);
 	g_signal_connect((gpointer) item, "activate",
-				G_CALLBACK(on_taglist_tree_popup_clicked), GINT_TO_POINTER(0));
+				G_CALLBACK(on_taglist_tree_popup_clicked), GINT_TO_POINTER(SYMBOL_ACTION_HIDE));
 
 	item = gtk_image_menu_item_new_with_label(_("Hide sidebar"));
 	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
@@ -349,11 +380,11 @@
 	gtk_widget_show(item);
 	gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item);
 	g_signal_connect((gpointer) item, "activate",
-				G_CALLBACK(on_taglist_tree_popup_clicked), GINT_TO_POINTER(1));
+				G_CALLBACK(on_taglist_tree_popup_clicked), GINT_TO_POINTER(SYMBOL_ACTION_HIDE_ALL));
 }
 
 
-void treeviews_create_openfiles_popup_menu(void)
+void treeviews_create_openfiles_popup_menu()
 {
 	GtkWidget *item;
 
@@ -363,7 +394,7 @@
 	gtk_widget_show(item);
 	gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
 	g_signal_connect((gpointer) item, "activate",
-				G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(0));
+				G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(OPENFILES_ACTION_REMOVE));
 
 	item = gtk_separator_menu_item_new();
 	gtk_widget_show(item);
@@ -373,7 +404,7 @@
 	gtk_widget_show(item);
 	gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
 	g_signal_connect((gpointer) item, "activate",
-				G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(1));
+				G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(OPENFILES_ACTION_SAVE));
 
 	item = gtk_image_menu_item_new_with_label(_("Reload"));
 	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
@@ -381,7 +412,7 @@
 	gtk_widget_show(item);
 	gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
 	g_signal_connect((gpointer) item, "activate",
-				G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(2));
+				G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(OPENFILES_ACTION_RELOAD));
 
 	item = gtk_separator_menu_item_new();
 	gtk_widget_show(item);
@@ -392,16 +423,16 @@
 		gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU));
 	gtk_widget_show(item);
 	gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
-	g_signal_connect((gpointer) item, "activate",
-				G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(3));
+	g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_openfiles_tree_popup_clicked),
+												GINT_TO_POINTER(OPENFILES_ACTION_HIDE));
 
 	item = gtk_image_menu_item_new_with_label(_("Hide sidebar"));
 	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
 		gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU));
 	gtk_widget_show(item);
 	gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
-	g_signal_connect((gpointer) item, "activate",
-				G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(4));
+	g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_openfiles_tree_popup_clicked),
+													GINT_TO_POINTER(OPENFILES_ACTION_HIDE_ALL));
 }
 
 
@@ -422,3 +453,132 @@
 	else return FALSE;
 }
 
+
+/* callbacks */
+
+static void on_openfiles_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_data)
+{
+	GtkTreeIter iter;
+	GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles));
+	GtkTreeModel *model;
+	gint idx = -1;
+
+	if (gtk_tree_selection_get_selected(selection, &model, &iter))
+	{
+		gtk_tree_model_get(model, &iter, 1, &idx, -1);
+		if (idx >= 0)
+		{
+			switch (GPOINTER_TO_INT(user_data))
+			{
+				case OPENFILES_ACTION_REMOVE:
+				{
+					document_remove(gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook), GTK_WIDGET(doc_list[idx].sci)));
+					break;
+				}
+				case OPENFILES_ACTION_SAVE:
+				{
+					if (doc_list[idx].changed) document_save_file(idx, FALSE);
+					break;
+				}
+				case OPENFILES_ACTION_RELOAD:
+				{
+					on_toolbutton23_clicked(NULL, NULL);
+					break;
+				}
+				case OPENFILES_ACTION_HIDE:
+				{
+					app->sidebar_openfiles_visible = FALSE;
+					ui_treeviews_show_hide(FALSE);
+					break;
+				}
+				case OPENFILES_ACTION_HIDE_ALL:
+				{
+					app->sidebar_visible = FALSE;
+					ui_treeviews_show_hide(TRUE);
+					break;
+				}
+			}
+		}
+	}
+}
+
+
+static void on_openfiles_tree_selection_changed(GtkTreeSelection *selection, gpointer data)
+{
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+	gint idx = 0;
+
+	// use switch_notebook_page to ignore changing the notebook page because it is already done
+	if (gtk_tree_selection_get_selected(selection, &model, &iter) && ! app->ignore_callback)
+	{
+		gtk_tree_model_get(model, &iter, 1, &idx, -1);
+		gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook),
+					gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook),
+					(GtkWidget*) doc_list[idx].sci));
+	}
+}
+
+
+static void on_taglist_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_data)
+{
+	switch (GPOINTER_TO_INT(user_data))
+	{
+		case SYMBOL_ACTION_HIDE:
+		{
+			app->sidebar_symbol_visible = FALSE;
+			ui_treeviews_show_hide(FALSE);
+			break;
+		}
+		case SYMBOL_ACTION_HIDE_ALL:
+		{
+			app->sidebar_visible = FALSE;
+			ui_treeviews_show_hide(TRUE);
+			break;
+		}
+	}
+}
+
+
+static void on_taglist_tree_selection_changed(GtkTreeSelection *selection, gpointer data)
+{
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+	gchar *string;
+
+	if (gtk_tree_selection_get_selected(selection, &model, &iter))
+	{
+		gtk_tree_model_get(model, &iter, 0, &string, -1);
+		if (string && (strlen(string) > 0))
+		{
+			gint idx = document_get_cur_idx();
+			utils_goto_line(idx, utils_get_local_tag(idx, string));
+			g_free(string);
+		}
+	}
+}
+
+
+static gboolean on_treeviews_button_press_event(GtkWidget *widget, GdkEventButton *event,
+																			gpointer user_data)
+{
+	if (event->button == 1)
+	{
+		if (GPOINTER_TO_INT(user_data) == TREEVIEW_SYMBOL)
+		{	// allow reclicking of taglist treeview item
+			GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
+			on_taglist_tree_selection_changed(select, NULL);
+		}
+	}
+
+	if (event->button == 3)
+	{	// popupmenu to hide or clear the active treeview
+		if (GPOINTER_TO_INT(user_data) == TREEVIEW_OPENFILES)
+			gtk_menu_popup(GTK_MENU(tv.popup_openfiles), NULL, NULL, NULL, NULL,
+																event->button, event->time);
+		else if (GPOINTER_TO_INT(user_data) == TREEVIEW_SYMBOL)
+			gtk_menu_popup(GTK_MENU(tv.popup_taglist), NULL, NULL, NULL, NULL,
+																event->button, event->time);
+	}
+	return FALSE;
+}

Modified: trunk/src/treeviews.h
===================================================================
--- trunk/src/treeviews.h	2006-10-29 13:03:13 UTC (rev 944)
+++ trunk/src/treeviews.h	2006-10-29 13:48:39 UTC (rev 945)
@@ -52,19 +52,19 @@
 
 void treeviews_init_tag_list(gint idx);
 
-void treeviews_prepare_openfiles(void);
+void treeviews_prepare_openfiles();
 
 GtkTreeIter treeviews_openfiles_add(gint idx, const gchar *string, gboolean changed);
 
 void treeviews_openfiles_update(GtkTreeIter iter, const gchar *string, gboolean changed);
 
-void treeviews_openfiles_update_all(void);
+void treeviews_openfiles_update_all();
 
 void treeviews_openfiles_remove(GtkTreeIter iter);
 
-void treeviews_create_openfiles_popup_menu(void);
+void treeviews_create_openfiles_popup_menu();
 
-void treeviews_create_taglist_popup_menu(void);
+void treeviews_create_taglist_popup_menu();
 
 /* compares the given data (GINT_TO_PONTER(idx)) with the idx from the selected row of openfiles
  * treeview, in case of a match the row is selected and TRUE is returned


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