0.8.11claws64
authorChristoph Hohmann <reboot@gmx.ch>
Sat, 29 Mar 2003 15:25:13 +0000 (15:25 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sat, 29 Mar 2003 15:25:13 +0000 (15:25 +0000)
* src/common/prefs.h
* src/plugins/image_viewer/Makefile.am
* src/plugins/image_viewer/plugin.c
* src/plugins/image_viewer/viewer.[ch]
* src/plugins/image_viewer/viewerprefs.[ch]     ** NEW **
        add PrefsPage for ImageViewer

ChangeLog.claws
TODO.claws
configure.ac
src/common/prefs.h
src/plugins/image_viewer/Makefile.am
src/plugins/image_viewer/plugin.c
src/plugins/image_viewer/viewer.c
src/plugins/image_viewer/viewer.h
src/plugins/image_viewer/viewerprefs.c [new file with mode: 0644]
src/plugins/image_viewer/viewerprefs.h [new file with mode: 0644]

index 8149c2d..3c81130 100644 (file)
@@ -1,3 +1,12 @@
+2003-03-29 [christoph] 0.8.11claws64
+
+       * src/common/prefs.h
+       * src/plugins/image_viewer/Makefile.am
+       * src/plugins/image_viewer/plugin.c
+       * src/plugins/image_viewer/viewer.[ch]
+       * src/plugins/image_viewer/viewerprefs.[ch]     ** NEW **
+               add PrefsPage for ImageViewer
+
 2003-03-28 [thorsten]  0.8.11claws63
 
        * src/common/session.c
index 2959739..92d18fb 100644 (file)
@@ -25,6 +25,8 @@ win32 0.8.0claws+
 
 [christoph]
 
+       o Maildir support
+       o complete UIDPLUS IMAP support
        o make summaryview display any list of messages,
          fix processing rules by score
        o privacy api that is independent from the crpyto system
index ed55b92..4041657 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws63
+EXTRA_VERSION=claws64
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 45c8ecf..047f5ef 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <stdio.h>
 
+#include <glib.h>
+
 typedef struct _PrefFile       PrefFile;
 
 struct _PrefFile {
index 8ad0ce7..479d4ea 100644 (file)
@@ -4,7 +4,8 @@ plugin_LTLIBRARIES = image_viewer.la
 
 image_viewer_la_SOURCES = \
        plugin.c \
-       viewer.c viewer.h
+       viewer.c viewer.h \
+       viewerprefs.c viewerprefs.h
 
 image_viewer_la_LDFLAGS = \
        -avoid-version -module \
index 89a1b21..104cba6 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include "prefs.h"
+
 #include "viewer.h"
+#include "viewerprefs.h"
 
 gint plugin_init(gchar **error)
 {
-       mimeview_register_viewer_factory(&image_viewer_factory);
+       prefs_init();
+       viewer_init();
        return 0;       
 }
 
 void plugin_done()
 {
-       mimeview_unregister_viewer_factory(&image_viewer_factory);
+       viewer_done();
+       prefs_done();
 }
 
 const gchar *plugin_name()
index 9be3808..4cd75e3 100644 (file)
@@ -38,7 +38,7 @@
 #include "utils.h"
 #include "mimeview.h"
 
-static gboolean resize = FALSE;
+#include "viewerprefs.h"
 
 typedef struct _ImageViewer ImageViewer;
 
@@ -99,7 +99,7 @@ static void image_viewer_show_mimepart(MimeViewer *_mimeviewer, const gchar *fil
                return;
        }
 
-       if (resize) {
+       if (imageviewerprefs.resize_img) {
                avail_width = imageviewer->scrolledwin->parent->allocation.width;
                avail_height = imageviewer->scrolledwin->parent->allocation.height;
                if (avail_width > 8) avail_width -= 8;
@@ -164,7 +164,7 @@ static void image_viewer_show_mimepart(MimeViewer *_mimeviewer, const gchar *fil
                return;
        }
 
-       if (resize) {
+       if (imageviewerprefs.resize_img) {
                avail_width = imageviewer->scrolledwin->parent->allocation.width;
                avail_height = imageviewer->scrolledwin->parent->allocation.height;
                if (avail_width > 8) avail_width -= 8;
@@ -286,3 +286,13 @@ MimeViewerFactory image_viewer_factory =
        
        image_viewer_create,
 };
+
+void viewer_init()
+{
+       mimeview_register_viewer_factory(&image_viewer_factory);
+}
+
+void viewer_done()
+{
+       mimeview_unregister_viewer_factory(&image_viewer_factory);
+}
index a5afc82..906e3a6 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "mimeview.h"
 
-extern MimeViewerFactory image_viewer_factory;
+void viewer_init();
+void viewer_done();
 
 #endif
diff --git a/src/plugins/image_viewer/viewerprefs.c b/src/plugins/image_viewer/viewerprefs.c
new file mode 100644 (file)
index 0000000..caa6710
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "defs.h"
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "intl.h"
+#include "common/utils.h"
+#include "prefs.h"
+#include "prefs_gtk.h"
+#include "prefswindow.h"
+
+#include "viewerprefs.h"
+
+#define PREFS_BLOCK_NAME "ImageViewer"
+
+struct ImageViewerPage
+{
+       PrefsPage page;
+       
+       GtkWidget *autoload;
+       GtkWidget *resize;
+};
+
+ImageViewerPrefs imageviewerprefs;
+
+static PrefParam param[] = {
+       {"display_img", "TRUE", &imageviewerprefs.display_img, P_BOOL,
+        NULL, NULL, NULL},
+       {"resize_image", "TRUE", &imageviewerprefs.resize_img, P_BOOL,
+        NULL, NULL, NULL},
+
+       {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
+};
+
+static void imageviewer_create_widget_func(PrefsPage * _page,
+                                          GtkWindow * window,
+                                          gpointer data)
+{
+       struct ImageViewerPage *page = (struct ImageViewerPage *) _page;
+
+       /* ------------------ code made by glade -------------------- */
+       GtkWidget *table2;
+       GtkWidget *label14;
+       GtkWidget *label15;
+       GtkWidget *autoload;
+       GtkWidget *resize;
+
+       table2 = gtk_table_new(2, 2, FALSE);
+       gtk_widget_ref(table2);
+       gtk_widget_show(table2);
+       gtk_container_set_border_width(GTK_CONTAINER(table2), 8);
+       gtk_table_set_row_spacings(GTK_TABLE(table2), 4);
+       gtk_table_set_col_spacings(GTK_TABLE(table2), 8);
+
+       label14 =
+           gtk_label_new(_("Automatically display attached images"));
+       gtk_widget_ref(label14);
+       gtk_widget_show(label14);
+       gtk_table_attach(GTK_TABLE(table2), label14, 0, 1, 0, 1,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment(GTK_MISC(label14), 0, 0.5);
+
+       label15 = gtk_label_new(_("Resize attached images"));
+       gtk_widget_ref(label15);
+       gtk_widget_show(label15);
+       gtk_table_attach(GTK_TABLE(table2), label15, 0, 1, 1, 2,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment(GTK_MISC(label15), 0, 0.5);
+
+       autoload = gtk_check_button_new_with_label("");
+       gtk_widget_ref(autoload);
+       gtk_widget_show(autoload);
+       gtk_table_attach(GTK_TABLE(table2), autoload, 1, 2, 0, 1,
+                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       resize = gtk_check_button_new_with_label("");
+       gtk_widget_ref(resize);
+       gtk_widget_show(resize);
+       gtk_table_attach(GTK_TABLE(table2), resize, 1, 2, 1, 2,
+                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       /* --------------------------------------------------------- */
+       gtk_widget_set_sensitive(GTK_WIDGET(autoload), FALSE);
+
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resize), imageviewerprefs.resize_img);
+
+       page->autoload = autoload;
+       page->resize = resize;
+
+       page->page.widget = table2;
+}
+
+static void imageviewer_destroy_widget_func(PrefsPage *_page)
+{
+}
+
+static void imageviewer_save_func(PrefsPage * _page)
+{
+       struct ImageViewerPage *page = (struct ImageViewerPage *) _page;
+       PrefFile *pfile;
+       gchar *rcpath;
+
+       imageviewerprefs.display_img =
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                        (page->autoload));
+       imageviewerprefs.resize_img =
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->resize));
+
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+       pfile = prefs_write_open(rcpath);
+       g_free(rcpath);
+       if (!pfile || (prefs_set_block_label(pfile, PREFS_BLOCK_NAME) < 0))
+               return;
+
+       if (prefs_write_param(param, pfile->fp) < 0) {
+               g_warning("failed to write ImageViewer configuration to file\n");
+               prefs_file_close_revert(pfile);
+               return;
+       }
+       fprintf(pfile->fp, "\n");
+
+       prefs_file_close(pfile);
+}
+
+static struct ImageViewerPage imageviewer_page;
+
+void prefs_init()
+{
+       prefs_set_default(param);
+       prefs_read_config(param, PREFS_BLOCK_NAME, COMMON_RC);
+
+       imageviewer_page.page.path = "Message View/Image Viewer";
+       imageviewer_page.page.create_widget = imageviewer_create_widget_func;
+       imageviewer_page.page.destroy_widget = imageviewer_destroy_widget_func;
+       imageviewer_page.page.save_page = imageviewer_save_func;
+
+       prefs_gtk_register_page((PrefsPage *) &imageviewer_page);
+}
+
+void prefs_done()
+{
+       prefs_gtk_unregister_page((PrefsPage *) &imageviewer_page);
+}
diff --git a/src/plugins/image_viewer/viewerprefs.h b/src/plugins/image_viewer/viewerprefs.h
new file mode 100644 (file)
index 0000000..e51049a
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
+#ifndef VIEWERPREFS_H
+#define VIEWERPREFS_H
+
+#include <glib.h>
+
+typedef struct _ImageViewerPrefs ImageViewerPrefs;
+
+struct _ImageViewerPrefs
+{
+       gboolean        display_img;
+       gboolean        resize_img;
+};
+
+extern ImageViewerPrefs imageviewerprefs;
+
+void prefs_init();
+void prefs_done();
+
+#endif