7
* Copyright (C) 2001-2007 Jean Bréfort <jean.brefort@normalesup.org>
9
* This program is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public License as
11
* published by the Free Software Foundation; either version 2 of the
12
* License, or (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
28
#include "application.h"
30
guint PrintResolution = 300;
32
static void on_print_resolution (GtkWidget *widget, gcPrefsDlg * dialog)
34
dialog->UpdatePrinting ();
37
gcPrefsDlg::gcPrefsDlg (gcApplication *App): Dialog (App, GLADEDIR"/prefs.glade", "prefs", App)
43
PrintResMenu = (GtkComboBox *) glade_xml_get_widget (xml, "printres");
44
PrintResBtn = (GtkSpinButton *) glade_xml_get_widget (xml, "printresbtn");
47
switch (PrintResolution) {
77
gtk_spin_button_set_value (PrintResBtn, PrintResolution);
78
gtk_widget_set_sensitive (GTK_WIDGET (PrintResBtn), active);
79
gtk_combo_box_set_active (PrintResMenu, PrintIndex);
80
g_signal_connect (PrintResMenu, "changed", G_CALLBACK (on_print_resolution), this);
81
FoVBtn = GTK_SPIN_BUTTON (glade_xml_get_widget (xml, "fov"));
82
gtk_spin_button_set_value (FoVBtn, FoV);
83
PsiEnt = (GtkEntry *) glade_xml_get_widget (xml, "psi");
84
ThetaEnt = (GtkEntry *) glade_xml_get_widget (xml, "theta");
85
PhiEnt = (GtkEntry *) glade_xml_get_widget (xml, "phi");
87
snprintf (m_buf, sizeof (m_buf) - 1, "%g", Psi);
88
gtk_entry_set_text (PsiEnt, m_buf);
89
snprintf (m_buf, sizeof (m_buf) - 1, "%g", Theta);
90
gtk_entry_set_text (ThetaEnt, m_buf);
91
snprintf (m_buf, sizeof (m_buf) - 1, "%g", Phi);
92
gtk_entry_set_text (PhiEnt, m_buf);
93
BackgroundBtn = (GtkColorButton *) glade_xml_get_widget (xml, "color");
95
color.red = (guint16) (Red * 65535.);
96
color.green = (guint16) (Green * 65535.);
97
color.blue = (guint16) (Blue * 65535.);
98
gtk_color_button_set_color (BackgroundBtn, &color);
99
gtk_widget_show_all (GTK_WIDGET (dialog));
102
gcPrefsDlg::~gcPrefsDlg()
106
bool gcPrefsDlg::Apply()
109
if (!GetNumber (PsiEnt, &x0, MinEqMax, -180, 180))
111
if (!GetNumber (ThetaEnt, &x1, MinEqMaxEq, 0, 180))
113
if (!GetNumber (PhiEnt, &x2, MinEqMax, -180, 180))
115
PrintResolution = gtk_spin_button_get_value_as_int (PrintResBtn);
119
FoV = gtk_spin_button_get_value_as_int(FoVBtn);
121
gtk_color_button_get_color (BackgroundBtn, &color);
122
Red = color.red / 65535.;
123
Green = color.green / 65535.;
124
Blue = color.blue / 65535.;
125
gconf_client_set_int (conf_client, "/apps/gcrystal/printing/resolution", PrintResolution, NULL);
126
gconf_client_set_int (conf_client, "/apps/gcrystal/views/fov", FoV, NULL);
127
gconf_client_set_float (conf_client, "/apps/gcrystal/views/psi", Psi, NULL);
128
gconf_client_set_float (conf_client, "/apps/gcrystal/views/theta", Theta, NULL);
129
gconf_client_set_float (conf_client, "/apps/gcrystal/views/phi", Phi, NULL);
130
gconf_client_set_float (conf_client, "/apps/gcrystal/views/red", Red, NULL);
131
gconf_client_set_float (conf_client, "/apps/gcrystal/views/green", Green, NULL);
132
gconf_client_set_float (conf_client, "/apps/gcrystal/views/blue", Blue, NULL);
136
void gcPrefsDlg::UpdatePrinting ()
138
int PrintRes = PrintResolution ;
139
int PrintIndex = gtk_combo_box_get_active (PrintResMenu);
167
gtk_spin_button_set_value (PrintResBtn, PrintRes);
168
gtk_widget_set_sensitive (GTK_WIDGET (PrintResBtn), (PrintIndex < 8)? false : true);