From 59335b597f3d46e08d9f6f9c16f20afa192320a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Wed, 18 Oct 2006 20:48:54 +0000 Subject: [PATCH] Use enum values to reference different treeview widgets (code cleanup). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@904 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 3 +++ src/callbacks.c | 16 ++++++++-------- src/geany.h | 11 +++++++++++ src/msgwindow.c | 6 +++--- src/msgwindow.h | 8 -------- src/treeviews.c | 4 ++-- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1659e1f7..88745227 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ * src/utils.c, src/treeviews.c, tagmanager/c.c: Use "::" as context separator only for C++, otherwise use ".". Detect module declarations in D and put them in the symbol list. + * src/callbacks.c, src/geany.h, src/msgwindow.c, src/treeviews.c: + Use enum values to reference different treeview widgets + (code cleanup). 2006-10-18 Nick Treleaven diff --git a/src/callbacks.c b/src/callbacks.c index bb31c450..e55f4eb6 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -1404,17 +1404,17 @@ on_tree_view_button_press_event (GtkWidget *widget, { if (event->type == GDK_2BUTTON_PRESS && user_data) { - if (GPOINTER_TO_INT(user_data) == 4) + if (GPOINTER_TO_INT(user_data) == MSG_MESSAGE) { // double click in the message treeview (results of 'Find usage') msgwin_goto_messages_file_line(); } - else if (GPOINTER_TO_INT(user_data) == 5) + else if (GPOINTER_TO_INT(user_data) == MSG_COMPILER) { // double click in the compiler treeview msgwin_goto_compiler_file_line(); } } - if (event->button == 1 && user_data && GPOINTER_TO_INT(user_data) == 7) + if (event->button == 1 && user_data && GPOINTER_TO_INT(user_data) == TREEVIEW_SYMBOL) { // allow reclicking of taglist treeview item GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); @@ -1423,15 +1423,15 @@ on_tree_view_button_press_event (GtkWidget *widget, if (user_data && event->button == 3) { // popupmenu to hide or clear the active treeview - if (user_data && GPOINTER_TO_INT(user_data) == 3) + 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 (user_data && GPOINTER_TO_INT(user_data) == 4) + 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 (user_data && GPOINTER_TO_INT(user_data) == 5) + 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 (user_data && GPOINTER_TO_INT(user_data) == 6) + 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 (user_data && GPOINTER_TO_INT(user_data) == 7) + 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; diff --git a/src/geany.h b/src/geany.h index 2b0ee75b..faa43a33 100644 --- a/src/geany.h +++ b/src/geany.h @@ -210,5 +210,16 @@ enum { GIGABYTE = (MEGABYTE*1024) }; +enum +{ + MSG_STATUS = 1, + MSG_COMPILER, + MSG_MESSAGE, + MSG_SCRATCH, + MSG_VTE, + TREEVIEW_SYMBOL, + TREEVIEW_OPENFILES +}; + #endif diff --git a/src/msgwindow.c b/src/msgwindow.c index a27d0e52..f50e9a38 100644 --- a/src/msgwindow.c +++ b/src/msgwindow.c @@ -90,7 +90,7 @@ void msgwin_prepare_status_tree_view(void) 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(3)); + G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(MSG_STATUS)); } @@ -114,7 +114,7 @@ void msgwin_prepare_msg_tree_view(void) gtk_widget_modify_font(msgwindow.tree_msg, pango_font_description_from_string(app->msgwin_font)); g_signal_connect(G_OBJECT(msgwindow.tree_msg), "button-press-event", - G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(4)); + G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(MSG_MESSAGE)); // selection handling select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg)); @@ -141,7 +141,7 @@ void msgwin_prepare_compiler_tree_view(void) gtk_widget_modify_font(msgwindow.tree_compiler, pango_font_description_from_string(app->msgwin_font)); g_signal_connect(G_OBJECT(msgwindow.tree_compiler), "button-press-event", - G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(5)); + G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(MSG_COMPILER)); // selection handling select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler)); diff --git a/src/msgwindow.h b/src/msgwindow.h index b9570fbc..038088a1 100644 --- a/src/msgwindow.h +++ b/src/msgwindow.h @@ -33,14 +33,6 @@ enum COLOR_BLUE }; -enum -{ - MSG_STATUS = 0, - MSG_COMPILER, - MSG_MESSAGE, - MSG_SCRATCH, - MSG_VTE -}; typedef struct diff --git a/src/treeviews.c b/src/treeviews.c index f02fce1d..1d614508 100644 --- a/src/treeviews.c +++ b/src/treeviews.c @@ -44,7 +44,7 @@ void treeviews_prepare_taglist(GtkWidget *tree, GtkTreeStore *store) 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(7)); + G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(TREEVIEW_SYMBOL)); gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE); @@ -254,7 +254,7 @@ void treeviews_prepare_openfiles(void) 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(6)); + G_CALLBACK(on_tree_view_button_press_event), GINT_TO_POINTER(TREEVIEW_OPENFILES)); // selection handling select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles));