diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLog.ja | 6 | ||||
-rw-r--r-- | libsylph/defs.h | 2 | ||||
-rw-r--r-- | libsylph/virtual.c | 10 | ||||
-rw-r--r-- | src/prefs_search_folder.c | 95 |
5 files changed, 111 insertions, 9 deletions
@@ -1,3 +1,10 @@ +2006-01-10 + + * libsylph/virtual.c + libsylph/defs.h + src/prefs_search_folder.c: implemented the modification of search + folder condition. + 2006-01-06 * src/prefs_search_folder.[ch] diff --git a/ChangeLog.ja b/ChangeLog.ja index 2b6198c2..cd0ea3db 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,9 @@ +2006-01-10 + + * libsylph/virtual.c + libsylph/defs.h + src/prefs_search_folder.c: 検索フォルダの条件の編集を実装。 + 2006-01-06 * src/prefs_search_folder.[ch] diff --git a/libsylph/defs.h b/libsylph/defs.h index a60c6ecd..0ebc35ef 100644 --- a/libsylph/defs.h +++ b/libsylph/defs.h @@ -73,8 +73,10 @@ #define FOLDER_LIST "folderlist.xml" #define CACHE_FILE ".sylpheed_cache" #define MARK_FILE ".sylpheed_mark" +#define SEARCH_CACHE "search_cache" #define CACHE_VERSION 0x21 #define MARK_VERSION 2 +#define SEARCH_CACHE_VERSION 1 #ifdef G_OS_WIN32 # define REMOTE_CMD_PORT 50215 diff --git a/libsylph/virtual.c b/libsylph/virtual.c index f7138c1c..c6449196 100644 --- a/libsylph/virtual.c +++ b/libsylph/virtual.c @@ -217,9 +217,10 @@ static GHashTable *virtual_read_search_cache(FolderItem *item) g_return_val_if_fail(item != NULL, NULL); path = folder_item_get_path(item); - file = g_strconcat(path, G_DIR_SEPARATOR_S, "search_cache", NULL); + file = g_strconcat(path, G_DIR_SEPARATOR_S, SEARCH_CACHE, NULL); debug_print("reading search cache: %s\n", file); - fp = procmsg_open_data_file(file, 1, DATA_READ, NULL, 0); + fp = procmsg_open_data_file(file, SEARCH_CACHE_VERSION, DATA_READ, + NULL, 0); g_free(file); g_free(path); if (!fp) @@ -484,8 +485,9 @@ static GSList *virtual_get_msg_list(Folder *folder, FolderItem *item, info.search_cache_table = NULL; path = folder_item_get_path(item); - cache_file = g_strconcat(path, G_DIR_SEPARATOR_S, "search_cache", NULL); - info.fp = procmsg_open_data_file(cache_file, 1, DATA_WRITE, NULL, 0); + cache_file = g_strconcat(path, G_DIR_SEPARATOR_S, SEARCH_CACHE, NULL); + info.fp = procmsg_open_data_file(cache_file, SEARCH_CACHE_VERSION, + DATA_WRITE, NULL, 0); g_free(cache_file); g_free(path); if (!info.fp) diff --git a/src/prefs_search_folder.c b/src/prefs_search_folder.c index d25ebf51..f392ce6d 100644 --- a/src/prefs_search_folder.c +++ b/src/prefs_search_folder.c @@ -85,6 +85,10 @@ static gint prefs_search_folder_key_press_cb GdkEventKey *event, PrefsSearchFolderDialog *dialog); +static void prefs_search_folder_select_folder + (GtkWidget *widget, + PrefsSearchFolderDialog *dialog); + static void prefs_search_folder_ok_cb (GtkWidget *widget, PrefsSearchFolderDialog *dialog); static void prefs_search_folder_apply_cb (GtkWidget *widget, @@ -149,7 +153,6 @@ static PrefsSearchFolderDialog *prefs_search_folder_create(FolderItem *item) vbox = gtk_vbox_new(FALSE, 6); gtk_widget_show(vbox); gtk_container_add(GTK_CONTAINER(dialog->notebook), vbox); - //gtk_container_set_border_width(GTK_CONTAINER(vbox), VBOX_BORDER); bool_hbox = gtk_hbox_new(FALSE, 12); gtk_widget_show(bool_hbox); @@ -209,6 +212,9 @@ static PrefsSearchFolderDialog *prefs_search_folder_create(FolderItem *item) gtk_box_pack_start(GTK_BOX(checkbtn_hbox), case_checkbtn, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(folder_btn), "clicked", + G_CALLBACK(prefs_search_folder_select_folder), + new_dialog); g_signal_connect(G_OBJECT(dialog->ok_btn), "clicked", G_CALLBACK(prefs_search_folder_ok_cb), new_dialog); g_signal_connect(G_OBJECT(dialog->apply_btn), "clicked", @@ -233,10 +239,11 @@ static void prefs_search_folder_set_dialog(PrefsSearchFolderDialog *dialog) { GSList *flist; FilterRule *rule; + GSList *cur; gchar *path; gchar *rule_file; - FolderItem *target; gint index; + gboolean case_sens = FALSE; path = folder_item_get_path(dialog->item); rule_file = g_strconcat(path, G_DIR_SEPARATOR_S, "filter.xml", NULL); @@ -250,7 +257,6 @@ static void prefs_search_folder_set_dialog(PrefsSearchFolderDialog *dialog) } rule = (FilterRule *)flist->data; - target = folder_find_item_from_identifier(rule->target_folder); index = menu_find_option_menu_index (GTK_OPTION_MENU(dialog->bool_optmenu), @@ -260,6 +266,21 @@ static void prefs_search_folder_set_dialog(PrefsSearchFolderDialog *dialog) gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->bool_optmenu), index); + gtk_entry_set_text(GTK_ENTRY(dialog->folder_entry), + rule->target_folder); + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(dialog->subfolder_checkbtn), + rule->recursive); + for (cur = rule->cond_list; cur != NULL; cur = cur->next) { + FilterCond *cond = (FilterCond *)cur->data; + if (FLT_IS_CASE_SENS(cond->match_flag)) { + case_sens = TRUE; + break; + } + } + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(dialog->case_checkbtn), case_sens); + prefs_filter_set_header_list(NULL); prefs_filter_edit_set_header_list(dialog->cond_edit, rule); prefs_filter_edit_add_rule_cond(dialog->cond_edit, rule); @@ -294,6 +315,23 @@ static gint prefs_search_folder_key_press_cb(GtkWidget *widget, return FALSE; } +static void prefs_search_folder_select_folder(GtkWidget *widget, + PrefsSearchFolderDialog *dialog) +{ + FolderItem *item; + gchar *id; + + item = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL); + if (!item || item->stype == F_VIRTUAL) + return; + + id = folder_item_get_identifier(item); + if (id) { + gtk_entry_set_text(GTK_ENTRY(dialog->folder_entry), id); + g_free(id); + } +} + static void prefs_search_folder_ok_cb(GtkWidget *widget, PrefsSearchFolderDialog *dialog) { @@ -304,8 +342,55 @@ static void prefs_search_folder_ok_cb(GtkWidget *widget, static void prefs_search_folder_apply_cb(GtkWidget *widget, PrefsSearchFolderDialog *dialog) { - // create filter rule - // delete search cache + const gchar *id; + FolderItem *item; + FilterBoolOp bool_op; + gboolean recursive; + gboolean case_sens; + GSList *cond_list; + FilterRule *rule; + GSList list; + gchar *file; + gchar *path; + + id = gtk_entry_get_text(GTK_ENTRY(dialog->folder_entry)); + item = folder_find_item_from_identifier(id); + if (!item) + return; + + bool_op = menu_get_option_menu_active_index + (GTK_OPTION_MENU(dialog->bool_optmenu)); + recursive = gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON(dialog->subfolder_checkbtn)); + case_sens = gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON(dialog->case_checkbtn)); + + cond_list = prefs_filter_edit_cond_edit_to_list(dialog->cond_edit, + case_sens); + if (!cond_list) + return; + + rule = filter_rule_new(dialog->item->name, bool_op, cond_list, NULL); + rule->target_folder = g_strdup(id); + rule->recursive = recursive; + list.data = rule; + list.next = NULL; + + path = folder_item_get_path(dialog->item); + file = g_strconcat(path, G_DIR_SEPARATOR_S, FILTER_LIST, NULL); + filter_write_file(&list, file); + g_free(file); + file = g_strconcat(path, G_DIR_SEPARATOR_S, FILTER_LIST, ".bak", NULL); + if (is_file_exist(file)) + g_unlink(file); + g_free(file); + file = g_strconcat(path, G_DIR_SEPARATOR_S, SEARCH_CACHE, NULL); + if (is_file_exist(file)) + g_unlink(file); + g_free(file); + g_free(path); + + filter_rule_free(rule); } static void prefs_search_folder_cancel_cb(GtkWidget *widget, |