Statistics
| Revision:

root / src / prefs_ui.h @ 2080

History | View | Annotate | Download (5.1 kB)

1 527 hiro
/*
2 527 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 1053 hiro
 * Copyright (C) 1999-2006 Hiroyuki Yamamoto
4 527 hiro
 *
5 527 hiro
 * This program is free software; you can redistribute it and/or modify
6 527 hiro
 * it under the terms of the GNU General Public License as published by
7 527 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 527 hiro
 * (at your option) any later version.
9 527 hiro
 *
10 527 hiro
 * This program is distributed in the hope that it will be useful,
11 527 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 527 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 527 hiro
 * GNU General Public License for more details.
14 527 hiro
 *
15 527 hiro
 * You should have received a copy of the GNU General Public License
16 527 hiro
 * along with this program; if not, write to the Free Software
17 527 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 527 hiro
 */
19 527 hiro
20 527 hiro
#ifndef __PREFS_UI_H__
21 527 hiro
#define __PREFS_UI_H__
22 527 hiro
23 527 hiro
#include <glib.h>
24 527 hiro
#include <gtk/gtkwidget.h>
25 527 hiro
#include <gtk/gtksignal.h>
26 527 hiro
#include <gtk/gtklabel.h>
27 527 hiro
#include <gtk/gtknotebook.h>
28 527 hiro
#include <gtk/gtkcheckbutton.h>
29 527 hiro
#include <gtk/gtkframe.h>
30 527 hiro
#include <gtk/gtkvbox.h>
31 527 hiro
#include <stdio.h>
32 527 hiro
33 527 hiro
typedef struct _PrefsDialog        PrefsDialog;
34 533 hiro
typedef struct _PrefsUIData        PrefsUIData;
35 527 hiro
36 527 hiro
#include "prefs.h"
37 527 hiro
#include "gtkutils.h"
38 527 hiro
39 527 hiro
#define VSPACING                10
40 527 hiro
#define VSPACING_NARROW                4
41 527 hiro
#define VSPACING_NARROW_2        2
42 765 hiro
#define VBOX_BORDER                12
43 527 hiro
#define DEFAULT_ENTRY_WIDTH        80
44 527 hiro
45 533 hiro
struct _PrefsUIData
46 533 hiro
{
47 533 hiro
        gchar *name;
48 533 hiro
        GtkWidget **widget;
49 533 hiro
        DataSetFunc data_set_func;
50 533 hiro
        WidgetSetFunc widget_set_func;
51 533 hiro
};
52 533 hiro
53 527 hiro
struct _PrefsDialog
54 527 hiro
{
55 527 hiro
        GtkWidget *window;
56 527 hiro
        GtkWidget *notebook;
57 527 hiro
58 527 hiro
        GtkWidget *confirm_area;
59 527 hiro
        GtkWidget *ok_btn;
60 527 hiro
        GtkWidget *cancel_btn;
61 527 hiro
        GtkWidget *apply_btn;
62 527 hiro
};
63 527 hiro
64 527 hiro
#define SET_NOTEBOOK_LABEL(notebook, str, page_num) \
65 527 hiro
{ \
66 527 hiro
        GtkWidget *label; \
67 527 hiro
 \
68 527 hiro
        label = gtk_label_new (str); \
69 527 hiro
        gtk_widget_show (label); \
70 527 hiro
        gtk_notebook_set_tab_label \
71 527 hiro
                (GTK_NOTEBOOK (notebook), \
72 527 hiro
                 gtk_notebook_get_nth_page \
73 527 hiro
                        (GTK_NOTEBOOK (notebook), page_num), \
74 527 hiro
                 label); \
75 527 hiro
}
76 527 hiro
77 765 hiro
#define APPEND_SUB_NOTEBOOK(notebook, vbox, str) \
78 765 hiro
{ \
79 765 hiro
        GtkWidget *label; \
80 765 hiro
 \
81 765 hiro
        label = gtk_label_new(str); \
82 765 hiro
        gtk_widget_show(label); \
83 765 hiro
        vbox = gtk_vbox_new(FALSE, VSPACING); \
84 765 hiro
        gtk_widget_show(vbox); \
85 765 hiro
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label); \
86 765 hiro
        gtk_container_set_border_width(GTK_CONTAINER(vbox), VBOX_BORDER); \
