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 "str_utils.h"
45 extern options_struct
*options
;
46 extern gliv_image
*current_image
;
47 extern GtkWidget
*gl_widget
;
49 /* Filled by the dialog. */
50 static options_struct
*new_options
;
51 static GtkWidget
*options_dialog
= NULL
;
53 static gboolean save_options
= FALSE
;
55 static void toggle_delay(void)
57 if (options
->delay
== 0)
59 gtk_widget_add_events(gl_widget
, GDK_POINTER_MOTION_MASK
);
61 options
->delay
= new_options
->delay
;
62 schedule_hide_cursor();
65 static void toggle_history(void)
67 options
->history_size
= new_options
->history_size
;
71 static void finish(gboolean apply
)
74 gboolean bg_color_changed
;
76 gtk_widget_hide(options_dialog
);
80 if (options
->fullscreen
!= new_options
->fullscreen
)
81 toggle_fullscreen(new_options
->fullscreen
);
83 if ((options
->maximize
== FALSE
&& new_options
->maximize
) ||
84 (options
->scaledown
== FALSE
&& new_options
->scaledown
)) {
86 options
->maximize
= new_options
->maximize
;
87 options
->scaledown
= new_options
->scaledown
;
89 matrix_set_max_zoom(-1, -1, TRUE
);
90 what
|= REFRESH_IMAGE
| REFRESH_STATUS
| APPEND_HISTORY
;
93 if (options
->menu_bar
!= new_options
->menu_bar
)
96 if (options
->status_bar
!= new_options
->status_bar
)
99 if (options
->scrollbars
!= new_options
->scrollbars
)
102 if (options
->dither
!= new_options
->dither
||
103 options
->mipmap
!= new_options
->mipmap
) {
105 options
->dither
= new_options
->dither
;
106 options
->mipmap
= new_options
->mipmap
;
109 what
|= REFRESH_IMAGE
;
112 if (options
->one_image
== FALSE
&& new_options
->one_image
)
115 if (options
->delay
!= new_options
->delay
)
118 if (options
->history_size
!= new_options
->history_size
)
121 if (options
->duration
!= new_options
->duration
)
122 if (slide_show_started()) {
123 options
->duration
= new_options
->duration
;
127 if (options
->thumbnails
!= new_options
->thumbnails
||
128 options
->thumb_width
!= new_options
->thumb_width
||
129 options
->thumb_height
!= new_options
->thumb_height
)
130 invalidate_last_tree();
132 bg_color_changed
= !gdk_color_equal(&options
->bg_col
,
133 &new_options
->bg_col
);
135 if (!gdk_color_equal(&options
->alpha1
, &new_options
->alpha1
) ||
136 !gdk_color_equal(&options
->alpha2
, &new_options
->alpha2
)) {
138 rt
->alpha_checks_changed
= TRUE
;
140 if (current_image
!= NULL
&& current_image
->has_alpha
)
141 what
|= REFRESH_IMAGE
;
145 options
= new_options
;
150 if (bg_color_changed
) {
152 what
|= REFRESH_IMAGE
;
157 gtk_widget_destroy(options_dialog
);
158 options_dialog
= NULL
;
163 static gboolean
key_press_event(GtkWidget
* unused
, GdkEventKey
* event
)
165 if (event
->keyval
== GDK_Escape
) {
173 /* Cancel and OK buttons */
175 static void add_cancel_button(GtkWidget
* button
)
177 g_signal_connect_swapped(button
, "clicked",
178 G_CALLBACK(finish
), GINT_TO_POINTER(FALSE
));
181 static void add_ok_button(GtkWidget
* button
)
183 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(button
), GTK_CAN_DEFAULT
);
184 g_signal_connect_swapped(button
, "clicked",
185 G_CALLBACK(finish
), GINT_TO_POINTER(TRUE
));
187 g_signal_connect(button
, "realize",
188 G_CALLBACK(gtk_widget_grab_default
), NULL
);
191 /* GtkColorSelection */
193 static void add_color_selection(GtkWidget
* color_sel
, GdkColor
* col
)
195 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(color_sel
), col
);
197 g_signal_connect(color_sel
, "color-changed",
198 G_CALLBACK(gtk_color_selection_get_current_color
), col
);
203 static gboolean
value_changed(GtkAdjustment
* adj
, gint
* val
)
205 *val
= (gint
) gtk_adjustment_get_value(adj
);
209 static void add_spin_button(GtkWidget
* button
, gint
* value
)
213 adj
= gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(button
));
214 gtk_adjustment_set_value(adj
, (gdouble
) * value
);
216 g_signal_connect(adj
, "value-changed", G_CALLBACK(value_changed
), value
);
221 static gboolean
toggled_button(GtkToggleButton
* button
, gboolean
* bool)
223 *bool = gtk_toggle_button_get_active(button
);
227 static void add_check_button(GtkWidget
* button
, gboolean
* value
)
229 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button
), *value
);
230 g_signal_connect(button
, "toggled", G_CALLBACK(toggled_button
), value
);
233 #include "glade_options.c"
235 void show_options(void)
237 if (options_dialog
!= NULL
)
240 new_options
= g_memdup(options
, sizeof(options_struct
));
241 options_dialog
= create_options_dialog();
243 g_signal_connect_swapped(options_dialog
, "delete-event",
244 G_CALLBACK(finish
), GINT_TO_POINTER(FALSE
));
246 g_signal_connect(options_dialog
, "key-press-event",
247 G_CALLBACK(key_press_event
), NULL
);
249 show_dialog(GTK_WIDGET(options_dialog
), _("Options"));