Constants editing done.

This commit is contained in:
gyboth 2009-03-11 20:54:15 +00:00
parent 1692d228c4
commit 285530ce8f
4 changed files with 146 additions and 7 deletions

View File

@ -624,7 +624,7 @@
<child>
<widget class="GtkButton" id="button_edit_constants">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Edit the constants used in the game (this won't change the file, however)</property>
<property name="tooltip" translatable="yes">Edit the constants used in the game</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
@ -3683,7 +3683,7 @@
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="default_width">650</property>
<property name="default_height">700</property>
<property name="default_height">600</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
@ -3938,6 +3938,86 @@
</packing>
</child>
<child>
<widget class="GtkButton" id="button_constants_save">
<property name="tooltip" translatable="yes">Save changes to the constants file. DON'T DO THIS UNLESS YOU REALLY KNOW WHAT YOU ARE DOING.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_constants_save_clicked" last_modification_time="Wed, 11 Mar 2009 20:40:57 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox22">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image6">
<property name="visible">True</property>
<property name="stock">gtk-save</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label56">
<property name="visible">True</property>
<property name="label" translatable="yes">Save to file</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_constants_reload">
<property name="visible">True</property>
@ -4021,7 +4101,7 @@
<child>
<widget class="GtkButton" id="button_constants_close">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Close window. Changes will be saved for the current session. To make permanent changes, edit constants files directly.</property>
<property name="tooltip" translatable="yes">Close window. Changes will only be saved for the current session, unless you also save to file.</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>

View File

@ -241,3 +241,24 @@ on_button_constants_close_clicked (GtkButton *button,
window_destroy(&window.constants);
}
void
on_button_constants_save_clicked (GtkButton *button,
gpointer user_data)
{
gchar buf[SMALL];
if(gtk_notebook_get_current_page(
GTK_NOTEBOOK(lookup_widget(GTK_WIDGET(button), "notebook_constants"))) == 3)
{
sprintf(buf, "%s%s%s", file_get_first_support_dir(),
G_DIR_SEPARATOR_S, opt_str("string_opt_appearance_file"));
file_save_opt_file(buf, &constants_app);
}
else
{
sprintf(buf, "%s%s%s", file_get_first_support_dir(),
G_DIR_SEPARATOR_S, opt_str("string_opt_constants_file"));
file_save_opt_file(buf, &constants);
}
}

View File

@ -85,5 +85,9 @@ on_button_constants_reload_clicked (GtkButton *button,
void
on_button_constants_close_clicked (GtkButton *button,
gpointer user_data);
#endif
void
on_button_constants_save_clicked (GtkButton *button,
gpointer user_data);
#endif

View File

@ -413,7 +413,7 @@ create_window_options (void)
button_edit_constants = gtk_button_new ();
gtk_widget_show (button_edit_constants);
gtk_box_pack_start (GTK_BOX (hbox8), button_edit_constants, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, button_edit_constants, _("Edit the constants used in the game (this won't change the file, however)"), NULL);
gtk_tooltips_set_tip (tooltips, button_edit_constants, _("Edit the constants used in the game"), NULL);
alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment3);
@ -1466,6 +1466,11 @@ create_window_constants (void)
GtkWidget *treeview_constants_app;
GtkWidget *label53;
GtkWidget *hseparator9;
GtkWidget *button_constants_save;
GtkWidget *alignment6;
GtkWidget *hbox22;
GtkWidget *image6;
GtkWidget *label56;
GtkWidget *button_constants_reload;
GtkWidget *alignment4;
GtkWidget *hbox20;
@ -1487,7 +1492,7 @@ create_window_constants (void)
gtk_container_set_border_width (GTK_CONTAINER (window_constants), 5);
gtk_window_set_title (GTK_WINDOW (window_constants), _("window1"));
gtk_window_set_position (GTK_WINDOW (window_constants), GTK_WIN_POS_CENTER);
gtk_window_set_default_size (GTK_WINDOW (window_constants), 650, 700);
gtk_window_set_default_size (GTK_WINDOW (window_constants), 650, 600);
vbox12 = gtk_vbox_new (FALSE, 5);
gtk_widget_show (vbox12);
@ -1558,6 +1563,27 @@ create_window_constants (void)
gtk_box_pack_start (GTK_BOX (vbox12), hseparator9, FALSE, TRUE, 0);
gtk_widget_set_size_request (hseparator9, -1, 10);
button_constants_save = gtk_button_new ();
gtk_widget_show (button_constants_save);
gtk_box_pack_start (GTK_BOX (vbox12), button_constants_save, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, button_constants_save, _("Save changes to the constants file. DON'T DO THIS UNLESS YOU REALLY KNOW WHAT YOU ARE DOING."), NULL);
alignment6 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment6);
gtk_container_add (GTK_CONTAINER (button_constants_save), alignment6);
hbox22 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox22);
gtk_container_add (GTK_CONTAINER (alignment6), hbox22);
image6 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image6);
gtk_box_pack_start (GTK_BOX (hbox22), image6, FALSE, FALSE, 0);
label56 = gtk_label_new_with_mnemonic (_("Save to file"));
gtk_widget_show (label56);
gtk_box_pack_start (GTK_BOX (hbox22), label56, FALSE, FALSE, 0);
button_constants_reload = gtk_button_new ();
gtk_widget_show (button_constants_reload);
gtk_box_pack_start (GTK_BOX (vbox12), button_constants_reload, FALSE, FALSE, 0);
@ -1582,7 +1608,7 @@ create_window_constants (void)
button_constants_close = gtk_button_new ();
gtk_widget_show (button_constants_close);
gtk_box_pack_start (GTK_BOX (vbox12), button_constants_close, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, button_constants_close, _("Close window. Changes will be saved for the current session. To make permanent changes, edit constants files directly."), NULL);
gtk_tooltips_set_tip (tooltips, button_constants_close, _("Close window. Changes will only be saved for the current session, unless you also save to file."), NULL);
gtk_widget_add_accelerator (button_constants_close, "clicked", accel_group,
GDK_Escape, (GdkModifierType) 0,
GTK_ACCEL_VISIBLE);
@ -1609,6 +1635,9 @@ create_window_constants (void)
g_signal_connect ((gpointer) window_constants, "delete_event",
G_CALLBACK (on_window_constants_delete_event),
NULL);
g_signal_connect ((gpointer) button_constants_save, "clicked",
G_CALLBACK (on_button_constants_save_clicked),
NULL);
g_signal_connect ((gpointer) button_constants_reload, "clicked",
G_CALLBACK (on_button_constants_reload_clicked),
NULL);
@ -1633,6 +1662,11 @@ create_window_constants (void)
GLADE_HOOKUP_OBJECT (window_constants, treeview_constants_app, "treeview_constants_app");
GLADE_HOOKUP_OBJECT (window_constants, label53, "label53");
GLADE_HOOKUP_OBJECT (window_constants, hseparator9, "hseparator9");
GLADE_HOOKUP_OBJECT (window_constants, button_constants_save, "button_constants_save");
GLADE_HOOKUP_OBJECT (window_constants, alignment6, "alignment6");
GLADE_HOOKUP_OBJECT (window_constants, hbox22, "hbox22");
GLADE_HOOKUP_OBJECT (window_constants, image6, "image6");
GLADE_HOOKUP_OBJECT (window_constants, label56, "label56");
GLADE_HOOKUP_OBJECT (window_constants, button_constants_reload, "button_constants_reload");
GLADE_HOOKUP_OBJECT (window_constants, alignment4, "alignment4");
GLADE_HOOKUP_OBJECT (window_constants, hbox20, "hbox20");