87 765 hiro
}
88 765 hiro
89 527 hiro
#define PACK_CHECK_BUTTON(box, chkbtn, label) \
90 527 hiro
{ \
91 527 hiro
        chkbtn = gtk_check_button_new_with_label(label); \
92 527 hiro
        gtk_widget_show(chkbtn); \
93 527 hiro
        gtk_box_pack_start(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \
94 527 hiro
}
95 527 hiro
96 527 hiro
#define PACK_END_CHECK_BUTTON(box, chkbtn, label) \
97 527 hiro
{ \
98 527 hiro
        chkbtn = gtk_check_button_new_with_label(label); \
99 527 hiro
        gtk_widget_show(chkbtn); \
100 527 hiro
        gtk_box_pack_end(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \
101 527 hiro
}
102 527 hiro
103 527 hiro
#define PACK_FRAME(box, frame, label) \
104 527 hiro
{ \
105 527 hiro
        frame = gtk_frame_new(label); \
106 527 hiro
        gtk_widget_show(frame); \
107 527 hiro
        gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0); \
108 527 hiro
        gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5); \
109 527 hiro
}
110 527 hiro
111 527 hiro
#define PACK_FRAME_WITH_CHECK_BUTTON(box, frame, chkbtn, label) \
112 527 hiro
{ \
113 527 hiro
        chkbtn = gtk_check_button_new_with_label(label); \
114 527 hiro
        gtk_widget_show(chkbtn); \
115 527 hiro
        PACK_FRAME(box, frame, NULL); \
116 527 hiro
        gtk_frame_set_label_widget(GTK_FRAME(frame), chkbtn); \
117 527 hiro
}
118 527 hiro
119 527 hiro
#define PACK_SMALL_LABEL(box, label, str) \
120 527 hiro
{ \
121 527 hiro
        label = gtk_label_new(str); \
122 527 hiro
        gtk_widget_show(label); \
123 527 hiro
        gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); \
124 527 hiro
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); \
125 527 hiro
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); \
126 527 hiro
        gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); \
127 527 hiro
        gtkut_widget_set_small_font_size(label); \
128 527 hiro
}
129 527 hiro
130 527 hiro
#define PACK_VSPACER(box, vbox, spacing) \
131 527 hiro
{ \
132 527 hiro
        vbox = gtk_vbox_new(FALSE, 0); \
133 527 hiro
        gtk_widget_show(vbox); \
134 527 hiro
        gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, TRUE, spacing); \
135 527 hiro
}
136 527 hiro
137 527 hiro
#define SET_TOGGLE_SENSITIVITY(togglewid, targetwid) \
138 527 hiro
{ \
139 527 hiro
        gtk_widget_set_sensitive(targetwid, FALSE); \
140 527 hiro
        g_signal_connect(G_OBJECT(togglewid), "toggled", \
141 527 hiro
                         G_CALLBACK(prefs_button_toggled), targetwid); \
142 527 hiro
}
143 527 hiro
144 1124 hiro
#define SET_TOGGLE_SENSITIVITY_REV(togglewid, targetwid) \
145 1124 hiro
{ \
146 1124 hiro
        gtk_widget_set_sensitive(targetwid, TRUE); \
147 1124 hiro
        g_signal_connect(G_OBJECT(togglewid), "toggled", \
148 1124 hiro
                         G_CALLBACK(prefs_button_toggled_rev), targetwid); \
149 1124 hiro
}
150 1124 hiro
151 527 hiro
void prefs_dialog_create        (PrefsDialog        *dialog);
152 527 hiro
void prefs_dialog_destroy        (PrefsDialog        *dialog);
153 527 hiro
154 527 hiro
void prefs_button_toggled        (GtkToggleButton        *toggle_btn,
155 527 hiro
                                 GtkWidget                *widget);
156 1124 hiro
void prefs_button_toggled_rev        (GtkToggleButton        *toggle_btn,
157 1124 hiro
                                 GtkWidget                *widget);
158 527 hiro
159 533 hiro
void prefs_register_ui                (PrefParam        *param,
160 533 hiro
                                 PrefsUIData        *ui_data);
161 533 hiro
162 527 hiro
void prefs_set_dialog                (PrefParam        *param);
163 527 hiro
void prefs_set_data_from_dialog        (PrefParam        *param);
164 527 hiro
void prefs_set_dialog_to_default(PrefParam        *param);
165 527 hiro
166 527 hiro
void prefs_set_data_from_entry        (PrefParam        *pparam);
167 527 hiro
void prefs_set_entry                (PrefParam        *pparam);
168 527 hiro
void prefs_set_data_from_text        (PrefParam        *pparam);
169 527 hiro
void prefs_set_text                (PrefParam        *pparam);
170 527 hiro
void prefs_set_data_from_toggle        (PrefParam        *pparam);
171 527 hiro
void prefs_set_toggle                (PrefParam        *pparam);
172 527 hiro
void prefs_set_data_from_spinbtn(PrefParam        *pparam);
173 527 hiro
void prefs_set_spinbtn                (PrefParam        *pparam);
174 527 hiro
void prefs_set_data_from_fontbtn(PrefParam        *pparam);
175 527 hiro
void prefs_set_fontbtn                (PrefParam        *pparam);
176 1053 hiro
void prefs_set_data_from_optmenu(PrefParam        *pparam);
177 1053 hiro
void prefs_set_optmenu                (PrefParam        *pparam);
178 527 hiro
179 527 hiro
#endif /* __PREFS_UI_H__ */