[tuxdroid-svn] r699 - in software/tux_framework/trunk: . SDK/gadget_maker bin libs
Status: Beta
Brought to you by:
ks156
From: remi <c2m...@c2...> - 2007-11-14 13:26:57
|
Author: remi Date: 2007-11-14 14:26:50 +0100 (Wed, 14 Nov 2007) New Revision: 699 Added: software/tux_framework/trunk/bin/ software/tux_framework/trunk/bin/README software/tux_framework/trunk/bin/frame software/tux_framework/trunk/bin/mgc2mgc software/tux_framework/trunk/bin/mgcep software/tux_framework/trunk/bin/pitch software/tux_framework/trunk/bin/window software/tux_framework/trunk/bin/x2x software/tux_framework/trunk/libs/DTW.py software/tux_framework/trunk/libs/GdgVoiceRec.py software/tux_framework/trunk/libs/_DTW.so Modified: software/tux_framework/trunk/SDK/gadget_maker/Template.tgf software/tux_framework/trunk/SDK/gadget_maker/tuxgagdetmaker.glade software/tux_framework/trunk/SDK/gadget_maker/tuxgagdetmaker.py software/tux_framework/trunk/libs/FWObject.py software/tux_framework/trunk/libs/GdgDebug.py software/tux_framework/trunk/libs/GdgDownload.py software/tux_framework/trunk/libs/GdgGuiUpdate.py software/tux_framework/trunk/libs/GdgObject.py software/tux_framework/trunk/libs/GdgThreads.py software/tux_framework/trunk/libs/GoogleTranslate.py software/tux_framework/trunk/libs/Languages.py software/tux_framework/trunk/libs/TGFCanvas.py software/tux_framework/trunk/libs/TGFParser.py software/tux_framework/trunk/libs/TGFormat.py software/tux_framework/trunk/libs/TextFilters.py software/tux_framework/trunk/libs/menu.py Log: Modified: software/tux_framework/trunk/SDK/gadget_maker/Template.tgf =================================================================== (Binary files differ) Modified: software/tux_framework/trunk/SDK/gadget_maker/tuxgagdetmaker.glade =================================================================== --- software/tux_framework/trunk/SDK/gadget_maker/tuxgagdetmaker.glade 2007-11-14 10:24:38 UTC (rev 698) +++ software/tux_framework/trunk/SDK/gadget_maker/tuxgagdetmaker.glade 2007-11-14 13:26:50 UTC (rev 699) @@ -51,7 +51,7 @@ <signal name="activate" handler="on_nouveau1_activate" last_modification_time="Mon, 10 Sep 2007 05:47:06 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image50"> + <widget class="GtkImage" id="image65"> <property name="visible">True</property> <property name="stock">gtk-new</property> <property name="icon_size">1</property> @@ -72,7 +72,7 @@ <signal name="activate" handler="on_ouvrir1_activate" last_modification_time="Mon, 10 Sep 2007 05:37:09 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image51"> + <widget class="GtkImage" id="image66"> <property name="visible">True</property> <property name="stock">gtk-open</property> <property name="icon_size">1</property> @@ -93,7 +93,7 @@ <signal name="activate" handler="on_ouvrir2_activate" last_modification_time="Mon, 10 Sep 2007 05:48:51 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image52"> + <widget class="GtkImage" id="image67"> <property name="visible">True</property> <property name="stock">gtk-open</property> <property name="icon_size">1</property> @@ -114,7 +114,7 @@ <signal name="activate" handler="on_enregistrer1_activate" last_modification_time="Sun, 23 Sep 2007 16:44:55 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image53"> + <widget class="GtkImage" id="image68"> <property name="visible">True</property> <property name="stock">gtk-save</property> <property name="icon_size">1</property> @@ -135,7 +135,7 @@ <signal name="activate" handler="on_enregistrer2_activate" last_modification_time="Mon, 10 Sep 2007 05:51:51 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image54"> + <widget class="GtkImage" id="image69"> <property name="visible">True</property> <property name="stock">gtk-save</property> <property name="icon_size">1</property> @@ -149,6 +149,27 @@ </child> <child> + <widget class="GtkImageMenuItem" id="recharger1"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Reload the TGF file</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_recharger1_activate" last_modification_time="Fri, 02 Nov 2007 08:31:54 GMT"/> + + <child internal-child="image"> + <widget class="GtkImage" id="image70"> + <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="separatormenuitem1"> <property name="visible">True</property> </widget> @@ -162,7 +183,7 @@ <signal name="activate" handler="on_execute1_activate" last_modification_time="Sun, 23 Sep 2007 18:09:15 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image55"> + <widget class="GtkImage" id="image71"> <property name="visible">True</property> <property name="stock">gtk-execute</property> <property name="icon_size">1</property> @@ -183,7 +204,7 @@ <signal name="activate" handler="on_stop1_activate" last_modification_time="Mon, 15 Oct 2007 08:43:14 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image56"> + <widget class="GtkImage" id="image72"> <property name="visible">True</property> <property name="stock">gtk-stop</property> <property name="icon_size">1</property> @@ -210,7 +231,7 @@ <signal name="activate" handler="on_quitter1_activate" last_modification_time="Sun, 23 Sep 2007 16:44:55 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image57"> + <widget class="GtkImage" id="image73"> <property name="visible">True</property> <property name="stock">gtk-quit</property> <property name="icon_size">1</property> @@ -228,11 +249,37 @@ </child> <child> - <widget class="GtkMenuItem" id="about"> + <widget class="GtkMenuItem" id="help1"> <property name="visible">True</property> - <property name="label" translatable="yes">About</property> + <property name="label" translatable="yes">_Help</property> <property name="use_underline">True</property> - <signal name="activate" handler="on_about_activate" last_modification_time="Mon, 10 Sep 2007 05:57:08 GMT"/> + <signal name="activate" handler="on_help1_activate" last_modification_time="Mon, 10 Sep 2007 05:57:08 GMT"/> + + <child> + <widget class="GtkMenu" id="help1_menu"> + + <child> + <widget class="GtkImageMenuItem" id="about1"> + <property name="visible">True</property> + <property name="label" translatable="yes">_About</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_about1_activate" last_modification_time="Tue, 13 Nov 2007 14:55:24 GMT"/> + + <child internal-child="image"> + <widget class="GtkImage" id="image74"> + <property name="visible">True</property> + <property name="stock">gtk-about</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> + </widget> + </child> </widget> </child> </widget> @@ -448,24 +495,6 @@ </child> <child> - <widget class="GtkButton" id="about_modify_button"> - <property name="width_request">80</property> - <property name="height_request">29</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Modify</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <signal name="clicked" handler="on_about_modify_button_clicked" last_modification_time="Sun, 23 Sep 2007 18:10:10 GMT"/> - </widget> - <packing> - <property name="x">104</property> - <property name="y">336</property> - </packing> - </child> - - <child> <widget class="GtkScrolledWindow" id="scrolledwindow3"> <property name="width_request">304</property> <property name="height_request">160</property> @@ -2343,6 +2372,249 @@ <property name="type">tab</property> </packing> </child> + + <child> + <widget class="GtkFrame" id="frame12"> + <property name="border_width">2</property> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + + <child> + <widget class="GtkAlignment" id="alignment12"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox12"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow12"> + <property name="width_request">500</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkFixed" id="fixed12"> + <property name="visible">True</property> + + <child> + <widget class="GtkLabel" id="label43"> + <property name="width_request">152</property> + <property name="height_request">16</property> + <property name="visible">True</property> + <property name="label" translatable="yes">Word string name:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</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> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="x">8</property> + <property name="y">0</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="vr_word_name_entry"> + <property name="width_request">160</property> + <property name="height_request">27</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="x">8</property> + <property name="y">16</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label44"> + <property name="width_request">160</property> + <property name="height_request">16</property> + <property name="visible">True</property> + <property name="label" translatable="yes">Word:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</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> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="x">8</property> + <property name="y">48</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="vr_word_entry"> + <property name="width_request">160</property> + <property name="height_request">27</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="x">8</property> + <property name="y">64</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="vr_add_button"> + <property name="width_request">160</property> + <property name="height_request">29</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Add</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_vr_add_button_clicked" last_modification_time="Fri, 09 Nov 2007 09:13:13 GMT"/> + </widget> + <packing> + <property name="x">8</property> + <property name="y">96</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="vr_delete_button"> + <property name="width_request">160</property> + <property name="height_request">29</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Delete</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_vr_delete_button_clicked" last_modification_time="Fri, 09 Nov 2007 09:14:05 GMT"/> + </widget> + <packing> + <property name="x">8</property> + <property name="y">128</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> + </child> + + <child> + <widget class="GtkLabel" id="label42"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Dictionary</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</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> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="tab_expand">False</property> + <property name="tab_fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label41"> + <property name="visible">True</property> + <property name="label" translatable="yes">Voice recognition</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> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> Modified: software/tux_framework/trunk/SDK/gadget_maker/tuxgagdetmaker.py =================================================================== --- software/tux_framework/trunk/SDK/gadget_maker/tuxgagdetmaker.py 2007-11-14 10:24:38 UTC (rev 698) +++ software/tux_framework/trunk/SDK/gadget_maker/tuxgagdetmaker.py 2007-11-14 13:26:50 UTC (rev 699) @@ -1,16 +1,30 @@ -#!/usr/bin/env python -# -*- coding: UTF8 -*- - -# Python module tuxgagdetmaker.py -# Autogenerated from tuxgagdetmaker.glade -# Generated on Sun Sep 23 20:15:21 2007 - -# Warning: Do not modify any context comment such as #-- -# They are required to keep user's code - +#!/usr/bin/python +# -*- coding: latin1 -*- +# ----------------------------------------------------------------------------- +# Tux Droid - Tux Gadget Maker +# Copyright (C) 2007 C2ME Sa <rem...@c2...> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ----------------------------------------------------------------------------- +# $Id: $ +# ----------------------------------------------------------------------------- import subprocess import time import thread +import threading import signal import os import sys @@ -26,12 +40,12 @@ from SimpleGladeApp import SimpleGladeApp from SimpleGladeApp import bindtextdomain -from GdgObject import * +from GdgObject import TGFormat, GdgDialog, GdgDialogQuestion import config app_name = "tuxgagdetmaker" -app_version = "0.0.1" +app_version = "0.1.1" glade_dir = "" locale_dir = "" @@ -74,6 +88,7 @@ self.last_opened_file = '' self.get_widget("codes_editor_entry").set_text(config.editor) self.fw_process = None + self.fw_process_mutex = threading.Lock() self.fw_loaded = False self.get_widget('stop1').set_sensitive(False) @@ -97,6 +112,9 @@ sys.exit(0) def on_nouveau1_activate(self, widget, *args): + if self.fw_process != None: + GdgDialog('Tux Gadget Maker', 'Please stop the execution of the gadget before!') + return # Make the file chooser f_c = gtk.FileChooserDialog('Select a TGF file ...', buttons = ( gtk.STOCK_CANCEL, @@ -118,6 +136,8 @@ if filename.lower().rfind('.tgf') == -1: filename = filename + '.tgf' f_c.destroy() + if filename == '': + return # Create the gadget and load it if not os.path.exists(filename): shutil.copy(TEMPLATE_PATH, filename) @@ -125,6 +145,9 @@ self.load_gadget(filename) def on_ouvrir1_activate(self, widget, *args): + if self.fw_process != None: + GdgDialog('Tux Gadget Maker', 'Please stop the execution of the gadget before!') + return # Make the file chooser f_c = gtk.FileChooserDialog('Select a TGF file ...', buttons = ( gtk.STOCK_CANCEL, @@ -150,6 +173,9 @@ self.load_gadget(filename) def on_ouvrir2_activate(self, widget, *args): + if self.fw_process != None: + GdgDialog('Tux Gadget Maker', 'Please stop the execution of the gadget before!') + return # Make the file chooser f_c = gtk.FileChooserDialog('Select a TGF directory ...', buttons = ( gtk.STOCK_CANCEL, @@ -175,20 +201,24 @@ def on_enregistrer2_activate(self, widget, *args): self.save_gadget_dir() + + def on_recharger1_activate(self, widget, *args): + self.reload_gadget() def on_execute1_activate(self, widget, *args): - if not self.fw_loaded: - self.execute_gadget() + self.execute_gadget() def on_stop1_activate(self, widget, *args): - if self.fw_loaded: - self.kill_gadget() + self.kill_gadget() def on_quitter1_activate(self, widget, *args): + if self.fw_process != None: + GdgDialog('Tux Gadget Maker', 'Please stop the execution of the gadget before!') + return self.get_widget("window1").destroy() - def on_a_propos1_activate(self, widget, *args): - print "on_À_propos1_activate called with self.%s" % widget.get_name() + def on_about1_activate(self, widget, *args): + GdgDialog('Tux Gadget Maker', 'Tux Gadget Maker V%s\n\n(C) 2007 C2ME Sa\nre...@c2...' %app_version, False, True) def on_about_modify_button_clicked(self, widget, *args): name = self.get_widget("about_name_entry").get_text() @@ -210,10 +240,12 @@ self.load_general_settings() def on_params_delete_button_clicked(self, widget, *args): - name = self.get_widget("params_name_entry").get_text() - if name in self.TGF_file.parser.settings.get_parameters_list(): - self.TGF_file.parser.settings.delete_parameter(name) - self.load_params_settings() + def on_yes_action(): + name = self.get_widget("params_name_entry").get_text() + if name in self.TGF_file.parser.settings.get_parameters_list(): + self.TGF_file.parser.settings.delete_parameter(name) + self.load_params_settings() + GdgDialogQuestion('Tux Gadget Maker', 'This action will definitively remove this parameter ! Continue ?', on_yes_action) def on_params_add_button_clicked(self, widget, *args): name = self.get_widget("params_name_entry").get_text() @@ -243,16 +275,19 @@ self.load_languages_strings() def on_strings_lg_delete_button_clicked(self, widget, *args): - model = self.get_widget("strings_lang_comboboxentry").get_model() - i = self.get_widget("strings_lang_comboboxentry").get_active() - lang = model[i][0] - idxb = lang.find('<') + 1 - idxe = lang.find('>') - lang_country = lang[idxb:idxe] - if lang_country in self.TGF_file.parser.i18n.get_languages_list(): - if lang_country != 'en_US': - self.TGF_file.parser.i18n.delete_language(lang_country) - self.load_languages_strings() + def on_yes_action(): + model = self.get_widget("strings_lang_comboboxentry").get_model() + i = self.get_widget("strings_lang_comboboxentry").get_active() + lang = model[i][0] + idxb = lang.find('<') + 1 + idxe = lang.find('>') + lang_country = lang[idxb:idxe] + if lang_country in self.TGF_file.parser.i18n.get_languages_list(): + if lang_country != 'en_US': + self.TGF_file.parser.i18n.delete_language(lang_country) + self.load_languages_strings() + + GdgDialogQuestion('Tux Gadget Maker', 'This action will definitively remove this language ! Continue ?', on_yes_action) def to_legal_string(self, message): if len(message) < 2: @@ -275,10 +310,13 @@ self.load_message_strings(self.current_lang_country) def on_strings_st_delete_button_clicked(self, widget, *args): - name = self.get_widget("strings_st_name_entry").get_text() - if name in self.TGF_file.parser.i18n.get_messages_list(): - self.TGF_file.parser.i18n.delete_message(name) - self.load_message_strings(self.current_lang_country) + def on_yes_action(): + name = self.get_widget("strings_st_name_entry").get_text() + if name in self.TGF_file.parser.i18n.get_messages_list(): + self.TGF_file.parser.i18n.delete_message(name) + self.load_message_strings(self.current_lang_country) + + GdgDialogQuestion('Tux Gadget Maker', 'This action will definitively remove this message ! Continue ?', on_yes_action) def on_strings_st_add_button_clicked(self, widget, *args): name = self.get_widget("strings_st_name_entry").get_text() @@ -311,8 +349,10 @@ self.load_guis_icons() def on_icons_delete_button_clicked(self, widget, *args): - self.TGF_file.parser.icons.remove(self.last_icon) - self.load_guis_icons() + def on_yes_action(): + self.TGF_file.parser.icons.remove(self.last_icon) + self.load_guis_icons() + GdgDialogQuestion('Tux Gadget Maker', 'This action will definitively remove this icon ! Continue ?', on_yes_action) def on_sounds_filechooserbutton_update_preview(self, widget, *args): filename = widget.get_filename() @@ -320,8 +360,10 @@ self.load_guis_sounds() def on_sounds_delete_button_clicked(self, widget, *args): - self.TGF_file.parser.sounds.remove(self.last_sound) - self.load_guis_sounds() + def on_yes_action(): + self.TGF_file.parser.sounds.remove(self.last_sound) + self.load_guis_sounds() + GdgDialogQuestion('Tux Gadget Maker', 'This action will definitively remove this sound ! Continue ?', on_yes_action) def on_codes_c_edit_button_clicked(self, widget, *args): my_path = self.TGF_file.parser.tgf_path + self.last_codes_common @@ -336,8 +378,10 @@ self.load_codes_libs() def on_codes_l_delete_button_clicked(self, widget, *args): - self.TGF_file.parser.libs.remove(self.last_codes_lib) - self.load_codes_libs() + def on_yes_action(): + self.TGF_file.parser.libs.remove(self.last_codes_lib) + self.load_codes_libs() + GdgDialogQuestion('Tux Gadget Maker', 'This action will definitively remove this library ! Continue ?', on_yes_action) def on_codes_l_edit_button_clicked(self, widget, *args): my_path = self.TGF_file.parser.tgf_path + '/Scripts/Python/' + self.last_codes_lib @@ -345,7 +389,23 @@ if os.path.exists(my_path): cmd = edit % my_path thread.start_new_thread(os.system,(cmd,)) + + def on_vr_delete_button_clicked(self, widget, *args): + def on_yes_action(): + name = self.get_widget("vr_word_entry").get_text() + if "vr_%s" % name in self.TGF_file.parser.i18n.get_messages_list(): + self.remove_from_dictionary(name) + self.delete_word_string(name) + self.load_dictionary() + GdgDialogQuestion('Tux Gadget Maker', 'This action will definitively remove this word ! Continue ?', on_yes_action) + def on_vr_add_button_clicked(self, widget, *args): + name = self.get_widget("vr_word_entry").get_text() + if not "vr_%s" % name in self.TGF_file.parser.i18n.get_messages_list(): + self.insert_in_dictionary(name) + self.insert_word_string(name) + self.load_dictionary() + def create_tree_views(self): """ Create the tree viewers @@ -476,6 +536,17 @@ self.codes_libs.set_reorderable(True) self.get_widget("scrolledwindow10").add(self.codes_libs) self.get_widget("scrolledwindow10").show_all() + # Dictionary + word_column = gtk.TreeViewColumn('Word') + word_cell = gtk.CellRendererText() + word_column.pack_start(word_cell, True) + word_column.add_attribute(word_cell, 'text', 0) + self.word_ls = gtk.ListStore(str) + self.word = gtk.TreeView(self.word_ls) + self.word.append_column(word_column) + self.word.set_reorderable(True) + self.get_widget("scrolledwindow12").add(self.word) + self.get_widget("scrolledwindow12").show_all() def load_gadget(self, path): """ @@ -532,6 +603,10 @@ self.load_codes_libs() self.codes_libs.get_selection().connect("changed", self.on_codes_libs_select) + # Load dictionary + self.load_dictionary() + self.word.get_selection().connect("changed", + self.on_word_select) def on_lang_viewer_select(self, obj): path = obj.get_selected_rows() @@ -613,11 +688,24 @@ path = path[1][0][0] name = self.codes_libs_ls[path][0] self.last_codes_lib = name + + def on_word_select(self, obj): + path = obj.get_selected_rows() + if len(path[1]) > 0: + path = path[1][0][0] + name = self.word_ls[path][0] + self.get_widget("vr_word_entry").set_text(name) + self.get_widget("vr_word_name_entry").set_text("vr_%s" % name) def load_general_settings(self): general_lst = self.TGF_file.parser.settings.get_generals_list() self.settings_general_ls.clear() + + sorted_list = [] for general in general_lst: + sorted_list.append(general) + sorted_list.sort() + for general in sorted_list: name = general value = self.TGF_file.parser.settings.get_general_value(general) if str(type(value)) == "<type 'str'>": @@ -711,25 +799,114 @@ if lib_path.lower().find('.py') != -1: if lib_path.lower().find('.pyp') == -1: self.codes_libs_ls.append([lib_path]) + + def insert_word_string(self, word): + name = "vr_%s" % word + value = self.to_legal_string(word) + value = self.__interpret_value(value) + if not name in self.TGF_file.parser.i18n.get_messages_list(): + self.TGF_file.parser.i18n.add_message(name, value) + self.load_message_strings(self.current_lang_country) + + def delete_word_string(self, word): + name = "vr_%s" % word + if name in self.TGF_file.parser.i18n.get_messages_list(): + self.TGF_file.parser.i18n.delete_message(name) + self.load_message_strings(self.current_lang_country) + + def load_dictionary(self): + dict_path = self.TGF_file.parser.tgf_path + '/Data/rc_dict' + self.word_ls.clear() + if os.path.isfile(dict_path): + f = open(dict_path, 'r') + st = f.read() + f.close() + global words + words = [] + exec str(st) in globals() + for word in words: + self.word_ls.append([word[0]]) + self.insert_word_string(word[0]) + + def insert_in_dictionary(self, new_word): + dict_path = self.TGF_file.parser.tgf_path + '/Data/rc_dict' + global words + words = [] + if os.path.isfile(dict_path): + f = open(dict_path, 'r') + st = f.read() + f.close() + exec str(st) in globals() + b = False + for word in words: + if word[0] == new_word: + b = True + break + if not b: + words.append([new_word, []]) + st = 'words=%s' % str(words) + f = open(dict_path, 'w') + f.write(st) + f.close() + + def remove_from_dictionary(self, new_word): + dict_path = self.TGF_file.parser.tgf_path + '/Data/rc_dict' + global words + words = [] + if os.path.isfile(dict_path): + f = open(dict_path, 'r') + st = f.read() + f.close() + exec str(st) in globals() + for i, word in enumerate(words): + if word[0] == new_word: + words.pop(i) + break + st = 'words=%s' % str(words) + f = open(dict_path, 'w') + f.write(st) + f.close() def close_gadget(self): + if self.fw_process != None: + GdgDialog('Tux Gadget Maker', 'Please stop the execution of the gadget before!') + return if self.TGF_file != None: self.TGF_file.mode = 'r' self.TGF_file.close() def save_gadget(self): + if self.fw_process != None: + GdgDialog('Tux Gadget Maker', 'Please stop the execution of the gadget before!') + return if self.TGF_file != None: + self.on_about_modify_button_clicked(None) tgf_path = self.TGF_file.c_path self.TGF_file.mode = 'a' self.TGF_file.close(True) def save_gadget_dir(self): + if self.fw_process != None: + GdgDialog('Tux Gadget Maker', 'Please stop the execution of the gadget before!') + return if self.TGF_file != None: + self.on_about_modify_button_clicked(None) tgf_path = self.TGF_file.d_path self.TGF_file.mode = 'a' self.TGF_file.close(True) + + def reload_gadget(self): + if self.fw_process != None: + GdgDialog('Tux Gadget Maker', 'Please stop the execution of the gadget before!') + return + if self.TGF_file != None: + tgf_path = self.TGF_file.c_path + self.save_gadget() + self.load_gadget(tgf_path) def execute_gadget(self): + if self.fw_process != None: + return def check_fw_active(): while True: try: @@ -741,7 +918,9 @@ time.sleep(0.1) self.get_widget('execute1').set_sensitive(True) self.get_widget('stop1').set_sensitive(False) - self.fw_loaded = False + self.fw_process_mutex.acquire() + self.fw_process = None + self.fw_process_mutex.release() if self.TGF_file != None: self.save_gadget() @@ -754,10 +933,17 @@ thread.start_new_thread(check_fw_active, ()) def kill_gadget(self): - if self.fw_process != None: + self.fw_process_mutex.acquire() + auth = self.fw_process + self.fw_process_mutex.release() + if auth != None: try: os.kill(self.fw_process.pid, signal.SIGKILL) os.waitpid(-1, os.WNOHANG) + time.sleep(0.5) + self.get_widget('execute1').set_sensitive(True) + self.get_widget('stop1').set_sensitive(False) + self.fw_process = None except: pass Added: software/tux_framework/trunk/bin/README =================================================================== --- software/tux_framework/trunk/bin/README (rev 0) +++ software/tux_framework/trunk/bin/README 2007-11-14 13:26:50 UTC (rev 699) @@ -0,0 +1,43 @@ +The following binary list is a part of Speech Signal Processing Toolkit (SPTK): + - frame + - mgc2mgc + - mgcep + - pitch + - window + - x2x + +Original README file of SPTK +---------------------------- + + Speech Signal Processing Toolkit (SPTK) + version 3.1 release October 1, 2007 + +The Speech Signal Processing Toolkit (SPTK) is a suite of speech +signal processing tools for UNIX environments, e.g., LPC +analysis, PARCOR analysis, LSP analysis, PARCOR synthesis +filter, LSP synthesis filter, vector quantization techniques, +and other extended versions of them. + +SPTK was developed and has been used in the research group of +Prof. Satoshi Imai (he has retired) and Prof. Takao Kobayashi +(currently he is with Interdisciplinary Graduate School of +Science and Engineering, Tokyo Institute of Technology) at P&I +laboratory, Tokyo Institute of Technology. A sub-set of tools +is chosen and arranged for distribution by Prof. Keiichi Tokuda +(currently he is with Department of Computer Science and +Engineering, Nagoya Institute of Technology) as a coordinator in +cooperation with Dr. Takashi Masuko (currently he is with +Corporate Research & Development Center, Toshiba Corp.), +Dr. Kazuhito Koishida (currently he is with Microsoft Research), +Dr. Shinji Sako (currently he is a Research Associate, Nagoya +Institute of Technology), Dr. Heiga Zen (currently he is a +PostDoc fellow at Nagoya Institute of Technology), and some +graduate students. + +The original source codes have been written by many people who +took part in activities of the research group. The most +original source codes of this distribution were written by Takao +Kobayashi (graph, data processing, FFT, sampling rate +conversion, etc.), Keiichi Tokuda (speech analysis, speech +synthesis, etc.), and Kazuhito Koishida (LSP, vector +quantization, etc.). Added: software/tux_framework/trunk/bin/frame =================================================================== (Binary files differ) Property changes on: software/tux_framework/trunk/bin/frame ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: software/tux_framework/trunk/bin/mgc2mgc =================================================================== (Binary files differ) Property changes on: software/tux_framework/trunk/bin/mgc2mgc ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: software/tux_framework/trunk/bin/mgcep =================================================================== (Binary files differ) Property changes on: software/tux_framework/trunk/bin/mgcep ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: software/tux_framework/trunk/bin/pitch =================================================================== (Binary files differ) Property changes on: software/tux_framework/trunk/bin/pitch ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: software/tux_framework/trunk/bin/window =================================================================== (Binary files differ) Property changes on: software/tux_framework/trunk/bin/window ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: software/tux_framework/trunk/bin/x2x =================================================================== (Binary files differ) Property changes on: software/tux_framework/trunk/bin/x2x ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: software/tux_framework/trunk/libs/DTW.py =================================================================== --- software/tux_framework/trunk/libs/DTW.py (rev 0) +++ software/tux_framework/trunk/libs/DTW.py 2007-11-14 13:26:50 UTC (rev 699) @@ -0,0 +1,45 @@ +#!/usr/bin/python +# -*- coding: latin1 -*- +# ----------------------------------------------------------------------------- +# Tux Droid - Voice recognition - DTW +# Copyright (C) 2007 C2ME Sa <rem...@c2...> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ----------------------------------------------------------------------------- +# $Id: $ +# ----------------------------------------------------------------------------- +from ctypes import * + +DTW_SO = '/opt/tuxdroid/apps/tux_framework/libs/_DTW.so' +lib = CDLL(DTW_SO) +_DTW = lib.DTW +_DTW.restype = c_float + +class m_patern(Structure): + _fields_ = [("matrix", POINTER(c_float)), + ("matrix_len", c_uint)] + +def list_to_m_patern(float_list): + t_float = tuple(float_list) + p1 = m_patern() + p1.matrix = (c_float * len(t_float))(*t_float) + p1.matrix_len = len(t_float) + return p1 + +def DTW(mcep_coeff1, mcep_coeff2): + v1 = list_to_m_patern(mcep_coeff1) + v2 = list_to_m_patern(mcep_coeff2) + return _DTW(v1, v2) Modified: software/tux_framework/trunk/libs/FWObject.py =================================================================== --- software/tux_framework/trunk/libs/FWObject.py 2007-11-14 10:24:38 UTC (rev 698) +++ software/tux_framework/trunk/libs/FWObject.py 2007-11-14 13:26:50 UTC (rev 699) @@ -29,9 +29,13 @@ import atexit import subprocess import threading +import commands from GdgObject import * +from GdgThreads import gadget_thread import TGFormat +sys.path.append('/opt/tuxdroid/apps/tux_framework') +from version import fw_version def regularize_path(path): path = path.replace('%20', '') @@ -40,6 +44,7 @@ class GdgFramework(object): def __init__(self, gadget_filename): + self.version = fw_version self.gdg_filename = regularize_path(gadget_filename) if not os.path.exists(self.gdg_filename): return @@ -47,6 +52,14 @@ self.__exit_flag = False self.__standby_mutex = threading.Lock() self.__unauthorized_gadgets = [] + self.__gtk_main_thread = None + + def kill(self): + try: + self.__close_gadgets() + os.kill(os.getpid(), 9) + except: + pass def run(self): if not os.path.exists(self.gdg_filename): @@ -55,7 +68,8 @@ self.__check_system_ready() gtk.gdk.threads_init() - thread.start_new_thread(gtk.main, ()) + self.__gtk_main_thread = threading.Thread(target = gtk.main) + self.__gtk_main_thread.start() if not self.__load_gadgets(): return @@ -63,6 +77,8 @@ self.__signal_binding() self._main_stopped = False self.__main() + gadget_thread.join() + self.kill() def exclude_gadget(self, gadget_name): """ @@ -73,7 +89,7 @@ """ self.__unauthorized_gadgets.append(gadget_name) if gadgets.has_key(gadget_name): - thread.start_new_thread(self.__close_gadget, (gadget_name,)) + gadget_thread.start_new_thread(self.__close_gadget, (gadget_name,)) def close_gadget(self, gadget_name): """ @@ -83,7 +99,7 @@ "gadget_name" as string : Name of the gadget to close """ if gadgets.has_key(gadget_name): - thread.start_new_thread(self.__close_gadget, (gadget_name,)) + gadget_thread.start_new_thread(self.__close_gadget, (gadget_name,)) def restart_gadget(self, gadget_name): """ @@ -97,7 +113,7 @@ def async(gadget_name, gadget_path): self.close_gadget(gadget_name) self.start_gadget(gadget_path) - thread.start_new_thread(async, (gadget_name, gadget_path)) + gadget_thread.start_new_thread(async, (gadget_name, gadget_path)) def start_gadget(self, gadget_path): """ @@ -114,6 +130,7 @@ if gadget_name != 'Manager': try: gadget = GdgObject(gadget_path, self) + gadget.notify.start() except: return None gadget.restore_GUI(True) @@ -124,6 +141,7 @@ def async_create(gadget_path): try: gadget = GdgObject(gadget_path, self) + gadget.notify.start() except: return if gadget.get_funct('initialization') != None: @@ -137,7 +155,7 @@ tux.sys.wait(0.1) gadget.get_funct('binds_clean_rules')() gadget.get_funct('make_main_menu')() - thread.start_new_thread(async_create, (gadget_path,)) + gadget_thread.start_new_thread(async_create, (gadget_path,)) return None def __check_tux_resources(self): @@ -179,8 +197,20 @@ t = process.readlines() app_count = int(t[0].replace('\n', '')) - 1 process.close() + if app_count > 1: - return False + my_pid = os.getpid() + st_pid = commands.getoutput("ps -ef | grep %s | grep python" % app_name) + splited = st_pid.split() + ap_list = [] + for i in range(app_count): + pid = splited[i*10:(i+1)*10][1] + if splited[i*10:(i+1)*10][1] != str(my_pid): + try: + os.kill(int(pid), signal.SIGKILL) + except: + pass + return True else: if tux.daemon.connected: tux.daemon.set_my_client_name('tdgagdet') @@ -209,10 +239,6 @@ self._main_stopped = True def __close_gadget(self, gadget_name): - if gadgets[gadget_name].get_funct('finalization') != None: - gadgets[gadget_name].get_funct('finalization')() - if gadget_name == 'Manager': - gadgets[gadget_name].get_funct('tray_destroy')() try: gadgets[gadget_name].destroy() gadgets.pop(gadget_name) @@ -261,21 +287,13 @@ finalize() gtk.main_quit() - + self.__exit_flag = True - - while not self._main_stopped: - time.sleep(0.1) - - # force application to exit - try: - os.kill(os.getpid(), 9) - except: - pass self.__standby_mutex.release() def __on_standby_async(self): - thread.start_new_thread(self.__on_standby, ()) + t = threading.Thread(target = self.__on_standby) + t.start() def __exit(self, signum, frame): """ @@ -315,20 +333,20 @@ manager_gdg = GdgObject(os.path.join(PATH_GADGETS, 'Manager.tgf'), self) manager_gdg.get_funct('show_splash_screen')() + for gdg in gadgets.keys(): + gadgets[gdg].notify.start() manager_gdg.insert_funct('close_application', self.__on_standby_async) manager_gdg.insert_funct('start_daemons', self.__check_tux_resources) - if not manager_gdg.gui('widget').showed(): - manager_gdg.gui('widget').show() - while manager_gdg.gui('widget').window == None: - tux.sys.wait(0.1) manager_gdg.get_funct('binds_clean_rules')() - manager_gdg.get_funct('make_main_menu')() for gdg in gadgets.keys(): - if gadgets[gdg].get_funct('initialization') != None: - gadgets[gdg].get_funct('initialization')() + if gdg != 'Manager': + if gadgets[gdg].get_funct('initialization') != None: + gadgets[gdg].get_funct('initialization')() + manager_gdg.get_funct('initialization')() return True else: gadget = GdgObject(self.gdg_filename, self) + gadget.notify.start() gadget.gui('widget').show() while not gadget.gui('widget').showed(): time.sleep(0.1) Modified: software/tux_framework/trunk/libs/GdgDebug.py =================================================================== --- software/tux_framework/trunk/libs/GdgDebug.py 2007-11-14 10:24:38 UTC (rev 698) +++ software/tux_framework/trunk/libs/GdgDebug.py 2007-11-14 13:26:50 UTC (rev 699) @@ -28,7 +28,7 @@ import syslog # Flag which allow the debug messages on a log file -ALLOW_LOG_FLAG = False +ALLOW_LOG_FLAG = True class GdgDebugger(object): """ Modified: software/tux_framework/trunk/libs/GdgDownload.py =================================================================== --- software/tux_framework/trunk/libs/GdgDownload.py 2007-11-14 10:24:38 UTC (rev 698) +++ software/tux_framework/trunk/libs/GdgDownload.py 2007-11-14 13:26:50 UTC (rev 699) @@ -79,7 +79,7 @@ A tuple(<boolean>, <string>) """ socket.setdefaulttimeout(timeout) - if not rss_server_available(url, timeout): + if not check_server_available(url, timeout): return False, '' req = urllib2.Request(url) try: Modified: software/tux_framework/trunk/libs/GdgGuiUpdate.py =================================================================== --- software/tux_framework/trunk/libs/GdgGuiUpdate.py 2007-11-14 10:24:38 UTC (rev 698) +++ software/tux_framework/trunk/libs/GdgGuiUpdate.py 2007-11-14 13:26:50 UTC (rev 699) @@ -32,14 +32,10 @@ self.__stack_mutex = threading.Lock() self.__stack_update = [] self.__thread = None - self.running = False self.start_loop() def destroy(self): self.stop_loop() - if self.__thread != None: - if self.__thread.isAlive(): - self.__thread.join() def insert(self, gui_op, *args): self.__stack_mutex.acquire() @@ -52,11 +48,13 @@ self.__thread.start() def stop_loop(self): - self.running = False + if self.__thread != None: + if self.__thread.isAlive(): + self.__thread._Thread__stop() + self.__thread.join() def __loop(self): - self.running = True - while self.running: + while True: gui_update = [] self.__stack_mutex.acquire() if len(self.__stack_update) > 0: @@ -64,6 +62,9 @@ self.__stack_mutex.release() if len(gui_update) > 0: gtk.gdk.threads_enter() - gui_update[0](*gui_update[1][0]) + try: + gui_update[0](*gui_update[1][0]) + except: + pass gtk.gdk.threads_leave() time.sleep(0.01) Modified: software/tux_framework/trunk/libs/GdgObject.py =================================================================== --- software/tux_framework/trunk/libs/GdgObject.py 2007-11-14 10:24:38 UTC (rev 698) +++ software/tux_framework/trunk/libs/GdgObject.py 2007-11-14 13:26:50 UTC (rev 699) @@ -33,20 +33,26 @@ from SimpleGladeApp import SimpleGladeApp from SimpleGladeApp import bindtextdomain import zipfile +import copy from TGFormat import * from TGFXml import * +from TGFCanvas import scene_struct from GoogleTranslate import * from Languages import * from TextFilters import * from GdgDebug import GdgDebugger -from GdgThreads import GdgThreads +from GdgThreads import gadget_thread from GdgGuiUpdate import GdgGuiUpdate from GdgDownload import GdgDownload +from tdrss import * +from GdgVoiceRec import VoiceRecParametrize, VoiceRecAcquire, VoiceRecMatching -sys.path.append('/opt/tuxdroid/api/python') +sys.path.append('/opt uxdroid/api/python') from tuxapi_const import * +from tuxapi_class import TuxSwitch from tux import * # This library create a tux object +PATH_APP = os.path.realpath(os.path.dirname(sys.argv[0])) # Container of gadgets gadgets = {} @@ -58,83 +64,170 @@ tts_mutex = threading.Lock() # Flag which allow the debug messages on the terminal debug_on_terminal = False +# Head switch +_tux_head_switch = TuxSwitch(tux, STATUS_HEAD_PUSH_SWITCH) +# Left wing switch +_tux_lwing_switch = TuxSwitch(tux, STATUS_LEFT_WING_PUSH) +# Right wing switch +_tux_rwing_switch = TuxSwitch(tux, STATUS_RIGHT_WING_PUSH) class GdgDialog(object): - def __init__(self, title, message): + def __init__(self, title, message, block = False, center_justify = False): self.message = message self.title = title - thread.start_new_thread(self.__show, ()) + self.__center_justify = center_justify + if block: + self.__show() + else: + gadget_thread.start_new_thread(self.__show_async, ()) + + def __show_async(self): + gtk.gdk.threads_enter() + self.__show() + gtk.gdk.threads_leave() def __show(self): - gtk.gdk.threads_enter() dialogue = gtk.Dialog(self.title, None, gtk.DIALOG_MODAL, ()) dialogue.set_property("width-request", 300) if gadgets.has_key('Manager'): dialogue.set_icon_from_file(gadgets['Manager'].icons['gadget.png']) - gtk.gdk.threads_leave() bt_alone = dialogue.add_button("Ok/Cancel", gtk.RESPONSE_APPLY) def on_click_okcancel(obj): - def async(): - dialogue.destroy() - thread.start_new_thread(async, ()) + dialogue.destroy() - gtk.gdk.threads_enter() bt_alone.connect("clicked", on_click_okcancel) box = gtk.HBox(spacing = 5) box.set_border_width(5) box.show() dialogue.vbox.pack_start(box) - identified_error = gtk.Label(self.message) - identified_error.show() - box.pack_start(identified_error) + txtv = gtk.TextView() + txtv.set_editable(False) + txtv.set_cursor_visible(False) + txtv.set_wrap_mode(gtk.WRAP_WORD) + txtv.set_left_margin(10) + txtv.set_right_margin(10) + txtv.set_property("width-request", 300) + if self.__center_justify: + txtv.set_justification(gtk.JUSTIFY_CENTER) + #txtv.set_property("height-request", 100) + #txtv.modify_base(gtk.STATE_NORMAL, dialogue.get_style().bg[gtk.STATE_PRELIGHT]) + buff = txtv.get_buffer() + buff.set_text(self.message) + txtv.show() + box.pack_start(txtv) dialogue.run() + +class GdgDialogScrolled(object): + + def __init__(self, title, message, gadget, block = False, center_justify = False): + self.message = message + self.title = title + self.__center_justify = center_justify + self.gadget = gadget + if block: + self.__show() + else: + gadget_thread.start_new_thread(self.__show_async, ()) + + def __show_async(self): + gtk.gdk.threads_enter() + self.__show() gtk.gdk.threads_leave() + def __show(self): + dialog = gtk.Dialog(self.title, None, gtk.DIALOG_MODAL, ()) + dialog.set_property("width-request", 300) + if gadgets.has_key('Manager'): + dialog.set_icon_from_file(self.gadget.get_icon('gadget.png')) + bt_alone = dialog.add_button("Ok/Cancel", gtk.RESPONSE_APPLY) + + def on_click_okcancel(obj): + dialog.destroy() + + bt_alone.connect("clicked", on_click_okcancel) + + hbox1 = gtk.HBox(spacing = 5) + hbox1.set_border_width(5) + hbox1.show() + dialog.vbox.pack_start(hbox1) + fd = gtk.ScrolledWindow() + fd.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + fd.set_property("width-request", 400) + fd.set_property("height-request", 300) + hbox1.pack_start(fd) + box = gtk.VBox(spacing=5) + fd.add_with_viewport(box) + txtv = gtk.TextView() + txtv.set_editable(False) + txtv.set_cursor_visible(False) + txtv.set_wrap_mode(gtk.WRAP_WORD) + txtv.set_left_margin(10) + txtv.set_right_margin(10) + #txtv.modify_base(gtk.STATE_NORMAL, my_dialog.get_style().bg[gtk.STATE_PRELIGHT]) + buff = txtv.get_buffer() + buff.set_text(self.message) + box.pack_start(txtv) + txtv.show() + dialog.show_all() + dialog.run() + class GdgDialogQuestion(object): - def __init__(self, title, message, on_yes_event): + def __init__(self, title, message, on_yes_event, block = False): self.message = message self.title = title self.on_yes_event = on_yes_event - thread.start_new_thread(self.__show, ()) + if block: + self.__show() + else: + gadget_thread.start_new_thread(self.__show_async, ()) + + def __show_async(self): + gtk.gdk.threads_enter() + self.__show() + gtk.gdk.threads_leave() def __show(self): - gtk.gdk.threads_enter() dialogue = gtk.Dialog(self.title, None, gtk.DIALOG_MODAL, ()) dialogue.set_property("width-request", 300) if gadgets.has_key('Manager'): dialogue.set_icon_from_file(gadgets['Manager'].icons['gadget.png']) - gtk.gdk.threads_leave() bt_yes = dialogue.add_button(gtk.STOCK_YES, gtk.RESPONSE_YES) bt_no = dialogue.add_button(gtk.STOCK_NO, gtk.RESPONSE_NO) def on_click_yes(obj): def async(): - dialogue.destroy() if self.on_yes_event != None: self.on_yes_event() - thread.start_new_thread(async, ()) + gadget_thread.start_new_thread(async, ()) + dialogue.destroy() def on_click_no(obj): - def async(): - ... [truncated message content] |