[gevice] use standar show_message() for display message



commit 8017e4d8572c002ed3c6024fbf15a16e079df959
Author: Alejandro Valdes jimenez <avaldes amvj in utalca cl>
Date:   Fri May 22 15:18:13 2009 -0400

    use standar show_message() for display message
---
 ChangeLog               |    8 ++++++++
 src/gevice.py           |    7 ++++---
 src/gevicedatabase.py   |   10 +++++-----
 src/geviceexport.py     |   17 +++++++++--------
 src/gevicemaintainer.py |   17 +++--------------
 src/geviceprefer.py     |   14 ++++----------
 6 files changed, 33 insertions(+), 40 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 429072c..dc68d18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-05-22  Alejandro Valdes jimenez  <avaldes gnome org>
+
+	* src/gevice.py: use show_message().
+	* src/gevicedatabase.py: use show_message().
+	* src/geviceexport.py: use show_message().
+	* src/gevicemaintainer.py: use show_message().
+	* src/geviceprefer.py: use show_message().
+
 2009-05-21  Alejandro Valdes Jimenez  <avaldes gnome org>
 
 	Fixes bug #583056.
diff --git a/src/gevice.py b/src/gevice.py
index 103803b..5356ddf 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -295,10 +295,11 @@ class Gevice:
     def main(self):
         gtk.main()
 
-    def show_message (self,msg,type):
-        dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL,type,gtk.BUTTONS_OK,msg)
-        dialog.run()
+    def show_message (self,msg,type_msg,buttons):
+        dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL,type_msg,buttons,msg)
+        result = dialog.run()
         dialog.destroy()
+        return result
 
     def close_page_of_notebook(self,widget,hbox_term):
         "close page of notebook"
diff --git a/src/gevicedatabase.py b/src/gevicedatabase.py
index 663a625..d1fed23 100644
--- a/src/gevicedatabase.py
+++ b/src/gevicedatabase.py
@@ -29,7 +29,7 @@ class GeviceDatabase:
             conn = psycopg2.connect("dbname=" + gevice.gpref.dbase + " user=" + gevice.gpref.user_dbase + " host=" + gevice.gpref.host + " password=" + passwd)
             return conn
         except:
