Revision: 3521 http://geany.svn.sourceforge.net/geany/?rev=3521&view=rev Author: eht16 Date: 2009-01-28 17:22:34 +0000 (Wed, 28 Jan 2009)
Log Message: ----------- Use the selection 'changed' signal of the treeview to update the popup menu items and show the popup menu on mouse button press events so right clicking on items will select them first.
Modified Paths: -------------- trunk/ChangeLog trunk/plugins/filebrowser.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-01-28 17:01:32 UTC (rev 3520) +++ trunk/ChangeLog 2009-01-28 17:22:34 UTC (rev 3521) @@ -4,9 +4,13 @@ Set the documents' mtime field properly for checking disk file changes. * src/document.c, src/keyfile.c, src/ui_utils.c, src/ui_utils.h: - Add a hiden preference "allow_always_save" to make the Save buttons/ + Add a hidden preference "allow_always_save" to make the Save buttons/ menu items always sensitive and allow saving files even without changes. + * plugins/filebrowser.c: + Use the selection 'changed' signal of the treeview to update the + popup menu items and show the popup menu on mouse button press events + so right clicking on items will select them first.
2009-01-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/plugins/filebrowser.c =================================================================== --- trunk/plugins/filebrowser.c 2009-01-28 17:01:32 UTC (rev 3520) +++ trunk/plugins/filebrowser.c 2009-01-28 17:22:34 UTC (rev 3521) @@ -568,40 +568,31 @@ }
-static gboolean on_button_press(GtkWidget *widget, GdkEventButton *event, gpointer user_data) +static void on_tree_selection_changed(GtkTreeSelection *selection, gpointer data) { - if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) - on_open_clicked(NULL, NULL); - else if (event->button == 3) - return TRUE; - return FALSE; -} + gboolean have_sel = (gtk_tree_selection_count_selected_rows(selection) > 0); + gboolean multi_sel = (gtk_tree_selection_count_selected_rows(selection) > 1);
- -static void update_popup_menu(GtkWidget *popup_menu) -{ - GtkTreeSelection *treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(file_view)); - gboolean have_sel = (gtk_tree_selection_count_selected_rows(treesel) > 0); - gboolean multi_sel = (gtk_tree_selection_count_selected_rows(treesel) > 1); - - gtk_widget_set_sensitive(popup_items.open, have_sel); - gtk_widget_set_sensitive(popup_items.open_external, have_sel); - gtk_widget_set_sensitive(popup_items.find_in_files, have_sel && ! multi_sel); + if (popup_items.open != NULL) + gtk_widget_set_sensitive(popup_items.open, have_sel); + if (popup_items.open_external != NULL) + gtk_widget_set_sensitive(popup_items.open_external, have_sel); + if (popup_items.find_in_files != NULL) + gtk_widget_set_sensitive(popup_items.find_in_files, have_sel && ! multi_sel); }
-/* delay updating popup menu until the selection has been set */ -static gboolean on_button_release(GtkWidget *widget, GdkEventButton *event, gpointer user_data) +static gboolean on_button_press(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - if (event->button == 3) + if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) + on_open_clicked(NULL, NULL); + else if (event->button == 3) { static GtkWidget *popup_menu = NULL;
if (popup_menu == NULL) popup_menu = create_popup_menu();
- update_popup_menu(popup_menu); - gtk_menu_popup(GTK_MENU(popup_menu), NULL, NULL, NULL, NULL, event->button, event->time); } @@ -703,9 +694,9 @@ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(file_view)); gtk_tree_selection_set_mode(select, GTK_SELECTION_MULTIPLE);
- g_signal_connect(G_OBJECT(file_view), "realize", G_CALLBACK(on_current_path), NULL); + g_signal_connect(file_view, "realize", G_CALLBACK(on_current_path), NULL); + g_signal_connect(select, "changed", G_CALLBACK(on_tree_selection_changed), NULL); g_signal_connect(file_view, "button-press-event", G_CALLBACK(on_button_press), NULL); - g_signal_connect(file_view, "button-release-event", G_CALLBACK(on_button_release), NULL); g_signal_connect(file_view, "key-press-event", G_CALLBACK(on_key_press), NULL); }
@@ -901,6 +892,8 @@ prepare_file_view(); completion_create();
+ popup_items.open = popup_items.open_external = popup_items.find_in_files = NULL; + scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrollwin),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.