00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <gtk/gtk.h>
00032 #include <gdk/gdk.h>
00033
00034
00035 #include <libergtk/ergtk.h>
00036
00037
00038 #include "i18n.h"
00039 #include "log.h"
00040 #include "settings.h"
00041 #include "settings_utils.h"
00042 #include "settings_style.h"
00043
00044 #include "advanced.h"
00045
00046
00047
00048
00049
00050
00051 typedef struct
00052 {
00053 gboolean enable_zooming;
00054 gboolean enable_scribble;
00055 gboolean enable_sd_card;
00056 gboolean index_with_thumbnails;
00057 } AdvancedSettings;
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 static AdvancedSettings g_original_settings;
00071 static AdvancedSettings g_current_settings;
00072
00073 static GtkWidget* g_advanced_settings_window = NULL;
00074 static GtkWidget* g_zooming_check = NULL;
00075 static GtkWidget* g_scribble_check = NULL;
00076 static GtkWidget* g_sd_card_check = NULL;
00077 static GtkWidget* g_thumbnail_check = NULL;
00078
00079
00080
00081
00082
00083 static GtkWidget* create_zooming_widgets (GtkBox* parent);
00084 static GtkWidget* create_scribble_widgets (GtkBox* parent);
00085 static GtkWidget* create_sd_card_widgets (GtkBox* parent);
00086 static GtkWidget* create_thumbnail_widgets (GtkBox* parent);
00087
00088 static void on_zooming_changed (GtkWidget *widget, gpointer data);
00089 static void on_scribble_changed (GtkWidget *widget, gpointer data);
00090 static void on_sd_card_changed (GtkWidget *widget, gpointer data);
00091 static void on_thumbnail_changed (GtkWidget *widget, gpointer data);
00092
00093 static void init_widgets_with_settings (void);
00094 static void on_listview_row_activated (GtkTreeView *view,
00095 GtkTreePath *path,
00096 GtkTreeViewColumn *column,
00097 gpointer user_data );
00098
00099 static void on_listview_navigate_cursor (erGtkListView *er_listview,
00100 erGtkListViewKeyPress keycode,
00101 gpointer user_data );
00102
00103 static gboolean on_focus_in(GtkWidget* widget, gpointer data );
00104 static gboolean on_focus_out(GtkWidget* widget, gpointer data );
00105
00106
00107
00108
00109
00110
00111
00112 void load_advanced_settings()
00113 {
00114 g_original_settings.enable_zooming = get_value_bool(GCONF_ENABLE_ZOOMING);
00115 g_original_settings.enable_scribble = get_value_bool(GCONF_ENABLE_SCRIBBLE);
00116 g_original_settings.enable_sd_card = get_value_bool(GCONF_ENABLE_SD_CARD);
00117 g_original_settings.index_with_thumbnails = get_value_bool(GCONF_INDEX_WITH_THUMBNAILS);
00118
00119 g_current_settings = g_original_settings;
00120
00121 LOGPRINTF("Loading advanced settings, done.");
00122 }
00123
00124
00125 void save_advanced_settings()
00126 {
00127 if (g_current_settings.enable_zooming != g_original_settings.enable_zooming)
00128 {
00129 set_value_bool(GCONF_ENABLE_ZOOMING, g_current_settings.enable_zooming);
00130 }
00131
00132 if (g_current_settings.enable_scribble != g_original_settings.enable_scribble)
00133 {
00134 set_value_bool(GCONF_ENABLE_SCRIBBLE, g_current_settings.enable_scribble);
00135 }
00136
00137 if (g_current_settings.enable_sd_card != g_original_settings.enable_sd_card)
00138 {
00139 set_value_bool(GCONF_ENABLE_SD_CARD, g_current_settings.enable_sd_card);
00140 }
00141
00142 if (g_current_settings.index_with_thumbnails != g_original_settings.index_with_thumbnails)
00143 {
00144 set_value_bool(GCONF_INDEX_WITH_THUMBNAILS, g_current_settings.index_with_thumbnails);
00145 }
00146
00147 LOGPRINTF("Saving advanced settings, done.");
00148 }
00149
00150 GtkWidget* create_advanced_window(GtkWidget* parent)
00151 {
00152
00153 GtkWidget* top_window = parent;
00154 gtk_window_maximize(GTK_WINDOW(top_window));
00155 gtk_window_set_resizable(GTK_WINDOW(top_window), FALSE);
00156 gtk_container_set_border_width(GTK_CONTAINER(top_window),WINDOW_BORDER_PADDING );
00157 gtk_window_set_modal(GTK_WINDOW(top_window), TRUE);
00158
00159
00160 GtkWidget* vboxtop = gtk_vbox_new(FALSE, 0);
00161 gtk_container_add(GTK_CONTAINER(top_window), vboxtop);
00162
00163
00164 create_title(GTK_VBOX(vboxtop), _("Settings"), _("Advanced Settings"));
00165
00166
00167 GtkWidget* view = create_settingsview();
00168 gtk_box_pack_start(GTK_BOX(vboxtop), view, FALSE, FALSE,0 );
00169 g_signal_connect(view, "row-activated", G_CALLBACK(on_listview_row_activated), NULL ) ;
00170 g_signal_connect(view, "navigate-cursor", G_CALLBACK(on_listview_navigate_cursor), NULL ) ;
00171 g_signal_connect(view, "focus-in-event", G_CALLBACK(on_focus_in), NULL );
00172 g_signal_connect(view, "focus-out-event", G_CALLBACK(on_focus_out), NULL );
00173
00174
00175 GtkWidget* vbox1 = GTK_WIDGET( create_frame(GTK_VBOX(vboxtop)) );
00176 create_zooming_widgets(GTK_BOX(vbox1));
00177
00178 GtkWidget* vbox2 = GTK_WIDGET( create_frame(GTK_VBOX(vboxtop)) );
00179 create_scribble_widgets(GTK_BOX(vbox2));
00180
00181 GtkWidget* vbox3 = GTK_WIDGET( create_frame(GTK_VBOX(vboxtop)) );
00182 create_sd_card_widgets(GTK_BOX(vbox3));
00183
00184 GtkWidget* vbox4 = GTK_WIDGET( create_frame(GTK_VBOX(vboxtop)) );
00185 create_thumbnail_widgets(GTK_BOX(vbox4));
00186
00187
00188 init_widgets_with_settings();
00189
00190 g_advanced_settings_window = top_window;
00191
00192 gtk_widget_grab_focus(view);
00193
00194 gtk_widget_show_all(top_window);
00195 return top_window;
00196 }
00197
00198
00199
00200
00201
00202
00203 static gboolean on_focus_in(GtkWidget* widget, gpointer data )
00204 {
00205 g_assert(widget != NULL ) ;
00206 ergtk_list_view_set_cursor( ERGTK_LIST_VIEW(widget), 0);
00207 return FALSE;
00208 }
00209
00210 static gboolean on_focus_out(GtkWidget* widget, gpointer data )
00211 {
00212 g_assert(widget != NULL ) ;
00213 GtkTreeSelection* my_selection = gtk_tree_view_get_selection((GtkTreeView*) widget);
00214 g_assert( my_selection != NULL ) ;
00215 gtk_tree_selection_unselect_all(my_selection);
00216 return FALSE;
00217 }
00218
00219 static void on_listview_row_activated ( GtkTreeView *view,
00220 GtkTreePath *path,
00221 GtkTreeViewColumn *column,
00222 gpointer user_data )
00223 {
00224 save_advanced_settings();
00225 main_quit();
00226 return;
00227 }
00228
00229 static void on_listview_navigate_cursor ( erGtkListView *er_listview,
00230 erGtkListViewKeyPress keycode,
00231 gpointer user_data )
00232 {
00233 GtkTreeSelection* my_selection = gtk_tree_view_get_selection((GtkTreeView*) er_listview);
00234 g_assert( my_selection != NULL ) ;
00235
00236
00237 switch (keycode)
00238 {
00239 case ERGTK_LIST_VIEW_PRESS_SHORT_DOWN:
00240 case ERGTK_LIST_VIEW_PRESS_LONG_DOWN:
00241 gtk_widget_grab_focus(GTK_WIDGET(g_zooming_check));
00242 gtk_tree_selection_unselect_all(my_selection);
00243 break;
00244 default:
00245 LOGPRINTF("illegal erGtkListViewKeyPress [%d]", keycode);
00246 ;
00247 break;
00248 }
00249 }
00250
00251
00252
00253
00254
00255
00256 static GtkWidget* create_zooming_widgets(GtkBox* parent)
00257 {
00258
00259 GtkWidget* top_level_vbox = gtk_vbox_new(FALSE, ITEM_SPACING);
00260 gtk_box_pack_start(parent, top_level_vbox, FALSE, FALSE, 0);
00261
00262
00263 GtkWidget* subject = subject_create();
00264 gtk_label_set_label(GTK_LABEL(subject),
00265 _("PDF Document Zoom"));
00266 gtk_box_pack_start(GTK_BOX(top_level_vbox), subject, FALSE, FALSE, 0);
00267
00268
00269 GtkWidget* desc = description_create();
00270 gtk_label_set_label(GTK_LABEL(desc),
00271 _("Enable custom zoom for PDF documents as well as the ability to pan the viewport of a zoomed-in page. "
00272 "Zooming is not available in reflowable document formats such as EPUB, TXT, and PDB."));
00273 gtk_box_pack_start(GTK_BOX(top_level_vbox), desc, FALSE, FALSE, 0);
00274
00275
00276 g_zooming_check = gtk_check_button_new_with_label(_("Enable zoom"));
00277 g_signal_connect(G_OBJECT(g_zooming_check),
00278 "toggled",
00279 G_CALLBACK(on_zooming_changed),
00280 NULL);
00281 gtk_box_pack_start(GTK_BOX(top_level_vbox), g_zooming_check, FALSE, FALSE, 0);
00282
00283 return top_level_vbox;
00284 }
00285
00286
00287
00288
00289
00290
00291 static GtkWidget* create_scribble_widgets(GtkBox* parent)
00292 {
00293
00294 GtkWidget* top_level_vbox = gtk_vbox_new(FALSE, ITEM_SPACING);
00295 gtk_box_pack_start(parent, top_level_vbox, FALSE, FALSE, 0);
00296
00297
00298 GtkWidget* subject = subject_create();
00299 gtk_label_set_label(GTK_LABEL(subject),
00300 _("PDF Annotation"));
00301 gtk_box_pack_start(GTK_BOX(top_level_vbox), subject, FALSE, FALSE, 0);
00302
00303
00304 GtkWidget* desc = description_create();
00305 gtk_label_set_label(GTK_LABEL(desc),
00306 _("Enable the ability to write on the Original Layout of a PDF document. "
00307 "Changing the font size of the document disables the writing features. "
00308 "Currently, annotations cannot be exported or merged."));
00309 gtk_box_pack_start(GTK_BOX(top_level_vbox), desc, FALSE, FALSE, 0);
00310
00311
00312 g_scribble_check = gtk_check_button_new_with_label(_("Enable writing"));
00313 g_signal_connect(G_OBJECT(g_scribble_check),
00314 "toggled",
00315 G_CALLBACK(on_scribble_changed),
00316 NULL);
00317 gtk_box_pack_start(GTK_BOX(top_level_vbox), g_scribble_check, FALSE, FALSE, 0);
00318
00319 return top_level_vbox;
00320 }
00321
00322
00323
00324
00325
00326
00327 static GtkWidget* create_sd_card_widgets(GtkBox* parent)
00328 {
00329
00330 GtkWidget* top_level_vbox = gtk_vbox_new(FALSE, ITEM_SPACING);
00331 gtk_box_pack_start(parent, top_level_vbox, FALSE, FALSE, 0);
00332
00333
00334 GtkWidget* subject = subject_create();
00335 gtk_label_set_label(GTK_LABEL(subject),
00336 _("Folder Based Navigation"));
00337 gtk_box_pack_start(GTK_BOX(top_level_vbox), subject, FALSE, FALSE, 0);
00338
00339
00340 GtkWidget* desc = description_create();
00341 gtk_label_set_label(GTK_LABEL(desc),
00342 _("Access the folder structure of the memory card by adding an SD Card icon on the Home screen."));
00343 gtk_box_pack_start(GTK_BOX(top_level_vbox), desc, FALSE, FALSE, 0);
00344
00345
00346 g_sd_card_check = gtk_check_button_new_with_label(_("Enable folder navigation"));
00347 g_signal_connect(G_OBJECT(g_sd_card_check),
00348 "toggled",
00349 G_CALLBACK(on_sd_card_changed),
00350 NULL);
00351 gtk_box_pack_start(GTK_BOX(top_level_vbox), g_sd_card_check, FALSE, FALSE, 0);
00352
00353 return top_level_vbox;
00354 }
00355
00356
00357
00358
00359
00360
00361 static GtkWidget* create_thumbnail_widgets(GtkBox* parent)
00362 {
00363
00364 GtkWidget* top_level_vbox = gtk_vbox_new(FALSE, ITEM_SPACING);
00365 gtk_box_pack_start(parent, top_level_vbox, FALSE, FALSE, 0);
00366
00367
00368 GtkWidget* subject = subject_create();
00369 gtk_label_set_label(GTK_LABEL(subject),
00370 _("Automatic Thumbnail Generation"));
00371 gtk_box_pack_start(GTK_BOX(top_level_vbox), subject, FALSE, FALSE, 0);
00372
00373
00374 GtkWidget* desc = description_create();
00375 gtk_label_set_label(GTK_LABEL(desc),
00376 _("Allow automatic thumbnail generation to occur while indexing content. "
00377 "Indexing will become slower when this option is enabled."));
00378 gtk_box_pack_start(GTK_BOX(top_level_vbox), desc, FALSE, FALSE, 0);
00379
00380
00381 g_thumbnail_check = gtk_check_button_new_with_label(_("Enable thumbnail generation"));
00382 g_signal_connect(G_OBJECT(g_thumbnail_check),
00383 "toggled",
00384 G_CALLBACK(on_thumbnail_changed),
00385 NULL);
00386 gtk_box_pack_start(GTK_BOX(top_level_vbox), g_thumbnail_check, FALSE, FALSE, 0);
00387
00388 return top_level_vbox;
00389 }
00390
00391
00392
00393 static void on_zooming_changed(GtkWidget *widget, gpointer data)
00394 {
00395 g_current_settings.enable_zooming = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
00396 }
00397
00398 static void on_scribble_changed(GtkWidget *widget, gpointer data)
00399 {
00400 g_current_settings.enable_scribble = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
00401 }
00402
00403 static void on_sd_card_changed(GtkWidget *widget, gpointer data)
00404 {
00405 g_current_settings.enable_sd_card = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
00406 }
00407
00408 static void on_thumbnail_changed(GtkWidget *widget, gpointer data)
00409 {
00410 g_current_settings.index_with_thumbnails = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
00411 }
00412
00413
00414 static void init_widgets_with_settings()
00415 {
00416 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(g_zooming_check),
00417 g_current_settings.enable_zooming );
00418
00419 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(g_scribble_check),
00420 g_current_settings.enable_scribble );
00421
00422 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(g_sd_card_check),
00423 g_current_settings.enable_sd_card );
00424
00425 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(g_thumbnail_check),
00426 g_current_settings.index_with_thumbnails );
00427 }
00428
00429
00430