OSDN Git Service

Gui improvement. save window states.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Thu, 31 Aug 2006 11:22:01 +0000 (20:22 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Thu, 31 Aug 2006 11:22:01 +0000 (20:22 +0900)
src/Hage1/board_window.py
src/Hage1/thread_window.py
src/data/board_window.glade
src/data/thread_window.glade

index b681771..862b454 100644 (file)
@@ -22,13 +22,14 @@ import gtk.glade
 import os
 import time
 import gobject
+import gconf
 
 import board_data
 import uri_opener
 import misc
 from threadlistmodel import ThreadListModel
 from BbsType import bbs_type_judge_uri
-
+import config
 import session
 
 GLADE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)),
@@ -72,6 +73,8 @@ class WinWrap:
         self.treeview.set_model(ThreadListModel())
 
         self.popupmenu = self.widget_tree.get_widget("popup_menu")
+        self.toolbar = self.widget_tree.get_widget("toolbar")
+        self.statusbar = self.widget_tree.get_widget("appbar")
 
         renderer = gtk.CellRendererText()
 
@@ -94,17 +97,51 @@ class WinWrap:
 
         sigdic = {"on_board_window_destroy": self.on_board_window_destroy,
                   "on_quit_activate": self.on_quit_activate,
-                  "on_load_local_activate": self.on_load_local_activate,
-                  "on_get_remote_activate": self.on_get_remote_activate,
+                  "on_refresh_activate": self.on_refresh_activate,
                   "on_treeview_row_activated":
                   lambda w,p,v: self.on_open_thread(w),
                   "on_treeview_button_press_event":
                   self.on_treeview_button_press_event,
                   "on_close_activate":
                   self.on_close_activate,
+                  "on_toolbar_activate": self.on_toolbar_activate,
+                  "on_statusbar_activate": self.on_statusbar_activate,
+                  "on_board_window_delete_event":
+                  self.on_board_window_delete_event,
                   "on_popup_menu_open_activate": self.on_open_thread}
         self.widget_tree.signal_autoconnect(sigdic)
 
+        self.gconf_client = gconf.client_get_default()
+        self.gconf_key_base = "/apps/" + config.APPNAME.lower() + \
+                              "/board_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.resize(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()
+
+    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 updated_thread_highlight(self, column, cell, model, iter):
 
         def is_updated_thread():
@@ -141,6 +178,13 @@ class WinWrap:
             cell.set_property("text", time.strftime(
                 "%Y/%m/%d(%a) %H:%M:%S", time.localtime(lastmod)))
 
+    def on_board_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_board_window_destroy(self, widget):
         pass
 
@@ -150,11 +194,7 @@ class WinWrap:
     def on_close_activate(self, widget):
         self.window.destroy()
 
-    def on_load_local_activate(self, widget):
-        t = board_data.LoadLocal(self.bbs, self.board, self.update_datastore)
-        t.start()
-
-    def on_get_remote_activate(self, widget):
+    def on_refresh_activate(self, widget):
         t = board_data.GetRemote(
             self.bbs, self.board, self.bbs_type.get_subject_txt_uri(),
             self.update_datastore)
