2001-04-19 14:21:46 +02:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
2006-01-13 18:24:38 +01:00
|
|
|
* Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
|
2001-04-19 14:21:46 +02:00
|
|
|
*
|
|
|
|
* 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
|
2005-09-21 20:22:51 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2001-04-19 14:21:46 +02:00
|
|
|
*/
|
|
|
|
|
2002-12-25 14:46:41 +01:00
|
|
|
#ifndef __PREFS_GTK_H__
|
|
|
|
#define __PREFS_GTK_H__
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gtk/gtkwidget.h>
|
|
|
|
#include <gtk/gtksignal.h>
|
|
|
|
#include <gtk/gtklabel.h>
|
|
|
|
#include <gtk/gtknotebook.h>
|
|
|
|
#include <gtk/gtkcheckbutton.h>
|
|
|
|
#include <gtk/gtkbox.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
typedef struct _PrefParam PrefParam;
|
|
|
|
typedef struct _PrefsDialog PrefsDialog;
|
|
|
|
|
2002-12-25 14:46:41 +01:00
|
|
|
#include "prefs.h"
|
2001-04-19 14:21:46 +02:00
|
|
|
#include "account.h"
|
2003-01-06 19:54:30 +01:00
|
|
|
#include "gtk/prefswindow.h"
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2001-09-13 15:38:32 +02:00
|
|
|
#define VSPACING 10
|
2001-09-09 16:00:28 +02:00
|
|
|
#define VSPACING_NARROW 4
|
|
|
|
#define VSPACING_NARROW_2 2
|
2005-12-02 11:51:43 +01:00
|
|
|
#define VBOX_BORDER 8
|
2001-09-09 16:00:28 +02:00
|
|
|
#define DEFAULT_ENTRY_WIDTH 80
|
|
|
|
#define PREFSBUFSIZE 1024
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
P_STRING,
|
|
|
|
P_INT,
|
|
|
|
P_BOOL,
|
|
|
|
P_ENUM,
|
|
|
|
P_USHORT,
|
2003-02-19 22:46:30 +01:00
|
|
|
P_COLOR,
|
2003-03-02 17:29:07 +01:00
|
|
|
P_PASSWORD,
|
2001-04-19 14:21:46 +02:00
|
|
|
P_OTHER
|
|
|
|
} PrefType;
|
|
|
|
|
|
|
|
typedef void (*DataSetFunc) (PrefParam *pparam);
|
|
|
|
typedef void (*WidgetSetFunc) (PrefParam *pparam);
|
|
|
|
|
|
|
|
struct _PrefParam {
|
|
|
|
gchar *name;
|
|
|
|
gchar *defval;
|
|
|
|
gpointer data;
|
|
|
|
PrefType type;
|
|
|
|
GtkWidget **widget;
|
|
|
|
DataSetFunc data_set_func;
|
|
|
|
WidgetSetFunc widget_set_func;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _PrefsDialog
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *notebook;
|
|
|
|
|
|
|
|
GtkWidget *ok_btn;
|
|
|
|
GtkWidget *cancel_btn;
|
|
|
|
GtkWidget *apply_btn;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SET_NOTEBOOK_LABEL(notebook, str, page_num) \
|
|
|
|
{ \
|
|
|
|
GtkWidget *label; \
|
2002-01-03 01:23:17 +01:00
|
|
|
gint i = page_num; \
|
|
|
|
\
|
2006-02-09 18:37:08 +01:00
|
|
|
label = gtk_label_new_with_mnemonic (str); \
|
2001-04-19 14:21:46 +02:00
|
|
|
gtk_widget_show (label); \
|
|
|
|
gtk_notebook_set_tab_label \
|
|
|
|
(GTK_NOTEBOOK (notebook), \
|
|
|
|
gtk_notebook_get_nth_page \
|
2002-01-03 01:23:17 +01:00
|
|
|
(GTK_NOTEBOOK (notebook), i), \
|
2001-04-19 14:21:46 +02:00
|
|
|
label); \
|
2002-01-03 01:23:17 +01:00
|
|
|
gtk_notebook_set_menu_label_text \
|
|
|
|
(GTK_NOTEBOOK (notebook), \
|
|
|
|
gtk_notebook_get_nth_page \
|
|
|
|
(GTK_NOTEBOOK (notebook), i), \
|
|
|
|
str);\
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define PACK_CHECK_BUTTON(box, chkbtn, label) \
|
|
|
|
{ \
|
|
|
|
chkbtn = gtk_check_button_new_with_label(label); \
|
|
|
|
gtk_widget_show(chkbtn); \
|
|
|
|
gtk_box_pack_start(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \
|
|
|
|
}
|
|
|
|
|
2001-05-08 15:15:53 +02:00
|
|
|
#define PACK_END_CHECK_BUTTON(box, chkbtn, label) \
|
|
|
|
{ \
|
|
|
|
chkbtn = gtk_check_button_new_with_label(label); \
|
|
|
|
gtk_widget_show(chkbtn); \
|
|
|
|
gtk_box_pack_end(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \
|
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
#define PACK_FRAME(box, frame, label) \
|
|
|
|
{ \
|
|
|
|
frame = gtk_frame_new(label); \
|
|
|
|
gtk_widget_show(frame); \
|
|
|
|
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0); \
|
|
|
|
gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5); \
|
|
|
|
}
|
|
|
|
|
2001-09-09 16:00:28 +02:00
|
|
|
#define PACK_VSPACER(box, vbox, spacing) \
|
|
|
|
{ \
|
|
|
|
vbox = gtk_vbox_new(FALSE, 0); \
|
|
|
|
gtk_widget_show(vbox); \
|
|
|
|
gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, TRUE, spacing); \
|
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
#define SET_TOGGLE_SENSITIVITY(togglewid, targetwid) \
|
|
|
|
{ \
|
2002-01-11 16:01:47 +01:00
|
|
|
gtk_widget_set_sensitive(targetwid, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglewid))); \
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(togglewid), "toggled", \
|
|
|
|
G_CALLBACK(prefs_button_toggled), targetwid); \
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2006-02-15 15:17:54 +01:00
|
|
|
#define SET_TOGGLE_SENSITIVITY_REVERSE(togglewid, targetwid) \
|
|
|
|
{ \
|
|
|
|
gtk_widget_set_sensitive(targetwid, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglewid))); \
|
|
|
|
g_signal_connect(G_OBJECT(togglewid), "toggled", \
|
|
|
|
G_CALLBACK(prefs_button_toggled_reverse), targetwid); \
|
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
void prefs_read_config (PrefParam *param,
|
|
|
|
const gchar *label,
|
2005-02-01 09:58:33 +01:00
|
|
|
const gchar *rcfile,
|
|
|
|
const gchar *encoding);
|
2001-04-19 14:21:46 +02:00
|
|
|
void prefs_config_parse_one_line(PrefParam *param,
|
|
|
|
const gchar *buf);
|
2004-07-16 13:12:46 +02:00
|
|
|
void prefs_write_config (PrefParam *param,
|
2001-04-19 14:21:46 +02:00
|
|
|
const gchar *label,
|
|
|
|
const gchar *rcfile);
|
|
|
|
gint prefs_write_param (PrefParam *param,
|
|
|
|
FILE *fp);
|
|
|
|
|
|
|
|
PrefFile *prefs_write_open (const gchar *path);
|
|
|
|
gint prefs_write_close (PrefFile *pfile);
|
|
|
|
gint prefs_write_close_revert (PrefFile *pfile);
|
|
|
|
|
|
|
|
void prefs_set_default (PrefParam *param);
|
|
|
|
void prefs_free (PrefParam *param);
|
|
|
|
|
|
|
|
void prefs_dialog_create (PrefsDialog *dialog);
|
2002-04-21 00:57:52 +02:00
|
|
|
void prefs_dialog_destroy (PrefsDialog *dialog);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
void prefs_button_toggled (GtkToggleButton *toggle_btn,
|
|
|
|
GtkWidget *widget);
|
2006-02-15 15:17:54 +01:00
|
|
|
void prefs_button_toggled_reverse (GtkToggleButton *toggle_btn,
|
|
|
|
GtkWidget *widget);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
void prefs_set_dialog (PrefParam *param);
|
|
|
|
void prefs_set_data_from_dialog (PrefParam *param);
|
|
|
|
void prefs_set_dialog_to_default(PrefParam *param);
|
|
|
|
|
|
|
|
void prefs_set_data_from_entry (PrefParam *pparam);
|
|
|
|
void prefs_set_entry (PrefParam *pparam);
|
|
|
|
void prefs_set_data_from_text (PrefParam *pparam);
|
|
|
|
void prefs_set_text (PrefParam *pparam);
|
|
|
|
void prefs_set_data_from_toggle (PrefParam *pparam);
|
|
|
|
void prefs_set_toggle (PrefParam *pparam);
|
|
|
|
void prefs_set_data_from_spinbtn(PrefParam *pparam);
|
|
|
|
void prefs_set_spinbtn (PrefParam *pparam);
|
|
|
|
|
2003-05-13 13:54:19 +02:00
|
|
|
void prefs_gtk_open (void);
|
2003-01-06 19:54:30 +01:00
|
|
|
void prefs_gtk_register_page (PrefsPage *page);
|
|
|
|
void prefs_gtk_unregister_page (PrefsPage *page);
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
#endif /* __PREFS_H__ */
|