-            gevice.show_message (_("Unable to connect to the database"),gtk.MESSAGE_ERROR)
+            result = gevice.show_message (_("Unable to connect to the database"),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
             return False
 
 
@@ -39,7 +39,7 @@ class GeviceDatabase:
             rows = self.cur.fetchall()
             return rows
         except:
-            gevice.show_message (_("Unable to execute SQL: " + sql),gtk.MESSAGE_ERROR)
+            result = gevice.show_message (_("Unable to execute SQL: " + sql),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
             return False
         
     def execute_sql_insert (self,gevice,sql):
@@ -47,7 +47,7 @@ class GeviceDatabase:
             self.cur.execute(sql)
             return True
         except:
-            gevice.show_message (_("Unable to execute SQL: " + sql),gtk.MESSAGE_ERROR)
+            result = gevice.show_message (_("Unable to execute SQL: " + sql),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
             return False
             
     def execute_sql_delete (self,gevice,sql):
@@ -55,7 +55,7 @@ class GeviceDatabase:
             self.cur.execute(sql)
             return True
         except:
-            gevice.show_message (_("Unable to execute SQL: " + sql),gtk.MESSAGE_ERROR)
+            result = gevice.show_message (_("Unable to execute SQL: " + sql),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
             return False
 
     def execute_sql_update (self,gevice,sql):
@@ -63,7 +63,7 @@ class GeviceDatabase:
             self.cur.execute(sql)
             return True
         except:
-            gevice.show_message (_("Unable to execute SQL: " + sql),gtk.MESSAGE_ERROR)
+            result = gevice.show_message (_("Unable to execute SQL: " + sql),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
             return False
 
     def load_interface (self,gevice):
diff --git a/src/geviceexport.py b/src/geviceexport.py
index 5a5d2f3..b6cc810 100644
--- a/src/geviceexport.py
+++ b/src/geviceexport.py
@@ -29,14 +29,15 @@ class GeviceExport:
     def save_file (self,gevice):
         if self.filename:
             self.filename = self.filename + self.ext
-
-            FILE = open (self.filename,"w")
-            if (FILE):
-                print self.filename
-                self.get_all_data_from_view (gevice,FILE)
-                FILE.close()    
-            else:
-                gevice.show_message (_("Can not write to file"),gtk.MESSAGE_ERROR)
+            
+            try:
+            	FILE = open (self.filename,"w")
+            	if (FILE):
+                	print self.filename
+                	self.get_all_data_from_view (gevice,FILE)
+                	FILE.close()
+            except:
+            	result = gevice.show_message (_("Can not write to file"),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
 
     def get_all_data_from_view (self,gevice,FILE):
         sql = "select nom_tipo_disp,nom_marca,nom_modelo,nom_tipo_disp || ' ' || nom_marca || ' ' || nom_modelo,count(nom_tipo_disp) "
diff --git a/src/gevicemaintainer.py b/src/gevicemaintainer.py
index 6422006..32bba73 100644
--- a/src/gevicemaintainer.py
+++ b/src/gevicemaintainer.py
@@ -203,9 +203,7 @@ class GeviceMaintainer:
 
         else:
             #show error message and delete the row.
-            dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,gtk.BUTTONS_OK,_("Name exist: " + newname) )
-            dialog.run()
-            dialog.destroy()
+            result = gevice.show_message (_("Name exist: ") + newname,gtk.MESSAGE_INFO,gtk.BUTTONS_OK)
 
        
     def is_newname_in_list(self,model,path,iter,newname):
@@ -266,10 +264,7 @@ class GeviceMaintainer:
         
         delete = sql["delete"] + str(id)
         
-        dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION,
-                gtk.BUTTONS_YES_NO, _("Do you want to remove: ") + name)
-
-        result = dialog.run()
+        result = gevice.show_message (_("Do you want to remove: ") + name,gtk.MESSAGE_QUESTION,gtk.BUTTONS_YES_NO)
 
         if result == gtk.RESPONSE_YES:
             if (gevice.gdbase.execute_sql_delete (gevice,delete)):
@@ -277,7 +272,6 @@ class GeviceMaintainer:
             
             gevice.gdbase.conn.commit()
 
-        dialog.destroy()       
 
     def on_button_rem_model_clicked(self,button,gevice,sql):
         selection = self.treeview.get_selection()
@@ -289,18 +283,13 @@ class GeviceMaintainer:
         
         delete = sql["delete"] + str(id)
         
-        dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION,
-                gtk.BUTTONS_YES_NO, _("Do you want to remove: ") + device + " " + name)
-
-        result = dialog.run()
+        result = gevice.show_message (_("Do you want to remove: ") + name,gtk.MESSAGE_QUESTION,gtk.BUTTONS_YES_NO)
 
         if result == gtk.RESPONSE_YES:
             if (gevice.gdbase.execute_sql_delete (gevice,delete)):
                 model.remove(iter)
             
             gevice.gdbase.conn.commit()
-
-        dialog.destroy()       
         
 
     def on_button_model_ok_clicked (self,button,gevice,sql):
diff --git a/src/geviceprefer.py b/src/geviceprefer.py
index 441822b..3a7895e 100644
--- a/src/geviceprefer.py
+++ b/src/geviceprefer.py
@@ -131,9 +131,8 @@ class GevicePrefer:
             gevice.modelusers.set(iter,0,newname)
             self.save_preferences(gevice)
         else:
-            dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,gtk.BUTTONS_OK,_("User exist: " + newname) )
-            dialog.run()
-            dialog.destroy()
+        	result = gevice.show_message (_("Name exist: ") + newname,gtk.MESSAGE_INFO,gtk.BUTTONS_OK)
+
 
     def is_newname_in_list(self,model,path,iter,newname):
         oldname = model.get(iter,0)[0]
@@ -170,17 +169,12 @@ class GevicePrefer:
         
         name = model.get(iter,0)[0]
                 
-        dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION,
-                gtk.BUTTONS_YES_NO, _("Do you want to remove: ") + name)
-
-        result = dialog.run()
-
+        result = gevice.show_message (_("Do you want to remove: ") + name,gtk.MESSAGE_QUESTION,gtk.BUTTONS_YES_NO)
+        
         if result == gtk.RESPONSE_YES:
                 model.remove(iter)
                 self.save_preferences(gevice)
             
-        dialog.destroy()       
-
 
     def on_button_background_clicked (self,button,entry):
         self.create_color_selection_dialog(_("Select background color"),entry)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]