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 */
30 #include "glade_options.h"
31 #include "gliv-image.h"
32 #include "gl_widget.h"
37 #include "rendering.h"
38 #include "scrollbars.h"
39 #include "next_image.h"
41 #include "mnemonics.h"
42 #include "images_menus.h"
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)
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
;
68 static void apply(void)
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
)
89 if (options
->status_bar
!= new_options
->status_bar
)
92 if (options
->scrollbars
!= new_options
->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
;
102 what
|= REFRESH_IMAGE
;
105 if (options
->one_image
== FALSE
&& new_options
->one_image
)
108 if (options
->delay
!= new_options
->delay
)
111 if (options
->history_size
!= new_options
->history_size
)
114 if (options
->duration
!= new_options
->duration
)
115 if (slide_show_started()) {
116 options
->duration
= new_options
->duration
;
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
)
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
;
141 options
= new_options
;
143 if (bg_color_changed
) {
145 what
|= REFRESH_IMAGE
;
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
);
163 static gboolean
value_changed(GtkAdjustment
* adj
, gint
* val
)
165 *val
= (gint
) gtk_adjustment_get_value(adj
);
169 static void add_spin_button(GtkWidget
* button
, gint
* value
)
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
);
181 static gboolean
toggled_button(GtkToggleButton
* button
, gboolean
* bool)
183 *bool = gtk_toggle_button_get_active(button
);
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
);
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
);
207 static gboolean
on_save_now_clicked(void)
209 save_rc(new_options
);
213 static gboolean
on_read_config_realize(GtkLabel
* widget
)
215 const gchar
*filename
= get_read_config_file();
218 if (filename
== NULL
)
219 filename
= _("NONE");
222 g_strdup_printf(_("This configuration file has been read: %s"),
225 gtk_label_set_text(widget
, text
);
231 static gboolean
on_write_config_realize(GtkLabel
* widget
)
233 const gchar
*filename
= get_write_config_file();
236 if (filename
== NULL
)
237 filename
= _("NONE");
240 g_strdup_printf(_("This configuration file will be written: %s"),
243 gtk_label_set_text(widget
, text
);
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
);
260 static gboolean
on_transition_box_realize(GtkWidget
* transition_box
)
262 gtk_widget_set_sensitive(transition_box
, options
->transitions
);
266 #include "glade_options.c"
268 gboolean
show_options(void)
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
)