Save search parameters

This commit is contained in:
Yevgen Muntyan 2006-06-04 22:14:33 -05:00
parent a5006ff5dc
commit 9e30f3424d
3 changed files with 58 additions and 4 deletions

View File

@ -62,6 +62,7 @@ const char *moo_edit_setting (const char *setting_name);
// #define MOO_EDIT_PREFS_SEARCH_SELECTED "search/search_selected"
#define MOO_EDIT_PREFS_QUICK_SEARCH_FLAGS "quick_search_flags"
#define MOO_EDIT_PREFS_SEARCH_FLAGS "search_flags"
//
// #define MOO_EDIT_PREFS_ON_EXTERNAL_CHANGES "on_external_changes"

View File

@ -17,6 +17,7 @@
#include "mooedit/mootextview.h"
#include "mooedit/mooeditdialogs.h"
#include "mooedit/mootextsearch.h"
#include "mooedit/mooeditprefs.h"
#include "mooutils/moohistoryentry.h"
#include "mooutils/mooentry.h"
#include "mooutils/moocompat.h"
@ -32,6 +33,8 @@ static MooHistoryList *search_history;
static MooHistoryList *replace_history;
static void init_find_history (void);
static GObject *moo_find_constructor (GType type,
guint n_props,
GObjectConstructParam *props);
@ -55,6 +58,26 @@ enum {
};
static void
init_find_history (void)
{
static gboolean been_here = FALSE;
if (!been_here)
{
been_here = TRUE;
search_history = moo_history_list_new ("MooFind");
replace_history = moo_history_list_new ("MooReplace");
last_search = moo_history_list_get_last_item (search_history);
moo_prefs_new_key_flags (moo_edit_setting (MOO_EDIT_PREFS_SEARCH_FLAGS),
MOO_TYPE_FIND_FLAGS, MOO_FIND_CASELESS);
last_search_flags = moo_prefs_get_flags (moo_edit_setting (MOO_EDIT_PREFS_SEARCH_FLAGS));
}
}
static void
moo_find_class_init (MooFindClass *klass)
{
@ -65,10 +88,7 @@ moo_find_class_init (MooFindClass *klass)
gobject_class->get_property = moo_find_get_property;
gobject_class->finalize = moo_find_finalize;
search_history = moo_history_list_new ("MooFind");
replace_history = moo_history_list_new ("MooReplace");
last_search = moo_history_list_get_last_item (search_history);
last_search_flags = MOO_FIND_CASELESS;
init_find_history ();
g_object_class_install_property (gobject_class,
PROP_REPLACE,
@ -656,6 +676,8 @@ moo_text_view_run_find_next (GtkTextView *view,
g_return_if_fail (GTK_IS_TEXT_VIEW (view));
init_find_history ();
if (!last_search)
return moo_text_view_run_find (view, msg_func, data);
@ -727,6 +749,8 @@ moo_text_view_run_find_prev (GtkTextView *view,
g_return_if_fail (GTK_IS_TEXT_VIEW (view));
init_find_history ();
if (!last_search)
return moo_text_view_run_find (view, msg_func, data);
@ -1008,6 +1032,32 @@ moo_text_view_run_replace (GtkTextView *view,
}
GType
moo_find_flags_get_type (void)
{
static GType type;
if (!type)
{
static GFlagsValue values[] = {
{ MOO_FIND_REGEX, (char*) "MOO_FIND_REGEX", (char*) "regex" },
{ MOO_FIND_CASELESS, (char*) "MOO_FIND_CASELESS", (char*) "caseless" },
{ MOO_FIND_IN_SELECTED, (char*) "MOO_FIND_IN_SELECTED", (char*) "selected" },
{ MOO_FIND_BACKWARDS, (char*) "MOO_FIND_BACKWARDS", (char*) "backwards" },
{ MOO_FIND_WHOLE_WORDS, (char*) "MOO_FIND_WHOLE_WORDS", (char*) "whole-words" },
{ MOO_FIND_FROM_CURSOR, (char*) "MOO_FIND_FROM_CURSOR", (char*) "from-cursor" },
{ MOO_FIND_DONT_PROMPT, (char*) "MOO_FIND_DONT_PROMPT", (char*) "do-not-prompt" },
{ MOO_FIND_REPL_LITERAL, (char*) "MOO_FIND_REPL_LITERAL", (char*) "repl-literal" },
{ 0, NULL, NULL }
};
type = g_flags_register_static ("MooFindFlags", values);
}
return type;
}
/****************************************************************************/
/* goto line
*/

View File

@ -23,6 +23,8 @@
G_BEGIN_DECLS
#define MOO_TYPE_FIND_FLAGS (moo_find_flags_get_type ())
#define MOO_TYPE_FIND (moo_find_get_type ())
#define MOO_FIND(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_FIND, MooFind))
#define MOO_FIND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_FIND, MooFindClass))
@ -63,6 +65,7 @@ typedef void (*MooFindMsgFunc) (const char *msg,
GType moo_find_get_type (void) G_GNUC_CONST;
GType moo_find_flags_get_type (void) G_GNUC_CONST;
GtkWidget *moo_find_new (gboolean replace);