#include "intl.h"
#include "main.h"
-#include "prefs.h"
+#include "prefs_gtk.h"
#include "prefs_matcher.h"
#include "prefs_scoring.h"
#include "prefs_common.h"
gchar *title[1];
- debug_print(_("Creating scoring setting window...\n"));
+ debug_print("Creating scoring configuration window...\n");
window = gtk_window_new (GTK_WINDOW_DIALOG);
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
gtk_widget_grab_default (ok_btn);
gtk_window_set_title (GTK_WINDOW(window),
- _("Scoring setting"));
+ _("Scoring configuration"));
gtk_signal_connect (GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(prefs_scoring_deleted), NULL);
gtk_signal_connect (GTK_OBJECT(window), "key_press_event",
gtk_widget_show (btn_hbox);
gtk_box_pack_start (GTK_BOX (reg_hbox), btn_hbox, FALSE, FALSE, 0);
- reg_btn = gtk_button_new_with_label (_("Register"));
+ reg_btn = gtk_button_new_with_label (_("Add"));
gtk_widget_show (reg_btn);
gtk_box_pack_start (GTK_BOX (btn_hbox), reg_btn, FALSE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (reg_btn), "clicked",
GTK_SIGNAL_FUNC (prefs_scoring_register_cb), NULL);
- subst_btn = gtk_button_new_with_label (_(" Substitute "));
+ subst_btn = gtk_button_new_with_label (_(" Replace "));
gtk_widget_show (subst_btn);
gtk_box_pack_start (GTK_BOX (btn_hbox), subst_btn, FALSE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (subst_btn), "clicked",
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- title[0] = _("Registered rules");
+ title[0] = _("Current scoring rules");
cond_clist = gtk_clist_new_with_titles(1, title);
gtk_widget_show (cond_clist);
gtk_container_add (GTK_CONTAINER (cond_scrolledwin), cond_clist);
gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);
- kill_score_label = gtk_label_new (_("Kill score"));
+ kill_score_label = gtk_label_new (_("Hide score"));
gtk_widget_show (kill_score_label);
gtk_misc_set_alignment (GTK_MISC (kill_score_label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox1), kill_score_label,
cur_important_score = prefs_common.important_score;
gtk_widget_show(scoring.kill_score_label);
gtk_widget_show(scoring.kill_score_entry);
- }
- else {
+ } else {
prefs_scoring = cur_item->prefs->scoring;
cur_kill_score = cur_item->prefs->kill_score;
cur_important_score = cur_item->prefs->important_score;
- if (cur_item->folder->type != F_NEWS) {
- gtk_widget_hide(scoring.kill_score_label);
- gtk_widget_hide(scoring.kill_score_entry);
- }
- else {
- gtk_widget_show(scoring.kill_score_label);
- gtk_widget_show(scoring.kill_score_entry);
- }
}
for(cur = prefs_scoring ; cur != NULL ;
ScoringProp *prop;
GSList * cur;
gchar * scoring_str;
- gchar * tmp;
GSList * prefs_scoring;
if (cur_item == NULL)
cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
if (*cond_str != '\0') {
- gchar * tmp;
-
matchers = matcher_parser_get_cond(cond_str);
if (matchers == NULL)
alertpanel_error(_("Match string is not valid."));
gchar * score_str;
ScoringProp * prop;
gint score;
- gchar * tmp;
cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
if (*cond_str == '\0') {
- alertpanel_error(_("Score is not set."));
+ alertpanel_error(_("Condition string is empty."));
return;
}
score_str = gtk_entry_get_text(GTK_ENTRY(scoring.score_entry));
if (*score_str == '\0') {
- alertpanel_error(_("Match string is not set."));
+ alertpanel_error(_("Score is not set."));
return;
}
cond = matcher_parser_get_cond(cond_str);
if (cond == NULL) {
- alertpanel_error(_("Match string is not valid."));
+ alertpanel_error(_("Condition string is not valid."));
return;
}
gchar * score_str;
ScoringProp * prop;
gint score;
- gchar * tmp;
if (!clist->selection) return;
cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
if (*cond_str == '\0') {
- alertpanel_error(_("Score is not set."));
+ alertpanel_error(_("Condition string is empty."));
return;
}
score_str = gtk_entry_get_text(GTK_ENTRY(scoring.score_entry));
if (*score_str == '\0') {
- alertpanel_error(_("Match string is not set."));
+ alertpanel_error(_("Score is not set."));
return;
}
cond = matcher_parser_get_cond(cond_str);
if (cond == NULL) {
- alertpanel_error(_("Match string is not valid."));
+ alertpanel_error(_("Condition string is not valid."));
return;
}
GdkEvent *event)
{
ScoringProp * prop;
- gchar * tmp;
gchar * scoring_str;
static void prefs_scoring_ok(void)
{
+ MatcherList * cond;
+ gchar * cond_str;
+ gchar * score_str;
+ gchar * scoring_str;
+ gchar * str;
+ ScoringProp * prop;
+ gint score;
+ gint row = 1;
+ AlertValue val;
+
+ cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
+ score_str = gtk_entry_get_text(GTK_ENTRY(scoring.score_entry));
+ if (*cond_str != '\0' && *score_str != '\0') {
+ score = atoi(score_str);
+ cond = matcher_parser_get_cond(cond_str);
+
+ if (cond == NULL) {
+ prefs_common_save_config();
+ prefs_scoring_set_list();
+ prefs_matcher_write_config();
+ if (cur_item != NULL)
+ folder_item_prefs_save_config(cur_item);
+ gtk_widget_hide(scoring.window);
+ inc_unlock();
+ return;
+ }
+ prop = scoringprop_new(cond, score);
+ str = scoringprop_to_string(prop);
+ while (gtk_clist_get_text(GTK_CLIST(scoring.cond_clist),
+ row, 0, &scoring_str)) {
+ if (strcmp(scoring_str, str) == 0) break;
+ row++;
+ }
+ if (strcmp(scoring_str, str) != 0) {
+ val = alertpanel(_("Entry not saved"),
+ _("The entry was not saved\nHave you really finished?"),
+ _("Yes"), _("No"), NULL);
+ if (G_ALERTDEFAULT != val) {
+ g_free(str);
+ return;
+ }
+ }
+ g_free(str);
+ }
prefs_common_save_config();
prefs_scoring_set_list();
prefs_matcher_write_config();
if (cur_item != NULL)
- prefs_folder_item_save_config(cur_item);
+ folder_item_prefs_save_config(cur_item);
gtk_widget_hide(scoring.window);
inc_unlock();
}