ok & cancel buttons added - xhdr parsing fixed
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Wed, 9 May 2001 14:24:02 +0000 (14:24 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Wed, 9 May 2001 14:24:02 +0000 (14:24 +0000)
ChangeLog.claws
src/news.c
src/prefs_filter.c
src/prefs_matcher.c

index cfafda1..03a0308 100644 (file)
@@ -1,6 +1,11 @@
-2001-05-08 [hoa]
+2001-05-09 [hoa]
        * src/prefs_matcher.c
                finished UI to define matching properties
+               added ok and cancel button
+       * src/prefs_filter.c
+               added ok and cancel button
+       * src/news.c
+               fixed some bug in xhdr parsing
 
 2001-05-08 [alfons]
 
index caa0dd8..08fa7c0 100644 (file)
@@ -581,6 +581,7 @@ static gchar * news_parse_xhdr(const gchar *xover_str, MsgInfo * info)
        gchar buf[NNTPBUFSIZE];
        gchar *p;
        gint num;
+       gchar * tmp;
 
        p = strchr(xover_str, ' ');
        if (!p)
@@ -593,7 +594,13 @@ static gchar * news_parse_xhdr(const gchar *xover_str, MsgInfo * info)
        if (info->msgnum != num)
                return NULL;
 
-       return g_strdup(p);
+       tmp = strchr(p, '\r');
+       if (!tmp) tmp = strchr(p, '\n');
+
+       if (tmp)
+               return g_strndup(p, tmp - p);
+       else
+               return g_strdup(p);
 }
 
 static GSList *news_delete_old_article(GSList *alist, gint first)
index 310c67a..14f8e6c 100644 (file)
@@ -49,7 +49,7 @@
 static struct Filter {
        GtkWidget *window;
 
-       GtkWidget *close_btn;
+       GtkWidget *ok_btn;
 
        GtkWidget *hdr_combo1;
        GtkWidget *hdr_combo2;
@@ -114,7 +114,8 @@ static gint prefs_filter_deleted    (GtkWidget      *widget,
 static void prefs_filter_key_pressed   (GtkWidget      *widget,
                                         GdkEventKey    *event,
                                         gpointer        data);
-static void prefs_filter_close         (void);
+static void prefs_filter_cancel                (void);
+static void prefs_filter_ok            (void);
 
 void prefs_filter_open(void)
 {
@@ -125,7 +126,7 @@ void prefs_filter_open(void)
        }
 
        manage_window_set_transient(GTK_WINDOW(filter.window));
-       gtk_widget_grab_focus(filter.close_btn);
+       gtk_widget_grab_focus(filter.ok_btn);
 
        prefs_filter_set_dialog();
 
@@ -136,7 +137,8 @@ static void prefs_filter_create(void)
 {
        GtkWidget *window;
        GtkWidget *vbox;
-       GtkWidget *close_btn;
+       GtkWidget *ok_btn;
+       GtkWidget *cancel_btn;
        GtkWidget *confirm_area;
 
        GtkWidget *vbox1;
@@ -195,11 +197,19 @@ static void prefs_filter_create(void)
        gtk_widget_show (vbox);
        gtk_container_add (GTK_CONTAINER (window), vbox);
 
+       gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
+                               &cancel_btn, _("Cancel"), NULL, NULL);
+       gtk_widget_show (confirm_area);
+       gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
+       gtk_widget_grab_default (ok_btn);
+
+       /*
        gtkut_button_set_create (&confirm_area, &close_btn, _("Close"),
                                 NULL, NULL, NULL, NULL);
        gtk_widget_show (confirm_area);
        gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
        gtk_widget_grab_default (close_btn);
+       */
 
        gtk_window_set_title (GTK_WINDOW(window),
                              _("Filter setting"));
@@ -211,8 +221,10 @@ static void prefs_filter_create(void)
                            GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
        gtk_signal_connect (GTK_OBJECT(window), "focus_out_event",
                            GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
-       gtk_signal_connect (GTK_OBJECT(close_btn), "clicked",
-                           GTK_SIGNAL_FUNC(prefs_filter_close), NULL);
+       gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
+                           GTK_SIGNAL_FUNC(prefs_filter_ok), NULL);
+       gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
+                           GTK_SIGNAL_FUNC(prefs_filter_cancel), NULL);
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
@@ -444,7 +456,7 @@ static void prefs_filter_create(void)
        gtk_widget_show_all(window);
 
        filter.window    = window;
-       filter.close_btn = close_btn;
+       filter.ok_btn = ok_btn;
 
        filter.hdr_combo1  = hdr_combo1;
        filter.hdr_combo2  = hdr_combo2;
@@ -809,7 +821,7 @@ static void prefs_filter_notrecv_radio_button_toggled(void)
 static gint prefs_filter_deleted(GtkWidget *widget, GdkEventAny *event,
                                 gpointer data)
 {
-       prefs_filter_close();
+       prefs_filter_cancel();
        return TRUE;
 }
 
@@ -817,12 +829,19 @@ static void prefs_filter_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                     gpointer data)
 {
        if (event && event->keyval == GDK_Escape)
-               prefs_filter_close();
+               prefs_filter_cancel();
 }
 
