Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Now installs a gschema conf file and saves window state between sessions

  • Loading branch information...
commit b4b824e4175317e54df06834c0bc03f6c7954b4c 1 parent bf1ab38
@sgringwe authored
View
1  CMakeLists.txt
@@ -62,3 +62,4 @@ add_subdirectory(rdio)
add_subdirectory(data)
add_subdirectory(po)
add_subdirectory(images)
+add_subdirectory(schemas)
View
1  rdio/CMakeLists.txt
@@ -7,6 +7,7 @@ vala_precompile(VALA_C
main.vala
config.vala
Rdio.vala
+ Settings.vala
Window.vala
CustomTitleBar.vala
MediaKeyListener.vala
View
4 rdio/Rdio.vala
@@ -32,10 +32,10 @@ public class Rdio.App : Gtk.Application {
public static Rdio.Window window { get; private set; }
// public static Rdio.Notifier notifier { get; private set; }
// public static Rdio.SoundMenu sound_menu { get; private set; }
- // public static Rdio.Settings settings { get; private set; }
+ public static Rdio.Settings settings { get; private set; }
public App () {
- // settings = new Rdio.Settings ();
+ settings = new Rdio.Settings ();
window = new Rdio.Window (this);
// sound_menu = new Rdio.SoundMenu ();
// notifier = new Rdio.Notifier ();
View
68 rdio/Settings.vala
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2011-2012 Scott Ringwelski <sgringwe@mtu.edu>
+ *
+ * Originally Written by Scott Ringwelski for Rdio Music Player
+ * Rdio Music Player: http://www.launchpad.net/beat-box
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * The Rdio project hereby grant permission for non-gpl compatible GStreamer
+ * plugins to be used and distributed together with GStreamer and Rdio. This
+ * permission is above and beyond the permissions granted by the GPL license
+ * Rdio is covered by.
+ */
+
+public class Rdio.Settings {
+ GLib.Settings settings;
+
+ public enum WindowState {
+ NORMAL = 0,
+ MAXIMIZED = 1,
+ FULLSCREEN = 2
+ }
+
+ public Settings () {
+ settings = new GLib.Settings ("apps.rdio");
+ }
+
+ public int window_width {
+ get {
+ return settings.get_int ("window-width");
+ }
+ set {
+ settings.set_int ("window-width", value);
+ }
+ }
+
+ public int window_height {
+ get {
+ return settings.get_int ("window-height");
+ }
+ set {
+ settings.set_int ("window-height", value);
+ }
+ }
+
+ public WindowState window_state {
+ get {
+ return (WindowState) settings.get_enum ("window-state");
+ }
+ set {
+ settings.set_enum ("window-state", value);
+ }
+ }
+}
+
View
40 rdio/Window.vala
@@ -12,6 +12,8 @@ public class Rdio.Window : Gtk.Window {
WebKit.WebView webview;
Gtk.ScrolledWindow scrolled_window;
+ bool window_maximized;
+
public Window (Gtk.Application gtk_app) {
app = gtk_app;
@@ -49,6 +51,12 @@ public class Rdio.Window : Gtk.Window {
setup_cookies ();
webview.open ("https://www.rdio.com/signin/");
+ set_default_size (App.settings.window_width, App.settings.window_height);
+ if(App.settings.window_state == Settings.WindowState.MAXIMIZED) {
+ window_maximized = true;
+ maximize();
+ }
+
show_all();
mkl = new MediaKeyListener ();
@@ -62,9 +70,13 @@ public class Rdio.Window : Gtk.Window {
sound_menu = new Rdio.SoundMenuIntegration();
sound_menu.initialize();
#endif
+
+
+ destroy.connect (on_quit);
+ window_state_event.connect(window_state_changed);
}
- private void setup_cookies () {
+ void setup_cookies () {
var user_rdio_folder = GLib.File.new_for_path (GLib.Path.build_filename (Environment.get_user_data_dir (), "rdio"));
// Make sure our config folder exists
@@ -85,4 +97,30 @@ public class Rdio.Window : Gtk.Window {
var cookiejar = new Soup.CookieJarText (user_rdio_cookie_file, false);
session.add_feature (cookiejar);
}
+
+ bool window_state_changed(Gdk.EventWindowState event) {
+ if((event.changed_mask & (Gdk.WindowState.MAXIMIZED | Gdk.WindowState.FULLSCREEN)) == 0)
+ return false;
+
+ window_maximized = ((event.new_window_state & (Gdk.WindowState.MAXIMIZED | Gdk.WindowState.FULLSCREEN)) != 0);
+
+ return false;
+ }
+
+ void on_quit() {
+ // Stop listening to window state changes
+ window_state_event.disconnect(window_state_changed);
+
+ // Terminate Libnotify
+ // Notify.uninit ();
+
+ // Save UI Information
+ if (window_maximized == true) {
+ App.settings.window_state = Settings.WindowState.MAXIMIZED;
+ }
+ if(!(window_maximized)) {
+ App.settings.window_width = get_allocated_width();
+ App.settings.window_height = get_allocated_height();
+ }
+ }
}
View
2  schemas/CMakeLists.txt
@@ -0,0 +1,2 @@
+include(GSettings)
+add_schema("apps.rdio.gschema.xml")
View
26 schemas/apps.rdio.gschema.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <enum id="apps.rdio.WindowStates">
+ <value nick="Normal" value="0" />
+ <value nick="Maximized" value="1" />
+ <value nick="Fullscreen" value="2" />
+ </enum>
+
+ <schema path="/apps/rdio/" id="apps.rdio" gettext-domain="rdio">
+ <key type="i" name="window-width">
+ <default>1100</default>
+ <summary>Window width</summary>
+ <description>Window width</description>
+ </key>
+ <key type="i" name="window-height">
+ <default>600</default>
+ <summary>Window height</summary>
+ <description>Window height</description>
+ </key>
+ <key name="window-state" enum="apps.rdio.WindowStates">
+ <default>"Normal"</default>
+ <summary>The saved state of the window.</summary>
+ <description>The saved state of the window.</description>
+ </key>
+ </schema>
+</schemalist>
Please sign in to comment.
Something went wrong with that request. Please try again.