Window sizes are now remembered for the Python console,
the 'Open URLs' and the 'Set mailbox order' windows.
This commit is contained in:
parent
989513b647
commit
9914197299
8 changed files with 211 additions and 4 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "foldersort.h"
|
||||
#include "inc.h"
|
||||
#include "utils.h"
|
||||
#include "prefs_common.h"
|
||||
|
||||
enum {
|
||||
FOLDERSORT_COL_NAME,
|
||||
|
@ -209,6 +210,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);
|
||||
|
@ -233,6 +242,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);
|
||||
|
@ -240,9 +250,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);
|
||||
|
||||
|
@ -326,6 +337,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;
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
88
src/plugins/python/python_prefs.c
Normal file
88
src/plugins/python/python_prefs.c
Normal file
|
@ -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@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);
|
||||
}
|
36
src/plugins/python/python_prefs.h
Normal file
36
src/plugins/python/python_prefs.h
Normal file
|
@ -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@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
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "textview.h"
|
||||
#include "mimeview.h"
|
||||
#include "prefs_common.h"
|
||||
#include "prefs_common.h"
|
||||
|
||||
enum {
|
||||
URI_OPENER_URL,
|
||||
|
@ -154,12 +153,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;
|
||||
|
@ -173,6 +180,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),
|
||||
|
@ -183,6 +191,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);
|
||||
|
@ -225,6 +235,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;
|
||||
|
|
Loading…
Reference in a new issue