OSDN Git Service

not visible at initializing top level window. set default size before showing.
[fukui-no-namari/fukui-no-namari.git] / src / Hage1 / thread_window.py
index 90294fb..94969ea 100644 (file)
@@ -28,6 +28,7 @@ import urlparse
 import gnome
 import gobject
 import threading
+import gconf
 
 import misc
 import datfile
@@ -39,6 +40,7 @@ import uri_opener
 from http_sub import HTTPRedirectHandler302
 from BbsType import bbs_type_judge_uri
 from BbsType import bbs_type_exception
+import config
 
 GLADE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                          "..", "data")
@@ -133,6 +135,8 @@ class WinWrap:
         glade_path = os.path.join(GLADE_DIR, GLADE_FILENAME)
         self.widget_tree = gtk.glade.XML(glade_path)
         self.window = self.widget_tree.get_widget("thread_window")
+        self.toolbar = self.widget_tree.get_widget("toolbar")
+        self.statusbar = self.widget_tree.get_widget("appbar")
         self.textview = self.widget_tree.get_widget("textview")
         self.textbuffer = self.textview.get_buffer()
         self.enditer = self.textbuffer.get_end_iter()
@@ -140,12 +144,16 @@ class WinWrap:
         self.leftmargintag = self.textbuffer.create_tag()
         self.leftmargintag.set_property("left-margin", 20)
 
-        sigdic = {"on_toolbutton_refresh_clicked": self.update,
-                  "on_toolbutton_compose_clicked": self.on_compose_clicked,
+        sigdic = {"on_refresh_activate": self.update,
+                  "on_compose_activate": self.on_compose_clicked,
+                  "on_toolbar_activate": self.on_toolbar_activate,
+                  "on_statusbar_activate": self.on_statusbar_activate,
                   "on_refresh_activate": self.update,
                   "on_close_activate": self.on_close_activate,
                   "on_quit_activate": self.on_quit_activate,
                   "on_show_board_activate": self.on_show_board_activate,
+                  "on_thread_window_delete_event":
+                  self.on_thread_window_delete_event,
                   "on_thread_window_destroy": self.on_thread_window_destroy}
         self.widget_tree.signal_autoconnect(sigdic)
 
@@ -155,10 +163,43 @@ class WinWrap:
         self.textview.connect("visibility-notify-event",
                               self.on_visibility_notify_event)
 
+        self.gconf_client = gconf.client_get_default()
+        self.gconf_key_base = "/apps/" + config.APPNAME.lower() + \
+                              "/thread_states/"
+
+        width = self.gconf_client.get_int(
+            self.gconf_key_base + "window_width")
+        height = self.gconf_client.get_int(
+            self.gconf_key_base + "window_height")
+        self.window.set_default_size(width, height)
+
+        if not self.gconf_client.get_bool(self.gconf_key_base + "toolbar"):
+            self.toolbar.parent.hide()
+        if not self.gconf_client.get_bool(self.gconf_key_base + "statusbar"):
+            self.statusbar.hide()
+
+        self.window.show()
+
     def on_compose_clicked(self, widget):
         import submit_window
         submit_window.open(self.bbs_type.get_thread_uri())
 
+    def on_toolbar_activate(self, widget):
+        if self.toolbar.parent.get_property("visible"):
+            self.toolbar.parent.hide()
+            self.gconf_client.set_bool(self.gconf_key_base + "toolbar", False)
+        else:
+            self.toolbar.parent.show()
+            self.gconf_client.set_bool(self.gconf_key_base + "toolbar", True)
+
+    def on_statusbar_activate(self, widget):
+        if self.statusbar.get_property("visible"):
+            self.statusbar.hide()
+            self.gconf_client.set_bool(self.gconf_key_base+"statusbar", False)
+        else:
+            self.statusbar.show()
+            self.gconf_client.set_bool(self.gconf_key_base + "statusbar", True)
+
     def on_event_after(self, widget, event):
         if event.type != gtk.gdk.BUTTON_RELEASE:
             return False
@@ -236,6 +277,13 @@ class WinWrap:
     def on_close_activate(self, widget):
         self.window.destroy()
 
+    def on_thread_window_delete_event(self, widget, event):
+        w, h = widget.get_size()
+        self.gconf_client.set_int(self.gconf_key_base + "window_width", w)
+        self.gconf_client.set_int(self.gconf_key_base + "window_height", h)
+
+        return False
+        
     def on_thread_window_destroy(self, widget):
         -1