[gevice] gevicefind.py: rewritten functions
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gevice] gevicefind.py: rewritten functions
- Date: Thu, 6 Oct 2011 14:20:32 +0000 (UTC)
commit 8e7b51bd03b4eb37fa08a854daf58f0f6732653e
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date: Thu Oct 6 11:20:16 2011 -0300
gevicefind.py: rewritten functions
ChangeLog | 10 ++-
src/gevice.py | 3 +-
src/gevicefind.py | 189 ++++++++++++++++++++++------------------------------
3 files changed, 89 insertions(+), 113 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 535ab36..200a834 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
2011-10-06 Alejandro Valdes Jimenez <avaldes gnome org>
+ * src/gevice.py:
+ * src/gevicefind.py:
+ * on_button_find_find_clicked(): rewritten
+ * search_in_iter(): new function.
+
+2011-10-06 Alejandro Valdes Jimenez <avaldes gnome org>
* data/ui/menu.xml: replace toolitem (ssh,telnet,local) for combobox)
* src/gevice.py: add support to conect to VNC, RDP remote desktop.
* src/gevicedevice.py:
@@ -15,8 +21,8 @@
2011-10-04 Alejandro Valdes Jimenez <avaldes gnome org>
* src/gevice.py:
- * show_message(). Add new parameter "window". This indicate the father window where show the message
- * on_action_save(). rewritten.
+ * show_message(): Add new parameter "window". This indicate the father window where show the message
+ * on_action_save(): rewritten.
* src/gevicedatabase.py: show_message() parameters are changed
* src/gevicedevice.py: show_message() parameters are changed
diff --git a/src/gevice.py b/src/gevice.py
index 38e8c51..967fccc 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -20,8 +20,6 @@ from gi.repository import Gtk, GdkPixbuf, Vte, GLib
import os
import os.path
-#import sys
-#import psycopg2
import config
import gevicefind
@@ -58,6 +56,7 @@ class Gevice:
self.modelproto.append (["rdp"])
self.modelproto.append (["xdmcp"])
+
# model for devices
self.gmodel = gevicemodel.GeviceModel(self)
diff --git a/src/gevicefind.py b/src/gevicefind.py
index 310e6c3..4bb8742 100644
--- a/src/gevicefind.py
+++ b/src/gevicefind.py
@@ -8,112 +8,83 @@ gettext.textdomain(config.PACKAGE)
from gettext import gettext as _
class GeviceFind:
- def __init__ (self):
- self.window_find = None
- self.button_find_cancel = None
- self.button_find_find = None
- self.entry_find = None
- self.radiobutton_namedevice = None
- self.radiobutton_ip = None
- self.radiobutton_serial = None
-
- self.list_names = {}
- self.list_ips = {}
- self.list_serials = {}
- self.token = []
-
- def load_interface (self,gevice):
- builder = Gtk.Builder()
- builder.add_from_file(os.path.join (config.UIDIR, "find.xml"))
-
- self.window_find = builder.get_object ("window_find")
- self.button_find_cancel = builder.get_object ("button_find_cancel")
- self.button_find_find = builder.get_object ("button_find_find")
- self.entry_find = builder.get_object ("entry_find")
- self.radiobutton_namedevice = builder.get_object ("radiobutton_namedevice")
- self.radiobutton_ip = builder.get_object ("radiobutton_ip")
- self.radiobutton_serial = builder.get_object ("radiobutton_serial")
-
- self.entry_find.grab_focus()
-
- self.window_find.connect ("delete-event",self.on_window_find_delete_event)
- self.button_find_cancel.connect ("clicked",self.on_button_cancel_find_clicked)
- self.button_find_find.connect ("clicked",self.on_button_find_find_clicked,gevice)
- self.entry_find.connect ("key-press-event", self.on_entry_find_key_press,gevice)
- self.radiobutton_namedevice.connect ("toggled", self.on_radiobutton_toggled)
- self.radiobutton_ip.connect ("toggled", self.on_radiobutton_toggled)
- self.radiobutton_serial.connect ("toggled", self.on_radiobutton_toggled)
-
- self.clear_lists()
- gevice.gmodel.treestore.foreach(self.copy_models_to_lists,None)
-
- def show_interface (self):
- self.window_find.show_all()
-
- def clear_lists (self):
- self.list_names = {}
- self.list_ips = {}
- self.list_serials = {}
-
- def on_radiobutton_toggled(self,radiobutton):
- self.entry_find.grab_focus()
-
- def copy_models_to_lists(self,model,path,iter,data):
- data = model.get(iter,config.COLUMN_NAME_DEV,config.COLUMN_IP_DEV,config.COLUMN_SERIAL_DEV)
-
- self.list_names[data[0]] = iter
- self.list_ips[data[1]] = iter
- self.list_serials[data[2]] = iter
-
- def close_window (self,window):
- window.destroy()
-
- def on_button_cancel_find_clicked (self,button):
- self.close_window (self.window_find)
-
- def on_window_find_delete_event (self,window,event):
- self.close_window (window)
-
- def on_button_find_find_clicked(self,button,gevice):
- if (self.radiobutton_namedevice.get_active() == True):
- list = self.list_names
- elif (self.radiobutton_ip.get_active() == True):
- list = self.list_ips
- elif (self.radiobutton_serial.get_active() == True):
- list = self.list_serials
-
- sname = self.entry_find.get_text().strip()
-
- for n in list.items():
- key = n[0]
- iter = n[1]
-
- res = key.find(sname)
- if res >= 0:
- try:
- self.token.index(key)
- except:
- self.token.append(key)
- selection = gevice.gmodel.treeview.get_selection()
-
- selection.set_mode(Gtk.SelectionMode.BROWSE)
- selection.select_iter(iter)
- print iter
-
- ####
-
- #first_iter = gevice.gmodel.treestore.get_iter_first()
- #path = gevice.gmodel.treestore.get_path(iter)
- #selection.select_iter(iter)
- #gevice.gmodel.treeview.grab_focus()
- ###
-
-
- #path = gevice.gmodel.treestore.get_path(iter)
-
- #gevice.gmodel.treeview.set_cursor(path,None,False)
- break
-
- def on_entry_find_key_press (self,widget,event,gevice):
- if Gdk.keyval_name(event.keyval) == "Return":
- self.on_button_find_find_clicked(None,gevice)
+ def __init__ (self):
+ self.window_find = None
+ self.button_find_cancel = None
+ self.button_find_find = None
+ self.entry_find = None
+ self.radiobutton_namedevice = None
+ self.radiobutton_ip = None
+ self.radiobutton_serial = None
+ self.data_finded = []
+
+ def load_interface (self,gevice):
+ builder = Gtk.Builder()
+ builder.add_from_file(os.path.join (config.UIDIR, "find.xml"))
+
+ self.window_find = builder.get_object ("window_find")
+ self.button_find_cancel = builder.get_object ("button_find_cancel")
+ self.button_find_find = builder.get_object ("button_find_find")
+ self.entry_find = builder.get_object ("entry_find")
+ self.radiobutton_namedevice = builder.get_object ("radiobutton_namedevice")
+ self.radiobutton_ip = builder.get_object ("radiobutton_ip")
+ self.radiobutton_serial = builder.get_object ("radiobutton_serial")
+
+ self.window_find.connect ("delete-event",self.on_window_find_delete_event)
+ self.button_find_cancel.connect ("clicked",self.on_button_cancel_find_clicked)
+ self.button_find_find.connect ("clicked",self.on_button_find_find_clicked,gevice)
+ self.entry_find.connect ("key-press-event", self.on_entry_find_key_press,gevice)
+ self.radiobutton_namedevice.connect ("toggled", self.on_radiobutton_toggled)
+ self.radiobutton_ip.connect ("toggled", self.on_radiobutton_toggled)
+ self.radiobutton_serial.connect ("toggled", self.on_radiobutton_toggled)
+
+ self.entry_find.grab_focus()
+
+ def show_interface (self):
+ self.window_find.show_all()
+
+ def on_radiobutton_toggled(self,radiobutton):
+ self.entry_find.grab_focus()
+
+ def close_window (self,window):
+ window.destroy()
+
+ def on_button_cancel_find_clicked (self,button):
+ self.close_window (self.window_find)
+
+ def on_window_find_delete_event (self,window,event):
+ self.close_window (window)
+
+ def search_in_iter (self,model,path,iter,gevice):
+ data = model.get_value(iter,self.column_find)
+ res = data.find(self.sname)
+
+ if (res >= 0):
+ try:
+ # exist in list?
+ self.data_finded.index(data)
+ except:
+ # add to list of match
+ self.data_finded.append(data)
+ selection = gevice.gmodel.treeview.get_selection()
+ gevice.gmodel.treeview.set_cursor(path,None,False)
+ gevice.gmodel.treeview.grab_focus()
+ selection.select_iter(iter)
+
+ return True
+
+ def on_button_find_find_clicked(self,button,gevice):
+ self.sname = self.entry_find.get_text().strip()
+
+ if (self.radiobutton_namedevice.get_active() == True):
+ self.column_find = config.COLUMN_NAME_DEV
+ elif (self.radiobutton_ip.get_active() == True):
+ self.column_find = config.COLUMN_IP_DEV
+ elif (self.radiobutton_serial.get_active() == True):
+ self.column_find = config.COLUMN_SERIAL_DEV
+
+ gevice.gmodel.treestore.foreach(self.search_in_iter,gevice)
+
+ def on_entry_find_key_press (self,widget,event,gevice):
+ if Gdk.keyval_name(event.keyval) == "Return":
+ self.on_button_find_find_clicked(None,gevice)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]