Compile modules based on HAVE_* features
[geeqie.git] / src / ui-misc.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef UI_MISC_H
23 #define UI_MISC_H
24
25 #include <ctime>
26
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28 #include <gdk/gdk.h>
29 #include <glib-object.h>
30 #include <glib.h>
31 #include <gtk/gtk.h>
32
33 /* these values are per GNOME HIG */
34
35 /* HIG 2.0 chapter 8 defines: */
36
37 /**
38  * @def PREF_PAD_GAP
39  * space between elements within control (ex: icon and it's text)
40  */
41 #define PREF_PAD_GAP     6
42
43 /**
44  * @def PREF_PAD_SPACE
45  * space between label and control(s)
46  */
47 #define PREF_PAD_SPACE  12
48
49 /**
50  * @def PREF_PAD_BORDER
51  * space between window border and controls
52  */
53 #define PREF_PAD_BORDER 12
54
55 /**
56  * @def PREF_PAD_INDENT
57  * indent for group members
58  */
59 #define PREF_PAD_INDENT 12
60
61 /**
62  * @def PREF_PAD_GROUP
63  * vertical space between groups
64  */
65 #define PREF_PAD_GROUP  18
66
67 /* HIG 2.0 chapter 3.13 defines: */
68
69 /**
70  * @def PREF_PAD_BUTTON_GAP
71  * gap between buttons in a dialog
72  */
73 #define PREF_PAD_BUTTON_GAP 6
74
75 /**
76  * @def PREF_PAD_BUTTON_SPACE
77  * space between buttons in a dialog and it's contents
78  */
79 #define PREF_PAD_BUTTON_SPACE 24
80
81 /* and these are not in the GNOME HIG */
82
83 /**
84  * @def PREF_PAD_TOOLBAR_GAP
85  * gap between similar toolbar items (buttons)
86  */
87 #define PREF_PAD_TOOLBAR_GAP 0
88
89 /**
90  * @def PREF_PAD_BUTTON_ICON_GAP
91  * HIG 2.0 states 6 pixels between icons and text,
92  * but GTK's stock buttons ignore this (hard coded to 2), we do it too for consistency
93  */
94 #define PREF_PAD_BUTTON_ICON_GAP 2
95
96
97 GtkWidget *pref_box_new(GtkWidget *parent_box, gboolean fill,
98                         GtkOrientation orientation, gboolean padding);
99
100 GtkWidget *pref_group_new(GtkWidget *parent_box, gboolean fill,
101                           const gchar *text, GtkOrientation orientation);
102 GtkWidget *pref_group_parent(GtkWidget *child);
103
104 GtkWidget *pref_frame_new(GtkWidget *parent_box, gboolean fill,
105                           const gchar *text,
106                           GtkOrientation orientation, gboolean padding);
107
108 GtkWidget *pref_spacer(GtkWidget *parent_box, gboolean padding);
109 GtkWidget *pref_line(GtkWidget *parent_box, gboolean padding);
110
111 GtkWidget *pref_label_new(GtkWidget *parent_box, const gchar *text);
112 GtkWidget *pref_label_new_mnemonic(GtkWidget *parent_box, const gchar *text, GtkWidget *widget);
113 void pref_label_bold(GtkWidget *label, gboolean bold, gboolean increase_size);
114
115 GtkWidget *pref_button_new(GtkWidget *parent_box, const gchar *icon_name,
116                            const gchar *text, GCallback func, gpointer data);
117
118 GtkWidget *pref_checkbox_new(GtkWidget *parent_box, const gchar *text, gboolean active,
119                              GCallback func, gpointer data);
120 GtkWidget *pref_checkbox_new_mnemonic(GtkWidget *parent_box, const gchar *text, gboolean active,
121                                       GCallback func, gpointer data);
122
123 GtkWidget *pref_checkbox_new_int(GtkWidget *parent_box, const gchar *text, gboolean active,
124                                  gboolean *result);
125
126 void pref_checkbox_link_sensitivity(GtkWidget *button, GtkWidget *widget);
127 void pref_checkbox_link_sensitivity_swap(GtkWidget *button, GtkWidget *widget);
128
129 GtkWidget *pref_radiobutton_new(GtkWidget *parent_box, GtkWidget *sibling,
130                                 const gchar *text, gboolean active,
131                                 GCallback func, gpointer data);
132 GtkWidget *pref_radiobutton_new_mnemonic(GtkWidget *parent_box, GtkWidget *sibling,
133                                          const gchar *text, gboolean active,
134                                          GCallback func, gpointer data);
135
136 GtkWidget *pref_radiobutton_new_int(GtkWidget *parent_box, GtkWidget *sibling,
137                                     const gchar *text, gboolean active,
138                                     gboolean *result, gboolean value,
139                                     GCallback func, gpointer data);
140
141 GtkWidget *pref_spin_new(GtkWidget *parent_box, const gchar *text, const gchar *suffix,
142                          gdouble min, gdouble max, gdouble step, gint digits,
143                          gdouble value,
144                          GCallback func, gpointer data);
145 GtkWidget *pref_spin_new_mnemonic(GtkWidget *parent_box, const gchar *text, const gchar *suffix,
146                                   gdouble min, gdouble max, gdouble step, gint digits,
147                                   gdouble value,
148                                   GCallback func, gpointer data);
149
150 GtkWidget *pref_spin_new_int(GtkWidget *parent_box, const gchar *text, const gchar *suffix,
151                              gint min, gint max, gint step,
152                              gint value, gint *value_var);
153
154 void pref_link_sensitivity(GtkWidget *widget, GtkWidget *watch);
155
156 void pref_signal_block_data(GtkWidget *widget, gpointer data);
157 void pref_signal_unblock_data(GtkWidget *widget, gpointer data);
158
159
160 GtkWidget *pref_table_new(GtkWidget *parent_box, gint, gint, gboolean, gboolean);
161
162 GtkWidget *pref_table_box(GtkWidget *table, gint column, gint row,
163                           GtkOrientation orientation, const gchar *text);
164
165 GtkWidget *pref_table_label(GtkWidget *table, gint column, gint row,
166                             const gchar *text, GtkAlign alignment);
167
168 GtkWidget *pref_table_button(GtkWidget *table, gint column, gint row,
169                              const gchar *stock_id, const gchar *text,
170                              GCallback func, gpointer data);
171
172 GtkWidget *pref_table_spin(GtkWidget *table, gint column, gint row,
173                            const gchar *text, const gchar *suffix,
174                            gdouble min, gdouble max, gdouble step, gint digits,
175                            gdouble value,
176                            GCallback func, gpointer data);
177
178 GtkWidget *pref_table_spin_new_int(GtkWidget *table, gint column, gint row,
179                                    const gchar *text, const gchar *suffix,
180                                    gint min, gint max, gint step,
181                                    gint value, gint *value_var);
182
183
184 GtkWidget *pref_toolbar_new(GtkWidget *parent_box);
185 GtkWidget *pref_toolbar_button(GtkWidget *toolbar,
186                                const gchar *icon_name, const gchar *label, gboolean toggle,
187                                const gchar *description,
188                                GCallback func, gpointer data);
189 void pref_toolbar_button_set_icon(GtkWidget *button, GtkWidget *widget, const gchar *stock_id);
190 GtkWidget *pref_toolbar_spacer(GtkWidget *toolbar);
191
192
193 GtkWidget *date_selection_new();
194
195 void date_selection_set(GtkWidget *widget, gint day, gint month, gint year);
196 GDateTime *date_selection_get(GtkWidget *widget);
197
198 void date_selection_time_set(GtkWidget *widget, time_t t);
199 time_t date_selection_time_get(GtkWidget *widget);
200
201
202 enum SizerPositionType {
203         SIZER_POS_LEFT   = 1 << 0,
204         SIZER_POS_RIGHT  = 1 << 1,
205         SIZER_POS_TOP    = 1 << 2,
206         SIZER_POS_BOTTOM = 1 << 3
207 };
208
209 void sizer_set_limits(GtkWidget *sizer,
210                       gint hsize_min, gint hsize_max,
211                       gint vsize_min, gint vsize_max);
212
213
214 void pref_list_int_set(const gchar *group, const gchar *key, gint value);
215 gboolean pref_list_int_get(const gchar *group, const gchar *key, gint *result);
216
217 void pref_list_double_set(const gchar *group, const gchar *key, gdouble value);
218 gboolean pref_list_double_get(const gchar *group, const gchar *key, gdouble *result);
219
220 void pref_list_string_set(const gchar *group, const gchar *key, const gchar *value);
221 gboolean pref_list_string_get(const gchar *group, const gchar *key, const gchar **result);
222
223
224 void pref_color_button_set_cb(GtkWidget *widget, gpointer data);
225 GtkWidget *pref_color_button_new(GtkWidget *parent_box,
226                                  const gchar *title, GdkRGBA *color,
227                                  GCallback func, gpointer data);
228
229 gchar *text_widget_text_pull(GtkWidget *text_widget);
230 gchar *text_widget_text_pull_selected(GtkWidget *text_widget);
231
232 struct ActionItem
233 {
234         const gchar *name; /* GtkActionEntry terminology */
235         const gchar *label;
236         const gchar *icon_name;
237 };
238
239 GList* get_action_items();
240 void action_items_free(GList *list);
241
242 gboolean defined_mouse_buttons(GtkWidget *widget, GdkEventButton *event, gpointer data);
243
244 // Copy pixbuf returned by gtk_icon_theme_load_icon() to avoid GTK+ keeping the old icon theme loaded
245 GdkPixbuf *gq_gtk_icon_theme_load_icon_copy(GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags);
246 #endif
247 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */