gyrus r318 - in branches/gyrus-python: . src src/glade
- From: avaldes svn gnome org
- To: svn-commits-list gnome org
- Subject: gyrus r318 - in branches/gyrus-python: . src src/glade
- Date: Fri, 18 Jan 2008 17:16:09 +0000 (GMT)
Author: avaldes
Date: Fri Jan 18 17:16:09 2008
New Revision: 318
URL: http://svn.gnome.org/viewvc/gyrus?rev=318&view=rev
Log:
Added:
branches/gyrus-python/src/gyrus_find.py
branches/gyrus-python/src/gyrus_print.py
Modified:
branches/gyrus-python/ChangeLog
branches/gyrus-python/TODO
branches/gyrus-python/setup.py
branches/gyrus-python/src/glade/find.glade
branches/gyrus-python/src/gyrus.py
branches/gyrus-python/src/gyrus_constant.py
Modified: branches/gyrus-python/TODO
==============================================================================
--- branches/gyrus-python/TODO (original)
+++ branches/gyrus-python/TODO Fri Jan 18 17:16:09 2008
@@ -1,3 +1,2 @@
- generate the reports
- translate to other languages
-- search mailbox
Modified: branches/gyrus-python/setup.py
==============================================================================
--- branches/gyrus-python/setup.py (original)
+++ branches/gyrus-python/setup.py Fri Jan 18 17:16:09 2008
@@ -25,5 +25,6 @@
'src/gyrus_constant.py',
'src/gyrus_session.py',
'src/gyrus_acl.py',
- 'src/gyrus_admin_mailbox.py']
+ 'src/gyrus_admin_mailbox.py',
+ 'src/gyrus_find.py']
)
Modified: branches/gyrus-python/src/glade/find.glade
==============================================================================
--- branches/gyrus-python/src/glade/find.glade (original)
+++ branches/gyrus-python/src/glade/find.glade Fri Jan 18 17:16:09 2008
@@ -1,167 +1,124 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
<glade-interface>
-
-<widget class="GtkDialog" id="dialog_find">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Find</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">True</property>
- <property name="resizable">False</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="has_separator">True</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox4">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area4">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="button26">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-close</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-7</property>
- <signal name="clicked" handler="on_button26_clicked" object="dialog_find" last_modification_time="Sun, 21 Nov 2004 16:21:00 GMT"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="button27">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-find</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">0</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox_find">
- <property name="border_width">10</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkHBox" id="hbox23">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">10</property>
-
- <child>
- <widget class="GtkLabel" id="label36">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Search for:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkComboBoxEntry" id="comboboxentry_mailbox">
- <property name="visible">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkCheckButton" id="checkbutton_entire_word">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Match _entire word only</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="padding">5</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkCheckButton" id="checkbutton_wrap_around">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">_Wrap around</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">True</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="padding">5</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
+ <widget class="GtkDialog" id="dialog_find">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Find</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox4">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkVBox" id="vbox_find">
+ <property name="visible">True</property>
+ <property name="border_width">10</property>
+ <child>
+ <widget class="GtkHBox" id="hbox23">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label36">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Search for:</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBoxEntry" id="comboboxentry_mailbox">
+ <property name="visible">True</property>
+ <child internal-child="entry">
+ <widget class="GtkEntry" id="comboboxentry-entry1">
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="checkbutton_entire_word">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Match _entire word only</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="checkbutton_wrap_around">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Wrap around</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area4">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="button_find_close">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-7</property>
+ <signal name="clicked" handler="on_button26_clicked" object="dialog_find"/>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button_find_find">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="label">gtk-find</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
Modified: branches/gyrus-python/src/gyrus.py
==============================================================================
--- branches/gyrus-python/src/gyrus.py (original)
+++ branches/gyrus-python/src/gyrus.py Fri Jan 18 17:16:09 2008
@@ -14,6 +14,8 @@
import gyrus_session
import gyrus_acl
import gyrus_admin_mailbox
+import gyrus_find
+import gyrus_print
gettext.bindtextdomain(APPNAME,DIRLOCALE)
gettext.textdomain(APPNAME)
@@ -118,9 +120,9 @@
self.actiongroup_server.add_actions([
('AddMailbox', gtk.STOCK_ADD, _('Add mailbox'),None, _('Add a mailbox under the one selected'), self.on_addmailbox_action),
- ('Find', gtk.STOCK_FIND, _('Find mailbox'),None, _('Search for a mailbox in current server'), self.tmp),
+ ('Find', gtk.STOCK_FIND, _('Find mailbox'),None, _('Search for a mailbox in current server'), self.on_find_action),
('Refresh', gtk.STOCK_REFRESH, None,'<control>R', _('Refresh the mailbox list'), self.on_refresh_action),
- ('Report', gtk.STOCK_INDEX, _('Create report'),None, _('Create report of users with quota problems'), self.tmp),
+ ('Report', gtk.STOCK_INDEX, _('Create report'),None, _('Create report of users with quota problems'), self.on_report_action),
])
self.actiongroup_mailbox.add_actions([
@@ -159,6 +161,7 @@
# create notebook
self.notebook = gtk.Notebook()
+ self.notebook.connect('switch-page',self.on_notebook_switch_page)
vbox.pack_start (self.notebook, False)
vbox.set_child_packing (self.notebook,True,True,0,gtk.PACK_START)
@@ -328,6 +331,14 @@
admin = self.imap_server[table]
return admin
+ def on_report_action (self,action):
+ admin = self.get_current_gyrus_admin()
+ gyrus_print.show_dialog_print(admin)
+
+
+ def on_find_action (self,action):
+ gyrus_find.load_page_find(self)
+
def on_refresh_action (self,action):
admin = self.get_current_gyrus_admin()
@@ -414,9 +425,47 @@
def on_button_page_clicked (self,button):
page = self.notebook.get_current_page()
- ###page = self.notebook.page_num(widget)
self.notebook.remove_page(page)
+ page = self.notebook.get_current_page()
+
+ if page < 0:
+ self.actiongroup_window.set_sensitive (True)
+ self.actiongroup_server.set_sensitive (False)
+ self.actiongroup_mailbox.set_sensitive (False)
+ self.actiongroup_acl.set_sensitive (False)
+ else:
+ admin = self.get_current_gyrus_admin()
+ self.verify_sensitive_actiongroup(admin)
+
+
+ def on_notebook_switch_page(self,notebook,page,page_num):
+ print "switch"
+
+ admin = self.get_current_gyrus_admin()
+ self.verify_sensitive_actiongroup (admin)
+
+
+ def verify_sensitive_actiongroup (self,admin):
+ #self.actiongroup_window.set_sensitive (True)
+ #self.actiongroup_server.set_sensitive (True)
+
+ selection = admin.treeview_users.get_selection()
+ model,iter = selection.get_selected()
+
+ if iter:
+ self.actiongroup_mailbox.set_sensitive (True)
+ else:
+ self.actiongroup_mailbox.set_sensitive (False)
+
+ selection = admin.treeview_acl.get_selection()
+ model,iter = selection.get_selected()
+ if iter:
+ self.actiongroup_acl.set_sensitive (True)
+ else:
+ self.actiongroup_acl.set_sensitive (False)
+
+
def load_table_page (self):
glade_file = gtk.glade.XML (DIRGYRUS + "glade/page.glade","table_page",None)
Modified: branches/gyrus-python/src/gyrus_constant.py
==============================================================================
--- branches/gyrus-python/src/gyrus_constant.py (original)
+++ branches/gyrus-python/src/gyrus_constant.py Fri Jan 18 17:16:09 2008
@@ -18,6 +18,9 @@
DEFAULT_WIDTH = 750
DEFAULT_HIGH = 550
+# for printing
+WIDTH_LINE = 1
+
# for model of sessions
COLUMN_NAME = 0
COLUMN_IP = 1
@@ -87,6 +90,8 @@
<separator/>
<toolitem action="Refresh"/>
<separator/>
+ <toolitem action="Report"/>
+ <separator/>
<toolitem action="Quit"/>
</placeholder>
</toolbar>
Added: branches/gyrus-python/src/gyrus_find.py
==============================================================================
--- (empty file)
+++ branches/gyrus-python/src/gyrus_find.py Fri Jan 18 17:16:09 2008
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+import pygtk
+pygtk.require('2.0')
+import gtk
+import gtk.glade
+import gettext
+import gnome
+
+from gyrus_constant import *
+
+gettext.bindtextdomain(APPNAME,DIRLOCALE)
+gettext.textdomain(APPNAME)
+_ = gettext.gettext
+
+gtk.glade.bindtextdomain(APPNAME,DIRLOCALE)
+gtk.glade.textdomain(APPNAME)
+
+
+def load_page_find (self):
+ glade_file = gtk.glade.XML (DIRGYRUS + "glade/find.glade",None,None)
+
+ self.dialog_find = glade_file.get_widget ("dialog_find")
+ self.comboboxentry_mailbox = glade_file.get_widget ("comboboxentry_mailbox")
+ self.checkbutton_entire_word = glade_file.get_widget ("checkbutton_entire_word")
+ self.checkbutton_wrap_around = glade_file.get_widget ("checkbutton_wrap_around")
+ self.button_find_close = glade_file.get_widget ("button_find_close")
+ self.button_find_find = glade_file.get_widget ("button_find_find")
+
+ self.button_find_close.connect ("clicked",on_button_find_close_clicked,self)
+ self.button_find_find.connect ("clicked",on_button_find_find_clicked,self)
+
+ self.dialog_find.show_all()
+
+def on_button_find_close_clicked (button,self):
+ self.dialog_find.destroy()
+
+def on_button_find_find_clicked (button,self):
+ admin = self.get_current_gyrus_admin()
+ key = self.comboboxentry_mailbox.get_active_text().strip()
+
+ more_mailboxes = None
+ wrap_around = None
+ search_from_beginning = None
+
+ if self.checkbutton_entire_word.get_active():
+ mode = "MODE_ENTIRE_WORD"
+ else:
+ mode = "MODE_ANY"
+
+ wrap_around = self.checkbutton_wrap_around.get_active()
+
+ selection = admin.treeview_users.get_selection()
+ model,iter = selection.get_selected()
+
+ # If no item is selected, start the search from the begin
+ if not iter:
+ iter = model.get_iter_first()
+ search_from_beginning = True
+ else:
+ iter = model.iter_next(iter)
+
+ # end of items
+ if not iter:
+ iter = model.get_iter_first()
+
+ search_from_beginning = False
+
+ while True:
+ value = model.get(iter,COLUMN_MAILBOX)
+
+ if mode == "MODE_ANY":
+ res = value[0].find(key)
+ if res >= 0:
+ found = True
+ else:
+ found = False
+ else:
+ if value[0] == key:
+ found = True
+ else:
+ found = False
+
+ if found:
+ selection = admin.treeview_users.get_selection()
+ selection.select_iter(iter)
+ path = model.get_path(iter)
+ admin.treeview_users.set_cursor(path,None,False)
+
+
+ # if 'wrap around' mode is selected allows starting over again
+ iter = model.iter_next(iter)
+ if iter:
+ more_mailboxes = True
+ else:
+ more_mailboxes = False
+
+ if not more_mailboxes and wrap_around and not search_from_beginning:
+ iter = model.get_iter_first()
+ more_mailboxes = True
+ search_from_beginning = True
+
+ if not found and more_mailboxes:
+ pass
+ else:
+ break
+
+ if not found:
+ self.show_message (_("The text was not found in the mailbox list."),gtk.MESSAGE_INFO)
Added: branches/gyrus-python/src/gyrus_print.py
==============================================================================
--- (empty file)
+++ branches/gyrus-python/src/gyrus_print.py Fri Jan 18 17:16:09 2008
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+import pygtk
+pygtk.require('2.0')
+import gtk
+import cairo
+import pango
+import gettext
+import gyrus_admin_mailbox
+
+from gyrus_constant import *
+
+gettext.bindtextdomain(APPNAME,DIRLOCALE)
+gettext.textdomain(APPNAME)
+_ = gettext.gettext
+
+gtk.glade.bindtextdomain(APPNAME,DIRLOCALE)
+gtk.glade.textdomain(APPNAME)
+
+def show_dialog_print(admin):
+ window = gtk.Window()
+ window.connect("destroy",gtk.main_quit)
+
+ op = gtk.PrintOperation()
+ settings = gtk.PrintSettings()
+ op.set_print_settings(settings)
+ op.set_n_pages(1)
+ op.set_unit(gtk.UNIT_MM)
+ op.connect("draw_page",draw_page,admin)
+ #op.connect("done",gtk.main_quit)
+
+ response = op.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG)
+
+ if response == gtk.PRINT_OPERATION_RESULT_APPLY:
+ settings = op.get_print_settings()
+
+
+def draw_page(PrintOperation,PrintContext,Page,admin):
+ context = PrintContext.get_cairo_context()
+ width = PrintContext.get_width()
+
+ page_setup = PrintContext.get_page_setup()
+ left_margin = page_setup.get_left_margin(gtk.UNIT_MM)
+ right_margin = page_setup.get_right_margin(gtk.UNIT_MM)
+ top_margin = page_setup.get_top_margin(gtk.UNIT_MM)
+ page_width = page_setup.get_page_width(gtk.UNIT_MM)
+ x = left_margin
+
+ layout = PrintContext.create_pango_layout()
+ desc = pango.FontDescription("Sans 10")
+ layout.set_font_description(desc)
+
+ # print header
+ print_header(context,layout,x,page_width,right_margin,top_margin)
+
+ model = admin.treeview_users.get_model()
+
+ y = top_margin + 8
+
+ iter = model.get_iter_first()
+ while iter:
+ mb = model.get(iter,COLUMN_MAILBOX)
+ res,msg,free,quota = gyrus_admin_mailbox.get_quota_of_mailbox (admin,mb[0])
+ print_string(context,layout,x,y,mb[0])
+
+ iter = model.iter_next(iter)
+ y = y + 4
+
+
+def print_line(context,width_line,x,width,y):
+ context.move_to(x,y)
+ context.line_to(width,y)
+ context.set_line_join(cairo.LINE_JOIN_ROUND)
+ context.set_line_width(width_line)
+ context.stroke()
+
+def print_string(context,layout,x,y,string):
+ context.move_to(x,y)
+ layout.set_text(string)
+ context.show_layout(layout)
+
+def print_header(context,layout,x,page_width,right_margin,top_margin):
+ print_line(context,WIDTH_LINE,x,page_width - right_margin,top_margin)
+ print_string(context,layout,x,top_margin + 1,_("Mailbox"))
+ print_string(context,layout,x + 40,top_margin + 1,_("Quota assigned"))
+ print_string(context,layout,x + 80,top_margin + 1,_("Quota used"))
+ print_string(context,layout,x + 120,top_margin + 1,_("Quota free"))
+ print_string(context,layout,x + 150,top_margin + 1,_("Status"))
+ print_line(context,WIDTH_LINE,x,page_width - right_margin,top_margin + 6)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]