Changeset - f22bd3eead48
[Not reviewed]
0 2 0
Joar Wandborg - 10 years ago 2013-12-17 13:11:59
joar@wandborg.se
[gtk] status_description => activity_description
2 files changed with 35 insertions and 21 deletions:
0 comments (0 inline, 0 general)
accounting/gtkclient.py
Show inline comments
 
import sys
 
import logging
 
import threading
 
import pkg_resources
 

	
 
from functools import wraps
 
from datetime import datetime
 

	
 
from gi.repository import Gtk
 
from gi.repository import GLib
 
from gi.repository import GObject
 

	
 
from accounting.client import Client
 

	
 
_log = logging.getLogger(__name__)
 

	
 

	
 
def indicate_activity(func_or_str):
 
    description = None
 

	
 
    def decorator(func):
 
        @wraps(func)
 
        def wrapper(self, *args, **kw):
 
            self.status_description.set_text(description)
 
            self.activity_description.set_text(description)
 
            self.activity_indicator.show()
 
            self.activity_indicator.start()
 

	
 
            return func(self, *args, **kw)
 

	
 
        return wrapper
 

	
 
    if callable(func_or_str):
 
        description = 'Working'
 
        return decorator(func_or_str)
 
    else:
 
        description = func_or_str
 
        return decorator
 

	
 

	
 
def indicate_activity_done(func):
 
    @wraps(func)
 
    def wrapper(self, *args, **kw):
 
        self.status_description.set_text('')
 
        self.activity_description.set_text('')
 
        self.activity_indicator.stop()
 
        self.activity_indicator.hide()
 

	
 
        return func(self, *args, **kw)
 

	
 
    return wrapper
 

	
 

	
 
class AccountingApplication:
 
    def __init__(self):
 
        #Gtk.Window.__init__(self, title='Accounting Client')
 

	
 
        self.client = Client()
 

	
 
        self.load_ui(pkg_resources.resource_filename(
 
            'accounting', 'res/client-ui.glade'))
 

	
 
        self.about_dialog.set_transient_for(self.accounting_window)
 

	
 
        self.accounting_window.connect('delete-event', Gtk.main_quit)
 
        self.accounting_window.set_border_width(0)
 
        self.accounting_window.set_default_geometry(640, 360)
 

	
 
        self.accounting_window.show_all()
accounting/res/client-ui.glade
Show inline comments
 
<?xml version="1.0" encoding="UTF-8"?>
 
<interface>
 
  <!-- interface-requires gtk+ 3.0 -->
 
  <object class="GtkListStore" id="posting_store">
 
    <columns>
 
      <!-- column-name Account -->
 
      <column type="gchararray"/>
 
      <!-- column-name Amount -->
 
      <column type="gchararray"/>
 
      <!-- column-name Symbol -->
 
      <column type="gchararray"/>
 
    </columns>
 
  </object>
 
  <object class="GtkAction" id="show_about">
 
    <property name="label" translatable="yes">About</property>
 
    <signal name="activate" handler="on_show_about_activate" swapped="no"/>
 
  </object>
 
  <object class="GtkWindow" id="accounting_window">
 
    <property name="can_focus">False</property>
 
    <accel-groups>
 
      <group name="transaction_accel_group"/>
 
    </accel-groups>
 
    <child>
 
      <object class="GtkBox" id="main">
 
        <property name="visible">True</property>
 
        <property name="can_focus">False</property>
 
        <property name="orientation">vertical</property>
 
        <child>
 
          <object class="GtkMenuBar" id="menu">
 
            <property name="visible">True</property>
 
            <property name="can_focus">False</property>
 
            <child>
 
              <object class="GtkMenuItem" id="menu_file">
 
                <property name="visible">True</property>
 
                <property name="can_focus">False</property>
 
                <property name="label" translatable="yes">_File</property>
 
                <property name="use_underline">True</property>
 
                <signal name="activate" handler="on_menuitem1_activate" swapped="no"/>
 
                <child type="submenu">
 
                  <object class="GtkMenu" id="get_transactions">
 
                    <property name="visible">True</property>
...
 
@@ -141,48 +127,49 @@
 
                    <child>
 
                      <object class="GtkCellRendererText" id="payee_renderer"/>
 
                      <attributes>
 
                        <attribute name="text">2</attribute>
 
                      </attributes>
 
                    </child>
 
                  </object>
 
                </child>
 
              </object>
 
              <packing>
 
                <property name="resize">True</property>
 
                <property name="shrink">True</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkBox" id="transaction_detail">
 
                <property name="visible">True</property>
 
                <property name="can_focus">False</property>
 
                <property name="orientation">vertical</property>
 
                <child>
 
                  <object class="GtkLabel" id="transaction_header">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <property name="ypad">18</property>
 
                    <property name="label" translatable="yes">January Licensing Fees</property>
 
                    <attributes>
 
                      <attribute name="scale" value="1.2"/>
 
                    </attributes>
 
                  </object>
 
                  <packing>
 
                    <property name="expand">False</property>
 
                    <property name="fill">False</property>
 
                    <property name="position">0</property>
 
                  </packing>
 
                </child>
 
                <child>
 
                  <object class="GtkTreeView" id="posting_view">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <property name="hexpand">True</property>
 
                    <property name="model">posting_store</property>
 
                    <property name="headers_clickable">False</property>
 
                    <property name="search_column">0</property>
 
                    <child>
 
                      <object class="GtkTreeViewColumn" id="posting_col_account">
 
                        <property name="title" translatable="yes">Account</property>
 
                        <child>
 
                          <object class="GtkCellRendererText" id="account_renderer"/>
 
                          <attributes>