-static void prefs_filter_close(void)
+static void prefs_filter_ok(void)
 {
        prefs_filter_write_config();
        gtk_widget_hide(filter.window);
        inc_autocheck_timer_set();      
 }
+
+static void prefs_filter_cancel(void)
+{
+       prefs_filter_read_config();
+       gtk_widget_hide(filter.window);
+       inc_autocheck_timer_set();      
+}
index adb2ef7..4800c69 100644 (file)
@@ -49,7 +49,7 @@
 static struct Matcher {
        GtkWidget *window;
 
-       GtkWidget *close_btn;
+       GtkWidget *ok_btn;
 
        GtkWidget *predicate_combo;
        GtkWidget *header_combo;
@@ -161,7 +161,8 @@ static void prefs_matcher_select    (GtkCList       *clist,
 static void prefs_matcher_key_pressed  (GtkWidget      *widget,
                                         GdkEventKey    *event,
                                         gpointer        data);
-static void prefs_matcher_close                (void);
+static void prefs_matcher_ok           (void);
+static void prefs_matcher_cancel               (void);
 static gint prefs_matcher_deleted(GtkWidget *widget, GdkEventAny *event,
                                  gpointer data);
 static void prefs_matcher_criteria_select(GtkList *list,
@@ -178,7 +179,7 @@ void prefs_matcher_open(MatcherList * matchers)
        }
 
        manage_window_set_transient(GTK_WINDOW(matcher.window));
-       gtk_widget_grab_focus(matcher.close_btn);
+       gtk_widget_grab_focus(matcher.ok_btn);
 
        tmp_matchers = matchers;
        prefs_matcher_set_dialog();
@@ -190,7 +191,8 @@ static void prefs_matcher_create(void)
 {
        GtkWidget *window;
        GtkWidget *vbox;
-       GtkWidget *close_btn;
+       GtkWidget *ok_btn;
+       GtkWidget *cancel_btn;
        GtkWidget *confirm_area;
 
        GtkWidget *vbox1;
@@ -250,11 +252,18 @@ static void prefs_matcher_create(void)
        gtk_widget_show (vbox);
        gtk_container_add (GTK_CONTAINER (window), vbox);
 
+       gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
+                               &cancel_btn, _("Cancel"), NULL, NULL);
+       gtk_widget_show (confirm_area);
+       gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
+       gtk_widget_grab_default (ok_btn);
+
+       /*
        gtkut_button_set_create (&confirm_area, &close_btn, _("Close"),
                                 NULL, NULL, NULL, NULL);
        gtk_widget_show (confirm_area);
        gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
-       gtk_widget_grab_default (close_btn);
+       gtk_widget_grab_default (close_btn);*/
 
        gtk_window_set_title (GTK_WINDOW(window),
                              _("Condition setting"));
@@ -266,8 +275,10 @@ static void prefs_matcher_create(void)
                            GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
        gtk_signal_connect (GTK_OBJECT(window), "focus_out_event",
                            GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
-       gtk_signal_connect (GTK_OBJECT(close_btn), "clicked",
-                           GTK_SIGNAL_FUNC(prefs_matcher_close), NULL);
+       gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
+                           GTK_SIGNAL_FUNC(prefs_matcher_ok), NULL);
+       gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
+                           GTK_SIGNAL_FUNC(prefs_matcher_cancel), NULL);
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
@@ -499,7 +510,8 @@ static void prefs_matcher_create(void)
        gtk_widget_show_all(window);
 
        matcher.window    = window;
-       matcher.close_btn = close_btn;
+
+       matcher.ok_btn = ok_btn;
 
        matcher.criteria_list = criteria_list;
        matcher.header_combo = header_combo;
@@ -1094,10 +1106,15 @@ static void prefs_matcher_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                     gpointer data)
 {
        if (event && event->keyval == GDK_Escape)
-               prefs_matcher_close();
+               prefs_matcher_cancel();
+}
+
+static void prefs_matcher_cancel(void)
+{
+       gtk_widget_hide(matcher.window);
 }
 
-static void prefs_matcher_close(void)
+static void prefs_matcher_ok(void)
 {
        prefs_matcher_set_list();
        gtk_widget_hide(matcher.window);
@@ -1106,6 +1123,6 @@ static void prefs_matcher_close(void)
 static gint prefs_matcher_deleted(GtkWidget *widget, GdkEventAny *event,
                                  gpointer data)
 {
-       prefs_matcher_close();
+       prefs_matcher_cancel();
        return TRUE;
 }