Make the treeview sortable by column
[gedit_cscope.git] / cscope / gedit_bind.py
blob757a08258f492983e23613b0bbc7719997e6ae66
1 import gedit
2 import os
3 import gtk
4 import gtk.glade
6 GLADE_FILE = os.path.join(os.path.dirname(__file__), "cscope.glade")
8 class CScopePluginHelper:
9 def __init__(self, plugin, window):
10 self._plugin = plugin
11 self._window = window
12 self._panel = self._window.get_bottom_panel()
13 self._cspanel = None
14 self.create_panel()
15 return
17 def deactivate(self):
18 self._plugin = None
19 self._window = None
20 self._panel = None
21 self._cspanel = None
23 def update_ui(self):
24 return
26 def create_panel(self):
27 # Open the Interface and bind with Botton Panel
28 glade_xml = gtk.glade.XML(GLADE_FILE, "CScopeBox")
29 self._cspanel = glade_xml.get_widget("CScopeBox")
30 image = gtk.Image()
31 image.set_from_stock(gtk.STOCK_DND_MULTIPLE, gtk.ICON_SIZE_BUTTON)
32 self._panel.add_item(self._cspanel, "CScope", image)
34 # Objects
35 self._fcDatabase = glade_xml.get_widget("fcDatabase")
36 self._bOpen = glade_xml.get_widget("bOpen")
37 self._bSearch = glade_xml.get_widget("bSearch")
38 self._eQuery = glade_xml.get_widget("eQuery")
39 self._cbTypeOfQuery = glade_xml.get_widget("cbTypeOfQuery")
40 self._tvResults = glade_xml.get_widget("tvResult")
42 self._search_data = gtk.ListStore(int, str, str, int, str, str)
43 self._tvResults.set_model(self._search_data)
45 tree_selection = self._tvResults.get_selection()
47 # Properties...
48 tree_selection.set_mode(gtk.SELECTION_SINGLE)
50 cell_no = gtk.TreeViewColumn("#")
51 cell_no.set_resizable(True)
52 cell_no.set_reorderable(True)
53 cell_no.set_sort_column_id(0)
54 cell_dir = gtk.TreeViewColumn("Directory")
55 cell_dir.set_resizable(True)
56 cell_dir.set_reorderable(True)
57 cell_dir.set_sort_column_id(1)
58 cell_filename = gtk.TreeViewColumn("File")
59 cell_filename.set_resizable(True)
60 cell_filename.set_reorderable(True)
61 cell_filename.set_sort_column_id(2)
62 cell_line_number = gtk.TreeViewColumn("Line")
63 cell_line_number.set_resizable(True)
64 cell_line_number.set_reorderable(True)
65 cell_line_number.set_sort_column_id(3)
66 cell_symbol = gtk.TreeViewColumn("Symbol")
67 cell_symbol.set_resizable(True)
68 cell_symbol.set_reorderable(True)
69 cell_symbol.set_sort_column_id(4)
70 cell_text = gtk.TreeViewColumn("Text")
71 cell_text.set_resizable(True)
72 cell_text.set_reorderable(True)
73 cell_text.set_sort_column_id(5)
75 # Now add the cell objects to the results_list treeview object
76 self._tvResults.append_column(cell_no)
77 self._tvResults.append_column(cell_dir)
78 self._tvResults.append_column(cell_filename)
79 self._tvResults.append_column(cell_line_number)
80 self._tvResults.append_column(cell_symbol)
81 self._tvResults.append_column(cell_text)
83 # Create text-rendering objects so that we can actually
84 # see the data that we'll put into the objects
85 text_renderer_no = gtk.CellRendererText()
86 text_renderer_dir = gtk.CellRendererText()
87 text_renderer_filename = gtk.CellRendererText()
88 text_renderer_line_number = gtk.CellRendererText()
89 text_renderer_symbol = gtk.CellRendererText()
90 text_renderer_text = gtk.CellRendererText()
92 # Pack the text renderer objects into the cell objects we created
93 cell_no.pack_start(text_renderer_no, True)
94 cell_dir.pack_start(text_renderer_dir, True)
95 cell_filename.pack_start(text_renderer_filename, True)
96 cell_line_number.pack_start(text_renderer_line_number, True)
97 cell_symbol.pack_start(text_renderer_symbol, True)
98 cell_text.pack_start(text_renderer_text, True)
100 # Now set the IDs to each of the text renderer objects and set them to "text" mode
101 cell_no.add_attribute(text_renderer_no, "text", 0)
102 cell_dir.add_attribute(text_renderer_dir, "text", 1)
103 cell_filename.add_attribute(text_renderer_filename, "text", 2)
104 cell_line_number.add_attribute(text_renderer_line_number, "text", 3)
105 cell_symbol.add_attribute(text_renderer_symbol, "text", 4)
106 cell_text.add_attribute(text_renderer_text, "text", 5)
109 self._search_data.append( (1, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
110 self._search_data.append( (2, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
111 self._search_data.append( (3, "/usr/sr/linux/arch/m68k/process", "process.c", 102, "do_up", "int do_up(int test)") )
112 self._search_data.append( (4, "/usr/sr/linux/arch/m68k/process", "process.c", 104, "do_up", "int do_up(int test)") )
113 self._search_data.append( (5, "/usr/sr/linux/arch/m68k/process", "process.c", 150, "do_up", "int do_up(int test)") )
114 self._search_data.append( (6, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
115 self._search_data.append( (7, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
116 self._search_data.append( (8, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
117 self._search_data.append( (9, "/usr/sr/linux/arch/m68k/process", "process.c", 102, "do_up", "int do_up(int test)") )
118 self._search_data.append( (10, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
119 self._search_data.append( (11, "/usr/sr/linux/arch/m68k/process", "process.c", 103, "do_up", "int do_up(int test)") )
120 self._search_data.append( (12, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
121 self._search_data.append( (13, "/usr/sr/linux/arch/m68k/process", "process.c", 104, "do_up", "int do_up(int test)") )
122 self._search_data.append( (14, "/usr/sr/linux/arch/m68k/process", "process.c", 150, "do_up", "int do_up(int test)") )
123 self._search_data.append( (15, "/usr/sr/linux/arch/m68k/process", "process.c", 160, "do_up", "int do_up(int test)") )
124 self._search_data.append( (16, "/usr/sr/linux/arch/m68k/process", "process.c", 170, "do_up", "int do_up(int test)") )
125 self._search_data.append( (17, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
126 self._search_data.append( (18, "/usr/sr/linux/arch/m68k/process", "process.c", 110, "do_up", "int do_up(int test)") )
127 self._search_data.append( (19, "/usr/sr/linux/arch/m68k/process", "process.c", 190, "do_up", "int do_up(int test)") )
128 self._search_data.append( (20, "/usr/sr/linux/arch/m68k/process", "process.c", 120, "do_up", "int do_up(int test)") )
129 self._search_data.append( (21, "/usr/sr/linux/arch/m68k/process", "process.c", 100, "do_up", "int do_up(int test)") )
131 return