1
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
3
* Copyright (C) 2012 Victor Eduardo <victoreduardm@gmail.com>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* See the file COPYING for the full license text.
13
public class Huddle.MainWindow : Gtk.Window {
14
private const int MIN_WIDTH = 750;
15
private const int MIN_HEIGHT = 440;
22
private Granite.Widgets.SidebarPaned contacts_pane = new Granite.Widgets.SidebarPaned ();
28
public MainWindow (App application) {
29
title = App.instance.program_name;
31
set_application (application);
32
set_icon (Icons.APP.render_at_size (48));
38
private void set_geometry () {
39
width_request = MIN_WIDTH;
40
height_request = MIN_HEIGHT;
41
window_position = Gtk.WindowPosition.CENTER;
43
width = (int) Settings.SavedState.instance.window_width;
44
height = (int) Settings.SavedState.instance.window_height;
45
set_default_size (width, height);
47
state = (State) Settings.SavedState.instance.window_state;
57
private void add_widgets () {
58
contacts_pane.position = (int) Settings.SavedState.instance.sidebar_width;
62
public void show_alert (string title, string message) {
63
var dialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
64
Gtk.ButtonsType.OK, title);
66
dialog.title = App.instance.program_name;
67
dialog.secondary_text = message;
68
dialog.secondary_use_markup = true;
75
* Called when the user tries to close the window.
77
public override bool delete_event (Gdk.EventAny event) {
78
if (Settings.Main.instance.hide_on_close) {
83
return false; // Let the window be destroyed
86
public override void destroy () {
87
Settings.SavedState.instance.sidebar_width = contacts_pane.position;
88
Settings.SavedState.instance.window_state = state;
89
Settings.SavedState.instance.window_width = width;
90
Settings.SavedState.instance.window_height = height;
95
public override bool configure_event (Gdk.EventConfigure event) {
96
bool window_maximized = (get_window ().get_state () == Gdk.WindowState.MAXIMIZED);
98
if (!window_maximized)
99
get_size (out width, out height);
101
state = window_maximized ? State.MAXIMIZED : State.NORMAL;
103
return base.configure_event (event);