Merged older cs.po file with newest pot file.
[gliv/czech_localization.git] / src / options.c
blob144ec79eb0f70423ff1a92f2a5382ac00a7e3147
1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 * See the COPYING file for license information.
18 * Guillaume Chazarain <guichaz@yahoo.fr>
21 /*****************************
22 * User configurable options *
23 *****************************/
25 #include <string.h> /* memcmp() */
26 #include <gdk/gdkkeysyms.h> /* GDK_Escape, GDK_c, GDK_C, GDK_o, GDK_O */
28 #include "gliv.h"
29 #include "options.h"
30 #include "glade_options.h"
31 #include "gliv-image.h"
32 #include "gl_widget.h"
33 #include "history.h"
34 #include "windows.h"
35 #include "matrix.h"
36 #include "messages.h"
37 #include "rendering.h"
38 #include "scrollbars.h"
39 #include "next_image.h"
40 #include "rcfile.h"
41 #include "mnemonics.h"
42 #include "images_menus.h"
44 extern rt_struct *rt;
45 extern options_struct *options;
46 extern GlivImage *current_image;
47 extern GtkWidget *gl_widget;
49 /* Filled by the dialog. */
50 static options_struct *new_options;
52 static void toggle_delay(void)
54 if (options->delay == 0)
55 /* Enable. */
56 gtk_widget_add_events(gl_widget, GDK_POINTER_MOTION_MASK);
58 options->delay = new_options->delay;
59 schedule_hide_cursor();
62 static void toggle_history(void)
64 options->history_size = new_options->history_size;
65 clean_history();
68 static void apply(void)
70 gint what = 0;
71 gboolean bg_color_changed;
73 if (options->fullscreen != new_options->fullscreen)
74 toggle_fullscreen(new_options->fullscreen);
76 if ((options->maximize == FALSE && new_options->maximize) ||
77 (options->scaledown == FALSE && new_options->scaledown)) {
79 options->maximize = new_options->maximize;
80 options->scaledown = new_options->scaledown;
82 matrix_set_max_zoom(-1, -1, TRUE);
83 what |= REFRESH_IMAGE | REFRESH_STATUS | APPEND_HISTORY;
86 if (options->menu_bar != new_options->menu_bar)
87 toggle_menu_bar();
89 if (options->status_bar != new_options->status_bar)
90 toggle_status_bar();
92 if (options->scrollbars != new_options->scrollbars)
93 toggle_scrollbars();
95 if (options->dither != new_options->dither ||
96 options->mipmap != new_options->mipmap) {
98 options->dither = new_options->dither;
99 options->mipmap = new_options->mipmap;
101 reload_images();
102 what |= REFRESH_IMAGE;
105 if (options->one_image == FALSE && new_options->one_image)
106 unload_images();
108 if (options->delay != new_options->delay)
109 toggle_delay();
111 if (options->history_size != new_options->history_size)
112 toggle_history();
114 if (options->duration != new_options->duration)
115 if (slide_show_started()) {
116 options->duration = new_options->duration;
117 start_slide_show();
120 if (options->filtering != new_options->filtering)
121 what |= REFRESH_IMAGE;
123 if (options->thumbnails != new_options->thumbnails ||
124 options->thumb_width != new_options->thumb_width ||
125 options->thumb_height != new_options->thumb_height ||
126 options->mnemonics != new_options->mnemonics)
127 obsolete_menus();
129 bg_color_changed = !gdk_color_equal(&options->bg_col, &new_options->bg_col);
131 if (!gdk_color_equal(&options->alpha1, &new_options->alpha1) ||
132 !gdk_color_equal(&options->alpha2, &new_options->alpha2)) {
134 rt->alpha_checks_changed = TRUE;
136 if (current_image != NULL && current_image->has_alpha)
137 what |= REFRESH_IMAGE;
140 g_free(options);
141 options = new_options;
143 if (bg_color_changed) {
144 update_bg_color();
145 what |= REFRESH_IMAGE;
148 refresh(what);
151 /* GtkColorButton */
153 static void add_color_button(GtkWidget * color_button, GdkColor * col)
155 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_button), col);
157 g_signal_connect(color_button, "color-set",
158 G_CALLBACK(gtk_color_button_get_color), col);
161 /* GtkSpinButton */
163 static gboolean value_changed(GtkAdjustment * adj, gint * val)
165 *val = (gint) gtk_adjustment_get_value(adj);
166 return TRUE;
169 static void add_spin_button(GtkWidget * button, gint * value)
171 GtkAdjustment *adj;
173 adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(button));
174 gtk_adjustment_set_value(adj, (gdouble) * value);
176 g_signal_connect(adj, "value-changed", G_CALLBACK(value_changed), value);
179 /* GtkCheckButton */
181 static gboolean toggled_button(GtkToggleButton * button, gboolean * bool)
183 *bool = gtk_toggle_button_get_active(button);
184 return TRUE;
187 static void add_check_button(GtkWidget * button, gboolean * value)
189 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *value);
190 g_signal_connect(button, "toggled", G_CALLBACK(toggled_button), value);
193 /* GtkComboBox */
195 static void on_initial_position_changed(GtkComboBox * initial_position)
197 new_options->initial_pos = gtk_combo_box_get_active(initial_position);
200 static void on_initial_position_realize(GtkComboBox * initial_position)
202 gtk_combo_box_set_active(initial_position, options->initial_pos);
205 /* Save Options */
207 static gboolean on_save_now_clicked(void)
209 save_rc(new_options);
210 return FALSE;
213 static gboolean on_read_config_realize(GtkLabel * widget)
215 const gchar *filename = get_read_config_file();
216 gchar *text;
218 if (filename == NULL)
219 filename = _("NONE");
221 text =
222 g_strdup_printf(_("This configuration file has been read: %s"),
223 filename);
225 gtk_label_set_text(widget, text);
226 g_free(text);
228 return FALSE;
231 static gboolean on_write_config_realize(GtkLabel * widget)
233 const gchar *filename = get_write_config_file();
234 gchar *text;
236 if (filename == NULL)
237 filename = _("NONE");
239 text =
240 g_strdup_printf(_("This configuration file will be written: %s"),
241 filename);
243 gtk_label_set_text(widget, text);
244 g_free(text);
246 return FALSE;
249 /* Transitions */
251 static gboolean on_transitions_toggled(GtkWidget * transition_box,
252 GtkToggleButton * button)
254 gboolean activated = gtk_toggle_button_get_active(button);
256 gtk_widget_set_sensitive(transition_box, activated);
257 return FALSE;
260 static gboolean on_transition_box_realize(GtkWidget * transition_box)
262 gtk_widget_set_sensitive(transition_box, options->transitions);
263 return FALSE;
266 #include "glade_options.c"
268 gboolean show_options(void)
270 gint response;
271 GtkDialog *options_dialog;
273 new_options = g_memdup(options, sizeof(options_struct));
274 options_dialog = GTK_DIALOG(create_options_dialog());
276 response = run_modal_dialog(options_dialog);
277 gtk_widget_destroy(GTK_WIDGET(options_dialog));
279 if (response == GTK_RESPONSE_OK)
280 apply();
282 return FALSE;