Moved all treeview related callback functions from callbacks.c to msgwindow.c and treeviews.c.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@945 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2006-10-29 13:48:39 +00:00
parent 77a424a270
commit 1aa3a761ac
8 changed files with 247 additions and 215 deletions

View File

@ -8,6 +8,10 @@
* src/document.c, src/treeviews.c, src/treeviews.h: * src/document.c, src/treeviews.c, src/treeviews.h:
Colour also the open files list items according to their changed Colour also the open files list items according to their changed
state. 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@btinternet.com> 2006-10-28 Nick Treleaven <nick.treleaven@btinternet.com>

View File

@ -1029,46 +1029,6 @@ toolbar_popup_menu (GtkWidget *widget,
} }
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 void
on_filetype_change (GtkMenuItem *menuitem, on_filetype_change (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
@ -1327,126 +1287,6 @@ on_show_color_chooser1_activate (GtkMenuItem *menuitem,
} }
/* 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 void
on_message_treeview_clear_activate (GtkMenuItem *menuitem, on_message_treeview_clear_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)

View File

@ -130,11 +130,6 @@ gboolean
on_close_all1_activate (GtkMenuItem *menuitem, on_close_all1_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
gboolean
on_tree_view_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
void void
on_crlf_activate (GtkMenuItem *menuitem, on_crlf_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
@ -224,15 +219,6 @@ void
on_entry1_changed (GtkEditable *editable, on_entry1_changed (GtkEditable *editable,
gpointer user_data); gpointer user_data);
void
on_openfiles_tree_selection_changed (GtkTreeSelection *selection,
gpointer data);
void
on_taglist_tree_selection_changed (GtkTreeSelection *selection,
gpointer data);
void void
on_filetype_change (GtkMenuItem *menuitem, on_filetype_change (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
@ -459,14 +445,6 @@ on_tv_notebook_switch_page (GtkNotebook *notebook,
guint page_num, guint page_num,
gpointer user_data); 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 gboolean
on_window_key_press_event (GtkWidget *widget, on_window_key_press_event (GtkWidget *widget,
GdkEventKey *event, GdkEventKey *event,

View File

@ -212,16 +212,6 @@ enum {
GIGABYTE = (MEGABYTE*1024) 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. // implementation in main.c; prototype is here so that all files can use it.

View File

@ -37,6 +37,7 @@
#include <stdlib.h> #include <stdlib.h>
// used for parse_file_line // used for parse_file_line
typedef struct typedef struct
{ {
@ -55,6 +56,8 @@ MessageWindow msgwindow;
static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line); 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() void msgwin_init()
@ -90,7 +93,7 @@ void msgwin_prepare_status_tree_view(void)
gtk_widget_modify_font(msgwindow.tree_status, pango_font_description_from_string(app->msgwin_font)); 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_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 @@ void msgwin_prepare_msg_tree_view(void)
gtk_widget_modify_font(msgwindow.tree_msg, pango_font_description_from_string(app->msgwin_font)); 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) // 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_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 // selection handling
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg)); select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg));
@ -143,7 +146,7 @@ void msgwin_prepare_compiler_tree_view(void)
gtk_widget_modify_font(msgwindow.tree_compiler, pango_font_description_from_string(app->msgwin_font)); 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) // 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_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 // selection handling
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler)); select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler));
@ -589,3 +592,51 @@ static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *
} }
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;
}

View File

@ -33,6 +33,15 @@ enum
COLOR_BLUE 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 typedef struct

View File

@ -27,6 +27,36 @@
#include "callbacks.h" #include "callbacks.h"
#include "treeviews.h" #include "treeviews.h"
#include "document.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 */ /* the following two functions are document-related, but I think they fit better here than in document.c */
@ -44,14 +74,15 @@ void treeviews_prepare_taglist(GtkWidget *tree, GtkTreeStore *store)
gtk_widget_modify_font(tree, pango_font_description_from_string(app->tagbar_font)); 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)); gtk_tree_view_set_model(GTK_TREE_VIEW(tree), GTK_TREE_MODEL(store));
g_signal_connect(G_OBJECT(tree), "button-press-event", 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); gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE);
// selection handling // selection handling
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); 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 @@ void treeviews_init_tag_list(gint idx)
/* does some preparing things to the open files list widget */ /* does some preparing things to the open files list widget */
void treeviews_prepare_openfiles(void) void treeviews_prepare_openfiles()
{ {
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
GtkTreeViewColumn *column; GtkTreeViewColumn *column;
@ -255,7 +286,7 @@ void treeviews_prepare_openfiles(void)
gtk_widget_modify_font(tv.tree_openfiles, pango_font_description_from_string(app->tagbar_font)); 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_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 // selection handling
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles)); select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles));
@ -306,7 +337,7 @@ void treeviews_openfiles_update(GtkTreeIter iter, const gchar *string, gboolean
} }
void treeviews_openfiles_update_all(void) void treeviews_openfiles_update_all()
{ {
guint i; guint i;
gint idx; gint idx;
@ -329,7 +360,7 @@ void treeviews_openfiles_update_all(void)
} }
void treeviews_create_taglist_popup_menu(void) void treeviews_create_taglist_popup_menu()
{ {
GtkWidget *item; GtkWidget *item;
@ -341,7 +372,7 @@ void treeviews_create_taglist_popup_menu(void)
gtk_widget_show(item); gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item); gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item);
g_signal_connect((gpointer) item, "activate", 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")); item = gtk_image_menu_item_new_with_label(_("Hide sidebar"));
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
@ -349,11 +380,11 @@ void treeviews_create_taglist_popup_menu(void)
gtk_widget_show(item); gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item); gtk_container_add(GTK_CONTAINER(tv.popup_taglist), item);
g_signal_connect((gpointer) item, "activate", 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; GtkWidget *item;
@ -363,7 +394,7 @@ void treeviews_create_openfiles_popup_menu(void)
gtk_widget_show(item); gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item); gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
g_signal_connect((gpointer) item, "activate", 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(); item = gtk_separator_menu_item_new();
gtk_widget_show(item); gtk_widget_show(item);
@ -373,7 +404,7 @@ void treeviews_create_openfiles_popup_menu(void)
gtk_widget_show(item); gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item); gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
g_signal_connect((gpointer) item, "activate", 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")); item = gtk_image_menu_item_new_with_label(_("Reload"));
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
@ -381,7 +412,7 @@ void treeviews_create_openfiles_popup_menu(void)
gtk_widget_show(item); gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item); gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
g_signal_connect((gpointer) item, "activate", 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(); item = gtk_separator_menu_item_new();
gtk_widget_show(item); gtk_widget_show(item);
@ -392,16 +423,16 @@ void treeviews_create_openfiles_popup_menu(void)
gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU)); gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU));
gtk_widget_show(item); gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item); gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
g_signal_connect((gpointer) item, "activate", g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_openfiles_tree_popup_clicked),
G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(3)); GINT_TO_POINTER(OPENFILES_ACTION_HIDE));
item = gtk_image_menu_item_new_with_label(_("Hide sidebar")); item = gtk_image_menu_item_new_with_label(_("Hide sidebar"));
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU)); gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU));
gtk_widget_show(item); gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item); gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), item);
g_signal_connect((gpointer) item, "activate", g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_openfiles_tree_popup_clicked),
G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(4)); GINT_TO_POINTER(OPENFILES_ACTION_HIDE_ALL));
} }
@ -422,3 +453,132 @@ gboolean treeviews_find_node(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter
else return FALSE; 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;
}

View File

@ -52,19 +52,19 @@ gint treeviews_sort_tag_list(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b
void treeviews_init_tag_list(gint idx); 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); 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(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_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 /* 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 * treeview, in case of a match the row is selected and TRUE is returned