Rename Search dialog as Replace dialog.

parent 40077162
......@@ -18,13 +18,13 @@ libdialogs_la_SOURCES = \
gedit-close-confirmation-dialog.h \
gedit-encodings-dialog.c \
gedit-encodings-dialog.h \
gedit-search-dialog.h \
gedit-search-dialog.c
gedit-replace-dialog.h \
gedit-replace-dialog.c
ui_DATA = \
gedit-encodings-dialog.ui \
gedit-preferences-dialog.ui \
gedit-search-dialog.ui
gedit-replace-dialog.ui
EXTRA_DIST = $(ui_DATA)
......
/*
* gedit-search-dialog.c
* gedit-replace-dialog.c
* This file is part of gedit
*
* Copyright (C) 2005 Paolo Maggi
......@@ -36,17 +36,17 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include "gedit-search-dialog.h"
#include "gedit-replace-dialog.h"
#include "gedit-history-entry.h"
#include "gedit-utils.h"
#include "gedit-marshal.h"
#include "gedit-dirs.h"
#define GEDIT_SEARCH_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
GEDIT_TYPE_SEARCH_DIALOG, \
GeditSearchDialogPrivate))
#define GEDIT_REPLACE_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
GEDIT_TYPE_REPLACE_DIALOG, \
GeditReplaceDialogPrivate))
struct _GeditSearchDialogPrivate
struct _GeditReplaceDialogPrivate
{
GtkWidget *table;
GtkWidget *search_label;
......@@ -66,13 +66,13 @@ struct _GeditSearchDialogPrivate
gboolean ui_error;
};
G_DEFINE_TYPE(GeditSearchDialog, gedit_search_dialog, GTK_TYPE_DIALOG)
G_DEFINE_TYPE(GeditReplaceDialog, gedit_replace_dialog, GTK_TYPE_DIALOG)
void
gedit_search_dialog_present_with_time (GeditSearchDialog *dialog,
gedit_replace_dialog_present_with_time (GeditReplaceDialog *dialog,
guint32 timestamp)
{
g_return_if_fail (GEDIT_SEARCH_DIALOG (dialog));
g_return_if_fail (GEDIT_REPLACE_DIALOG (dialog));
gtk_window_present_with_time (GTK_WINDOW (dialog), timestamp);
......@@ -80,11 +80,11 @@ gedit_search_dialog_present_with_time (GeditSearchDialog *dialog,
}
static void
gedit_search_dialog_class_init (GeditSearchDialogClass *klass)
gedit_replace_dialog_class_init (GeditReplaceDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (GeditSearchDialogPrivate));
g_type_class_add_private (object_class, sizeof (GeditReplaceDialogPrivate));
}
static void
......@@ -124,8 +124,8 @@ insert_text_handler (GtkEditable *editable,
}
static void
search_text_entry_changed (GtkEditable *editable,
GeditSearchDialog *dialog)
search_text_entry_changed (GtkEditable *editable,
GeditReplaceDialog *dialog)
{
const gchar *search_string;
......@@ -135,32 +135,32 @@ search_text_entry_changed (GtkEditable *editable,
if (*search_string != '\0')
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_FIND_RESPONSE, TRUE);
GEDIT_REPLACE_DIALOG_FIND_RESPONSE, TRUE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, TRUE);
GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE, TRUE);
}
else
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_FIND_RESPONSE, FALSE);
GEDIT_REPLACE_DIALOG_FIND_RESPONSE, FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE, FALSE);
GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE, FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, FALSE);
GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE, FALSE);
}
}
static void
response_handler (GeditSearchDialog *dialog,
gint response_id,
gpointer data)
response_handler (GeditReplaceDialog *dialog,
gint response_id,
gpointer data)
{
const gchar *str;
switch (response_id)
{
case GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE:
case GEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
case GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE:
case GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE:
str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
if (*str != '\0')
{
......@@ -174,7 +174,7 @@ response_handler (GeditSearchDialog *dialog,
g_free (text);
}
/* fall through, so that we also save the find entry */
case GEDIT_SEARCH_DIALOG_FIND_RESPONSE:
case GEDIT_REPLACE_DIALOG_FIND_RESPONSE:
str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
if (*str != '\0')
{
......@@ -191,18 +191,18 @@ response_handler (GeditSearchDialog *dialog,
}
static void
gedit_search_dialog_init (GeditSearchDialog *dlg)
gedit_replace_dialog_init (GeditReplaceDialog *dlg)
{
GtkWidget *content;
GtkWidget *error_widget;
gboolean ret;
gchar *file;
gchar *root_objects[] = {
"search_dialog_content",
"replace_dialog_content",
NULL
};
dlg->priv = GEDIT_SEARCH_DIALOG_GET_PRIVATE (dlg);
dlg->priv = GEDIT_REPLACE_DIALOG_GET_PRIVATE (dlg);
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
......@@ -221,11 +221,11 @@ gedit_search_dialog_init (GeditSearchDialog *dlg)
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))),
6);
file = gedit_dirs_get_ui_file ("gedit-search-dialog.ui");
file = gedit_dirs_get_ui_file ("gedit-replace-dialog.ui");
ret = gedit_utils_get_ui_objects (file,
root_objects,
&error_widget,
"search_dialog_content", &content,
"replace_dialog_content", &content,
"table", &dlg->priv->table,
"search_label", &dlg->priv->search_label,
"replace_with_label", &dlg->priv->replace_label,
......@@ -294,29 +294,29 @@ gedit_search_dialog_init (GeditSearchDialog *dlg)
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->replace_all_button,
GEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE);
GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->replace_button,
GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE);
GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->find_button,
GEDIT_SEARCH_DIALOG_FIND_RESPONSE);
GEDIT_REPLACE_DIALOG_FIND_RESPONSE);
g_object_set (G_OBJECT (dlg->priv->find_button),
"can-default", TRUE,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
GEDIT_SEARCH_DIALOG_FIND_RESPONSE);
GEDIT_REPLACE_DIALOG_FIND_RESPONSE);
/* insensitive by default */
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
GEDIT_SEARCH_DIALOG_FIND_RESPONSE,
GEDIT_REPLACE_DIALOG_FIND_RESPONSE,
FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE,
GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE,
FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
GEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE,
FALSE);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
......@@ -346,11 +346,11 @@ gedit_search_dialog_init (GeditSearchDialog *dlg)
}
GtkWidget *
gedit_search_dialog_new (GtkWindow *parent)
gedit_replace_dialog_new (GtkWindow *parent)
{
GeditSearchDialog *dlg;
GeditReplaceDialog *dlg;
dlg = g_object_new (GEDIT_TYPE_SEARCH_DIALOG,
dlg = g_object_new (GEDIT_TYPE_REPLACE_DIALOG,
NULL);
if (parent != NULL)
......@@ -366,21 +366,21 @@ gedit_search_dialog_new (GtkWindow *parent)
}
void
gedit_search_dialog_set_search_text (GeditSearchDialog *dialog,
const gchar *text)
gedit_replace_dialog_set_search_text (GeditReplaceDialog *dialog,
const gchar *text)
{
g_return_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog));
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),
GEDIT_SEARCH_DIALOG_FIND_RESPONSE,
GEDIT_REPLACE_DIALOG_FIND_RESPONSE,
(text != '\0'));
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE,
(text != '\0'));
}
......@@ -388,18 +388,18 @@ gedit_search_dialog_set_search_text (GeditSearchDialog *dialog,
* The text must be unescaped before searching.
*/
const gchar *
gedit_search_dialog_get_search_text (GeditSearchDialog *dialog)
gedit_replace_dialog_get_search_text (GeditReplaceDialog *dialog)
{
g_return_val_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog), NULL);
g_return_val_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog), NULL);
return gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
}
void
gedit_search_dialog_set_replace_text (GeditSearchDialog *dialog,
const gchar *text)
gedit_replace_dialog_set_replace_text (GeditReplaceDialog *dialog,
const gchar *text)
{
g_return_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog));
g_return_if_fail (text != NULL);
gtk_entry_set_text (GTK_ENTRY (dialog->priv->replace_text_entry),
......@@ -407,81 +407,81 @@ gedit_search_dialog_set_replace_text (GeditSearchDialog *dialog,
}
const gchar *
gedit_search_dialog_get_replace_text (GeditSearchDialog *dialog)
gedit_replace_dialog_get_replace_text (GeditReplaceDialog *dialog)
{
g_return_val_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog), NULL);
g_return_val_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog), NULL);
return gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
}
void
gedit_search_dialog_set_match_case (GeditSearchDialog *dialog,
gboolean match_case)
gedit_replace_dialog_set_match_case (GeditReplaceDialog *dialog,
gboolean match_case)
{
g_return_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton),
match_case);
}
gboolean
gedit_search_dialog_get_match_case (GeditSearchDialog *dialog)
gedit_replace_dialog_get_match_case (GeditReplaceDialog *dialog)
{
g_return_val_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
g_return_val_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton));
}
void
gedit_search_dialog_set_entire_word (GeditSearchDialog *dialog,
gboolean entire_word)
gedit_replace_dialog_set_entire_word (GeditReplaceDialog *dialog,
gboolean entire_word)
{
g_return_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton),
entire_word);
}
gboolean
gedit_search_dialog_get_entire_word (GeditSearchDialog *dialog)
gedit_replace_dialog_get_entire_word (GeditReplaceDialog *dialog)
{
g_return_val_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
g_return_val_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton));
}
void
gedit_search_dialog_set_backwards (GeditSearchDialog *dialog,
gboolean backwards)
gedit_replace_dialog_set_backwards (GeditReplaceDialog *dialog,
gboolean backwards)
{
g_return_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton),
backwards);
}
gboolean
gedit_search_dialog_get_backwards (GeditSearchDialog *dialog)
gedit_replace_dialog_get_backwards (GeditReplaceDialog *dialog)
{
g_return_val_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
g_return_val_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton));
}
void
gedit_search_dialog_set_wrap_around (GeditSearchDialog *dialog,
gboolean wrap_around)
gedit_replace_dialog_set_wrap_around (GeditReplaceDialog *dialog,
gboolean wrap_around)
{
g_return_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton),
wrap_around);
}
gboolean
gedit_search_dialog_get_wrap_around (GeditSearchDialog *dialog)
gedit_replace_dialog_get_wrap_around (GeditReplaceDialog *dialog)
{
g_return_val_if_fail (GEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
g_return_val_if_fail (GEDIT_IS_REPLACE_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton));
}
......
/*
* gedit-search-dialog.h
* gedit-replace-dialog.h
* This file is part of gedit
*
* Copyright (C) 2005 Paolo Maggi
......@@ -28,8 +28,8 @@
* $Id$
*/
#ifndef __GEDIT_SEARCH_DIALOG_H__
#define __GEDIT_SEARCH_DIALOG_H__
#ifndef __GEDIT_REPLACE_DIALOG_H__
#define __GEDIT_REPLACE_DIALOG_H__
#include <gtk/gtk.h>
......@@ -38,83 +38,83 @@ G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define GEDIT_TYPE_SEARCH_DIALOG (gedit_search_dialog_get_type())
#define GEDIT_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_SEARCH_DIALOG, GeditSearchDialog))
#define GEDIT_SEARCH_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_SEARCH_DIALOG, GeditSearchDialog const))
#define GEDIT_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_SEARCH_DIALOG, GeditSearchDialogClass))
#define GEDIT_IS_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GEDIT_TYPE_SEARCH_DIALOG))
#define GEDIT_IS_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_SEARCH_DIALOG))
#define GEDIT_SEARCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_SEARCH_DIALOG, GeditSearchDialogClass))
#define GEDIT_TYPE_REPLACE_DIALOG (gedit_replace_dialog_get_type())
#define GEDIT_REPLACE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_REPLACE_DIALOG, GeditReplaceDialog))
#define GEDIT_REPLACE_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_REPLACE_DIALOG, GeditReplaceDialog const))
#define GEDIT_REPLACE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_REPLACE_DIALOG, GeditReplaceDialogClass))
#define GEDIT_IS_REPLACE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GEDIT_TYPE_REPLACE_DIALOG))
#define GEDIT_IS_REPLACE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_REPLACE_DIALOG))
#define GEDIT_REPLACE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_REPLACE_DIALOG, GeditReplaceDialogClass))
/* Private structure type */
typedef struct _GeditSearchDialogPrivate GeditSearchDialogPrivate;
typedef struct _GeditReplaceDialogPrivate GeditReplaceDialogPrivate;
/*
* Main object structure
*/
typedef struct _GeditSearchDialog GeditSearchDialog;
typedef struct _GeditReplaceDialog GeditReplaceDialog;
struct _GeditSearchDialog
struct _GeditReplaceDialog
{
GtkDialog dialog;
/*< private > */
GeditSearchDialogPrivate *priv;
GeditReplaceDialogPrivate *priv;
};
/*
* Class definition
*/
typedef struct _GeditSearchDialogClass GeditSearchDialogClass;
typedef struct _GeditReplaceDialogClass GeditReplaceDialogClass;
struct _GeditSearchDialogClass
struct _GeditReplaceDialogClass
{
GtkDialogClass parent_class;
};
enum
{
GEDIT_SEARCH_DIALOG_FIND_RESPONSE = 100,
GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE,
GEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE
GEDIT_REPLACE_DIALOG_FIND_RESPONSE = 100,
GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE,
GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE
};
/*
* Public methods
*/
GType gedit_search_dialog_get_type (void) G_GNUC_CONST;
GType gedit_replace_dialog_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_search_dialog_new (GtkWindow *parent);
GtkWidget *gedit_replace_dialog_new (GtkWindow *parent);
void gedit_search_dialog_present_with_time (GeditSearchDialog *dialog,
guint32 timestamp);
void gedit_replace_dialog_present_with_time (GeditReplaceDialog *dialog,
guint32 timestamp);
void gedit_search_dialog_set_search_text (GeditSearchDialog *dialog,
const gchar *text);
const gchar *gedit_search_dialog_get_search_text (GeditSearchDialog *dialog);
void gedit_replace_dialog_set_search_text (GeditReplaceDialog *dialog,
const gchar *text);
const gchar *gedit_replace_dialog_get_search_text (GeditReplaceDialog *dialog);
void gedit_search_dialog_set_replace_text (GeditSearchDialog *dialog,
const gchar *text);
const gchar *gedit_search_dialog_get_replace_text (GeditSearchDialog *dialog);
void gedit_replace_dialog_set_replace_text (GeditReplaceDialog *dialog,
const gchar *text);
const gchar *gedit_replace_dialog_get_replace_text (GeditReplaceDialog *dialog);
void gedit_search_dialog_set_match_case (GeditSearchDialog *dialog,
gboolean match_case);
gboolean gedit_search_dialog_get_match_case (GeditSearchDialog *dialog);
void gedit_replace_dialog_set_match_case (GeditReplaceDialog *dialog,
gboolean match_case);
gboolean gedit_replace_dialog_get_match_case (GeditReplaceDialog *dialog);
void gedit_search_dialog_set_entire_word (GeditSearchDialog *dialog,
gboolean entire_word);
gboolean gedit_search_dialog_get_entire_word (GeditSearchDialog *dialog);
void gedit_replace_dialog_set_entire_word (GeditReplaceDialog *dialog,
gboolean entire_word);
gboolean gedit_replace_dialog_get_entire_word (GeditReplaceDialog *dialog);
void gedit_search_dialog_set_backwards (GeditSearchDialog *dialog,
gboolean backwards);
gboolean gedit_search_dialog_get_backwards (GeditSearchDialog *dialog);
void gedit_replace_dialog_set_backwards (GeditReplaceDialog *dialog,
gboolean backwards);
gboolean gedit_replace_dialog_get_backwards (GeditReplaceDialog *dialog);
void gedit_search_dialog_set_wrap_around (GeditSearchDialog *dialog,
gboolean wrap_around);
gboolean gedit_search_dialog_get_wrap_around (GeditSearchDialog *dialog);
void gedit_replace_dialog_set_wrap_around (GeditReplaceDialog *dialog,
gboolean wrap_around);
gboolean gedit_replace_dialog_get_wrap_around (GeditReplaceDialog *dialog);
G_END_DECLS
#endif /* __GEDIT_SEARCH_DIALOG_H__ */
#endif /* __GEDIT_REPLACE_DIALOG_H__ */
/* ex:ts=8:noet: */
......@@ -45,9 +45,9 @@
#include "gedit-window.h"
#include "gedit-window-private.h"
#include "gedit-utils.h"
#include "dialogs/gedit-search-dialog.h"
#include "dialogs/gedit-replace-dialog.h"
#define GEDIT_SEARCH_DIALOG_KEY "gedit-search-dialog-key"
#define GEDIT_REPLACE_DIALOG_KEY "gedit-replace-dialog-key"
#define GEDIT_LAST_SEARCH_DATA_KEY "gedit-last-search-data-key"
typedef struct _LastSearchData LastSearchData;
......@@ -64,7 +64,7 @@ last_search_data_free (LastSearchData *data)
}
static void
last_search_data_restore_position (GeditSearchDialog *dlg)
last_search_data_restore_position (GeditReplaceDialog *dlg)
{
LastSearchData *data;
......@@ -79,7 +79,7 @@ last_search_data_restore_position (GeditSearchDialog *dlg)
}
static void
last_search_data_store_position (GeditSearchDialog *dlg)
last_search_data_store_position (GeditReplaceDialog *dlg)
{
LastSearchData *data;
......@@ -224,8 +224,8 @@ run_search (GeditView *view,
}
static void
do_find (GeditSearchDialog *dialog,
GeditWindow *window)
do_find (GeditReplaceDialog *dialog,
GeditWindow *window)
{
GeditView *active_view;
GeditDocument *doc;
......@@ -247,12 +247,12 @@ do_find (GeditSearchDialog *dialog,
doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
entry_text = gedit_search_dialog_get_search_text (dialog);
entry_text = gedit_replace_dialog_get_search_text (dialog);
match_case = gedit_search_dialog_get_match_case (dialog);
entire_word = gedit_search_dialog_get_entire_word (dialog);
search_backwards = gedit_search_dialog_get_backwards (dialog);
wrap_around = gedit_search_dialog_get_wrap_around (dialog);
match_case = gedit_replace_dialog_get_match_case (dialog);
entire_word = gedit_replace_dialog_get_entire_word (dialog);
search_backwards = gedit_replace_dialog_get_backwards (dialog);
wrap_around = gedit_replace_dialog_get_wrap_around (dialog);
GEDIT_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
GEDIT_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
......@@ -278,7 +278,7 @@ do_find (GeditSearchDialog *dialog,
text_not_found (window, entry_text);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE,
GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE,
found);
}
......@@ -326,8 +326,8 @@ replace_selected_text (GtkTextBuffer *buffer,
}
static void
do_replace (GeditSearchDialog *dialog,
GeditWindow *window)
do_replace (GeditReplaceDialog *dialog,
GeditWindow *window)
{
GeditDocument *doc;
const gchar *search_entry_text;
......@@ -341,12 +341,12 @@ do_replace (GeditSearchDialog *dialog,
if (doc == NULL)
return;
search_entry_text = gedit_search_dialog_get_search_text (dialog);
search_entry_text = gedit_replace_dialog_get_search_text (dialog);
g_return_if_fail ((search_entry_text) != NULL);
g_return_if_fail ((*search_entry_text) != '\0');
/* replace text may be "", we just delete */
replace_entry_text = gedit_search_dialog_get_replace_text (dialog);
replace_entry_text = gedit_replace_dialog_get_replace_text (dialog);
g_return_if_fail ((replace_entry_text) != NULL);
unescaped_search_text = gedit_utils_unescape_search_text (search_entry_text);
......@@ -355,7 +355,7 @@ do_replace (GeditSearchDialog *dialog,
&selected_text,
NULL);
match_case = gedit_search_dialog_get_match_case (dialog);
match_case = gedit_replace_dialog_get_match_case (dialog);
if ((selected_text == NULL) ||
(match_case && (strcmp (selected_text, unescaped_search_text) != 0)) ||
......@@ -382,8 +382,8 @@ do_replace (GeditSearchDialog *dialog,
}
static void
do_replace_all (GeditSearchDialog *dialog,
GeditWindow *window)
do_replace_all (GeditReplaceDialog *dialog,
GeditWindow *window)
{
GeditView *active_view;
GeditDocument *doc;
......@@ -400,16 +400,16 @@ do_replace_all (GeditSearchDialog *dialog,
doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
search_entry_text = gedit_search_dialog_get_search_text (dialog);
search_entry_text = gedit_replace_dialog_get_search_text (dialog);
g_return_if_fail ((search_entry_text) != NULL);
g_return_if_fail ((*search_entry_text) != '\0');
/* replace text may be "", we just delete all occurrencies */
replace_entry_text = gedit_search_dialog_get_replace_text (dialog);
replace_entry_text = gedit_replace_dialog_get_replace_text (dialog);
g_return_if_fail ((replace_entry_text) != NULL);
match_case = gedit_search_dialog_get_match_case (dialog);
entire_word = gedit_search_dialog_get_entire_word (dialog);
match_case = gedit_replace_dialog_get_match_case (dialog);
entire_word = gedit_replace_dialog_get_entire_word (dialog);
GEDIT_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
GEDIT_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
......@@ -429,26 +429,26 @@ do_replace_all (GeditSearchDialog *dialog,
}
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE,
GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE,
FALSE);
}
static void
search_dialog_response_cb (GeditSearchDialog *dialog,
gint response_id,
GeditWindow *window)
replace_dialog_response_cb (GeditReplaceDialog *dialog,
gint response_id,
GeditWindow *window)
{
gedit_debug (DEBUG_COMMANDS);
switch (response_id)
{
case GEDIT_SEARCH_DIALOG_FIND_RESPONSE:
case GEDIT_REPLACE_DIALOG_FIND_RESPONSE:
do_find (dialog, window);
break;
case GEDIT_SEARCH_DIALOG_REPLACE_RESPONSE:
case GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE:
do_replace (dialog, window);
break;
case GEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
case GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE:
do_replace_all (dialog, window);
break;
default:
......@@ -458,9 +458,9 @@ search_dialog_response_cb (GeditSearchDialog *dialog,
}
static gboolean
search_dialog_delete_event_cb (GtkWidget *widget,
GdkEventAny *event,
gpointer user_data)
replace_dialog_delete_event_cb (GtkWidget *widget,
GdkEventAny *event,
gpointer user_data)
{
gedit_debug (DEBUG_COMMANDS);
......@@ -469,13 +469,13 @@ search_dialog_delete_event_cb (GtkWidget *widget,
}
static void
search_dialog_destroyed (GeditWindow *window,
GeditSearchDialog *dialog)
replace_dialog_destroyed (GeditWindow *window,
GeditReplaceDialog *dialog)
{
gedit_debug (DEBUG_COMMANDS);
g_object_set_data (G_OBJECT (window),
GEDIT_SEARCH_DIALOG_KEY,
GEDIT_REPLACE_DIALOG_KEY,
NULL);
g_object_set_data (G_OBJECT (dialog),
GEDIT_LAST_SEARCH_DATA_KEY,
......@@ -487,23 +487,23 @@ create_dialog (GeditWindow *window)
{
GtkWidget *dialog;
dialog = gedit_search_dialog_new (GTK_WINDOW (window));
dialog = gedit_replace_dialog_new (GTK_WINDOW (window));
g_signal_connect (dialog,
"response",
G_CALLBACK (search_dialog_response_cb),
G_CALLBACK (replace_dialog_response_cb),
window);
g_signal_connect (dialog,
"delete-event",
G_CALLBACK (search_dialog_delete_event_cb),
G_CALLBACK (replace_dialog_delete_event_cb),
NULL);
g_object_set_data (G_OBJECT (window),
GEDIT_SEARCH_DIALOG_KEY,
GEDIT_REPLACE_DIALOG_KEY,
dialog);
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) search_dialog_destroyed,
(GWeakNotify) replace_dialog_destroyed,
window);