void gth_datetime_from_timeval (GthDateTime *dt, GTimeVal *tv) { char *exif_date; exif_date = _g_time_val_to_exif_date (tv); gth_datetime_from_exif_date (dt, exif_date); g_free (exif_date); }
void dlg_change_date (GthBrowser *browser, GList *file_list) { DialogData *data; GTimeVal timeval; GthDateTime *datetime; data = g_new0 (DialogData, 1); data->browser = browser; data->file_list = _g_object_list_ref (file_list); data->builder = _gtk_builder_new_from_file ("change-date.ui", "change_date"); data->settings = g_settings_new (GTHUMB_CHANGE_DATE_SCHEMA); /* Get the widgets. */ data->dialog = GET_WIDGET ("change_date_dialog"); data->date_selector = gth_time_selector_new (); gth_time_selector_show_time (GTH_TIME_SELECTOR (data->date_selector), TRUE, TRUE); gtk_widget_show (data->date_selector); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_selector_box")), data->date_selector, TRUE, TRUE, 0); /* Set widgets data. */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("change_last_modified_checkbutton")), g_settings_get_boolean (data->settings, PREF_CHANGE_DATE_SET_LAST_MODIFIED_DATE)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("change_comment_checkbutton")), g_settings_get_boolean (data->settings, PREF_CHANGE_DATE_SET_COMMENT_DATE)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_following_date_radiobutton")), g_settings_get_boolean (data->settings, PREF_CHANGE_DATE_TO_FOLLOWING_DATE)); datetime = gth_datetime_new (); g_get_current_time (&timeval); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_following_date_radiobutton")))) { char *s; s = g_settings_get_string (data->settings, PREF_CHANGE_DATE_DATE); if (strcmp (s, "") != 0) gth_datetime_from_exif_date (datetime, s); else gth_datetime_from_timeval (datetime, &timeval); g_free (s); } else gth_datetime_from_timeval (datetime, &timeval); gth_time_selector_set_value (GTH_TIME_SELECTOR (data->date_selector), datetime); gth_datetime_free (datetime); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_last_modified_date_radiobutton")), g_settings_get_boolean (data->settings, PREF_CHANGE_DATE_TO_FILE_MODIFIED_DATE)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_creation_date_radiobutton")), g_settings_get_boolean (data->settings, PREF_CHANGE_DATE_TO_FILE_CREATION_DATE)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_photo_original_date_radiobutton")), g_settings_get_boolean (data->settings, PREF_CHANGE_DATE_TO_PHOTO_ORIGINAL_DATE)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_time_radiobutton")), g_settings_get_boolean (data->settings, PREF_CHANGE_DATE_ADJUST_TIME)); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_time_radiobutton")))) { int adjustement; int sign; int hours; int minutes; int seconds; adjustement = g_settings_get_int (data->settings, PREF_CHANGE_DATE_TIME_ADJUSTMENT); if (adjustement < 0) { sign = -1; adjustement = - adjustement; } else sign = 1; hours = adjustement / 3600; adjustement = adjustement % 3600; minutes = adjustement / 60; adjustement = adjustement % 60; seconds = adjustement; gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("adjust_time_h_spinbutton")), hours); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("adjust_time_m_spinbutton")), minutes); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("adjust_time_s_spinbutton")), seconds); gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("adjust_sign_combobox")), (sign >= 0) ? 0 : 1); } update_sensitivity (data); /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (dialog_destroy_cb), data); g_signal_connect_swapped (GET_WIDGET ("close_button"), "clicked", G_CALLBACK (gtk_widget_destroy), G_OBJECT (data->dialog)); g_signal_connect (GET_WIDGET ("ok_button"), "clicked", G_CALLBACK (ok_button_clicked), data); g_signal_connect (GET_WIDGET ("change_last_modified_checkbutton"), "clicked", G_CALLBACK (radio_button_clicked), data); g_signal_connect (GET_WIDGET ("change_comment_checkbutton"), "clicked", G_CALLBACK (radio_button_clicked), data); g_signal_connect (GET_WIDGET ("to_following_date_radiobutton"), "clicked", G_CALLBACK (radio_button_clicked), data); g_signal_connect (GET_WIDGET ("to_last_modified_date_radiobutton"), "clicked", G_CALLBACK (radio_button_clicked), data); g_signal_connect (GET_WIDGET ("to_creation_date_radiobutton"), "clicked", G_CALLBACK (radio_button_clicked), data); g_signal_connect (GET_WIDGET ("to_photo_original_date_radiobutton"), "clicked", G_CALLBACK (radio_button_clicked), data); g_signal_connect (GET_WIDGET ("adjust_time_radiobutton"), "clicked", G_CALLBACK (radio_button_clicked), data); /* run dialog. */ gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (browser)); gtk_window_set_modal (GTK_WINDOW (data->dialog), FALSE); gtk_widget_show (data->dialog); }