From e47883cd16c914158b9d20da67b7b06d8c7265a7 Mon Sep 17 00:00:00 2001 From: Mamoru TASAKA Date: Thu, 21 May 2015 14:32:56 +0900 Subject: set focus when showing search dialog https://bugzilla.gnome.org/show_bug.cgi?id=745454 To avoid GnomeCmdSearchDialog priv->result_list receive "key-press-event", explicitly set focus on pattern_combo when search dialog is raised. diff --git a/src/dialogs/gnome-cmd-search-dialog.cc b/src/dialogs/gnome-cmd-search-dialog.cc index 3c8407e..e2125a1 100644 --- a/src/dialogs/gnome-cmd-search-dialog.cc +++ b/src/dialogs/gnome-cmd-search-dialog.cc @@ -1116,6 +1116,12 @@ static void gnome_cmd_search_dialog_class_init (GnomeCmdSearchDialogClass *klass } +void GnomeCmdSearchDialog::show_and_set_focus() +{ + gtk_widget_show(*this); + priv->profile_component->set_focus(); +} + GnomeCmdSearchDialog::GnomeCmdSearchDialog(GnomeCmdData::SearchConfig &cfg): defaults(cfg) { gtk_window_set_default_size (*this, defaults.width, defaults.height); diff --git a/src/dialogs/gnome-cmd-search-dialog.h b/src/dialogs/gnome-cmd-search-dialog.h index f5b950c..84bc2bf 100644 --- a/src/dialogs/gnome-cmd-search-dialog.h +++ b/src/dialogs/gnome-cmd-search-dialog.h @@ -55,6 +55,8 @@ struct GnomeCmdSearchDialog GnomeCmdData::SearchConfig &defaults; + void show_and_set_focus(); + GnomeCmdSearchDialog(GnomeCmdData::SearchConfig &defaults); ~GnomeCmdSearchDialog(); }; diff --git a/src/gnome-cmd-selection-profile-component.cc b/src/gnome-cmd-selection-profile-component.cc index 96d4a18..d56e450 100644 --- a/src/gnome-cmd-selection-profile-component.cc +++ b/src/gnome-cmd-selection-profile-component.cc @@ -237,6 +237,11 @@ void GnomeCmdSelectionProfileComponent::copy(GnomeCmdData::Selection &profile) profile.match_case = profile.content_search && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->case_check)); } +void GnomeCmdSelectionProfileComponent::set_focus() +{ + gtk_widget_grab_focus (priv->pattern_combo); +} + void GnomeCmdSelectionProfileComponent::set_name_patterns_history(GList *history) { diff --git a/src/gnome-cmd-selection-profile-component.h b/src/gnome-cmd-selection-profile-component.h index 1620703..95924c0 100644 --- a/src/gnome-cmd-selection-profile-component.h +++ b/src/gnome-cmd-selection-profile-component.h @@ -55,6 +55,7 @@ struct GnomeCmdSelectionProfileComponent void update(); void copy(); // copies component to associated profile void copy(GnomeCmdData::Selection &profile); // copies component to specified profile + void set_focus(); void set_name_patterns_history(GList *history); void set_content_patterns_history(GList *history); diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc index b0bee29..f65ce53 100644 --- a/src/gnome-cmd-user-actions.cc +++ b/src/gnome-cmd-user-actions.cc @@ -1023,7 +1023,7 @@ void edit_search (GtkMenuItem *menuitem, gpointer not_used) if (!main_win->file_search_dlg) main_win->file_search_dlg = new GnomeCmdSearchDialog(gnome_cmd_data.search_defaults); - gtk_widget_show (*main_win->file_search_dlg); + main_win->file_search_dlg->show_and_set_focus(); } -- cgit v0.10.2