[Commits] [SCM] claws branch, master, updated. 3.17.3-1-gb2fffbb
wwp at claws-mail.org
wwp at claws-mail.org
Mon Dec 24 19:49:31 CET 2018
The branch, master has been updated
via b2fffbb32b0a7eeac9ed4ec6b99f429e4b064fb3 (commit)
from d2f6919629e3da32181ef9a3918db0c1821680f9 (commit)
Summary of changes:
src/gtk/foldersort.c | 23 ++++-
src/plugins/python/Makefile.am | 2 +
src/plugins/python/python_plugin.c | 28 ++++++-
src/plugins/python/python_prefs.c | 88 ++++++++++++++++++++
.../{fancy/fancy_prefs.h => python/python_prefs.h} | 37 +++-----
src/prefs_common.c | 10 +++
src/prefs_common.h | 4 +
src/uri_opener.c | 24 +++++-
8 files changed, 186 insertions(+), 30 deletions(-)
create mode 100644 src/plugins/python/python_prefs.c
copy src/plugins/{fancy/fancy_prefs.h => python/python_prefs.h} (59%)
- Log -----------------------------------------------------------------
commit b2fffbb32b0a7eeac9ed4ec6b99f429e4b064fb3
Author: wwp <subscript at free.fr>
Date: Mon Dec 24 19:44:30 2018 +0100
Window sizes are now remembered for the Python console,
the 'Open URLs' and the 'Set mailbox order' windows.
diff --git a/src/gtk/foldersort.c b/src/gtk/foldersort.c
index 9c5eb69..12bcf1d 100644
--- a/src/gtk/foldersort.c
+++ b/src/gtk/foldersort.c
@@ -26,6 +26,7 @@
#include "foldersort.h"
#include "inc.h"
#include "utils.h"
+#include "prefs_common.h"
enum {
FOLDERSORT_COL_NAME,
@@ -199,6 +200,14 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, FolderSortDia
return FALSE;
}
+static void foldersort_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation)
+{
+ cm_return_if_fail(allocation != NULL);
+
+ prefs_common.foldersortwin_width = allocation->width;
+ prefs_common.foldersortwin_height = allocation->height;
+}
+
void foldersort_open()
{
FolderSortDialog *dialog = g_new0(FolderSortDialog, 1);
@@ -223,6 +232,7 @@ void foldersort_open()
GtkCellRenderer *rdr;
GtkTreeSelection *selector;
GtkTreeIter iter;
+ static GdkGeometry geometry;
window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "foldersort");
g_object_set_data(G_OBJECT(window), "window", window);
@@ -230,9 +240,10 @@ void foldersort_open()
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(window), _("Set mailbox order"));
gtk_window_set_modal(GTK_WINDOW(window), TRUE);
- gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(delete_event), dialog);
+ g_signal_connect (G_OBJECT(window), "size_allocate",
+ G_CALLBACK (foldersort_size_allocate_cb), NULL);
g_signal_connect(G_OBJECT(window), "key_press_event",
G_CALLBACK(key_pressed), dialog);
@@ -316,6 +327,16 @@ void foldersort_open()
gtk_widget_show(movedown_btn);
gtk_box_pack_start(GTK_BOX(btn_vbox), movedown_btn, FALSE, FALSE, 0);
+ if (!geometry.min_height) {
+ geometry.min_width = 400;
+ geometry.min_height = 300;
+ }
+
+ gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
+ GDK_HINT_MIN_SIZE);
+ gtk_widget_set_size_request(window, prefs_common.foldersortwin_width,
+ prefs_common.foldersortwin_height);
+
dialog->window = window;
dialog->moveup_btn = moveup_btn;
dialog->movedown_btn = movedown_btn;
diff --git a/src/plugins/python/Makefile.am b/src/plugins/python/Makefile.am
index 36ca7c4..6c2e988 100644
--- a/src/plugins/python/Makefile.am
+++ b/src/plugins/python/Makefile.am
@@ -29,6 +29,8 @@ python_la_SOURCES = \
nodetype.c \
nodetype.h \
python_plugin.c \
+ python_prefs.c \
+ python_prefs.h \
python-hooks.c \
python-hooks.h \
python-shell.c \
diff --git a/src/plugins/python/python_plugin.c b/src/plugins/python/python_plugin.c
index e9fcd6e..c07181b 100644
--- a/src/plugins/python/python_plugin.c
+++ b/src/plugins/python/python_plugin.c
@@ -40,6 +40,7 @@
#include "python-hooks.h"
#include "clawsmailmodule.h"
#include "file-utils.h"
+#include "python_prefs.h"
#define PYTHON_SCRIPTS_BASE_DIR "python-scripts"
#define PYTHON_SCRIPTS_MAIN_DIR "main"
@@ -70,13 +71,32 @@ static gboolean python_console_delete_event(GtkWidget *widget, GdkEvent *event,
return TRUE;
}
+static void size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation)
+{
+ cm_return_if_fail(allocation != NULL);
+
+ python_config.console_win_width = allocation->width;
+ python_config.console_win_height = allocation->height;
+}
+
static void setup_python_console(void)
{
GtkWidget *vbox;
GtkWidget *console;
+ static GdkGeometry geometry;
python_console = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(python_console, 600, 400);
+ g_signal_connect (G_OBJECT(python_console), "size_allocate",
+ G_CALLBACK (size_allocate_cb), NULL);
+ if (!geometry.min_height) {
+ geometry.min_width = 600;
+ geometry.min_height = 400;
+ }
+
+ gtk_window_set_geometry_hints(GTK_WINDOW(python_console), NULL, &geometry,
+ GDK_HINT_MIN_SIZE);
+ gtk_widget_set_size_request(python_console, python_config.console_win_width,
+ python_config.console_win_height);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(python_console), vbox);
@@ -652,6 +672,9 @@ gint plugin_init(gchar **error)
if(!check_plugin_version(MAKE_NUMERIC_VERSION(3,7,6,9), VERSION_NUMERIC, _("Python"), error))
return -1;
+ /* init/load prefs */
+ python_prefs_init();
+
/* load hooks */
hook_compose_create = hooks_register_hook(COMPOSE_CREATED_HOOKLIST, my_compose_create_hook, NULL);
if(hook_compose_create == 0) {
@@ -727,6 +750,9 @@ gboolean plugin_done(void)
parasite_python_done();
+ /* save prefs */
+ python_prefs_done();
+
debug_print("Python plugin done and unloaded.\n");
return FALSE;
}
diff --git a/src/plugins/python/python_prefs.c b/src/plugins/python/python_prefs.c
new file mode 100644
index 0000000..bfc2c19
--- /dev/null
+++ b/src/plugins/python/python_prefs.c
@@ -0,0 +1,88 @@
+/*
+ * Claws Mail -- A GTK+ based, lightweight, and fast e-mail client
+ * Copyright(C) 1999-2015 the Claws Mail Team
+ * == Fancy Plugin ==
+ * This file Copyright (C) 2009-2015 Salvatore De Paolis
+ * <iwkse at claws-mail.org> and the Claws Mail 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 3 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 tothe Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "claws-features.h"
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include "common/version.h"
+#include "defs.h"
+#include "claws.h"
+#include "plugin.h"
+#include "file-utils.h"
+#include "utils.h"
+#include "prefs.h"
+#include "prefs_common.h"
+#include "prefs_gtk.h"
+#include "python_prefs.h"
+
+#define PREFS_BLOCK_NAME "Python"
+
+PythonConfig python_config;
+
+static PrefParam prefs[] = {
+ {"console_win_width", "-1", &python_config.console_win_width,
+ P_INT, NULL, NULL, NULL},
+ {"console_win_height", "-1", &python_config.console_win_height,
+ P_INT, NULL, NULL, NULL},
+ {0,0,0,0,0,0,0}
+};
+
+void python_prefs_init(void)
+{
+ static gchar *path[3];
+ gchar *rcpath;
+
+ path[0] = _("Plugins");
+ path[1] = "Python";
+ path[2] = NULL;
+
+ prefs_set_default(prefs);
+ rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+ prefs_read_config(prefs, PREFS_BLOCK_NAME, rcpath, NULL);
+ g_free(rcpath);
+}
+
+void python_prefs_done(void)
+{
+ PrefFile *pref_file;
+ gchar *rc_file_path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ COMMON_RC, NULL);
+ pref_file = prefs_write_open(rc_file_path);
+ g_free(rc_file_path);
+
+ if (!(pref_file) || (prefs_set_block_label(pref_file, PREFS_BLOCK_NAME) < 0))
+ return;
+
+ if (prefs_write_param(prefs, pref_file->fp) < 0) {
+ g_warning("failed to write Python Plugin configuration");
+ prefs_file_close_revert(pref_file);
+ return;
+ }
+
+ if (fprintf(pref_file->fp, "\n") < 0) {
+ FILE_OP_ERROR(rc_file_path, "fprintf");
+ prefs_file_close_revert(pref_file);
+ } else
+ prefs_file_close(pref_file);
+}
diff --git a/src/plugins/python/python_prefs.h b/src/plugins/python/python_prefs.h
new file mode 100644
index 0000000..c762fc9
--- /dev/null
+++ b/src/plugins/python/python_prefs.h
@@ -0,0 +1,36 @@
+/*
+ * Claws Mail -- A GTK+ based, lightweight, and fast e-mail client
+ * Copyright(C) 1999-2018 the Claws Mail Team
+ * == Fancy Plugin ==
+ * This file Copyright (C) 2009 -2014 Salvatore De Paolis
+ * <iwkse at claws-mail.org> and the Claws Mail 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 3 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 tothe Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PYTHON_PREFS_H
+#define PYTHON_PREFS_H
+
+typedef struct _PythonConfig PythonConfig;
+
+struct _PythonConfig
+{
+ gint console_win_width;
+ gint console_win_height;
+};
+
+extern PythonConfig python_config;
+
+void python_prefs_init(void);
+void python_prefs_done(void);
+
+#endif
diff --git a/src/prefs_common.c b/src/prefs_common.c
index 1f0fbce..5ce34dd 100644
--- a/src/prefs_common.c
+++ b/src/prefs_common.c
@@ -1062,6 +1062,16 @@ static PrefParam param[] = {
{"sslmanwin_height", "-1", &prefs_common.sslmanwin_height, P_INT,
NULL, NULL, NULL},
+ {"uriopenerwin_width", "-1", &prefs_common.uriopenerwin_width, P_INT,
+ NULL, NULL, NULL},
+ {"uriopenerwin_height", "-1", &prefs_common.uriopenerwin_height, P_INT,
+ NULL, NULL, NULL},
+
+ {"foldersortwin_width", "400", &prefs_common.foldersortwin_width, P_INT,
+ NULL, NULL, NULL},
+ {"foldersortwin_height", "300", &prefs_common.foldersortwin_height, P_INT,
+ NULL, NULL, NULL},
+
{"addressbookwin_width", "520", &prefs_common.addressbookwin_width, P_INT,
NULL, NULL, NULL},
{"addressbookwin_height", "-1", &prefs_common.addressbookwin_height, P_INT,
diff --git a/src/prefs_common.h b/src/prefs_common.h
index 0563080..05a7896 100644
--- a/src/prefs_common.h
+++ b/src/prefs_common.h
@@ -498,6 +498,10 @@ struct _PrefsCommon
gint tagswin_height;
gint sslmanwin_width;
gint sslmanwin_height;
+ gint uriopenerwin_width;
+ gint uriopenerwin_height;
+ gint foldersortwin_width;
+ gint foldersortwin_height;
gint addressbookwin_width;
gint addressbookwin_height;
gint addressbookeditpersonwin_width;
diff --git a/src/uri_opener.c b/src/uri_opener.c
index 8c47de1..99d34e5 100644
--- a/src/uri_opener.c
+++ b/src/uri_opener.c
@@ -37,7 +37,6 @@
#include "textview.h"
#include "mimeview.h"
#include "prefs_common.h"
-#include "prefs_common.h"
enum {
URI_OPENER_URL,
@@ -156,12 +155,20 @@ static GtkWidget *uri_opener_scrolled_win_create(void)
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_widget_set_size_request(scrolledwin, 500, 250);
+ gtk_widget_set_size_request(scrolledwin, 200, 250);
gtk_widget_show(scrolledwin);
return scrolledwin;
}
+static void uri_opener_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation)
+{
+ cm_return_if_fail(allocation != NULL);
+
+ prefs_common.uriopenerwin_width = allocation->width;
+ prefs_common.uriopenerwin_height = allocation->height;
+}
+
static void uri_opener_create(void)
{
GtkWidget *window;
@@ -175,6 +182,7 @@ static void uri_opener_create(void)
GtkWidget *open_btn;
GtkWidget *close_btn;
GtkWidget *scrolledwin;
+ static GdkGeometry geometry;
window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "uri_opener");
gtk_window_set_title (GTK_WINDOW(window),
@@ -185,6 +193,8 @@ static void uri_opener_create(void)
gtk_window_set_resizable(GTK_WINDOW (window), TRUE);
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(uri_opener_close_cb), NULL);
+ g_signal_connect (G_OBJECT(window), "size_allocate",
+ G_CALLBACK (uri_opener_size_allocate_cb), NULL);
g_signal_connect(G_OBJECT(window), "key_press_event",
G_CALLBACK(key_pressed), NULL);
MANAGE_WINDOW_SIGNALS_CONNECT (window);
@@ -227,6 +237,16 @@ static void uri_opener_create(void)
gtk_widget_show_all(vbox1);
gtk_container_add(GTK_CONTAINER (window), vbox1);
+ if (!geometry.min_height) {
+ geometry.min_width = 450;
+ geometry.min_height = 300;
+ }
+
+ gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
+ GDK_HINT_MIN_SIZE);
+ gtk_widget_set_size_request(window, prefs_common.uriopenerwin_width,
+ prefs_common.uriopenerwin_height);
+
opener.window = window;
opener.hbox_scroll = hbox_scroll;
opener.hbox1 = hbox1;
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list