...
 
@@ -217,96 +204,123 @@
 
                  <packing>
 
                    <property name="expand">True</property>
 
                    <property name="fill">True</property>
 
                    <property name="position">1</property>
 
                  </packing>
 
                </child>
 
              </object>
 
              <packing>
 
                <property name="resize">True</property>
 
                <property name="shrink">True</property>
 
              </packing>
 
            </child>
 
          </object>
 
          <packing>
 
            <property name="expand">True</property>
 
            <property name="fill">True</property>
 
            <property name="position">1</property>
 
          </packing>
 
        </child>
 
        <child>
 
          <object class="GtkBox" id="status_bar">
 
            <property name="visible">True</property>
 
            <property name="can_focus">False</property>
 
            <child>
 
              <placeholder/>
 
              <object class="GtkLabel" id="label1">
 
                <property name="visible">True</property>
 
                <property name="can_focus">False</property>
 
                <property name="ypad">2</property>
 
              </object>
 
              <packing>
 
                <property name="expand">False</property>
 
                <property name="fill">True</property>
 
                <property name="position">0</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkSpinner" id="activity_indicator">
 
                <property name="can_focus">False</property>
 
                <property name="margin_left">5</property>
 
                <property name="margin_right">5</property>
 
                <property name="margin_top">5</property>
 
                <property name="margin_bottom">5</property>
 
              </object>
 
              <packing>
 
                <property name="expand">False</property>
 
                <property name="fill">True</property>
 
                <property name="pack_type">end</property>
 
                <property name="position">1</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkLabel" id="status_description">
 
              <object class="GtkLabel" id="activity_description">
 
                <property name="can_focus">False</property>
 
                <property name="ypad">1</property>
 
                <property name="label" translatable="yes">Working...</property>
 
              </object>
 
              <packing>
 
                <property name="expand">False</property>
 
                <property name="fill">True</property>
 
                <property name="pack_type">end</property>
 
                <property name="position">2</property>
 
              </packing>
 
            </child>
 
          </object>
 
          <packing>
 
            <property name="expand">False</property>
 
            <property name="fill">True</property>
 
            <property name="position">2</property>
 
          </packing>
 
        </child>
 
      </object>
 
    </child>
 
  </object>
 
  <object class="GtkAboutDialog" id="about_dialog">
 
    <property name="can_focus">False</property>
 
    <property name="border_width">5</property>
 
    <property name="window_position">center-always</property>
 
    <property name="window_position">center-on-parent</property>
 
    <property name="destroy_with_parent">True</property>
 
    <property name="type_hint">dialog</property>
 
    <property name="type_hint">splashscreen</property>
 
    <property name="transient_for">accounting_window</property>
 
    <property name="program_name">Accounting Client</property>
 
    <property name="version">dev</property>
 
    <property name="website">http://gitorious.org/conservancy/accounting-api</property>
 
    <property name="website_label" translatable="yes">Source code</property>
 
    <property name="license_type">lgpl-2-1</property>
 
    <signal name="close" handler="on_about_dialog_close" swapped="no"/>
 
    <signal name="response" handler="on_about_dialog_response" swapped="no"/>
 
  </object>
 
  <object class="GtkListStore" id="posting_store">
 
    <columns>
 
      <!-- column-name Account -->
 
      <column type="gchararray"/>
 
      <!-- column-name Amount -->
 
      <column type="gchararray"/>
 
      <!-- column-name Symbol -->
 
      <column type="gchararray"/>
 
    </columns>
 
  </object>
 
  <object class="GtkAction" id="show_about">
 
    <property name="label" translatable="yes">About</property>
 
    <signal name="activate" handler="on_show_about_activate" swapped="no"/>
 
  </object>
 
  <object class="GtkAccelGroup" id="transaction_accel_group"/>
 
  <object class="GtkActionGroup" id="transaction_actions">
 
    <property name="accel_group">transaction_accel_group</property>
 
    <child>
 
      <object class="GtkAction" id="refresh">
 
        <property name="label" translatable="yes">Test</property>
 
        <signal name="activate" handler="on_transaction_refresh_activate" swapped="no"/>
 
      </object>
 
      <accelerator key="r" modifiers="GDK_CONTROL_MASK"/>
 
    </child>
 
  </object>
 
  <object class="GtkListStore" id="transaction_store">
 
    <columns>
 
      <!-- column-name ID -->
 
      <column type="gchararray"/>
 
      <!-- column-name Date -->
 
      <column type="gchararray"/>
 
      <!-- column-name Payee -->
 
      <column type="gchararray"/>
 
    </columns>
 
  </object>
 
</interface>
0 comments (0 inline, 0 general)