[gnome-games] glines: Move preferences to .ui file
- From: Thomas Hindoe Paaboel Andersen <thomashpa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] glines: Move preferences to .ui file
- Date: Wed, 5 Oct 2011 21:41:49 +0000 (UTC)
commit 010047ac4824bb6ce1f2fa2207dc31e72c245c63
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date: Wed Oct 5 23:38:42 2011 +0200
glines: Move preferences to .ui file
configure.in | 1 +
glines/Makefile.am | 2 +-
glines/data/Makefile.am | 7 +
glines/data/glines-preferences.ui | 268 +++++++++++++++++++++++++++++++++++++
glines/glines.c | 125 ++++++------------
po/POTFILES.in | 1 +
6 files changed, 318 insertions(+), 86 deletions(-)
---
diff --git a/configure.in b/configure.in
index e03b26e..e52567a 100644
--- a/configure.in
+++ b/configure.in
@@ -866,6 +866,7 @@ gnotravex/pixmaps/Makefile
gnotski/Makefile
gnotski/help/Makefile
glines/Makefile
+glines/data/Makefile
glines/glines.desktop.in
glines/help/Makefile
quadrapassel/Makefile
diff --git a/glines/Makefile.am b/glines/Makefile.am
index c53dc2c..8c37f43 100644
--- a/glines/Makefile.am
+++ b/glines/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS =
+SUBDIRS = data
if BUILD_HELP
SUBDIRS += help
diff --git a/glines/data/Makefile.am b/glines/data/Makefile.am
new file mode 100644
index 0000000..de8730c
--- /dev/null
+++ b/glines/data/Makefile.am
@@ -0,0 +1,7 @@
+uidir = $(pkgdatadir)/glines/
+ui_DATA = \
+ glines-preferences.ui
+
+EXTRA_DIST = $(ui_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/glines/data/glines-preferences.ui b/glines/data/glines-preferences.ui
new file mode 100644
index 0000000..a7492e9
--- /dev/null
+++ b/glines/data/glines-preferences.ui
@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="preferences_dialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Five or More Preferences</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkBox" id="content_area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="appearance">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Appearance</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="hexpand">True</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Image:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">B_ackground color:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">colorbutton1</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkColorButton" id="colorbutton1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">12</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Board Size</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkRadioButton" id="radiobutton_small">
+ <property name="label" translatable="yes">_Small</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin_left">12</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="radiobutton_medium">
+ <property name="label" translatable="yes">_Medium</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin_left">12</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radiobutton_small</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="radiobutton_large">
+ <property name="label" translatable="yes">_Large</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin_left">12</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radiobutton_small</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">12</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">General</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_fast_moves">
+ <property name="label" translatable="yes">_Use fast moves</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin_left">12</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkButton" id="closebutton1">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-7">closebutton1</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/glines/glines.c b/glines/glines.c
index a4c123e..7ecfbe7 100644
--- a/glines/glines.c
+++ b/glines/glines.c
@@ -91,6 +91,7 @@ static const GamesScoresCategory scorecats[] = {
static GamesScores *highscores;
static GSettings *settings;
+static GtkBuilder *builder_preferences
static gint hfieldsize;
static gint vfieldsize;
@@ -127,8 +128,6 @@ static cairo_surface_t *preview_surfaces[7] = { NULL, NULL, NULL, NULL, NULL, NU
static cairo_surface_t *blank_surface = NULL;
static cairo_surface_t *blank_preview_surface = NULL;
-static GtkWidget *fast_moves_toggle_button = NULL;
-
static GamesFileList *theme_file_list = NULL;
static int active = -1;
@@ -1303,9 +1302,6 @@ conf_value_changed_cb (GSettings *settings, gchar *key)
if (timeout_tmp != move_timeout)
move_timeout = timeout_tmp;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fast_moves_toggle_button),
- (move_timeout == 10));
-
} else if (strcmp (key, KEY_SIZE) == 0) {
gint size_tmp;
size_tmp = g_settings_get_int (settings, KEY_SIZE);
@@ -1384,104 +1380,63 @@ pref_dialog_response (GtkDialog * dialog, gint response, gpointer data)
void
game_props_callback (void)
{
- GtkWidget *w, *omenu, *l, *fv;
- GtkWidget *frame;
- GtkWidget *table;
- GtkWidget *vbox;
- GtkWidget *button;
- int i;
- GSList *group;
+ gchar *ui_path;
+ GError *error = NULL;
+ GtkWidget *omenu;
+ GtkWidget *grid;
+ GtkWidget *color_button;
+ GtkWidget *size_radio;
+ GtkWidget *fast_moves_checkbutton;
if (!pref_dialog) {
- pref_dialog = gtk_dialog_new_with_buttons (_("Five or More Preferences"),
- GTK_WINDOW (app),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE, NULL);
+ ui_path = g_build_filename (games_runtime_get_directory (GAMES_RUNTIME_GAME_DATA_DIRECTORY), "glines-preferences.ui", NULL);
+ builder_preferences = gtk_builder_new ();
+ gtk_builder_add_from_file (builder_preferences, ui_path, &error);
+ g_free (ui_path);
+
+ if (error) {
+ g_critical ("Unable to load the user interface file: %s", error->message);
+ g_error_free (error);
+ g_assert_not_reached ();
+ }
+
+ pref_dialog = GTK_WIDGET (gtk_builder_get_object (builder_preferences, "preferences_dialog"));
g_signal_connect (pref_dialog, "response",
G_CALLBACK (pref_dialog_response), NULL);
g_signal_connect (pref_dialog, "delete-event",
G_CALLBACK (gtk_widget_hide), NULL);
- gtk_window_set_resizable (GTK_WINDOW (pref_dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (pref_dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pref_dialog))), 2);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pref_dialog))),
- vbox, FALSE, FALSE, 0);
-
- frame = games_frame_new (_("Appearance"));
- table = gtk_table_new (2, 2, FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (table), 0);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-
- l = gtk_label_new_with_mnemonic (_("_Image:"));
- gtk_misc_set_alignment (GTK_MISC (l), 0, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), l, 0, 1, 0, 1);
-
+ grid = GTK_WIDGET (gtk_builder_get_object (builder_preferences, "grid1"));
omenu = fill_menu ();
+ gtk_widget_show_all (GTK_WIDGET (omenu));
+ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (omenu), 1, 0, 1, 1);
g_signal_connect (omenu, "changed",
G_CALLBACK (set_selection), NULL);
- gtk_table_attach_defaults (GTK_TABLE (table), omenu, 1, 2, 0, 1);
- gtk_label_set_mnemonic_widget (GTK_LABEL (l), omenu);
+ color_button = GTK_WIDGET (gtk_builder_get_object (builder_preferences, "colorbutton1"));
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (color_button), &backgnd.color);
+ g_signal_connect (color_button, "color-set",
+ G_CALLBACK (bg_color_callback), NULL);
- l = gtk_label_new_with_mnemonic (_("B_ackground color:"));
- gtk_misc_set_alignment (GTK_MISC (l), 0, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), l, 0, 1, 1, 2);
+ size_radio = GTK_WIDGET (gtk_builder_get_object (builder_preferences, "radiobutton_small"));
+ g_signal_connect (size_radio, "clicked",
+ G_CALLBACK (size_callback), GINT_TO_POINTER (1));
- {
- w = gtk_color_button_new ();
- gtk_color_button_set_color (GTK_COLOR_BUTTON (w), &backgnd.color);
- g_signal_connect (w, "color-set",
- G_CALLBACK (bg_color_callback), NULL);
- }
+ size_radio = GTK_WIDGET (gtk_builder_get_object (builder_preferences, "radiobutton_medium"));
+ g_signal_connect (size_radio, "clicked",
+ G_CALLBACK (size_callback), GINT_TO_POINTER (2));
- gtk_table_attach_defaults (GTK_TABLE (table), w, 1, 2, 1, 2);
- gtk_label_set_mnemonic_widget (GTK_LABEL (l), w);
+ size_radio = GTK_WIDGET (gtk_builder_get_object (builder_preferences, "radiobutton_large"));
+ g_signal_connect (size_radio, "clicked",
+ G_CALLBACK (size_callback), GINT_TO_POINTER (3));
-
- frame = games_frame_new (_("Board Size"));
- fv = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_add (GTK_CONTAINER (frame), fv);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-
- group = NULL;
- for (i = 0; i < G_N_ELEMENTS (scorecats); ++i) {
- button = gtk_radio_button_new_with_mnemonic (group, g_dpgettext2 (NULL, "board size", scorecats[i].name));
- if (game_size == i)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
-
- g_signal_connect (button, "clicked",
- G_CALLBACK (size_callback), GINT_TO_POINTER (i + 1));
-
- gtk_box_pack_start (GTK_BOX (fv), button, FALSE, FALSE, 0);
-
- group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
- }
-
- frame = games_frame_new (C_("preferences", "General"));
- fv = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_add (GTK_CONTAINER (frame), fv);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-
- fast_moves_toggle_button =
- gtk_check_button_new_with_mnemonic (_("_Use fast moves"));
+ fast_moves_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder_preferences, "checkbutton_fast_moves"));
if (move_timeout == 10) {
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON (fast_moves_toggle_button), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fast_moves_checkbutton), TRUE);
}
- g_signal_connect (fast_moves_toggle_button, "clicked",
- G_CALLBACK (set_fast_moves_callback), NULL);
- gtk_container_add (GTK_CONTAINER (fv), fast_moves_toggle_button);
-
- gtk_widget_show_all (pref_dialog);
+ g_signal_connect (fast_moves_checkbutton, "clicked",
+ G_CALLBACK (set_fast_moves_callback), NULL);
pref_dialog_done = TRUE;
}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ae3f45c..61b6c33 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,6 +25,7 @@ glchess/src/test-chess-game.vala
glines/glines.c
glines/glines.h
glines/glines.desktop.in.in
+[type: gettext/glade]glines/data/glines-preferences.ui
glines/org.gnome.glines.gschema.xml.in
gnect/data/gnect.desktop.in.in
gnect/data/gnect.schemas.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]