2005-10-26 [colin] 1.9.15cvs111
[claws.git] / src / news_gtk.c
index b285a378595cae651bfd5fb4be76df3f25248974..eb67a4c729bcc53412d7860480f369f75cf57d3f 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
 #include "defs.h"
 
 #include <glib.h>
+#include <glib/gi18n.h>
 
 #include <gtk/gtk.h>
 
-#include "intl.h"
 #include "utils.h"
 #include "folder.h"
 #include "folderview.h"
 #include "account.h"
 #include "alertpanel.h"
 #include "grouplistdialog.h"
+#include "prefs_common.h"
+#include "news_gtk.h"
 #include "common/hooks.h"
 #include "inc.h"
 
 static void subscribe_newsgroup_cb(FolderView *folderview, guint action, GtkWidget *widget);
 static void unsubscribe_newsgroup_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void remove_news_server_cb(FolderView *folderview, guint action, GtkWidget *widget);
 static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
 static void download_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void sync_cb(FolderView *folderview, guint action, GtkWidget *widget);
 
 static GtkItemFactoryEntry news_popup_entries[] =
 {
        {N_("/_Subscribe to newsgroup..."),     NULL, subscribe_newsgroup_cb,    0, NULL},
        {N_("/_Unsubscribe newsgroup"),         NULL, unsubscribe_newsgroup_cb,  0, NULL},
        {N_("/---"),                            NULL, NULL,                      0, "<Separator>"},
-       {N_("/Down_load"),                      NULL, download_cb,               0, NULL},
+       {N_("/Synchronise"),                    NULL, sync_cb,          0, NULL},
+       {N_("/Down_load messages"),             NULL, download_cb,               0, NULL},
        {N_("/---"),                            NULL, NULL,                      0, "<Separator>"},
        {N_("/_Check for new messages"),        NULL, update_tree_cb,            0, NULL},
        {N_("/---"),                            NULL, NULL,                      0, "<Separator>"},
-       {N_("/Remove _news account"),           NULL, remove_news_server_cb,     0, NULL},
-       {N_("/---"),                            NULL, NULL,                      0, "<Separator>"},
 };
 
 static void set_sensitivity(GtkItemFactory *factory, FolderItem *item);
@@ -86,8 +87,6 @@ static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
 
        SET_SENS("/Subscribe to newsgroup...", folder_item_parent(item) == NULL);
        SET_SENS("/Unsubscribe newsgroup",     folder_item_parent(item) != NULL);
-       SET_SENS("/Remove news account",       folder_item_parent(item) == NULL);
-
        SET_SENS("/Check for new messages",    folder_item_parent(item) == NULL);
 
 #undef SET_SENS
@@ -199,9 +198,10 @@ static void unsubscribe_newsgroup_cb(FolderView *folderview, guint action,
        old_id = folder_item_get_identifier(item);
 
        name = trim_string(item->path, 32);
-       message = g_strdup_printf(_("Really unsubscribe newsgroup `%s'?"), name);
-       avalue = alertpanel(_("Unsubscribe newsgroup"), message,
-                           _("Yes"), _("+No"), NULL);
+       message = g_strdup_printf(_("Really unsubscribe newsgroup '%s'?"), name);
+       avalue = alertpanel_full(_("Unsubscribe newsgroup"), message,
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL, FALSE,
+                                NULL, ALERT_WARNING, G_ALERTALTERNATE);
        g_free(message);
        g_free(name);
        if (avalue != G_ALERTDEFAULT) return;
@@ -218,57 +218,12 @@ static void unsubscribe_newsgroup_cb(FolderView *folderview, guint action,
        g_free(old_id);
 }
 
-static void remove_news_server_cb(FolderView *folderview, guint action,
-                                 GtkWidget *widget)
-{
-       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
-       FolderItem *item;
-       PrefsAccount *account;
-       gchar *name;
-       gchar *message;
-       AlertValue avalue;
-
-       if (!folderview->selected) return;
-
-       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
-       g_return_if_fail(item != NULL);
-       g_return_if_fail(item->folder != NULL);
-       g_return_if_fail(FOLDER_TYPE(item->folder) == F_NEWS);
-       g_return_if_fail(item->folder->account != NULL);
-
-       name = trim_string(item->folder->name, 32);
-       message = g_strdup_printf(_("Really delete news account `%s'?"), name);
-       avalue = alertpanel(_("Delete news account"), message,
-                           _("Yes"), _("+No"), NULL);
-       g_free(message);
-       g_free(name);
-
-       if (avalue != G_ALERTDEFAULT) return;
-
-       if (folderview->opened == folderview->selected ||
-           gtk_ctree_is_ancestor(ctree,
-                                 folderview->selected,
-                                 folderview->opened)) {
-               summary_clear_all(folderview->summaryview);
-               folderview->opened = NULL;
-       }
-
-       account = item->folder->account;
-       folderview_unselect(folderview);
-       summary_clear_all(folderview->summaryview);
-       folder_destroy(item->folder);
-       account_destroy(account);
-       account_set_menu();
-       main_window_reflect_prefs_all();
-       folder_write_list();
-}
-
 static void update_tree_cb(FolderView *folderview, guint action,
                           GtkWidget *widget)
 {
        FolderItem *item;
 
-       item = folderview_get_selected(folderview);
+       item = folderview_get_selected_item(folderview);
        g_return_if_fail(item != NULL);
 
        summary_show(folderview->summaryview, NULL);
@@ -278,28 +233,24 @@ static void update_tree_cb(FolderView *folderview, guint action,
        folderview_check_new(item->folder);
 }
 
-static void download_cb(FolderView *folderview, guint action,
-                       GtkWidget *widget)
+static void sync_cb(FolderView *folderview, guint action,
+                          GtkWidget *widget)
 {
-       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
-       MainWindow *mainwin = folderview->mainwin;
        FolderItem *item;
 
-       if (!folderview->selected) return;
+       item = folderview_get_selected_item(folderview);
+       g_return_if_fail(item != NULL);
+       folder_synchronise(item->folder);
+}
 
-       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+void news_gtk_synchronise(FolderItem *item)
+{
+       MainWindow *mainwin = mainwindow_get_mainwindow();
+       FolderView *folderview = mainwin->folderview;
+       
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
-#if 0
-       if (!prefs_common.online_mode) {
-               if (alertpanel(_("Offline"),
-                              _("You are offline. Go online?"),
-                              _("Yes"), _("No"), NULL) == G_ALERTDEFAULT)
-                       main_window_toggle_online(folderview->mainwin, TRUE);
-               else
-                       return;
-       }
-#endif
+
        main_window_cursor_wait(mainwin);
        inc_lock();
        main_window_lock(mainwin);
@@ -310,7 +261,7 @@ static void download_cb(FolderView *folderview, guint action,
                gchar *name;
 
                name = trim_string(item->name, 32);
-               alertpanel_error(_("Error occurred while downloading messages in `%s'."), name);
+               alertpanel_error(_("Error occurred while downloading messages in '%s'."), name);
                g_free(name);
        }
        folder_set_ui_func(item->folder, NULL, NULL);
@@ -320,3 +271,15 @@ static void download_cb(FolderView *folderview, guint action,
        inc_unlock();
        main_window_cursor_normal(mainwin);
 }
+
+static void download_cb(FolderView *folderview, guint action,
+                       GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+
+       if (!folderview->selected) return;
+
+       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+       news_gtk_synchronise(item);
+}