Added work offline availability.
authorColin Leroy <colin@colino.net>
Sun, 21 Apr 2002 12:11:43 +0000 (12:11 +0000)
committerColin Leroy <colin@colino.net>
Sun, 21 Apr 2002 12:11:43 +0000 (12:11 +0000)
12 files changed:
ChangeLog.claws
configure.in
src/compose.c
src/inc.c
src/mainwindow.c
src/mainwindow.h
src/pixmaps/work_offline.xpm [new file with mode: 0644]
src/pixmaps/work_online.xpm [new file with mode: 0644]
src/prefs_common.c
src/prefs_common.h
src/stock_pixmap.c
src/stock_pixmap.h

index 7beae2c4658429e86f2057590e994d00cbf766ad..95a2bae58ae2566b982c8ae7c04cbca7be644564 100644 (file)
@@ -1,3 +1,11 @@
+2002-04-21 [colin]     0.7.4claws89
+       * src/compose.c
+       * src/inc.c
+       * src/mainwindow.[ch]
+       * src/prefs_common.[ch]
+       * src/stock_pixmap.[ch]
+               Added "Work offline" ability.
+
 2002-04-21 [colin]     0.7.4claws88
        
        * src/mimeview.c
index 95936a5e1f1f36482eb5c8b99eb89f9330527e2c..0a9e8376f6b6337283f98b510b3b304420511b24 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws88
+EXTRA_VERSION=claws89
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 67526467eaf15ad809145e7f22a3eb6db641b9bc..b7fcada67dc467ca37be794b5453abb5715caa07 100644 (file)
@@ -5919,6 +5919,12 @@ static void compose_send_cb(gpointer data, guint action, GtkWidget *widget)
 {
        Compose *compose = (Compose *)data;
        gint val;
+       
+       if (prefs_common.work_offline)
+               if (alertpanel(_("Offline warning"), 
+                              _("You're working offline. Override?"),
+                              _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+               return;
 
        val = compose_send(compose);
 
index aed7c6ec66e4e06b91d5ad10438dbb96389c1e10..de6183bc6bd3a82e28e485f59a74110ee08466ab 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -166,6 +166,12 @@ void inc_mail(MainWindow *mainwin, gboolean notify)
 
        if (inc_lock_count) return;
 
+       if (prefs_common.work_offline)
+               if (alertpanel(_("Offline warning"), 
+                              _("You're working offline. Override?"),
+                              _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+               return;
+
        inc_autocheck_timer_remove();
        summary_write_cache(mainwin->summaryview);
        main_window_lock(mainwin);
@@ -249,6 +255,12 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
        GList *list, *queue_list = NULL;
        IncProgressDialog *inc_dialog;
        gint new_msgs = 0;
+       
+       if (prefs_common.work_offline)
+               if (alertpanel(_("Offline warning"), 
+                              _("You're working offline. Override?"),
+                              _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+               return;
 
        if (inc_lock_count) return;
 
@@ -1256,8 +1268,10 @@ void inc_autocheck_timer_init(MainWindow *mainwin)
 static void inc_autocheck_timer_set_interval(guint interval)
 {
        inc_autocheck_timer_remove();
-
-       if (prefs_common.autochk_newmail && autocheck_data) {
+       /* last test is to avoid re-enabling auto_check after modifying 
+          the common preferences */
+       if (prefs_common.autochk_newmail && autocheck_data
+           && prefs_common.work_offline == FALSE) {
                autocheck_timer = gtk_timeout_add
                        (interval, inc_autocheck_func, autocheck_data);
                debug_print("added timer = %d\n", autocheck_timer);
index d6b32cb3b63d478effb21470d11fb8350c656f9b..e09cc23c32c7b7e9b64aae123302f95ed5b1f654 100644 (file)
@@ -242,6 +242,9 @@ static void toggle_expand_summaryview_cb     (MainWindow    *mainwin,
 static void toggle_expand_messageview_cb        (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
+static void toggle_work_offline_cb      (MainWindow    *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
                                 guint action,
                                 GtkWidget *widget);
@@ -432,6 +435,9 @@ static void new_account_cb   (MainWindow    *mainwin,
 static void account_menu_cb     (GtkMenuItem   *menuitem,
                                  gpointer       data);
 
+static void online_switch_clicked(GtkButton     *btn, 
+                                 gpointer data);
+
 static void manual_open_cb      (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
@@ -481,6 +487,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_File/_Import mbox file..."),     NULL, import_mbox_cb, 0, NULL},
        {N_("/_File/_Export to mbox file..."),  NULL, export_mbox_cb, 0, NULL},
        {N_("/_File/Empty _trash"),             "<shift>D", empty_trash_cb, 0, NULL},
+       {N_("/_File/_Work offline"),            "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},                                               
        {N_("/_File/---"),                      NULL, NULL, 0, "<Separator>"},
        {N_("/_File/_Save as..."),              "<control>S", save_as_cb, 0, NULL},
        {N_("/_File/_Print..."),                NULL, print_cb, 0, NULL},
@@ -763,7 +770,6 @@ static GtkItemFactoryEntry fwd_popup_entries[] =
        {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
 };
 
-
 MainWindow *main_window_create(SeparateType type)
 {
        MainWindow *mainwin;
@@ -778,6 +784,10 @@ MainWindow *main_window_create(SeparateType type)
        GtkWidget *statuslabel;
        GtkWidget *ac_button;
        GtkWidget *ac_label;
+       GtkWidget *online_status;
+       GtkWidget *offline_status;
+       GtkWidget *online_switch;
+       GtkWidget *offline_switch;
 
        FolderView *folderview;
        SummaryView *summaryview;
@@ -886,6 +896,19 @@ MainWindow *main_window_create(SeparateType type)
        gtk_widget_set_usize(progressbar, 120, 1);
        gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
 
+       online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
+       offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
+       online_switch = gtk_button_new ();
+       offline_switch = gtk_button_new ();
+       gtk_container_add (GTK_CONTAINER(online_switch), online_status);
+       gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
+       gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
+       gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
+       gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
+       gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
+       gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
+       
        statuslabel = gtk_label_new("");
        gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
 
@@ -902,6 +925,7 @@ MainWindow *main_window_create(SeparateType type)
 
        gtk_widget_show_all(hbox_stat);
 
+       gtk_widget_hide(offline_switch);
        /* create views */
        mainwin->folderview  = folderview  = folderview_create();
        mainwin->summaryview = summaryview = summary_create();
@@ -933,6 +957,8 @@ MainWindow *main_window_create(SeparateType type)
        mainwin->replyall_popup = replyall_popup;
        mainwin->replysender_popup = replysender_popup;
        mainwin->fwd_popup = fwd_popup;
+       mainwin->online_switch = online_switch;
+       mainwin->offline_switch = offline_switch;
        
        /* set context IDs for status bar */
        mainwin->mainwin_cid = gtk_statusbar_get_context_id
@@ -1068,6 +1094,10 @@ MainWindow *main_window_create(SeparateType type)
 
        mainwin_list = g_list_append(mainwin_list, mainwin);
 
+       /* init work_offline */
+       if (prefs_common.work_offline)
+               online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
+
        return mainwin;
 }
 
@@ -1581,6 +1611,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/File/Import mbox file..."   , M_UNLOCKED},
                {"/File/Export to mbox file...", M_UNLOCKED},
                {"/File/Empty trash"           , M_UNLOCKED},
+               {"/File/Work offline"          , M_UNLOCKED},
                {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
                {"/File/Print..."  , M_TARGET_EXIST|M_UNLOCKED},
                /* {"/File/Close", M_UNLOCKED}, */
@@ -2548,8 +2579,47 @@ static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkW
        messageview_toggle_view_real(mainwin->messageview);
 }
 
-static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
+static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
+{
+       if (GTK_CHECK_MENU_ITEM(widget)->active) {
+               online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
+       } else {
+               online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);           
+       }
+}
 
+static void online_switch_clicked (GtkButton *btn, gpointer data) 
+{
+       MainWindow *mainwin;
+       GtkItemFactory *ifactory;
+       GtkCheckMenuItem *menuitem;
+
+       mainwin = (MainWindow *) data;
+       
+       ifactory = gtk_item_factory_from_widget(mainwin->menubar);
+       menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
+       
+       g_return_if_fail(mainwin != NULL);
+       g_return_if_fail(menuitem != NULL);
+       
+       if (btn == GTK_BUTTON(mainwin->online_switch)) {
+               /* go offline */
+               gtk_widget_hide (mainwin->online_switch);
+               gtk_widget_show (mainwin->offline_switch);
+               menuitem->active = TRUE;
+               prefs_common.work_offline = TRUE;
+               inc_autocheck_timer_remove();           
+       } else {
+               /*go online */
+               gtk_widget_hide (mainwin->offline_switch);
+               gtk_widget_show (mainwin->online_switch);
+               menuitem->active = FALSE;
+               prefs_common.work_offline = FALSE;
+               inc_autocheck_timer_set();
+       }
+}
+
+static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
 {
        MainWindow *mainwin;
        SeparateType type;
@@ -2602,6 +2672,12 @@ static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        GList *list;
 
+       if (prefs_common.work_offline)
+               if (alertpanel(_("Offline warning"), 
+                              _("You're working offline. Override?"),
+                              _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+               return;
+
        for (list = folder_get_list(); list != NULL; list = list->next) {
                Folder *folder = list->data;
 
index fe8b8f75039f0f8e7f13ba253d87289619c90599..4e379fce374dfc3278f7db16ba07ead7450589a6 100644 (file)
@@ -121,6 +121,8 @@ struct _MainWindow
        GtkWidget *ac_button;
        GtkWidget *ac_label;
        GtkWidget *ac_menu;
+       GtkWidget *online_switch;
+       GtkWidget *offline_switch;
 
        /* context IDs for status bar */
        gint mainwin_cid;
diff --git a/src/pixmaps/work_offline.xpm b/src/pixmaps/work_offline.xpm
new file mode 100644 (file)
index 0000000..8b70d22
--- /dev/null
@@ -0,0 +1,13 @@
+/* XPM */
+static char * work_offline_xpm[] = {
+"24 6 4 1",
+"      c None",
+".     c #000000",
+"+     c #D8BE6A",
+"@     c #8E7D45",
+"............  ..........",
+"+++++++++++.  .@++++++++",
+"++++++++++.  .@+++++++++",
+"++++++++++.  .@+++++++++",
+"@@@@@@@@@.  .@@@@@@@@@@@",
+"..........  ............"};
diff --git a/src/pixmaps/work_online.xpm b/src/pixmaps/work_online.xpm
new file mode 100644 (file)
index 0000000..5bb7116
--- /dev/null
@@ -0,0 +1,13 @@
+/* XPM */
+static char * work_online_xpm[] = {
+"24 6 4 1",
+"      c None",
+".     c #000000",
+"+     c #D8BE6A",
+"@     c #8E7D45",
+"........................",
+"++++++++++++++.@++++++++",
+"+++++++++++++.@+++++++++",
+"+++++++++++++.@+++++++++",
+"@@@@@@@@@@@@.@@@@@@@@@@@",
+"........................"};
index f338bd20d108b49920ec5de7c405f607ce4cd013..2ee48890c2b2d047bfba854c2b461839d4e43cac 100644 (file)
@@ -755,6 +755,8 @@ static PrefParam param[] = {
        {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
         P_BOOL, &other.checkbtn_warnqueued,
         prefs_set_data_from_toggle, prefs_set_toggle},
+       {"work_offline", "FALSE", &prefs_common.work_offline, P_BOOL,
+        NULL, NULL, NULL},
 
        {"kill_score", "-9999", &prefs_common.kill_score, P_INT,
         NULL, NULL, NULL},
index 6a640b75f265556c381d02e5c8144943baa2aa78..74f1481172793238a1d0f14ec48bea3472d7f04d 100644 (file)
@@ -228,6 +228,11 @@ struct _PrefsCommon
        gboolean ask_on_clean;
        gboolean warn_queued_on_exit;
        gboolean return_receipt;
+       
+       /* boolean for work offline 
+          stored here for use in inc.c */
+       gboolean work_offline;
+
 };
 
 extern PrefsCommon prefs_common;
index 66922cc009c2b12a2b5afd8c27de3f8ddd810323..51e824439f94149079b49e77b9a95da212f88d93 100644 (file)
@@ -83,6 +83,8 @@
 #include "pixmaps/unread.xpm"
 #include "pixmaps/vcard.xpm"
 #include "pixmaps/ignorethread.xpm"
+#include "pixmaps/work_online.xpm"
+#include "pixmaps/work_offline.xpm"
 
 typedef struct _StockPixmapData        StockPixmapData;
 
@@ -168,6 +170,8 @@ static StockPixmapData pixmaps[] =
        {trash_hrm_xpm                  , NULL, NULL, "trash_close_hrm", "  "},
        {unread_xpm                             , NULL, NULL, "unread", "  "},
        {vcard_xpm                              , NULL, NULL, "vcard", "  "},
+       {work_online_xpm                        , NULL, NULL, "work_online", "  "},
+       {work_offline_xpm                       , NULL, NULL, "work_offline", "  "},
 };
 
 /* return newly constructed GtkPixmap from GdkPixmap */
index 3faf61307622b41b9c1e99ae293af612615cdfe2..d2b52783283b61b50978acbd54a4535a789a3f64 100644 (file)
@@ -93,7 +93,9 @@ typedef enum
        STOCK_PIXMAP_TRASH_CLOSE_HRM,
        STOCK_PIXMAP_UNREAD,
        STOCK_PIXMAP_VCARD,
-
+       STOCK_PIXMAP_WORK_ONLINE,
+       STOCK_PIXMAP_WORK_OFFLINE,
+       
        N_STOCK_PIXMAPS
 } StockPixmap;