00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00031 #include <string.h>
00032 #include <gtk/gtk.h>
00033
00034 #include <liberdm/display.h>
00035 #include <libergtk/ergtk.h>
00036
00037 #include "setupLog.h"
00038 #include "displayStatus.h"
00039 #include "gtkInfoItem.h"
00040 #include "gtkSettingItem.h"
00041 #include "iLiadArcLocData.h"
00042 #include "iLiadArcLocScreen.h"
00043 #include "settings.h"
00044 #include "languages.h"
00045
00046
00047 static GtkWidget* g_archive_settingitem = NULL;
00048 static GtkWidget* g_export_settingitem = NULL;
00049 static gtkArcLoc_t g_archive_locs[arcTypeUndefined] = {
00050 { arcNews },
00051 { arcBooks },
00052 { arcDocs },
00053 { arcNotes },
00054 };
00055 static gtkArcLoc_t g_export_loc;
00056 static GtkWidget* g_info_item = NULL;
00057
00058
00059 static GtkWidget *gtk_archive_location_new(gtkArcLoc_t *arcLoc);
00060 static GtkWidget *iLiad_archive_location_create_buttons(gtkArcLoc_t *arcLoc);
00061 static void on_selection_update(erGtkSelectionGroup * selection, gpointer button, gpointer data);
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 GtkWidget *iLiad_archive_location_create(void)
00075 {
00076 int i;
00077 GtkWidget *item;
00078 GtkWidget *top_vbox;
00079 GtkWidget *vbox;
00080 GtkWidget *widget;
00081
00082 ST_LOGPRINTF("entry");
00083
00084
00085 top_vbox = gtk_vbox_new(FALSE, ARC_LOC_SCR_SPACING_V);
00086
00087
00088 item = gtk_settingitem_new("");
00089 gtk_widget_set_size_request(item, -1, -1);
00090 gtk_box_pack_start(GTK_BOX(top_vbox), item, FALSE, FALSE, 0);
00091 g_archive_settingitem = item;
00092
00093
00094 vbox = gtk_vbox_new(FALSE, SETTINGITEM_ITEM_SPACING);
00095 gtk_settingitem_add_details(GTK_SETTINGITEM(item), vbox);
00096
00097
00098 for (i = 0 ; i < sizeof(g_archive_locs) / sizeof(g_archive_locs[0]) ; i++)
00099 {
00100 widget = gtk_archive_location_new(&g_archive_locs[i]);
00101 gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);
00102 }
00103
00104
00105 item = gtk_settingitem_new("");
00106 gtk_widget_set_size_request(item, -1, -1);
00107 gtk_box_pack_start(GTK_BOX(top_vbox), item, FALSE, FALSE, 0);
00108 g_export_settingitem = item;
00109
00110 widget = gtk_archive_location_new(&g_export_loc);
00111 gtk_settingitem_add_details(GTK_SETTINGITEM(item), widget);
00112 gtk_widget_show_all(widget);
00113
00114
00115 widget = gtk_infoitem_new(FALSE);
00116 gtk_box_pack_start(GTK_BOX(top_vbox), widget, FALSE, FALSE, 0);
00117 g_info_item = widget;
00118
00119
00120 gtk_widget_show_all(vbox);
00121 gtk_widget_show(g_archive_settingitem);
00122 gtk_widget_show(g_export_settingitem);
00123 gtk_widget_show(top_vbox);
00124 return top_vbox;
00125 }
00126
00127 static GtkWidget *gtk_archive_location_new(gtkArcLoc_t *arcLoc)
00128 {
00129 GtkWidget *background;
00130 GtkWidget *alignment;
00131 GtkWidget *vbox;
00132 GtkWidget *title;
00133 GtkWidget *subTitle;
00134 GtkWidget *widget;
00135
00136 ST_LOGPRINTF("entry");
00137 g_return_val_if_fail(arcLoc, NULL);
00138
00139
00140
00141
00142
00143 background = gtk_event_box_new();
00144 gtk_widget_set_name(background, "archive_location_background");
00145 gtk_widget_set_size_request(background, ARC_LOC_ITEM_BK_W, ARC_LOC_ITEM_BK_H);
00146
00147
00148
00149
00150 alignment = gtk_alignment_new(0, 0, 0, 0);
00151 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
00152 ARC_LOC_SCR_ITEM_PADDING_T, ARC_LOC_SCR_ITEM_PADDING_B,
00153 ARC_LOC_SCR_ITEM_PADDING_L, ARC_LOC_SCR_ITEM_PADDING_R);
00154 gtk_container_add(GTK_CONTAINER(background), alignment);
00155
00156 vbox = gtk_vbox_new(FALSE, ARC_LOC_SCR_SPACING_V);
00157 gtk_container_add(GTK_CONTAINER(alignment), vbox);
00158
00159
00160 title = gtk_label_new("");
00161 gtk_box_pack_start(GTK_BOX(vbox), title, FALSE, FALSE, 0);
00162 gtk_widget_set_name(title, "archive_location_title");
00163 gtk_widget_set_size_request(title, ARC_LOC_ITEM_LABEL_W, (-1));
00164 gtk_label_set_single_line_mode(GTK_LABEL(title), FALSE);
00165 gtk_label_set_line_wrap(GTK_LABEL(title), FALSE);
00166 gtk_label_set_justify(GTK_LABEL(title), GTK_JUSTIFY_LEFT);
00167 gtk_misc_set_alignment(GTK_MISC(title), 0.0, 0.0);
00168 arcLoc->title = title;
00169
00170
00171 subTitle = gtk_label_new("");
00172 gtk_box_pack_start(GTK_BOX(vbox), subTitle, FALSE, FALSE, 0);
00173 gtk_widget_set_name(subTitle, "archive_location_info_text");
00174 gtk_widget_set_size_request(subTitle, ARC_LOC_ITEM_LABEL_W, (-1));
00175 gtk_label_set_single_line_mode(GTK_LABEL(subTitle), FALSE);
00176 gtk_label_set_line_wrap(GTK_LABEL(subTitle), TRUE);
00177 gtk_label_set_justify(GTK_LABEL(subTitle), GTK_JUSTIFY_LEFT);
00178 gtk_misc_set_alignment(GTK_MISC(subTitle), 0.0, 0.0);
00179 arcLoc->subTitle = subTitle;
00180
00181
00182 widget = iLiad_archive_location_create_buttons(arcLoc);
00183 gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);
00184
00185
00186 return background;
00187 }
00188
00189 static GtkWidget *iLiad_archive_location_create_buttons(gtkArcLoc_t *arcLoc)
00190 {
00191 int i;
00192 GtkWidget *hbox;
00193 GtkWidget *button;
00194 GtkWidget *selection;
00195 GtkToggleButton *button_tbl[ARC_LOC_BTN_NUM + 1];
00196
00197 ST_LOGPRINTF("entry");
00198
00199
00200
00201
00202
00203
00204 hbox = gtk_hbox_new(FALSE, ARC_LOC_BTN_SPACING_H);
00205 for (i = 0; i < ARC_LOC_BTN_NUM; i++)
00206 {
00207 button = ergtk_toggle_button_new_with_label("");
00208 button_tbl[i] = GTK_TOGGLE_BUTTON(button);
00209 gtk_widget_set_size_request(GTK_WIDGET(button), ARC_LOC_BTN_W, ARC_LOC_BTN_H);
00210 gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), FALSE, FALSE, 0);
00211
00212 arcLoc->buttons[i] = GTK_WIDGET(button);
00213 }
00214 button_tbl[i] = NULL;
00215
00216
00217 selection = ergtk_selection_group_new(button_tbl);
00218 gtk_widget_set_name(selection, "archive_location_background");
00219 ergtk_selection_group_set_details(ERGTK_SELECTION_GROUP(selection), 1, 1);
00220 g_signal_connect(G_OBJECT(selection), "selection-update", G_CALLBACK(on_selection_update), arcLoc);
00221 arcLoc->selection = selection;
00222
00223 return hbox;
00224 }
00225
00226 void iLiad_archive_location_set_text(void)
00227 {
00228 int i;
00229 gtkArcLoc_t *arcLoc;
00230 GtkWidget **button_tbl;
00231
00232 ST_LOGPRINTF("entry");
00233
00234 if (g_archive_settingitem)
00235 {
00236 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_archive_settingitem), _("Archive locations"));
00237
00238 arcLoc = &g_archive_locs[arcNews];
00239 gtk_label_set_text(GTK_LABEL(arcLoc->title), _("Newspapers"));
00240 gtk_label_set_text(GTK_LABEL(arcLoc->subTitle), _("Select a memory type for the 'NEWS' button."));
00241
00242 arcLoc = &g_archive_locs[arcBooks];
00243 gtk_label_set_text(GTK_LABEL(arcLoc->title), _("Books"));
00244 gtk_label_set_text(GTK_LABEL(arcLoc->subTitle), _("Select a memory type for the 'BOOKS' button."));
00245
00246 arcLoc = &g_archive_locs[arcDocs];
00247 gtk_label_set_text(GTK_LABEL(arcLoc->title), _("Documents"));
00248 gtk_label_set_text(GTK_LABEL(arcLoc->subTitle), _("Select a memory type for the 'DOCS' button."));
00249
00250 arcLoc = &g_archive_locs[arcNotes];
00251 gtk_label_set_text(GTK_LABEL(arcLoc->title), _("Notes"));
00252 gtk_label_set_text(GTK_LABEL(arcLoc->subTitle), _("Select a memory type for the 'NOTES' button."));
00253
00254
00255 for (i = 0 ; i < sizeof(g_archive_locs) / sizeof(g_archive_locs[0]) ; i++)
00256 {
00257 button_tbl = g_archive_locs[i].buttons;
00258 gtk_button_set_label(GTK_BUTTON(button_tbl[arcLocMain]), _("Internal memory"));
00259 gtk_button_set_label(GTK_BUTTON(button_tbl[arcLocCard]), _("MMC card" ));
00260 gtk_button_set_label(GTK_BUTTON(button_tbl[arcLocUSB ]), _("USB stick" ));
00261 gtk_button_set_label(GTK_BUTTON(button_tbl[arcLocCF ]), _("CF card" ));
00262 }
00263 }
00264
00265 if (g_export_settingitem)
00266 {
00267 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_export_settingitem), _("USB Connection"));
00268
00269
00270 arcLoc = &g_export_loc;
00271 gtk_label_set_text(GTK_LABEL(arcLoc->title), _("Export via USB"));
00272 gtk_label_set_text(GTK_LABEL(arcLoc->subTitle), _("Select a memory type to be exported to the PC via the USB cable."));
00273
00274 button_tbl = g_export_loc.buttons;
00275 gtk_button_set_label(GTK_BUTTON(button_tbl[arcLocMain]), _("Internal memory"));
00276 gtk_button_set_label(GTK_BUTTON(button_tbl[arcLocCard]), _("MMC card" ));
00277 gtk_button_set_label(GTK_BUTTON(button_tbl[arcLocUSB ]), _("USB stick" ));
00278 gtk_button_set_label(GTK_BUTTON(button_tbl[arcLocCF ]), _("CF card" ));
00279 }
00280
00281 if (g_info_item)
00282 {
00283
00284 gtk_infoitem_set_text( GTK_INFOITEM(g_info_item),
00285 _("\nWhen you select a memory type for an archive key, "
00286 "the iLiad will use this as storage for newly downloaded items from iDS.") );
00287 }
00288 }
00289
00290 void iLiad_archive_location_display_data(void)
00291 {
00292 int i;
00293 arcType_e type;
00294 arcLocType_e location;
00295 GtkWidget *button;
00296
00297 ST_LOGPRINTF("entry");
00298
00299 for (i = 0 ; i < sizeof(g_archive_locs) / sizeof(g_archive_locs[0]) ; i++)
00300 {
00301 type = g_archive_locs[i].arcType;
00302 location = iLiad_archive_location_data_get(type);
00303
00304 button = g_archive_locs[i].buttons[location];
00305 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
00306 }
00307
00308 location = iLiad_export_location_data_get();
00309 button = g_export_loc.buttons[location];
00310 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
00311 }
00312
00313
00314 static void on_selection_update(erGtkSelectionGroup * selection, gpointer button, gpointer data)
00315 {
00316 const gtkArcLoc_t *arcLoc = (gtkArcLoc_t*)data;
00317
00318 int button_id = 0;
00319 arcLocType_e location;
00320
00321
00322 ST_LOGPRINTF("entry");
00323 g_return_if_fail(data != NULL);
00324
00325 ergtk_selection_group_get_selected_buttons(ERGTK_SELECTION_GROUP(arcLoc->selection), &button_id, 1);
00326 if (button_id >= 0 && button_id < arcLocUndefined)
00327 {
00328 location = button_id;
00329 }
00330 else
00331 {
00332 location = arcLocMain;
00333 }
00334
00335 if (arcLoc == &g_export_loc)
00336 {
00337 iLiad_export_location_data_set(location);
00338 }
00339 else
00340 {
00341 iLiad_archive_location_data_set(arcLoc->arcType, location);
00342 }
00343 }