Updating branch refs/heads/master to 5e15028e1996f53490687414c2ceac2c80521979 (commit) from 8370e736a1bcf4fc585dece42dc328fd1b7d4d70 (commit)
commit 5e15028e1996f53490687414c2ceac2c80521979 Author: Nick Schermer <n...@xfce.org> Date: Thu Dec 27 20:04:14 2012 +0100 Add search dialog. po/POTFILES.in | 1 + terminal/Makefile.am | 2 + terminal/terminal-screen.c | 39 +++++ terminal/terminal-screen.h | 11 ++ terminal/terminal-search-dialog.c | 279 +++++++++++++++++++++++++++++++++++++ terminal/terminal-search-dialog.h | 55 +++++++ terminal/terminal-window-ui.xml | 6 + terminal/terminal-window.c | 110 +++++++++++++++ 8 files changed, 503 insertions(+), 0 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 3e11c35..36d1199 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -17,6 +17,7 @@ terminal/terminal-preferences-dialog.c terminal/terminal-preferences.glade terminal/terminal-preferences.c terminal/terminal-screen.c +terminal/terminal-search-dialog.c terminal/terminal-widget.c terminal/terminal-window.c diff --git a/terminal/Makefile.am b/terminal/Makefile.am index eeb1817..cb1b96f 100644 --- a/terminal/Makefile.am +++ b/terminal/Makefile.am @@ -24,6 +24,7 @@ xfce4_terminal_headers = \ terminal-options.h \ terminal-preferences.h \ terminal-preferences-dialog.h \ + terminal-search-dialog.h \ terminal-private.h \ terminal-screen.h \ terminal-widget.h \ @@ -42,6 +43,7 @@ xfce4_terminal_SOURCES = \ terminal-options.c \ terminal-preferences.c \ terminal-preferences-dialog.c \ + terminal-search-dialog.c \ terminal-screen.c \ terminal-widget.c \ terminal-window.c diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c index 98a2840..2f93ab0 100644 --- a/terminal/terminal-screen.c +++ b/terminal/terminal-screen.c @@ -2188,3 +2188,42 @@ terminal_screen_set_encoding (TerminalScreen *screen, terminal_return_if_fail (TERMINAL_IS_SCREEN (screen)); vte_terminal_set_encoding (VTE_TERMINAL (screen->terminal), charset); } + + + +void +terminal_screen_search_set_gregex (TerminalScreen *screen, + GRegex *regex, + gboolean wrap_around) +{ + terminal_return_if_fail (TERMINAL_IS_SCREEN (screen)); + vte_terminal_search_set_gregex (VTE_TERMINAL (screen->terminal), regex); + vte_terminal_search_set_wrap_around (VTE_TERMINAL (screen->terminal), wrap_around); +} + + + +gboolean +terminal_screen_search_has_gregex (TerminalScreen *screen) +{ + terminal_return_val_if_fail (TERMINAL_IS_SCREEN (screen), FALSE); + return vte_terminal_search_get_gregex (VTE_TERMINAL (screen->terminal)) != NULL; +} + + + +void +terminal_screen_search_find_next (TerminalScreen *screen) +{ + terminal_return_if_fail (TERMINAL_IS_SCREEN (screen)); + vte_terminal_search_find_next (VTE_TERMINAL (screen->terminal)); +} + + + +void +terminal_screen_search_find_previous (TerminalScreen *screen) +{ + terminal_return_if_fail (TERMINAL_IS_SCREEN (screen)); + vte_terminal_search_find_previous (VTE_TERMINAL (screen->terminal)); +} diff --git a/terminal/terminal-screen.h b/terminal/terminal-screen.h index cf4badc..1a03a42 100644 --- a/terminal/terminal-screen.h +++ b/terminal/terminal-screen.h @@ -95,6 +95,17 @@ const gchar *terminal_screen_get_encoding (TerminalScreen *scree void terminal_screen_set_encoding (TerminalScreen *screen, const gchar *charset); +void terminal_screen_search_set_gregex (TerminalScreen *screen, + GRegex *regex, + gboolean wrap_around); + +gboolean terminal_screen_search_has_gregex (TerminalScreen *screen); + +void terminal_screen_search_find_next (TerminalScreen *screen); + +void terminal_screen_search_find_previous (TerminalScreen *screen); + + G_END_DECLS #endif /* !__TERMINAL_SCREEN_H__ */ diff --git a/terminal/terminal-search-dialog.c b/terminal/terminal-search-dialog.c new file mode 100644 index 0000000..ef3cdb7 --- /dev/null +++ b/terminal/terminal-search-dialog.c @@ -0,0 +1,279 @@ +/*- + * Copyright 2012 Nick Schermer <n...@xfce.org> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_MEMORY_H +#include <memory.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include <libxfce4ui/libxfce4ui.h> + +#include <terminal/terminal-search-dialog.h> +#include <terminal/terminal-private.h> + + + +static void terminal_search_dialog_finalize (GObject *object); +static void terminal_search_dialog_clear_gregex (TerminalSearchDialog *dialog); +static void terminal_search_dialog_entry_icon_release (GtkWidget *entry, + GtkEntryIconPosition icon_pos); +static void terminal_search_dialog_entry_changed (GtkWidget *entry, + TerminalSearchDialog *dialog); + + +struct _TerminalSearchDialogClass +{ + GtkDialogClass __parent__; +}; + +struct _TerminalSearchDialog +{ + GtkDialog __parent__; + + GRegex *last_gregex; + + GtkWidget *button_prev; + GtkWidget *button_next; + + GtkWidget *entry; + + GtkWidget *match_case; + GtkWidget *match_regex; + GtkWidget *match_word; + GtkWidget *wrap_around; +}; + + + +G_DEFINE_TYPE (TerminalSearchDialog, terminal_search_dialog, GTK_TYPE_DIALOG) + + + +static void +terminal_search_dialog_class_init (TerminalSearchDialogClass *klass) +{ + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = terminal_search_dialog_finalize; +} + + + +static void +terminal_search_dialog_init (TerminalSearchDialog *dialog) +{ + GtkWidget *hbox; + GtkWidget *vbox; + GtkWidget *label; + + gtk_window_set_title (GTK_WINDOW (dialog), _("Find")); + gtk_window_set_default_size (GTK_WINDOW (dialog), 400, -1); + + gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); + + dialog->button_prev = xfce_gtk_button_new_mixed (GTK_STOCK_GO_BACK, _("_Previous")); + gtk_dialog_add_action_widget (GTK_DIALOG (dialog), dialog->button_prev, TERMINAL_RESPONSE_SEARCH_PREV); + gtk_widget_set_can_default (dialog->button_prev, TRUE); + + dialog->button_next = xfce_gtk_button_new_mixed (GTK_STOCK_GO_FORWARD, _("_Next")); + gtk_dialog_add_action_widget (GTK_DIALOG (dialog), dialog->button_next, TERMINAL_RESPONSE_SEARCH_NEXT); + + vbox = gtk_vbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); + + hbox = gtk_hbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); + + label = gtk_label_new_with_mnemonic (_("_Search for:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + dialog->entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), dialog->entry, TRUE, TRUE, 0); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->entry); + gtk_entry_set_activates_default (GTK_ENTRY (dialog->entry), TRUE); + gtk_entry_set_icon_from_stock (GTK_ENTRY (dialog->entry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR); + g_signal_connect (G_OBJECT (dialog->entry), "icon-release", + G_CALLBACK (terminal_search_dialog_entry_icon_release), NULL); + g_signal_connect (G_OBJECT (dialog->entry), "changed", + G_CALLBACK (terminal_search_dialog_entry_changed), dialog); + + dialog->match_case = gtk_check_button_new_with_mnemonic (_("C_ase sensitive")); + gtk_box_pack_start (GTK_BOX (vbox), dialog->match_case, FALSE, FALSE, 0); + g_signal_connect_swapped (G_OBJECT (dialog->match_case), "toggled", + G_CALLBACK (terminal_search_dialog_clear_gregex), dialog); + + dialog->match_regex = gtk_check_button_new_with_mnemonic (_("Match as _regular expression")); + gtk_box_pack_start (GTK_BOX (vbox), dialog->match_regex, FALSE, FALSE, 0); + g_signal_connect_swapped (G_OBJECT (dialog->match_regex), "toggled", + G_CALLBACK (terminal_search_dialog_clear_gregex), dialog); + + dialog->match_word = gtk_check_button_new_with_mnemonic (_("Match _entire word only")); + gtk_box_pack_start (GTK_BOX (vbox), dialog->match_word, FALSE, FALSE, 0); + g_signal_connect_swapped (G_OBJECT (dialog->match_word), "toggled", + G_CALLBACK (terminal_search_dialog_clear_gregex), dialog); + + dialog->wrap_around = gtk_check_button_new_with_mnemonic (_("_Wrap around")); + gtk_box_pack_start (GTK_BOX (vbox), dialog->wrap_around, FALSE, FALSE, 0); + g_signal_connect_swapped (G_OBJECT (dialog->wrap_around), "toggled", + G_CALLBACK (terminal_search_dialog_clear_gregex), dialog); + + terminal_search_dialog_entry_changed (dialog->entry, dialog); +} + + + +static void +terminal_search_dialog_finalize (GObject *object) +{ + terminal_search_dialog_clear_gregex (TERMINAL_SEARCH_DIALOG (object)); + + (*G_OBJECT_CLASS (terminal_search_dialog_parent_class)->finalize) (object); +} + + + +static void +terminal_search_dialog_clear_gregex (TerminalSearchDialog *dialog) +{ + if (dialog->last_gregex != NULL) + { + g_regex_unref (dialog->last_gregex); + dialog->last_gregex = NULL; + } +} + + + +static void +terminal_search_dialog_entry_icon_release (GtkWidget *entry, + GtkEntryIconPosition icon_pos) +{ + if (icon_pos == GTK_ENTRY_ICON_SECONDARY) + gtk_entry_set_text (GTK_ENTRY (entry), ""); +} + + + +static void +terminal_search_dialog_entry_changed (GtkWidget *entry, + TerminalSearchDialog *dialog) +{ + const gchar *text; + gboolean has_text; + + text = gtk_entry_get_text (GTK_ENTRY (dialog->entry)); + has_text = IS_STRING (text); + + terminal_search_dialog_clear_gregex (dialog); + + gtk_widget_set_sensitive (dialog->button_prev, has_text); + gtk_widget_set_sensitive (dialog->button_next, has_text); + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), + has_text ? TERMINAL_RESPONSE_SEARCH_PREV : GTK_RESPONSE_CLOSE); +} + + + +GtkWidget * +terminal_search_dialog_new (GtkWindow *parent) +{ + return g_object_new (TERMINAL_TYPE_SEARCH_DIALOG, + "transient-for", parent, NULL); +} + + + +gboolean +terminal_search_dialog_get_wrap_around (TerminalSearchDialog *dialog) +{ + terminal_return_val_if_fail (TERMINAL_IS_SEARCH_DIALOG (dialog), FALSE); + return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->wrap_around)); +} + + + +GRegex * +terminal_search_dialog_get_regex (TerminalSearchDialog *dialog, + GError **error) +{ + const gchar *pattern; + GRegexCompileFlags flags = G_REGEX_OPTIMIZE; + gchar *pattern_escaped = NULL; + gchar *word_regex = NULL; + GRegex *regex; + + terminal_return_val_if_fail (TERMINAL_IS_SEARCH_DIALOG (dialog), NULL); + terminal_return_val_if_fail (error == NULL || *error == NULL, NULL); + + /* if not cleared, use the old regex */ + if (dialog->last_gregex != NULL) + return g_regex_ref (dialog->last_gregex); + + /* unset if no pattern is typed */ + pattern = gtk_entry_get_text (GTK_ENTRY (dialog->entry)); + if (!IS_STRING (pattern)) + return NULL; + + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->match_case))) + flags |= G_REGEX_CASELESS; + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->match_regex))) + flags |= G_REGEX_MULTILINE; + else + { + pattern_escaped = g_regex_escape_string (pattern, -1); + pattern = pattern_escaped; + } + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->match_word))) + { + word_regex = g_strdup_printf ("\\b%s\\b", pattern); + pattern = word_regex; + } + + regex = g_regex_new (pattern, flags, 0, error); + + g_free (pattern_escaped); + g_free (word_regex); + + /* keep around */ + if (regex != NULL) + dialog->last_gregex = g_regex_ref (regex); + + return regex; +} + + + +void +terminal_search_dialog_present (TerminalSearchDialog *dialog) +{ + terminal_return_if_fail (TERMINAL_IS_SEARCH_DIALOG (dialog)); + + gtk_window_present (GTK_WINDOW (dialog)); + gtk_widget_grab_focus (dialog->entry); +} diff --git a/terminal/terminal-search-dialog.h b/terminal/terminal-search-dialog.h new file mode 100644 index 0000000..6abe0d6 --- /dev/null +++ b/terminal/terminal-search-dialog.h @@ -0,0 +1,55 @@ +/*- + * Copyright 2012 Nick Schermer <n...@xfce.org> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __TERMINAL_SEARCH_DIALOG_H__ +#define __TERMINAL_SEARCH_DIALOG_H__ + +#include <vte/vte.h> + +G_BEGIN_DECLS + +#define TERMINAL_TYPE_SEARCH_DIALOG (terminal_search_dialog_get_type ()) +#define TERMINAL_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_SEARCH_DIALOG, TerminalSearchDialog)) +#define TERMINAL_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_SEARCH_DIALOG, TerminalSearchDialogClass)) +#define TERMINAL_IS_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_SEARCH_DIALOG)) +#define TERMINAL_IS_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_SEARCH_DIALOG)) +#define TERMINAL_SEARCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_SEARCH_DIALOG, TerminalSearchDialogClass)) + +typedef struct _TerminalSearchDialog TerminalSearchDialog; +typedef struct _TerminalSearchDialogClass TerminalSearchDialogClass; + +enum +{ + TERMINAL_RESPONSE_SEARCH_NEXT, + TERMINAL_RESPONSE_SEARCH_PREV +}; + +GType terminal_search_dialog_get_type (void) G_GNUC_CONST; + +GtkWidget *terminal_search_dialog_new (GtkWindow *parent); + +gboolean terminal_search_dialog_get_wrap_around (TerminalSearchDialog *dialog); + +GRegex *terminal_search_dialog_get_regex (TerminalSearchDialog *dialog, + GError **error); + +void terminal_search_dialog_present (TerminalSearchDialog *dialog); + +G_END_DECLS + +#endif /* !__TERMINAL_SEARCH_DIALOG_H__ */ diff --git a/terminal/terminal-window-ui.xml b/terminal/terminal-window-ui.xml index 089a3ed..c278142 100644 --- a/terminal/terminal-window-ui.xml +++ b/terminal/terminal-window-ui.xml @@ -35,6 +35,10 @@ <menu action="terminal-menu"> <menuitem action="set-title"/> <separator/> + <menuitem action="search"/> + <menuitem action="search-next"/> + <menuitem action="search-prev"/> + <separator/> <menuitem action="set-encoding"/> <separator/> <menuitem action="reset"/> @@ -87,6 +91,8 @@ <toolitem action="copy"/> <toolitem action="paste"/> <separator/> + <toolitem action="search"/> + <separator/> <toolitem action="fullscreen"/> <toolitem action="preferences"/> <separator/> diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c index a59ca32..d3c7b43 100644 --- a/terminal/terminal-window.c +++ b/terminal/terminal-window.c @@ -47,6 +47,7 @@ #include <terminal/terminal-enum-types.h> #include <terminal/terminal-options.h> #include <terminal/terminal-preferences-dialog.h> +#include <terminal/terminal-search-dialog.h> #include <terminal/terminal-private.h> #include <terminal/terminal-marshal.h> #include <terminal/terminal-encoding-action.h> @@ -171,6 +172,12 @@ static void terminal_window_action_goto_tab (GtkRadioAc GtkNotebook *notebook); static void terminal_window_action_set_title (GtkAction *action, TerminalWindow *window); +static void terminal_window_action_search (GtkAction *action, + TerminalWindow *window); +static void terminal_window_action_search_next (GtkAction *action, + TerminalWindow *window); +static void terminal_window_action_search_prev (GtkAction *action, + TerminalWindow *window); static void terminal_window_action_reset (GtkAction *action, TerminalWindow *window); static void terminal_window_action_reset_and_clear (GtkAction *action, @@ -206,6 +213,8 @@ struct _TerminalWindow GtkWidget *toolbar; GtkWidget *notebook; + GtkWidget *search_dialog; + /* pushed size of screen */ glong grid_width; glong grid_height; @@ -222,6 +231,8 @@ struct _TerminalWindow GtkAction *action_move_tab_left; GtkAction *action_move_tab_right; GtkAction *action_copy; + GtkAction *action_search_next; + GtkAction *action_search_prev; }; @@ -249,6 +260,9 @@ static const GtkActionEntry action_entries[] = { "view-menu", NULL, N_ ("_View"), NULL, NULL, NULL, }, { "terminal-menu", NULL, N_ ("_Terminal"), NULL, NULL, NULL, }, { "set-title", NULL, N_ ("_Set Title..."), NULL, NULL, G_CALLBACK (terminal_window_action_set_title), }, + { "search", GTK_STOCK_FIND, N_ ("_Find..."), "<control><shift>f", NULL, G_CALLBACK (terminal_window_action_search), }, + { "search-next", NULL, N_ ("Find Ne_xt"), NULL, NULL, G_CALLBACK (terminal_window_action_search_next), }, + { "search-prev", NULL, N_ ("Find Pre_vious"), NULL, NULL, G_CALLBACK (terminal_window_action_search_prev), }, { "reset", NULL, N_ ("_Clear Scrollback"), NULL, NULL, G_CALLBACK (terminal_window_action_reset), }, { "reset-and-clear", NULL, N_ ("Clear Scrollback and _Reset"), NULL, NULL, G_CALLBACK (terminal_window_action_reset_and_clear), }, { "go-menu", NULL, N_ ("_Go"), NULL, NULL, NULL, }, @@ -432,6 +446,8 @@ terminal_window_init (TerminalWindow *window) window->action_move_tab_left = gtk_action_group_get_action (window->action_group, "move-tab-left"); window->action_move_tab_right = gtk_action_group_get_action (window->action_group, "move-tab-right"); window->action_copy = gtk_action_group_get_action (window->action_group, "copy"); + window->action_search_next = gtk_action_group_get_action (window->action_group, "search-next"); + window->action_search_prev = gtk_action_group_get_action (window->action_group, "search-prev"); } @@ -445,6 +461,7 @@ terminal_window_finalize (GObject *object) g_object_unref (G_OBJECT (window->action_group)); g_object_unref (G_OBJECT (window->ui_manager)); g_object_unref (G_OBJECT (window->encoding_action)); + g_slist_free (window->gomenu_actions); (*G_OBJECT_CLASS (terminal_window_parent_class)->finalize) (object); @@ -709,6 +726,7 @@ terminal_window_update_actions (TerminalWindow *window) gboolean cycle_tabs; gint page_num; gint n_pages; + gboolean can_search; /* determine the number of pages */ n_pages = gtk_notebook_get_n_pages (notebook); @@ -739,6 +757,10 @@ terminal_window_update_actions (TerminalWindow *window) gtk_action_set_sensitive (window->action_copy, terminal_screen_has_selection (window->active)); + can_search = terminal_screen_search_has_gregex (window->active); + gtk_action_set_sensitive (window->action_search_next, can_search); + gtk_action_set_sensitive (window->action_search_prev, can_search); + /* update the "Go" menu */ action = g_object_get_qdata (G_OBJECT (window->active), gomenu_action_quark); if (G_LIKELY (action != NULL)) @@ -1682,6 +1704,94 @@ terminal_window_action_set_title (GtkAction *action, static void +terminal_window_action_search_response (GtkWidget *dialog, + gint response_id, + TerminalWindow *window) +{ + GRegex *regex; + GError *error = NULL; + gboolean wrap_around; + gboolean can_search; + + terminal_return_if_fail (TERMINAL_IS_WINDOW (window)); + terminal_return_if_fail (TERMINAL_IS_SEARCH_DIALOG (dialog)); + terminal_return_if_fail (TERMINAL_IS_SCREEN (window->active)); + terminal_return_if_fail (window->search_dialog == dialog); + + if (response_id == TERMINAL_RESPONSE_SEARCH_NEXT + || response_id == TERMINAL_RESPONSE_SEARCH_PREV) + { + regex = terminal_search_dialog_get_regex (TERMINAL_SEARCH_DIALOG (dialog), &error); + if (G_LIKELY (error == NULL)) + { + wrap_around = terminal_search_dialog_get_wrap_around (TERMINAL_SEARCH_DIALOG (dialog)); + terminal_screen_search_set_gregex (window->active, regex, wrap_around); + if (regex != NULL) + g_regex_unref (regex); + + if (response_id == TERMINAL_RESPONSE_SEARCH_NEXT) + terminal_screen_search_find_next (window->active); + else + terminal_screen_search_find_previous (window->active); + } + else + { + xfce_dialog_show_error (GTK_WINDOW (dialog), error, _("Failed to create the regular expression")); + g_error_free (error); + } + } + else + { + /* hide dialog */ + gtk_widget_hide (dialog); + } + + /* update actions */ + can_search = terminal_screen_search_has_gregex (window->active); + gtk_action_set_sensitive (window->action_search_next, can_search); + gtk_action_set_sensitive (window->action_search_prev, can_search); +} + + + +static void +terminal_window_action_search (GtkAction *action, + TerminalWindow *window) +{ + if (window->search_dialog == NULL) + { + window->search_dialog = terminal_search_dialog_new (GTK_WINDOW (window)); + g_signal_connect (G_OBJECT (window->search_dialog), "response", + G_CALLBACK (terminal_window_action_search_response), window); + gtk_widget_show_all (window->search_dialog); + } + + terminal_search_dialog_present (TERMINAL_SEARCH_DIALOG (window->search_dialog)); +} + + + +static void +terminal_window_action_search_next (GtkAction *action, + TerminalWindow *window) +{ + if (G_LIKELY (window->active != NULL)) + terminal_screen_search_find_next (window->active); +} + + + +static void +terminal_window_action_search_prev (GtkAction *action, + TerminalWindow *window) +{ + if (G_LIKELY (window->active != NULL)) + terminal_screen_search_find_previous (window->active); +} + + + +static void terminal_window_action_reset (GtkAction *action, TerminalWindow *window) { _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits