[five-or-more/arnaudb/wip/gtk4: 4/28] Use Gtk namespace.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/arnaudb/wip/gtk4: 4/28] Use Gtk namespace.
- Date: Fri, 27 Mar 2020 16:16:19 +0000 (UTC)
commit d14ac01e20df4957820583c9e1cceca25832c9b6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Mar 12 17:51:57 2020 +0100
Use Gtk namespace.
src/main.vala | 2 +-
src/preferences-dialog.vala | 18 ++++++++++--------
src/view.vala | 16 +++++++++-------
src/window.vala | 38 +++++++++++++++++++-------------------
4 files changed, 39 insertions(+), 35 deletions(-)
---
diff --git a/src/main.vala b/src/main.vala
index a537149..b7e4f24 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -80,7 +80,7 @@ private class FiveOrMoreApp: Gtk.Application
set_accels_for_action ("app.help", {"F1"});
var board_size_action = lookup_action("change-size");
BoardSize size = (BoardSize)settings.get_int (FiveOrMoreApp.KEY_SIZE);
- (board_size_action as SimpleAction).set_state (new Variant.string(size.to_string()));
+ ((SimpleAction)board_size_action).set_state (new Variant.string(size.to_string()));
}
private void new_game_cb ()
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index fdbc42e..e0c872d 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -21,20 +21,22 @@
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
+using Gtk;
+
[GtkTemplate (ui = "/org/gnome/five-or-more/ui/preferences-dialog.ui")]
-private class PreferencesDialog : Gtk.Dialog
+private class PreferencesDialog : Dialog
{
- private Settings settings;
+ private GLib.Settings settings;
[GtkChild]
- private Gtk.ComboBoxText theme_box;
+ private ComboBoxText theme_box;
[GtkChild]
- private Gtk.ColorButton color_button;
+ private ColorButton color_button;
- private void theme_set_cb (Gtk.ComboBox self)
+ private void theme_set_cb (ComboBox self)
{
- var combo_box_text = self as Gtk.ComboBoxText;
+ var combo_box_text = (ComboBoxText) self;
var theme = combo_box_text.get_active_id ();
foreach (var t in ThemeRenderer.themes)
{
@@ -48,14 +50,14 @@ private class PreferencesDialog : Gtk.Dialog
}
}
- private void color_set_cb (Gtk.ColorButton self)
+ private void color_set_cb (ColorButton self)
{
var color = self.get_rgba ();
if (!settings.set_string (FiveOrMoreApp.KEY_BACKGROUND_COLOR, color.to_string ()))
warning ("Failed to set color: %s", color.to_string ());
}
- internal PreferencesDialog (Settings settings)
+ internal PreferencesDialog (GLib.Settings settings)
{
this.settings = settings;
diff --git a/src/view.vala b/src/view.vala
index 3b38777..5ccfda4 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -21,15 +21,17 @@
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
-private class View : Gtk.DrawingArea
+using Gtk;
+
+private class View : DrawingArea
{
private const int MINIMUM_BOARD_SIZE = 256;
- private Settings settings;
+ private GLib.Settings settings;
private Game? game = null;
private ThemeRenderer? theme = null;
- private Gtk.StyleContext cs;
- private Gtk.CssProvider provider;
+ private StyleContext cs;
+ private CssProvider provider;
private Gdk.Rectangle board_rectangle;
@@ -49,16 +51,16 @@ private class View : Gtk.DrawingArea
private int animation_state;
private uint animation_id;
- internal View (Settings settings, Game game, ThemeRenderer theme)
+ internal View (GLib.Settings settings, Game game, ThemeRenderer theme)
{
this.settings = settings;
this.game = game;
this.theme = theme;
cs = get_style_context ();
- provider = new Gtk.CssProvider ();
+ provider = new CssProvider ();
cs.add_class ("game-view");
- cs.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_USER);
+ cs.add_provider (provider, STYLE_PROVIDER_PRIORITY_USER);
set_background_color ();
settings.changed[FiveOrMoreApp.KEY_BACKGROUND_COLOR].connect (() => {
diff --git a/src/window.vala b/src/window.vala
index 430b5d6..1550428 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -21,22 +21,24 @@
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
+using Gtk;
+
[GtkTemplate (ui = "/org/gnome/five-or-more/ui/five-or-more.ui")]
-private class GameWindow : Gtk.ApplicationWindow
+private class GameWindow : ApplicationWindow
{
[GtkChild]
- private Gtk.HeaderBar headerbar;
+ private HeaderBar headerbar;
[GtkChild]
- private Gtk.Box preview_hbox;
+ private Box preview_hbox;
[GtkChild]
- private Gtk.MenuButton primary_menu_button;
+ private MenuButton primary_menu_button;
[GtkChild]
private Games.GridFrame grid_frame;
- private Settings? settings = null;
+ private GLib.Settings? settings = null;
private bool window_tiled;
internal bool window_maximized { internal get; private set; }
internal int window_width { internal get; private set; }
@@ -53,7 +55,7 @@ private class GameWindow : Gtk.ApplicationWindow
_("Score: %d")
};
- internal GameWindow (Gtk.Application app, Settings settings)
+ internal GameWindow (Gtk.Application app, GLib.Settings settings)
{
Object (application: app);
@@ -103,7 +105,7 @@ private class GameWindow : Gtk.ApplicationWindow
return false;
}
- protected override void size_allocate (Gtk.Allocation allocation)
+ protected override void size_allocate (Allocation allocation)
{
base.size_allocate (allocation);
@@ -151,26 +153,24 @@ private class GameWindow : Gtk.ApplicationWindow
primary_menu_button.set_active (false);
if (game.score > 0) {
- var flags = Gtk.DialogFlags.DESTROY_WITH_PARENT;
- var restart_game_dialog = new Gtk.MessageDialog (this,
- flags,
- Gtk.MessageType.WARNING,
- Gtk.ButtonsType.NONE,
- _("Are you sure you want to restart the game?"),
- null);
- restart_game_dialog.add_buttons (_("_Cancel"), Gtk.ResponseType.CANCEL,
- _("_Restart"), Gtk.ResponseType.OK,
- null);
+ var flags = DialogFlags.DESTROY_WITH_PARENT;
+ var restart_game_dialog = new MessageDialog (this,
+ flags,
+ MessageType.WARNING,
+ ButtonsType.NONE,
+ _("Are you sure you want to restart the game?"));
+ restart_game_dialog.add_buttons (_("_Cancel"), ResponseType.CANCEL,
+ _("_Restart"), ResponseType.OK);
var result = restart_game_dialog.run ();
restart_game_dialog.destroy ();
switch (result)
{
- case Gtk.ResponseType.OK:
+ case ResponseType.OK:
if (!settings.set_int (FiveOrMoreApp.KEY_SIZE, size))
warning ("Failed to set size: %d", size);
break;
- case Gtk.ResponseType.CANCEL:
+ case ResponseType.CANCEL:
break;
}
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]