Kaydet (Commit) 3d91095b authored tarafından Nick Treleaven's avatar Nick Treleaven

Fix bug with choosing 'show full path name' from documents list popup

menu when there is no selected item (can happen after using the command
twice).
Fix hiding the sidebar/documents list from the popup menu when there's
no selected item.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1975 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 94fbc4ba
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
plugins/pluginmacros.h: plugins/pluginmacros.h:
Add pluginmacros.h to define common macros for app, utils, etc. Add pluginmacros.h to define common macros for app, utils, etc.
Add more documentation/comments to demoplugin.c. Add more documentation/comments to demoplugin.c.
* src/treeviews.c:
Fix bug with choosing 'show full path name' from documents list popup
menu when there is no selected item (can happen after using the command
twice).
Fix hiding the sidebar/documents list from the popup menu when there's
no selected item.
2007-10-23 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2007-10-23 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
......
...@@ -53,7 +53,6 @@ enum ...@@ -53,7 +53,6 @@ enum
OPENFILES_ACTION_REMOVE = 0, OPENFILES_ACTION_REMOVE = 0,
OPENFILES_ACTION_SAVE, OPENFILES_ACTION_SAVE,
OPENFILES_ACTION_RELOAD, OPENFILES_ACTION_RELOAD,
OPENFILES_ACTION_FULLPATH,
OPENFILES_ACTION_HIDE, OPENFILES_ACTION_HIDE,
OPENFILES_ACTION_HIDE_ALL, OPENFILES_ACTION_HIDE_ALL,
SYMBOL_ACTION_SORT_BY_NAME, SYMBOL_ACTION_SORT_BY_NAME,
...@@ -69,7 +68,8 @@ static GtkWidget *tag_window; // scrolled window that holds the symbol list GtkT ...@@ -69,7 +68,8 @@ static GtkWidget *tag_window; // scrolled window that holds the symbol list GtkT
/* callback prototypes */ /* callback prototypes */
static void on_taglist_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_data); 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_selection_changed(GtkTreeSelection *selection, gpointer data);
static void on_openfiles_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_data); static void on_openfiles_document_action(GtkMenuItem *menuitem, gpointer user_data);
static void on_openfiles_hide_item_clicked(GtkMenuItem *menuitem, gpointer user_data);
static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection); static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection);
static gboolean on_treeviews_button_press_event(GtkWidget *widget, GdkEventButton *event, static gboolean on_treeviews_button_press_event(GtkWidget *widget, GdkEventButton *event,
gpointer user_data); gpointer user_data);
...@@ -381,6 +381,13 @@ static void create_taglist_popup_menu() ...@@ -381,6 +381,13 @@ static void create_taglist_popup_menu()
} }
static void on_openfiles_fullpath_activate(GtkCheckMenuItem *item)
{
prefs.sidebar_openfiles_fullpath = gtk_check_menu_item_get_active(item);
treeviews_openfiles_update_all();
}
static void create_openfiles_popup_menu() static void create_openfiles_popup_menu()
{ {
GtkWidget *item; GtkWidget *item;
...@@ -391,7 +398,7 @@ static void create_openfiles_popup_menu() ...@@ -391,7 +398,7 @@ static void create_openfiles_popup_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), GINT_TO_POINTER(OPENFILES_ACTION_REMOVE)); G_CALLBACK(on_openfiles_document_action), 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);
...@@ -401,7 +408,7 @@ static void create_openfiles_popup_menu() ...@@ -401,7 +408,7 @@ static void create_openfiles_popup_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), GINT_TO_POINTER(OPENFILES_ACTION_SAVE)); G_CALLBACK(on_openfiles_document_action), GINT_TO_POINTER(OPENFILES_ACTION_SAVE));
item = gtk_image_menu_item_new_with_mnemonic(_("_Reload")); item = gtk_image_menu_item_new_with_mnemonic(_("_Reload"));
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
...@@ -409,7 +416,7 @@ static void create_openfiles_popup_menu() ...@@ -409,7 +416,7 @@ static void create_openfiles_popup_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), GINT_TO_POINTER(OPENFILES_ACTION_RELOAD)); G_CALLBACK(on_openfiles_document_action), 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);
...@@ -418,15 +425,15 @@ static void create_openfiles_popup_menu() ...@@ -418,15 +425,15 @@ static void create_openfiles_popup_menu()
tv.popup_openfiles_fullpath = gtk_check_menu_item_new_with_mnemonic(_("Show _full path name")); tv.popup_openfiles_fullpath = gtk_check_menu_item_new_with_mnemonic(_("Show _full path name"));
gtk_widget_show(tv.popup_openfiles_fullpath); gtk_widget_show(tv.popup_openfiles_fullpath);
gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), tv.popup_openfiles_fullpath); gtk_container_add(GTK_CONTAINER(tv.popup_openfiles), tv.popup_openfiles_fullpath);
g_signal_connect((gpointer) tv.popup_openfiles_fullpath, "toggled", g_signal_connect((gpointer) tv.popup_openfiles_fullpath, "activate",
G_CALLBACK(on_openfiles_tree_popup_clicked), GINT_TO_POINTER(OPENFILES_ACTION_FULLPATH)); G_CALLBACK(on_openfiles_fullpath_activate), NULL);
item = gtk_image_menu_item_new_with_mnemonic(_("_Hide")); item = gtk_image_menu_item_new_with_mnemonic(_("_Hide"));
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_CALLBACK(on_openfiles_tree_popup_clicked), g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_openfiles_hide_item_clicked),
GINT_TO_POINTER(OPENFILES_ACTION_HIDE)); GINT_TO_POINTER(OPENFILES_ACTION_HIDE));
item = gtk_image_menu_item_new_with_mnemonic(_("H_ide sidebar")); item = gtk_image_menu_item_new_with_mnemonic(_("H_ide sidebar"));
...@@ -434,7 +441,7 @@ static void create_openfiles_popup_menu() ...@@ -434,7 +441,7 @@ static void create_openfiles_popup_menu()
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_CALLBACK(on_openfiles_tree_popup_clicked), g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_openfiles_hide_item_clicked),
GINT_TO_POINTER(OPENFILES_ACTION_HIDE_ALL)); GINT_TO_POINTER(OPENFILES_ACTION_HIDE_ALL));
} }
...@@ -467,7 +474,7 @@ void treeviews_select_openfiles_item(gint idx) ...@@ -467,7 +474,7 @@ void treeviews_select_openfiles_item(gint idx)
/* callbacks */ /* callbacks */
static void on_openfiles_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_data) static void on_openfiles_document_action(GtkMenuItem *menuitem, gpointer user_data)
{ {
GtkTreeIter iter; GtkTreeIter iter;
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles)); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv.tree_openfiles));
...@@ -496,33 +503,32 @@ static void on_openfiles_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user ...@@ -496,33 +503,32 @@ static void on_openfiles_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user
on_toolbutton23_clicked(NULL, NULL); on_toolbutton23_clicked(NULL, NULL);
break; break;
} }
case OPENFILES_ACTION_FULLPATH:
{
if (! app->ignore_callback)
{
prefs.sidebar_openfiles_fullpath = ! prefs.sidebar_openfiles_fullpath;
treeviews_openfiles_update_all();
}
break;
}
case OPENFILES_ACTION_HIDE:
{
prefs.sidebar_openfiles_visible = FALSE;
ui_treeviews_show_hide(FALSE);
break;
}
case OPENFILES_ACTION_HIDE_ALL:
{
ui_prefs.sidebar_visible = FALSE;
ui_treeviews_show_hide(TRUE);
break;
}
} }
} }
} }
} }
static void on_openfiles_hide_item_clicked(GtkMenuItem *menuitem, gpointer user_data)
{
switch (GPOINTER_TO_INT(user_data))
{
case OPENFILES_ACTION_HIDE:
{
prefs.sidebar_openfiles_visible = FALSE;
ui_treeviews_show_hide(FALSE);
break;
}
case OPENFILES_ACTION_HIDE_ALL:
{
ui_prefs.sidebar_visible = FALSE;
ui_treeviews_show_hide(TRUE);
break;
}
}
}
static gboolean change_focus(gpointer data) static gboolean change_focus(gpointer data)
{ {
gint idx = (gint) data; gint idx = (gint) data;
...@@ -627,10 +633,8 @@ static gboolean on_treeviews_button_press_event(GtkWidget *widget, GdkEventButto ...@@ -627,10 +633,8 @@ static gboolean on_treeviews_button_press_event(GtkWidget *widget, GdkEventButto
{ // popupmenu to hide or clear the active treeview { // popupmenu to hide or clear the active treeview
if (GPOINTER_TO_INT(user_data) == TREEVIEW_OPENFILES) if (GPOINTER_TO_INT(user_data) == TREEVIEW_OPENFILES)
{ {
app->ignore_callback = TRUE;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tv.popup_openfiles_fullpath), gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tv.popup_openfiles_fullpath),
prefs.sidebar_openfiles_fullpath); prefs.sidebar_openfiles_fullpath);
app->ignore_callback = FALSE;
gtk_menu_popup(GTK_MENU(tv.popup_openfiles), NULL, NULL, NULL, NULL, gtk_menu_popup(GTK_MENU(tv.popup_openfiles), NULL, NULL, NULL, NULL,
event->button, event->time); event->button, event->time);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment