gnome-commander r2316 - in branches/gcmd-1-3: . src src/intviewer
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r2316 - in branches/gcmd-1-3: . src src/intviewer
- Date: Tue, 25 Nov 2008 21:44:26 +0000 (UTC)
Author: epiotr
Date: Tue Nov 25 21:44:26 2008
New Revision: 2316
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2316&view=rev
Log:
Find file dlg: copy searched text phrase into intviewer text search dlg (F3-F3)
Modified:
branches/gcmd-1-3/ChangeLog
branches/gcmd-1-3/src/gnome-cmd-data.cc
branches/gcmd-1-3/src/gnome-cmd-data.h
branches/gcmd-1-3/src/gnome-cmd-search-dialog.cc
branches/gcmd-1-3/src/intviewer/search-dlg.cc
branches/gcmd-1-3/src/intviewer/viewer-utils.cc
branches/gcmd-1-3/src/intviewer/viewer-utils.h
Modified: branches/gcmd-1-3/src/gnome-cmd-data.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-data.cc (original)
+++ branches/gcmd-1-3/src/gnome-cmd-data.cc Tue Nov 25 21:44:26 2008
@@ -822,6 +822,15 @@
}
+inline void GnomeCmdData::save_intviewer_defaults()
+{
+ gnome_cmd_data_set_string_history ("/internal_viewer/text_pattern%d", intviewer_defaults.text_patterns.ents);
+ gnome_cmd_data_set_string_history ("/internal_viewer/hex_pattern%d", intviewer_defaults.hex_patterns.ents);
+ gnome_cmd_data_set_bool ("/internal_viewer/case_sens", intviewer_defaults.case_sensitive);
+ gnome_cmd_data_set_int ("/internal_viewer/last_mode", intviewer_defaults.search_mode);
+}
+
+
inline void GnomeCmdData::save_rename_history()
{
GList *from = NULL;
@@ -976,6 +985,22 @@
}
+inline void GnomeCmdData::load_intviewer_defaults()
+{
+ GList *list = NULL;
+
+ list = load_string_history ("/internal_viewer/text_pattern%d", -1);
+ intviewer_defaults.text_patterns.ents = list;
+ intviewer_defaults.text_patterns.pos = list;
+ list = load_string_history ("/internal_viewer/hex_pattern%d", -1);
+ intviewer_defaults.hex_patterns.ents = list;
+ intviewer_defaults.hex_patterns.pos = list;
+
+ intviewer_defaults.case_sensitive = gnome_cmd_data_get_bool ("/internal_viewer/case_sens", FALSE);
+ intviewer_defaults.search_mode = gnome_cmd_data_get_int ("/internal_viewer/last_mode", 0);
+}
+
+
inline void GnomeCmdData::load_rename_history()
{
gint size;
@@ -1377,6 +1402,7 @@
//load_dir_history ();
load_search_defaults();
load_rename_history();
+ load_intviewer_defaults();
load_auto_load_plugins();
set_vfs_volume_monitor ();
@@ -1731,6 +1757,7 @@
save_fav_apps ("fav-apps");
save_search_defaults();
save_rename_history();
+ save_intviewer_defaults();
save_local_bookmarks();
save_smb_bookmarks();
save_auto_load_plugins();
Modified: branches/gcmd-1-3/src/gnome-cmd-data.h
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-data.h (original)
+++ branches/gcmd-1-3/src/gnome-cmd-data.h Tue Nov 25 21:44:26 2008
@@ -72,6 +72,18 @@
~AdvrenameConfig() { if (regexes) g_object_unref (regexes); }
};
+ struct IntViewerConfig
+ {
+ History text_patterns;
+ History hex_patterns;
+ gboolean case_sensitive;
+ guint search_mode;
+
+ IntViewerConfig(): text_patterns(INTVIEWER_HISTORY_SIZE),
+ hex_patterns(INTVIEWER_HISTORY_SIZE),
+ case_sensitive(FALSE), search_mode(0) {}
+ };
+
struct FilterSettings
{
gboolean file_types[8];
@@ -95,12 +107,14 @@
void load_local_bookmarks();
void load_rename_history();
void load_search_defaults();
+ void load_intviewer_defaults();
void load_smb_bookmarks();
void save_auto_load_plugins();
void save_cmdline_history();
void save_local_bookmarks();
void save_rename_history();
void save_search_defaults();
+ void save_intviewer_defaults();
void save_smb_bookmarks();
public:
@@ -117,6 +131,7 @@
SearchConfig search_defaults;
AdvrenameConfig advrename_defaults;
+ IntViewerConfig intviewer_defaults;
gboolean case_sens_sort;
GnomeCmdExtDispMode ext_disp_mode;
Modified: branches/gcmd-1-3/src/gnome-cmd-search-dialog.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-search-dialog.cc (original)
+++ branches/gcmd-1-3/src/gnome-cmd-search-dialog.cc Tue Nov 25 21:44:26 2008
@@ -530,7 +530,10 @@
gnome_cmd_data.search_defaults.name_patterns.add(data->name_pattern);
gnome_cmd_data.search_defaults.directories.add(data->dir);
if (data->content_search)
+ {
gnome_cmd_data.search_defaults.content_patterns.add(data->content_pattern);
+ gnome_cmd_data.intviewer_defaults.text_patterns.add(data->content_pattern);
+ }
dialog->priv->result_list->remove_all_files();
Modified: branches/gcmd-1-3/src/intviewer/search-dlg.cc
==============================================================================
--- branches/gcmd-1-3/src/intviewer/search-dlg.cc (original)
+++ branches/gcmd-1-3/src/intviewer/search-dlg.cc Tue Nov 25 21:44:26 2008
@@ -28,6 +28,8 @@
#include <libgnome/libgnome.h>
#include "libgviewer.h"
+#include "gnome-cmd-includes.h"
+#include "gnome-cmd-data.h"
using namespace std;
@@ -35,8 +37,6 @@
// HEX history doesn't work yet
#undef HEX_HISTORY
-#define SEARCH_DLG_MAX_HISTORY 16
-
static GtkDialogClass *parent_class = NULL;
void entry_changed(GtkEntry *entry, gpointer user_data);
@@ -52,61 +52,13 @@
GtkWidget *case_sensitive_checkbox;
SEARCHMODE searchmode;
- gboolean case_sensitive;
- gchar *last_entry_text;
gchar *search_text_string;
guint8 *search_hex_buffer;
guint search_hex_buflen;
- GList *text_pattern_history;
-#if HEX_HISTORY
- GList *hex_pattern_history;
-#endif
};
-static void load_search_dlg_state (GViewerSearchDlg *sdlg)
-{
- g_return_if_fail (sdlg!=NULL);
- g_return_if_fail (sdlg->priv!=NULL);
-
- sdlg->priv->text_pattern_history = gviewer_load_string_history (GVIEWER_DEFAULT_PATH_PREFIX "text_pattern%d", -1);
-
-#if HEX_HISTORY
- sdlg->priv->hex_pattern_history = gviewer_load_string_history (GVIEWER_DEFAULT_PATH_PREFIX "hex_pattern%d", -1);
-#endif
-
- sdlg->priv->last_entry_text = gviewer_get_string (GVIEWER_DEFAULT_PATH_PREFIX "last_text", "");
-
- sdlg->priv->searchmode = SEARCH_MODE_TEXT;
- int i = gviewer_get_int (GVIEWER_DEFAULT_PATH_PREFIX "last_mode", (int) SEARCH_MODE_TEXT);
- if (i==(int) SEARCH_MODE_HEX)
- sdlg->priv->searchmode = SEARCH_MODE_HEX;
-
- sdlg->priv->case_sensitive = gviewer_get_bool (GVIEWER_DEFAULT_PATH_PREFIX "case_sens", FALSE);
-}
-
-
-static void save_search_dlg_state (GViewerSearchDlg *sdlg)
-{
- g_return_if_fail (sdlg!=NULL);
- g_return_if_fail (sdlg->priv!=NULL);
-
- gnome_config_set_int (GVIEWER_DEFAULT_PATH_PREFIX "last_mode", (int) sdlg->priv->searchmode);
- gnome_config_set_bool (GVIEWER_DEFAULT_PATH_PREFIX "case_sens", sdlg->priv->case_sensitive);
-
- gviewer_write_string_history (GVIEWER_DEFAULT_PATH_PREFIX "text_pattern%d", sdlg->priv->text_pattern_history);
-
-#if HEX_HISTORY
- gviewer_write_string_history (GVIEWER_DEFAULT_PATH_PREFIX "hex_pattern%d", sdlg->priv->hex_pattern_history);
-#endif
-
- gnome_config_set_string (GVIEWER_DEFAULT_PATH_PREFIX "last_text", sdlg->priv->last_entry_text);
-
- gnome_config_sync ();
-}
-
-
guint8 *gviewer_search_dlg_get_search_hex_buffer (GViewerSearchDlg *sdlg, /*out*/ guint *buflen)
{
g_return_val_if_fail (sdlg!=NULL, NULL);
@@ -148,19 +100,19 @@
g_return_val_if_fail (sdlg!=NULL, TRUE);
g_return_val_if_fail (sdlg->priv!=NULL, TRUE);
- return sdlg->priv->case_sensitive;
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sdlg->priv->case_sensitive_checkbox));
}
-static void set_text_history (GViewerSearchDlg *sdlg)
+inline void set_text_history (GViewerSearchDlg *sdlg)
{
- for (GList *strings = sdlg->priv->text_pattern_history; strings; strings = strings->next)
- if (strings->data!=NULL)
- gtk_combo_box_prepend_text(GTK_COMBO_BOX(sdlg->priv->entry), (gchar *) strings->data);
+ for (GList *i=gnome_cmd_data.intviewer_defaults.text_patterns.ents; i; i=i->next)
+ if (i->data)
+ gtk_combo_box_append_text (GTK_COMBO_BOX (sdlg->priv->entry), (gchar *) i->data);
}
-static void set_text_mode (GViewerSearchDlg *sdlg)
+inline void set_text_mode (GViewerSearchDlg *sdlg)
{
gtk_widget_grab_focus (sdlg->priv->entry);
sdlg->priv->searchmode = SEARCH_MODE_TEXT;
@@ -174,11 +126,10 @@
static void set_hex_mode (GViewerSearchDlg *sdlg)
{
#if HEX_HISTORY
- for (GList *strings = sdlg->priv->hex_pattern_history; strings; strings = strings->next)
- if (strings->data!=NULL)
- gtk_combo_box_prepend_text (GTK_COMBO_BOX (sdlg->priv->entry), (gchar *) strings->data);
+ for (GList *i=gnome_cmd_data.intviewer_defaults.hex_patterns.ents; i; i=i->next)
+ if (i->data)
+ gtk_combo_box_prepend_text (GTK_COMBO_BOX (sdlg->priv->entry), (gchar *) i->data);
#endif
-
gtk_widget_grab_focus (sdlg->priv->entry);
sdlg->priv->searchmode = SEARCH_MODE_HEX;
@@ -224,45 +175,24 @@
g_return_if_fail (sdlg->priv->search_text_string==NULL);
g_return_if_fail (sdlg->priv->search_hex_buffer==NULL);
- gchar *pattern;
-
- if (sdlg->priv->searchmode==SEARCH_MODE_TEXT)
- {
- // Text mode search
- pattern = gtk_combo_box_get_active_text(GTK_COMBO_BOX(sdlg->priv->entry));
+ gchar *pattern = gtk_combo_box_get_active_text (GTK_COMBO_BOX (sdlg->priv->entry));
- sdlg->priv->search_text_string = g_strdup(pattern);
+ sdlg->priv->search_text_string = g_strdup (pattern);
- // Add a new text pattern to the history list
- if (!gviewer_find_string_history(sdlg->priv->text_pattern_history, pattern))
- sdlg->priv->text_pattern_history = g_list_append(sdlg->priv->text_pattern_history, pattern);
-
- if (g_list_length(sdlg->priv->text_pattern_history)>SEARCH_DLG_MAX_HISTORY)
- sdlg->priv->text_pattern_history = g_list_delete_link(sdlg->priv->text_pattern_history, g_list_first(sdlg->priv->text_pattern_history));
+ if (sdlg->priv->searchmode==SEARCH_MODE_TEXT) // text mode search
+ {
+ gnome_cmd_data.intviewer_defaults.text_patterns.add(pattern);
- sdlg->priv->case_sensitive = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(sdlg->priv->case_sensitive_checkbox));
+ gnome_cmd_data.intviewer_defaults.case_sensitive =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sdlg->priv->case_sensitive_checkbox));
}
- else
+ else // hex mode search
{
- // Hex Mode Search
- pattern = gtk_combo_box_get_active_text(GTK_COMBO_BOX(sdlg->priv->entry));
- sdlg->priv->search_text_string = g_strdup(pattern);
-
sdlg->priv->search_hex_buffer = text2hex(pattern, &sdlg->priv->search_hex_buflen);
g_return_if_fail (sdlg->priv->search_hex_buffer!=NULL);
-#if HEX_HISTORY
- // Add a new text pattern to the history list
- if (!gviewer_find_string_history(sdlg->priv->hex_pattern_history, pattern))
- sdlg->priv->hex_pattern_history = g_list_prepend (sdlg->priv->hex_pattern_history, pattern);
-#endif
-
+ gnome_cmd_data.intviewer_defaults.hex_patterns.add(pattern);
}
-
- // Store the text
- g_free (sdlg->priv->last_entry_text);
- sdlg->priv->last_entry_text = g_strdup (pattern);
}
@@ -304,14 +234,14 @@
static void search_dlg_init (GViewerSearchDlg *sdlg)
{
+ GtkDialog *dlg = GTK_DIALOG (sdlg);
+
GtkTable *table;
GtkWidget *entry;
sdlg->priv = g_new0(GViewerSearchDlgPrivate, 1);
- GtkDialog *dlg = GTK_DIALOG (sdlg);
-
- load_search_dlg_state(sdlg);
+ sdlg->priv->searchmode = (SEARCHMODE) gnome_cmd_data.intviewer_defaults.search_mode;
gtk_window_set_title(GTK_WINDOW (dlg), _("Find"));
gtk_window_set_modal(GTK_WINDOW (dlg), TRUE);
@@ -371,9 +301,10 @@
set_text_mode (sdlg);
}
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sdlg->priv->case_sensitive_checkbox), sdlg->priv->case_sensitive);
- if (sdlg->priv->last_entry_text!=NULL)
- gtk_entry_set_text(GTK_ENTRY(entry), sdlg->priv->last_entry_text);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sdlg->priv->case_sensitive_checkbox), gnome_cmd_data.intviewer_defaults.case_sensitive);
+
+ if (!gnome_cmd_data.intviewer_defaults.text_patterns.empty())
+ gtk_entry_set_text(GTK_ENTRY(entry), gnome_cmd_data.intviewer_defaults.text_patterns.front());
gtk_widget_grab_focus (sdlg->priv->entry);
}
@@ -388,24 +319,11 @@
if (w->priv)
{
- save_search_dlg_state (w);
+ gnome_cmd_data.intviewer_defaults.search_mode = w->priv->searchmode;
g_free (w->priv->search_text_string);
w->priv->search_text_string = NULL;
- if (w->priv->text_pattern_history!=NULL)
- gviewer_free_string_history(w->priv->text_pattern_history);
- w->priv->text_pattern_history=NULL;
-
-#if HEX_HISTORY
- if (w->priv->hex_pattern_history!=NULL)
- gviewer_free_string_history(w->priv->hex_pattern_history);
- w->priv->hex_pattern_history=NULL;
-#endif
-
- g_free (w->priv->last_entry_text);
- w->priv->last_entry_text = NULL;
-
g_free (w->priv);
w->priv = NULL;
}
Modified: branches/gcmd-1-3/src/intviewer/viewer-utils.cc
==============================================================================
--- branches/gcmd-1-3/src/intviewer/viewer-utils.cc (original)
+++ branches/gcmd-1-3/src/intviewer/viewer-utils.cc Tue Nov 25 21:44:26 2008
@@ -64,58 +64,6 @@
}
-void gviewer_free_string_history (GList *strings)
-{
- for (GList *temp = strings; temp; temp = temp->next)
- if (temp->data!=NULL)
- {
- g_free (temp->data);
- temp->data = NULL;
- }
- g_list_free(strings);
-}
-
-
-void gviewer_write_string_history (gchar *format, GList *strings)
-{
- gchar key[128];
-
- for (gint i=0; strings; strings = strings->next, ++i)
- {
- snprintf (key, sizeof (key), format, i);
- gnome_config_set_string(key, (gchar *) strings->data);
- }
-}
-
-
-gboolean gviewer_find_string_history (GList *strings, const gchar *text)
-{
- for (; strings; strings = strings->next)
- if (strings->data!=NULL)
- if (strcmp((gchar *) strings->data, text)==0)
- return TRUE;
- return FALSE;
-}
-
-
-GList *gviewer_load_string_history (gchar *format, gint size)
-{
- GList *list = NULL;
-
- for (gint i=0; i < size || size == -1; ++i)
- {
- gchar *key = g_strdup_printf (format, i);
- gchar *value = gviewer_get_string (key, NULL);
- g_free (key);
- if (!value)
- break;
- list = g_list_append (list, value);
- }
-
- return list;
-}
-
-
int unicode2utf8 (unsigned int unicode, unsigned char *out)
{
int bytes_needed = 0;
@@ -225,7 +173,7 @@
{
idx++;
len++;
- }
+ }
else
return NULL;
Modified: branches/gcmd-1-3/src/intviewer/viewer-utils.h
==============================================================================
--- branches/gcmd-1-3/src/intviewer/viewer-utils.h (original)
+++ branches/gcmd-1-3/src/intviewer/viewer-utils.h Tue Nov 25 21:44:26 2008
@@ -31,11 +31,6 @@
gint gviewer_get_int (const gchar *path, int def);
gboolean gviewer_get_bool (const gchar *path, gboolean def);
-void gviewer_write_string_history (gchar *format, GList *strings);
-GList *gviewer_load_string_history (gchar *format, gint size);
-void gviewer_free_string_history (GList *strings);
-gboolean gviewer_find_string_history(GList *strings, const gchar *text);
-
int unicode2utf8(unsigned int unicode, unsigned char *out);
char_type *convert_utf8_to_chartype_array(const gchar *utf8text, /*out*/ int *array_length);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]