index 90294fb..1d9e761 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,41 @@ 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.resize(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()
+
     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 +275,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
 
index 635d449..4733053 100644 (file)
@@ -22,6 +22,7 @@
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="enable_layout_config">True</property>
   <signal name="destroy" handler="on_board_window_destroy" last_modification_time="Wed, 09 Aug 2006 23:41:09 GMT"/>
+  <signal name="delete_event" handler="on_board_window_delete_event" last_modification_time="Thu, 31 Aug 2006 11:00:02 GMT"/>
 
   <child internal-child="dock">
     <widget class="BonoboDock" id="bonobodock1">
                    <widget class="GtkMenu" id="file1_menu">
 
                      <child>
-                       <widget class="GtkImageMenuItem" id="load_local">
+                       <widget class="GtkImageMenuItem" id="close">
                          <property name="visible">True</property>
-                         <property name="label" translatable="yes">_Load Local</property>
-                         <property name="use_underline">True</property>
-                         <signal name="activate" handler="on_load_local_activate" last_modification_time="Wed, 09 Aug 2006 23:33:12 GMT"/>
-                         <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                         <property name="stock_item">GNOMEUIINFO_MENU_CLOSE_ITEM</property>
+                         <signal name="activate" handler="on_close_activate" last_modification_time="Sun, 20 Aug 2006 13:00:02 GMT"/>
+                       </widget>
+                     </child>
 
-                         <child internal-child="image">
-                           <widget class="GtkImage" id="image10">
-                             <property name="visible">True</property>
-                             <property name="stock">gtk-disconnect</property>
-                             <property name="icon_size">1</property>
-                             <property name="xalign">0.5</property>
-                             <property name="yalign">0.5</property>
-                             <property name="xpad">0</property>
-                             <property name="ypad">0</property>
-                           </widget>
-                         </child>
+                     <child>
+                       <widget class="GtkSeparatorMenuItem" id="separator1">
+                         <property name="visible">True</property>
                        </widget>
                      </child>
 
                      <child>
-                       <widget class="GtkImageMenuItem" id="get_remote">
+                       <widget class="GtkImageMenuItem" id="quit">
                          <property name="visible">True</property>
-                         <property name="label" translatable="yes">_Get Remote</property>
+                         <property name="stock_item">GNOMEUIINFO_MENU_EXIT_ITEM</property>
+                         <signal name="activate" handler="on_quit_activate" last_modification_time="Wed, 09 Aug 2006 23:42:32 GMT"/>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+
+             <child>
+               <widget class="GtkMenuItem" id="edit1">
+                 <property name="visible">True</property>
+                 <property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>
+               </widget>
+             </child>
+
+             <child>
+               <widget class="GtkMenuItem" id="view1">
+                 <property name="visible">True</property>
+                 <property name="stock_item">GNOMEUIINFO_MENU_VIEW_TREE</property>
+
+                 <child>
+                   <widget class="GtkMenu" id="view1_menu">
+
+                     <child>
+                       <widget class="GtkImageMenuItem" id="refresh">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">_Refresh</property>
                          <property name="use_underline">True</property>
-                         <signal name="activate" handler="on_get_remote_activate" last_modification_time="Wed, 09 Aug 2006 23:34:05 GMT"/>
+                         <signal name="activate" handler="on_refresh_activate" last_modification_time="Thu, 31 Aug 2006 09:40:44 GMT"/>
                          <accelerator key="R" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                          <child internal-child="image">
-                           <widget class="GtkImage" id="image11">
+                           <widget class="GtkImage" id="image17">
                              <property name="visible">True</property>
-                             <property name="stock">gtk-connect</property>
+                             <property name="stock">gtk-refresh</property>
                              <property name="icon_size">1</property>
                              <property name="xalign">0.5</property>
                              <property name="yalign">0.5</property>
                      </child>
 
                      <child>
-                       <widget class="GtkImageMenuItem" id="close">
+                       <widget class="GtkSeparatorMenuItem" id="separator2">
                          <property name="visible">True</property>
-                         <property name="stock_item">GNOMEUIINFO_MENU_CLOSE_ITEM</property>
-                         <signal name="activate" handler="on_close_activate" last_modification_time="Sun, 20 Aug 2006 13:00:02 GMT"/>
                        </widget>
                      </child>
 
                      <child>
-                       <widget class="GtkSeparatorMenuItem" id="separator1">
+                       <widget class="GtkMenuItem" id="toolbar">
                          <property name="visible">True</property>
+                         <property name="label" translatable="yes">_Toolbar</property>
+                         <property name="use_underline">True</property>
+                         <signal name="activate" handler="on_toolbar_activate" last_modification_time="Thu, 31 Aug 2006 09:21:48 GMT"/>
                        </widget>
                      </child>
 
                      <child>
-                       <widget class="GtkImageMenuItem" id="quit">
+                       <widget class="GtkMenuItem" id="statusbar">
                          <property name="visible">True</property>
-                         <property name="stock_item">GNOMEUIINFO_MENU_EXIT_ITEM</property>
-                         <signal name="activate" handler="on_quit_activate" last_modification_time="Wed, 09 Aug 2006 23:42:32 GMT"/>
+                         <property name="label" translatable="yes">St_atusbar</property>
+                         <property name="use_underline">True</property>
+                         <signal name="activate" handler="on_statusbar_activate" last_modification_time="Thu, 31 Aug 2006 09:21:48 GMT"/>
                        </widget>
                      </child>
                    </widget>
              </child>
 
              <child>
-               <widget class="GtkMenuItem" id="edit1">
-                 <property name="visible">True</property>
-                 <property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>
-               </widget>
-             </child>
-
-             <child>
-               <widget class="GtkMenuItem" id="view1">
-                 <property name="visible">True</property>
-                 <property name="stock_item">GNOMEUIINFO_MENU_VIEW_TREE</property>
-               </widget>
-             </child>
-
-             <child>
                <widget class="GtkMenuItem" id="help1">
                  <property name="visible">True</property>
                  <property name="stock_item">GNOMEUIINFO_MENU_HELP_TREE</property>
          <property name="shadow_type">GTK_SHADOW_OUT</property>
 
          <child>
-           <widget class="GtkToolbar" id="toolbar1">
+           <widget class="GtkToolbar" id="toolbar">
              <property name="visible">True</property>
              <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
              <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
              <property name="show_arrow">True</property>
 
              <child>
-               <widget class="GtkToolButton" id="load_local_button">
-                 <property name="visible">True</property>
-                 <property name="tooltip" translatable="yes">Load Local</property>
-                 <property name="label" translatable="yes">Load Local</property>
-                 <property name="use_underline">True</property>
-                 <property name="stock_id">gtk-disconnect</property>
-                 <property name="visible_horizontal">True</property>
-                 <property name="visible_vertical">True</property>
-                 <property name="is_important">False</property>
-                 <signal name="clicked" handler="on_load_local_activate" last_modification_time="Wed, 09 Aug 2006 23:36:57 GMT"/>
-               </widget>
-               <packing>
-                 <property name="expand">False</property>
-                 <property name="homogeneous">True</property>
-               </packing>
-             </child>
-
-             <child>
-               <widget class="GtkToolButton" id="get_remote_button">
+               <widget class="GtkToolButton" id="toolbarbutton_refresh">
                  <property name="visible">True</property>
-                 <property name="tooltip" translatable="yes">Get Remote</property>
-                 <property name="label" translatable="yes">Get Remote</property>
-                 <property name="use_underline">True</property>
-                 <property name="stock_id">gtk-connect</property>
+                 <property name="stock_id">gtk-refresh</property>
                  <property name="visible_horizontal">True</property>
                  <property name="visible_vertical">True</property>
                  <property name="is_important">False</property>
-                 <signal name="clicked" handler="on_get_remote_activate" last_modification_time="Wed, 09 Aug 2006 23:37:43 GMT"/>
+                 <signal name="clicked" handler="on_refresh_activate" last_modification_time="Thu, 31 Aug 2006 09:43:06 GMT"/>
                </widget>
                <packing>
                  <property name="expand">False</property>
   </child>
 
   <child internal-child="appbar">
-    <widget class="GnomeAppBar" id="appbar1">
+    <widget class="GnomeAppBar" id="appbar">
       <property name="visible">True</property>
       <property name="has_progress">True</property>
       <property name="has_status">True</property>
index 53eabd9..3878b6a 100644 (file)
@@ -21,6 +21,7 @@
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="enable_layout_config">True</property>
   <signal name="destroy" handler="on_thread_window_destroy" last_modification_time="Wed, 16 Aug 2006 03:37:07 GMT"/>
+  <signal name="delete_event" handler="on_thread_window_delete_event" last_modification_time="Thu, 31 Aug 2006 10:56:18 GMT"/>
 
   <child internal-child="dock">
     <widget class="BonoboDock" id="bonobodock1">
                    <widget class="GtkMenu" id="file1_menu">
 
                      <child>
-                       <widget class="GtkMenuItem" id="show_board">
+                       <widget class="GtkImageMenuItem" id="show_board">
                          <property name="visible">True</property>
                          <property name="label" translatable="yes">Show Board</property>
                          <property name="use_underline">True</property>
                          <signal name="activate" handler="on_show_board_activate" last_modification_time="Mon, 21 Aug 2006 03:30:53 GMT"/>
+
+                         <child internal-child="image">
+                           <widget class="GtkImage" id="image5">
+                             <property name="visible">True</property>
+                             <property name="stock">gtk-go-up</property>
+                             <property name="icon_size">1</property>
+                             <property name="xalign">0.5</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xpad">0</property>
+                             <property name="ypad">0</property>
+                           </widget>
+                         </child>
                        </widget>
                      </child>
 
                      <child>
-                       <widget class="GtkImageMenuItem" id="refresh">
+                       <widget class="GtkImageMenuItem" id="compose">
                          <property name="visible">True</property>
-                         <property name="label" translatable="yes">_Refresh</property>
+                         <property name="label" translatable="yes">_Compose Message</property>
                          <property name="use_underline">True</property>
-                         <signal name="activate" handler="on_refresh_activate" last_modification_time="Wed, 16 Aug 2006 03:34:22 GMT"/>
-                         <accelerator key="R" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                         <signal name="activate" handler="on_compose_activate" last_modification_time="Thu, 31 Aug 2006 09:58:49 GMT"/>
+                         <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                          <child internal-child="image">
-                           <widget class="GtkImage" id="image1">
+                           <widget class="GtkImage" id="image6">
                              <property name="visible">True</property>
-                             <property name="stock">gtk-refresh</property>
+                             <property name="stock">gnome-stock-mail-new</property>
                              <property name="icon_size">1</property>
                              <property name="xalign">0.5</property>
                              <property name="yalign">0.5</property>
                <widget class="GtkMenuItem" id="view1">
                  <property name="visible">True</property>
                  <property name="stock_item">GNOMEUIINFO_MENU_VIEW_TREE</property>
+
+                 <child>
+                   <widget class="GtkMenu" id="view1_menu">
+
+                     <child>
+                       <widget class="GtkImageMenuItem" id="refresh">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">_Refresh</property>
+                         <property name="use_underline">True</property>
+                         <signal name="activate" handler="on_refresh_activate" last_modification_time="Wed, 16 Aug 2006 03:34:22 GMT"/>
+                         <accelerator key="R" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+
+                         <child internal-child="image">
+                           <widget class="GtkImage" id="image7">
+                             <property name="visible">True</property>
+                             <property name="stock">gtk-refresh</property>
+                             <property name="icon_size">1</property>
+                             <property name="xalign">0.5</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xpad">0</property>
+                             <property name="ypad">0</property>
+                           </widget>
+                         </child>
+                       </widget>
+                     </child>
+
+                     <child>
+                       <widget class="GtkSeparatorMenuItem" id="separator3">
+                         <property name="visible">True</property>
+                       </widget>
+                     </child>
+
+                     <child>
+                       <widget class="GtkMenuItem" id="toolbar">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">_Toolbar</property>
+                         <property name="use_underline">True</property>
+                         <signal name="activate" handler="on_toolbar_activate" last_modification_time="Thu, 31 Aug 2006 09:57:31 GMT"/>
+                       </widget>
+                     </child>
+
+                     <child>
+                       <widget class="GtkMenuItem" id="statusbar">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">_Statusbar</property>
+                         <property name="use_underline">True</property>
+                         <signal name="activate" handler="on_statusbar_activate" last_modification_time="Thu, 31 Aug 2006 09:57:31 GMT"/>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
                </widget>
              </child>
 
          <property name="shadow_type">GTK_SHADOW_OUT</property>
 
          <child>
-           <widget class="GtkToolbar" id="toolbar1">
+           <widget class="GtkToolbar" id="toolbar">
              <property name="visible">True</property>
              <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
              <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
                  <property name="visible_horizontal">True</property>
                  <property name="visible_vertical">True</property>
                  <property name="is_important">False</property>
-                 <signal name="clicked" handler="on_toolbutton_refresh_clicked" last_modification_time="Wed, 16 Aug 2006 03:30:49 GMT"/>
+                 <signal name="clicked" handler="on_refresh_activate" last_modification_time="Thu, 31 Aug 2006 09:59:24 GMT"/>
+               </widget>
+               <packing>
+                 <property name="expand">False</property>
+                 <property name="homogeneous">True</property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkToolButton" id="toolbutton_showboard">
+                 <property name="visible">True</property>
+                 <property name="label" translatable="yes">Board</property>
+                 <property name="use_underline">True</property>
+                 <property name="stock_id">gtk-go-up</property>
+                 <property name="visible_horizontal">True</property>
+                 <property name="visible_vertical">True</property>
+                 <property name="is_important">False</property>
+                 <signal name="clicked" handler="on_show_board_activate" last_modification_time="Thu, 31 Aug 2006 10:08:27 GMT"/>
                </widget>
                <packing>
                  <property name="expand">False</property>
                  <property name="visible_horizontal">True</property>
                  <property name="visible_vertical">True</property>
                  <property name="is_important">False</property>
-                 <signal name="clicked" handler="on_toolbutton_compose_clicked" last_modification_time="Fri, 25 Aug 2006 21:52:37 GMT"/>
+                 <signal name="clicked" handler="on_compose_activate" last_modification_time="Thu, 31 Aug 2006 09:59:12 GMT"/>
                </widget>
                <packing>
                  <property name="expand">False</property>
   </child>
 
   <child internal-child="appbar">
-    <widget class="GnomeAppBar" id="appbar1">
+    <widget class="GnomeAppBar" id="appbar">
       <property name="visible">True</property>
       <property name="has_progress">True</property>
       <property name="has_status">True</property>