From 27679e3fbc5a4a757a6f86db7c97c38b83519317 Mon Sep 17 00:00:00 2001 From: Luigi 'Comio' Mantellini Date: Thu, 28 Feb 2008 23:24:27 +0100 Subject: [PATCH] Initial events handling... --- cscope/cscope.glade | 3 ++- cscope/cscope.py | 43 +++++++++++++++++++++++++++++-------------- cscope/gedit_bind.py | 52 +++++++++++++++++++++++++++++----------------------- 3 files changed, 60 insertions(+), 38 deletions(-) diff --git a/cscope/cscope.glade b/cscope/cscope.glade index b1fc053..80f98ff 100644 --- a/cscope/cscope.glade +++ b/cscope/cscope.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -109,6 +109,7 @@ Find files #including this file: GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Search 0 + False diff --git a/cscope/cscope.py b/cscope/cscope.py index d03878d..37f202f 100644 --- a/cscope/cscope.py +++ b/cscope/cscope.py @@ -22,32 +22,46 @@ CSCOPE_TOGGLECASE = 'c' class CScope: def __init__(self): # Executable - self.exe = '/usr/bin/cscope' - self.param = '-l' - self.running = 0 + self._exe = '/usr/bin/cscope' + self._param = '-l' + self._running = 0 + self._db = 'cscope.out' return def setHome(self, path): - if self.running == 1: + if self._running == 1: self.shutdown() + print "Path" + path os.chdir(path) return - def shutdown(self): - if self.running == 1: + def setDb(self, path): + if self._running == 1: + self.shutdown() + self._db = path + return + + def shutdown(self): + if self._running == 1: # cscope is running... self._sendcmd(CSCOPE_QUIT) # now is off + self._running = 0 + return def start(self): - if self.running == 1: + if self._running == 1: self.shutdown() - (self.csout, self.csin) = os.popen2(self.exe + ' ' + self.param) - self.running = 1 + (self.csout, self.csin) = os.popen2(self._exe + ' -f' + self._db + ' ' + self._param) + print self._exe + ' -f' + self._db + ' ' + self._param + if (self.csout == None or self.csin == None): + return -1 + self._running = 1 + return 0 def query(self, cmd, symbol): - if self.running != 1: - self.start() + if self._running != 1: + return -1 self._sendcmd(cmd+symbol) # Find lines lines = -1 @@ -77,12 +91,13 @@ class CScope: return result def _sendcmd(self, cmd): - if self.running != 1: + if self._running != 1: self.start() self.csout.write(cmd) self.csout.write('\n') self.csout.flush() def setExecutable(self, cmd, param): - self.exe = cmd - self.param = param + self._exe = cmd + self._param = param + diff --git a/cscope/gedit_bind.py b/cscope/gedit_bind.py index c4628dc..5016a28 100644 --- a/cscope/gedit_bind.py +++ b/cscope/gedit_bind.py @@ -2,6 +2,7 @@ import gedit import os import gtk import gtk.glade +import cscope GLADE_FILE = os.path.join(os.path.dirname(__file__), "cscope.glade") @@ -62,6 +63,7 @@ class CScopePluginHelper: self._panel = self._window.get_bottom_panel() self._cspanel = None self.create_panel() + self._cscope = cscope.CScope() return def deactivate(self): @@ -91,28 +93,32 @@ class CScopePluginHelper: self._cbTypeOfQuery.set_active(0) + self._bSearch.connect("clicked", self.do_search) + self._bOpen.connect("clicked", self.do_opendb) + self._result = CScopeResult(self._tvResults) - - self._result.append( (1, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - self._result.append( (2, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - self._result.append( (3, "/usr/sr/linux/arch/m68k/process", "process.c", 102, "do_up", "int do_up(int test)") ) - self._result.append( (4, "/usr/sr/linux/arch/m68k/process", "process.c", 104, "do_up", "int do_up(int test)") ) - self._result.append( (5, "/usr/sr/linux/arch/m68k/process", "process.c", 150, "do_up", "int do_up(int test)") ) - self._result.append( (6, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - self._result.append( (7, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - self._result.append( (8, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - self._result.append( (9, "/usr/sr/linux/arch/m68k/process", "process.c", 102, "do_up", "int do_up(int test)") ) - self._result.append( (10, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - self._result.append( (11, "/usr/sr/linux/arch/m68k/process", "process.c", 103, "do_up", "int do_up(int test)") ) - self._result.append( (12, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - self._result.append( (13, "/usr/sr/linux/arch/m68k/process", "process.c", 104, "do_up", "int do_up(int test)") ) - self._result.append( (14, "/usr/sr/linux/arch/m68k/process", "process.c", 150, "do_up", "int do_up(int test)") ) - self._result.append( (15, "/usr/sr/linux/arch/m68k/process", "process.c", 160, "do_up", "int do_up(int test)") ) - self._result.append( (16, "/usr/sr/linux/arch/m68k/process", "process.c", 170, "do_up", "int do_up(int test)") ) - self._result.append( (17, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - self._result.append( (18, "/usr/sr/linux/arch/m68k/process", "process.c", 110, "do_up", "int do_up(int test)") ) - self._result.append( (19, "/usr/sr/linux/arch/m68k/process", "process.c", 190, "do_up", "int do_up(int test)") ) - self._result.append( (20, "/usr/sr/linux/arch/m68k/process", "process.c", 120, "do_up", "int do_up(int test)") ) - self._result.append( (21, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") ) - + + return + + def do_search(self, button): + ris = self._cscope.query(str(self._cbTypeOfQuery.get_active()), self._eQuery.get_text()) + self._result.clear() + i = 0 + for rec in ris: + [filename, funcname, rowno, text] = rec + self._result.append( + ( i, + os.path.dirname(filename), + os.path.basename(filename), + rowno, + funcname, + text )) + i = i + 1 + return + + def do_opendb(self, button): + self._cscope.shutdown() + self._cscope.setDb(self._fcDatabase.get_filename()) + self._cscope.setHome(os.path.dirname(self._fcDatabase.get_filename())) + self._cscope.start() return -- 2.11.4.GIT