xed/xedit/dialogs/xedit-search-dialog.c

655 lines
18 KiB
C
Raw Normal View History

2011-11-07 13:46:58 -06:00
/*
2016-01-25 08:13:49 -06:00
* xedit-search-dialog.c
* This file is part of xedit
2011-11-07 13:46:58 -06:00
*
* Copyright (C) 2005 Paolo Maggi
*
* 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
2012-11-18 19:54:49 -06:00
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
2011-11-07 13:46:58 -06:00
*/
/*
2016-01-25 08:13:49 -06:00
* Modified by the xedit Team, 2005. See the AUTHORS file for a
* list of people on the xedit Team.
2011-11-07 13:46:58 -06:00
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <glib/gi18n.h>
2013-10-29 18:56:56 -05:00
#include <gtk/gtk.h>
2011-11-07 13:46:58 -06:00
#include <gdk/gdkkeysyms.h>
2016-01-25 08:13:49 -06:00
#include "xedit-search-dialog.h"
#include "xedit-history-entry.h"
#include "xedit-utils.h"
#include "xedit-marshal.h"
#include "xedit-dirs.h"
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
#define XEDIT_SEARCH_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
XEDIT_TYPE_SEARCH_DIALOG, \
XeditSearchDialogPrivate))
2011-11-07 13:46:58 -06:00
/* Signals */
enum
{
SHOW_REPLACE,
LAST_SIGNAL
};
static guint dialog_signals [LAST_SIGNAL] = { 0 };
2016-01-25 08:13:49 -06:00
struct _XeditSearchDialogPrivate
2011-11-07 13:46:58 -06:00
{
gboolean show_replace;
GtkWidget *table;
GtkWidget *search_label;
GtkWidget *search_entry;
GtkWidget *search_text_entry;
GtkWidget *replace_label;
GtkWidget *replace_entry;
GtkWidget *replace_text_entry;
GtkWidget *match_case_checkbutton;
GtkWidget *entire_word_checkbutton;
GtkWidget *backwards_checkbutton;
GtkWidget *wrap_around_checkbutton;
GtkWidget *parse_escapes_checkbutton;
2011-11-07 13:46:58 -06:00
GtkWidget *find_button;
GtkWidget *replace_button;
GtkWidget *replace_all_button;
gboolean ui_error;
};
2016-01-25 08:13:49 -06:00
G_DEFINE_TYPE(XeditSearchDialog, xedit_search_dialog, GTK_TYPE_DIALOG)
2011-11-07 13:46:58 -06:00
enum
{
PROP_0,
PROP_SHOW_REPLACE
};
static void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_property (GObject *object,
2011-11-07 13:46:58 -06:00
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
2016-01-25 08:13:49 -06:00
XeditSearchDialog *dlg = XEDIT_SEARCH_DIALOG (object);
2011-11-07 13:46:58 -06:00
switch (prop_id)
{
case PROP_SHOW_REPLACE:
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_show_replace (dlg,
2011-11-07 13:46:58 -06:00
g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_property (GObject *object,
2011-11-07 13:46:58 -06:00
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
2016-01-25 08:13:49 -06:00
XeditSearchDialog *dlg = XEDIT_SEARCH_DIALOG (object);
2011-11-07 13:46:58 -06:00
switch (prop_id)
{
case PROP_SHOW_REPLACE:
g_value_set_boolean (value, dlg->priv->show_replace);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_present_with_time (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
guint32 timestamp)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_SEARCH_DIALOG (dialog));
2011-11-07 13:46:58 -06:00
gtk_window_present_with_time (GTK_WINDOW (dialog), timestamp);
gtk_widget_grab_focus (dialog->priv->search_text_entry);
}
static gboolean
2016-01-25 08:13:49 -06:00
show_replace (XeditSearchDialog *dlg)
2011-11-07 13:46:58 -06:00
{
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_show_replace (dlg, TRUE);
2011-11-07 13:46:58 -06:00
return TRUE;
}
static void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_class_init (XeditSearchDialogClass *klass)
2011-11-07 13:46:58 -06:00
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkBindingSet *binding_set;
2016-01-25 08:13:49 -06:00
object_class->set_property = xedit_search_dialog_set_property;
object_class->get_property = xedit_search_dialog_get_property;
2011-11-07 13:46:58 -06:00
klass->show_replace = show_replace;
dialog_signals[SHOW_REPLACE] =
g_signal_new ("show_replace",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2016-01-25 08:13:49 -06:00
G_STRUCT_OFFSET (XeditSearchDialogClass, show_replace),
2011-11-07 13:46:58 -06:00
NULL, NULL,
2016-01-25 08:13:49 -06:00
xedit_marshal_BOOLEAN__NONE,
2011-11-07 13:46:58 -06:00
G_TYPE_BOOLEAN, 0);
g_object_class_install_property (object_class, PROP_SHOW_REPLACE,
g_param_spec_boolean ("show-replace",
"Show Replace",
"Whether the dialog is used for Search&Replace",
FALSE,
G_PARAM_READWRITE));
2016-01-25 08:13:49 -06:00
g_type_class_add_private (object_class, sizeof (XeditSearchDialogPrivate));
2011-11-07 13:46:58 -06:00
binding_set = gtk_binding_set_by_class (klass);
/* Note: we cannot use the keyval/modifier associated with the
* GTK_STOCK_FIND_AND_REPLACE stock item since MATE HIG suggests Ctrl+h
* for Replace while gtk+ uses Ctrl+r */
gtk_binding_entry_add_signal (binding_set, GDK_KEY_h, GDK_CONTROL_MASK, "show_replace", 0);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_H, GDK_CONTROL_MASK, "show_replace", 0);
2011-11-07 13:46:58 -06:00
}
static void
insert_text_handler (GtkEditable *editable,
const gchar *text,
gint length,
gint *position,
gpointer data)
{
static gboolean insert_text = FALSE;
gchar *escaped_text;
gint new_len;
/* To avoid recursive behavior */
if (insert_text)
return;
2016-01-25 08:13:49 -06:00
escaped_text = xedit_utils_escape_search_text (text);
2011-11-07 13:46:58 -06:00
new_len = strlen (escaped_text);
if (new_len == length)
{
g_free (escaped_text);
return;
}
insert_text = TRUE;
g_signal_stop_emission_by_name (editable, "insert_text");
gtk_editable_insert_text (editable, escaped_text, new_len, position);
insert_text = FALSE;
g_free (escaped_text);
}
static void
search_text_entry_changed (GtkEditable *editable,
2016-01-25 08:13:49 -06:00
XeditSearchDialog *dialog)
2011-11-07 13:46:58 -06:00
{
const gchar *search_string;
search_string = gtk_entry_get_text (GTK_ENTRY (editable));
g_return_if_fail (search_string != NULL);
if (*search_string != '\0')
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_FIND_RESPONSE, TRUE);
2011-11-07 13:46:58 -06:00
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, TRUE);
2011-11-07 13:46:58 -06:00
}
else
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_FIND_RESPONSE, FALSE);
2011-11-07 13:46:58 -06:00
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE, FALSE);
2011-11-07 13:46:58 -06:00
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, FALSE);
2011-11-07 13:46:58 -06:00
}
}
static void
2016-01-25 08:13:49 -06:00
response_handler (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
gint response_id,
gpointer data)
{
const gchar *str;
switch (response_id)
{
2016-01-25 08:13:49 -06:00
case XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE:
case XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
2011-11-07 13:46:58 -06:00
str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
if (*str != '\0')
{
gchar *text;
2016-01-25 08:13:49 -06:00
text = xedit_utils_unescape_search_text (str);
xedit_history_entry_prepend_text
(XEDIT_HISTORY_ENTRY (dialog->priv->replace_entry),
2011-11-07 13:46:58 -06:00
text);
g_free (text);
}
/* fall through, so that we also save the find entry */
2016-01-25 08:13:49 -06:00
case XEDIT_SEARCH_DIALOG_FIND_RESPONSE:
2011-11-07 13:46:58 -06:00
str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
if (*str != '\0')
{
gchar *text;
2016-01-25 08:13:49 -06:00
text = xedit_utils_unescape_search_text (str);
xedit_history_entry_prepend_text
(XEDIT_HISTORY_ENTRY (dialog->priv->search_entry),
2011-11-07 13:46:58 -06:00
text);
g_free (text);
}
}
}
static void
2016-01-25 08:13:49 -06:00
show_replace_widgets (XeditSearchDialog *dlg,
2011-11-07 13:46:58 -06:00
gboolean show_replace)
{
if (show_replace)
{
gtk_widget_show (dlg->priv->replace_label);
gtk_widget_show (dlg->priv->replace_entry);
gtk_widget_show (dlg->priv->replace_all_button);
gtk_widget_show (dlg->priv->replace_button);
gtk_table_set_row_spacings (GTK_TABLE (dlg->priv->table), 12);
gtk_window_set_title (GTK_WINDOW (dlg), _("Replace"));
}
else
{
gtk_widget_hide (dlg->priv->replace_label);
gtk_widget_hide (dlg->priv->replace_entry);
gtk_widget_hide (dlg->priv->replace_all_button);
gtk_widget_hide (dlg->priv->replace_button);
gtk_table_set_row_spacings (GTK_TABLE (dlg->priv->table), 0);
gtk_window_set_title (GTK_WINDOW (dlg), _("Find"));
}
gtk_widget_show (dlg->priv->find_button);
}
static void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_init (XeditSearchDialog *dlg)
2011-11-07 13:46:58 -06:00
{
GtkWidget *content;
GtkWidget *error_widget;
gboolean ret;
gchar *file;
gchar *root_objects[] = {
"search_dialog_content",
NULL
};
2016-01-25 08:13:49 -06:00
dlg->priv = XEDIT_SEARCH_DIALOG_GET_PRIVATE (dlg);
2011-11-07 13:46:58 -06:00
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
NULL);
/* HIG defaults */
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dlg))),
5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))),
6);
2016-01-25 08:13:49 -06:00
file = xedit_dirs_get_ui_file ("xedit-search-dialog.ui");
ret = xedit_utils_get_ui_objects (file,
2011-11-07 13:46:58 -06:00
root_objects,
&error_widget,
"search_dialog_content", &content,
"table", &dlg->priv->table,
"search_label", &dlg->priv->search_label,
"replace_with_label", &dlg->priv->replace_label,
"match_case_checkbutton", &dlg->priv->match_case_checkbutton,
"entire_word_checkbutton", &dlg->priv->entire_word_checkbutton,
"search_backwards_checkbutton", &dlg->priv->backwards_checkbutton,
"wrap_around_checkbutton", &dlg->priv->wrap_around_checkbutton,
"parse_escapes_checkbutton", &dlg->priv->parse_escapes_checkbutton,
2011-11-07 13:46:58 -06:00
NULL);
g_free (file);
if (!ret)
{
gtk_widget_show (error_widget);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
error_widget,
TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (error_widget),
5);
dlg->priv->ui_error = TRUE;
return;
}
2016-01-25 08:13:49 -06:00
dlg->priv->search_entry = xedit_history_entry_new ("history-search-for",
2011-11-07 13:46:58 -06:00
TRUE);
gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
2016-01-25 08:13:49 -06:00
xedit_history_entry_set_escape_func
(XEDIT_HISTORY_ENTRY (dlg->priv->search_entry),
(XeditHistoryEntryEscapeFunc) xedit_utils_escape_search_text);
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
dlg->priv->search_text_entry = xedit_history_entry_get_entry
(XEDIT_HISTORY_ENTRY (dlg->priv->search_entry));
2011-11-07 13:46:58 -06:00
gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->search_text_entry),
TRUE);
gtk_widget_show (dlg->priv->search_entry);
gtk_table_attach_defaults (GTK_TABLE (dlg->priv->table),
dlg->priv->search_entry,
1, 2, 0, 1);
2016-01-25 08:13:49 -06:00
dlg->priv->replace_entry = xedit_history_entry_new ("history-replace-with",
2011-11-07 13:46:58 -06:00
TRUE);
2016-01-25 08:13:49 -06:00
xedit_history_entry_set_escape_func
(XEDIT_HISTORY_ENTRY (dlg->priv->replace_entry),
(XeditHistoryEntryEscapeFunc) xedit_utils_escape_search_text);
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
dlg->priv->replace_text_entry = xedit_history_entry_get_entry
(XEDIT_HISTORY_ENTRY (dlg->priv->replace_entry));
2011-11-07 13:46:58 -06:00
gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->replace_text_entry),
TRUE);
gtk_widget_show (dlg->priv->replace_entry);
gtk_table_attach_defaults (GTK_TABLE (dlg->priv->table),
dlg->priv->replace_entry,
1, 2, 1, 2);
gtk_label_set_mnemonic_widget (GTK_LABEL (dlg->priv->search_label),
dlg->priv->search_entry);
gtk_label_set_mnemonic_widget (GTK_LABEL (dlg->priv->replace_label),
dlg->priv->replace_entry);
dlg->priv->find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
dlg->priv->replace_all_button = gtk_button_new_with_mnemonic (_("Replace _All"));
2016-01-25 08:13:49 -06:00
dlg->priv->replace_button = xedit_gtk_button_new_with_stock_icon (_("_Replace"),
2011-11-07 13:46:58 -06:00
GTK_STOCK_FIND_AND_REPLACE);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->replace_all_button,
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE);
2011-11-07 13:46:58 -06:00
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->replace_button,
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE);
2011-11-07 13:46:58 -06:00
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->find_button,
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_FIND_RESPONSE);
2011-11-07 13:46:58 -06:00
g_object_set (G_OBJECT (dlg->priv->find_button),
"can-default", TRUE,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_FIND_RESPONSE);
2011-11-07 13:46:58 -06:00
/* insensitive by default */
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_FIND_RESPONSE,
2011-11-07 13:46:58 -06:00
FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE,
2011-11-07 13:46:58 -06:00
FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
2011-11-07 13:46:58 -06:00
FALSE);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
content, FALSE, FALSE, 0);
g_object_unref (content);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
g_signal_connect (dlg->priv->search_text_entry,
"insert_text",
G_CALLBACK (insert_text_handler),
NULL);
g_signal_connect (dlg->priv->replace_text_entry,
"insert_text",
G_CALLBACK (insert_text_handler),
NULL);
g_signal_connect (dlg->priv->search_text_entry,
"changed",
G_CALLBACK (search_text_entry_changed),
dlg);
g_signal_connect (dlg,
"response",
G_CALLBACK (response_handler),
NULL);
}
GtkWidget *
2016-01-25 08:13:49 -06:00
xedit_search_dialog_new (GtkWindow *parent,
2011-11-07 13:46:58 -06:00
gboolean show_replace)
{
2016-01-25 08:13:49 -06:00
XeditSearchDialog *dlg;
2011-11-07 13:46:58 -06:00
2016-01-25 08:13:49 -06:00
dlg = g_object_new (XEDIT_TYPE_SEARCH_DIALOG,
2011-11-07 13:46:58 -06:00
"show-replace", show_replace,
NULL);
if (parent != NULL)
{
gtk_window_set_transient_for (GTK_WINDOW (dlg),
parent);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg),
TRUE);
}
return GTK_WIDGET (dlg);
}
gboolean
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_show_replace (XeditSearchDialog *dialog)
2011-11-07 13:46:58 -06:00
{
2016-01-25 08:13:49 -06:00
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
2011-11-07 13:46:58 -06:00
return dialog->priv->show_replace;
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_show_replace (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
gboolean show_replace)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
2011-11-07 13:46:58 -06:00
if (dialog->priv->ui_error)
return;
dialog->priv->show_replace = show_replace != FALSE;
show_replace_widgets (dialog, dialog->priv->show_replace);
g_object_notify (G_OBJECT (dialog), "show-replace");
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_search_text (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
const gchar *text)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
2011-11-07 13:46:58 -06:00
g_return_if_fail (text != NULL);
gtk_entry_set_text (GTK_ENTRY (dialog->priv->search_text_entry),
text);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_FIND_RESPONSE,
2011-11-07 13:46:58 -06:00
(text != '\0'));
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
2016-01-25 08:13:49 -06:00
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
2011-11-07 13:46:58 -06:00
(text != '\0'));
}
/*
* The text must be unescaped before searching.
*/
const gchar *
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_search_text (XeditSearchDialog *dialog)
2011-11-07 13:46:58 -06:00
{
2016-01-25 08:13:49 -06:00
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), NULL);
2011-11-07 13:46:58 -06:00
return gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_replace_text (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
const gchar *text)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
2011-11-07 13:46:58 -06:00
g_return_if_fail (text != NULL);
gtk_entry_set_text (GTK_ENTRY (dialog->priv->replace_text_entry),
text);
}
const gchar *
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_replace_text (XeditSearchDialog *dialog)
2011-11-07 13:46:58 -06:00
{
2016-01-25 08:13:49 -06:00
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), NULL);
2011-11-07 13:46:58 -06:00
return gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_match_case (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
gboolean match_case)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
2011-11-07 13:46:58 -06:00
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton),
match_case);
}
gboolean
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_match_case (XeditSearchDialog *dialog)
2011-11-07 13:46:58 -06:00
{
2016-01-25 08:13:49 -06:00
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
2011-11-07 13:46:58 -06:00
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton));
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_entire_word (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
gboolean entire_word)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
2011-11-07 13:46:58 -06:00
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton),
entire_word);
}
gboolean
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_entire_word (XeditSearchDialog *dialog)
2011-11-07 13:46:58 -06:00
{
2016-01-25 08:13:49 -06:00
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
2011-11-07 13:46:58 -06:00
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton));
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_backwards (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
gboolean backwards)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
2011-11-07 13:46:58 -06:00
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton),
backwards);
}
gboolean
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_backwards (XeditSearchDialog *dialog)
2011-11-07 13:46:58 -06:00
{
2016-01-25 08:13:49 -06:00
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
2011-11-07 13:46:58 -06:00
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton));
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_wrap_around (XeditSearchDialog *dialog,
2011-11-07 13:46:58 -06:00
gboolean wrap_around)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
2011-11-07 13:46:58 -06:00
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton),
wrap_around);
}
gboolean
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_wrap_around (XeditSearchDialog *dialog)
2011-11-07 13:46:58 -06:00
{
2016-01-25 08:13:49 -06:00
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
2011-11-07 13:46:58 -06:00
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton));
}
void
2016-01-25 08:13:49 -06:00
xedit_search_dialog_set_parse_escapes (XeditSearchDialog *dialog,
gboolean parse_escapes)
{
2016-01-25 08:13:49 -06:00
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->parse_escapes_checkbutton),
parse_escapes);
}
gboolean
2016-01-25 08:13:49 -06:00
xedit_search_dialog_get_parse_escapes (XeditSearchDialog *dialog)
{
2016-01-25 08:13:49 -06:00
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->parse_escapes_checkbutton));
}