[blam/gtk-builder] Restore the window size on startup
- From: Carlos MartĂn Nieto <cmartin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [blam/gtk-builder] Restore the window size on startup
- Date: Fri, 11 Oct 2013 13:06:00 +0000 (UTC)
commit 8da36c1de8e5d02c28db370a0be726a860871144
Author: Carlos MartĂn Nieto <cmn dwim me>
Date: Fri Oct 11 11:39:24 2013 +0200
Restore the window size on startup
src/Blam.cs | 35 +++++++++++++++++++++++++++++++++++
src/Conf.cs | 35 +++++++++++++++++++++++++++++++++++
src/blam.ui | 5 ++---
3 files changed, 72 insertions(+), 3 deletions(-)
---
diff --git a/src/Blam.cs b/src/Blam.cs
index 2762036..e5ad61e 100644
--- a/src/Blam.cs
+++ b/src/Blam.cs
@@ -23,6 +23,8 @@ namespace Blam
ItemList ItemList;
FeedList FeedList;
ItemView ItemView;
+ Paned mainPaned;
+ Paned itemPaned;
ScrolledWindow FeedListSw;
ScrolledWindow ItemListSw;
@@ -63,6 +65,9 @@ namespace Blam
ItemViewSw = bld.GetObject<ScrolledWindow>("item-view-scroll");
ItemViewSw.Child = ItemView;
+ mainPaned = bld.GetObject<Paned>("main-paned");
+ itemPaned = bld.GetObject<Paned>("item-paned");
+
ItemList.SelectionChanged()
.Select(obj => ((TreeSelection)obj.Sender).Item())
.Where(item => item != null)
@@ -77,6 +82,7 @@ namespace Blam
.Subscribe(chan => ItemList.Channel = chan);
wireMenuItems(bld);
+ restoreWindowState();
}
void wireMenuItems(Builder bld)
@@ -153,6 +159,35 @@ namespace Blam
Application.Quit();
args.RetVal = true;
}
+
+ void restoreWindowState()
+ {
+ int width, height;
+ int position_x, position_y;
+ string state;
+
+
+ width = Conf.Get("ui/main_window_width", 600);
+ height = Conf.Get("ui/main_window_height", 400);
+
+ MainWindow.Resize(width, height);
+
+ position_x = Conf.Get("ui/main_window_position_x", -1);
+ position_y = Conf.Get("ui/main_window_position_y", -1);
+ if (position_x >= 0 && position_y >= 0) {
+ MainWindow.Move(position_x, position_y);
+ }
+
+ width = Conf.Get("ui/channel_list_width", 180);
+ mainPaned.Position = width;
+
+ height = Conf.Get("ui/item_list_height", 100);
+ itemPaned.Position = height;
+
+ if (Conf.Get("ui/main_window_state", "normal") == "maximized")
+ MainWindow.Maximize();
+ }
+
}
public class Blam
diff --git a/src/Conf.cs b/src/Conf.cs
index a65af88..aa6d20a 100644
--- a/src/Conf.cs
+++ b/src/Conf.cs
@@ -8,6 +8,41 @@
using GConf;
using System;
+namespace Blam
+{
+ public static class Conf
+ {
+ static string confBase = "/apps/blam";
+ static GConf.Client client;
+
+ static Conf()
+ {
+ client = new GConf.Client();
+ }
+
+ static string fullKey(string key)
+ {
+ if (key.StartsWith("/")) {
+ return key;
+ }
+
+ return confBase + "/" + key;
+ }
+
+ public static T Get<T>(string key, T def)
+ {
+ T res;
+ try {
+ res = (T) client.Get(fullKey(key));
+ } catch {
+ res = def;
+ }
+
+ return res;
+ }
+ }
+}
+
namespace Imendio.Blam {
public class Conf {
diff --git a/src/blam.ui b/src/blam.ui
index 5636e0a..eadf4c6 100644
--- a/src/blam.ui
+++ b/src/blam.ui
@@ -113,7 +113,6 @@
<property name="tooltip_markup">Create a new group</property>
<property name="tooltip_text" translatable="yes">Create a new group</property>
<property name="use_action_appearance">False</property>
- <property name="image">image1</property>
<property name="use_stock">False</property>
</object>
</child>
@@ -222,7 +221,7 @@
</packing>
</child>
<child>
- <object class="GtkHPaned" id="hpaned1">
+ <object class="GtkHPaned" id="main-paned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
@@ -267,7 +266,7 @@
</packing>
</child>
<child>
- <object class="GtkVPaned" id="vpaned1">
+ <object class="GtkVPaned" id="item-paned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]