/gpump/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/gpump/trunk

« back to all changes in this revision

Viewing changes to src/app.js

  • Committer: Gustav Hartvigsson
  • Date: 2014-06-10 10:32:48 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20140610103248-7c7erbqb8ze9r1if
* Now saves the Height, Width, X and Y of the window on quit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * in the file lgpl-3.0.txt in the root of this project.
6
6
 */
7
7
 
 
8
const cairo = imports.gi.cairo;
8
9
const Gio = imports.gi.Gio;
9
10
const GLib = imports.gi.GLib;
 
11
const GObject = imports.gi.GObject;
10
12
const Gtk = imports.gi.Gtk;
11
13
const Lang = imports.lang;
12
14
const _ = imports.gettext.gettext;
20
22
  Extends: Gtk.Application,
21
23
  
22
24
  _init: function () {
 
25
    this.settings = SettingsData.get_settings ();
 
26
    
23
27
    this.parent ({
24
28
      application_id: "org.gego.gpump",
25
29
      flags: Gio.ApplicationFlags.FLAGS_NONE,
26
 
      register_session: true
 
30
      register_session: true,
27
31
    });
28
32
   GLib.set_application_name (_("GPump"));
29
33
    
30
 
    this.settings = SettingsData.get_settings ();
31
34
  },
32
35
  
33
36
  vfunc_activate: function () {
42
45
    this._prepare_app_menu ();
43
46
    this._prepare_header_bar ();
44
47
    
 
48
    
45
49
    this.window.show_all ();
46
50
  },
47
51
  
54
58
      application: this,
55
59
      type: Gtk.WindowType.TOPLEVEL,
56
60
      title: GLib.get_application_name (),
57
 
      default_height: 500,
58
 
      default_width: 500,
 
61
      default_height: this.settings.get_setting ("ui.h").data,
 
62
      default_width: this.settings.get_setting ("ui.w").data,
59
63
      height_request: 500,
60
64
      width_request: 500,
61
65
      window_position: Gtk.WindowPosition.CENTER
67
71
      show_close_button: true
68
72
    })));
69
73
    
 
74
    if (!(this.settings.get_setting ("ui.x").data < 0 &&
 
75
        this.settings.get_setting ("ui.y").data < 0)){
 
76
      this.window.move (this.settings.get_setting ("ui.x").data, this.settings.get_setting ("ui.y").data);
 
77
    }
 
78
    
70
79
    print ("derp!\n");
71
80
    
72
81
    this.window.add (( this.scroll_view = new Gtk.ScrolledWindow () ));
98
107
    
99
108
    let quit_action = new Gio.SimpleAction ({name: "quit"});
100
109
    quit_action.connect ('activate', Lang.bind (this, function () {
 
110
      let allocation = this.window.get_allocation ();
 
111
      this.settings.set_setting ("ui.h", allocation.height);
 
112
      this.settings.set_setting ("ui.w", allocation.width);
 
113
      
 
114
      let win_pos = this.window.get_position ();
 
115
      this.settings.set_setting ("ui.x", win_pos[0]);
 
116
      this.settings.set_setting ("ui.y", win_pos[1]);
 
117
      this.settings.commit_to_file ();
101
118
      this.quit ();
102
119
    }));
103
120
    this.add_action (quit_action);
104
121
    
105
122
    let preferences_action = new Gio.SimpleAction ({name: "preferences"});
106
123
    preferences_action.connect ('activate', Lang.bind (this, function (){
107
 
      let pref_dialog = new PreferencesUI.PreferencesUI ();
 
124
      let pref_dialog = new PreferencesUI.PreferencesUI ({
 
125
        transient_for: this.window,
 
126
        parent: this.window,
 
127
        window_position: Gtk.WindowPosition.CENTER_ON_PARENT
 
128
      });
108
129
      pref_dialog.run ();
109
130
    }));
110
131
    this.add_action (preferences_action)