summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-04-09 16:34:46 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2009-04-09 16:34:46 +0200
commit6c8579ace43e612b38315ccea68fe87c048ba8fd (patch)
tree3167854f0234f8ca61e1b481e9830f17d8fe4d1a /src
parent3ff338efaf140a7d7d30e018144c4ab41044e446 (diff)
downloadabrt-6c8579ace43e612b38315ccea68fe87c048ba8fd.tar.gz
abrt-6c8579ace43e612b38315ccea68fe87c048ba8fd.tar.xz
abrt-6c8579ace43e612b38315ccea68fe87c048ba8fd.zip
Fixed gui for new daemon API
removed unneeded code some UI improvements
Diffstat (limited to 'src')
-rw-r--r--src/Gui/CCDBusBackend.py4
-rw-r--r--src/Gui/CCDump.py23
-rw-r--r--src/Gui/CCDumpList.py3
-rw-r--r--src/Gui/CCMainWindow.py18
-rw-r--r--src/Gui/CCReport.py1
-rw-r--r--src/Gui/CCReporterDialog.py65
-rw-r--r--src/Gui/CC_gui_functions.py1
-rw-r--r--src/Gui/CellRenderers.py65
-rw-r--r--src/Gui/Makefile.am4
-rw-r--r--src/Gui/report.glade4
10 files changed, 142 insertions, 46 deletions
diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py
index 208539d4..33da6cb0 100644
--- a/src/Gui/CCDBusBackend.py
+++ b/src/Gui/CCDBusBackend.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import dbus
import gobject
from dbus.mainloop.glib import DBusGMainLoop
@@ -61,6 +62,7 @@ class DBusManager(gobject.GObject):
#for arg in args:
# print "Analyze complete for: %s" % arg
# emit signal to let clients know that analyze has been completed
+ # FIXME - rewrite with CCReport class
self.emit("analyze-complete", dump)
def connect_to_daemon(self):
@@ -91,7 +93,7 @@ class DBusManager(gobject.GObject):
row_dict = None
rows = []
# FIXME check the arguments
- for row in self.cc.GetCrashInfosMap(""):
+ for row in self.cc.GetCrashInfos(""):
row_dict = {}
for column in row:
row_dict[column] = row[column]
diff --git a/src/Gui/CCDump.py b/src/Gui/CCDump.py
index 38fc369d..04bca621 100644
--- a/src/Gui/CCDump.py
+++ b/src/Gui/CCDump.py
@@ -1,5 +1,10 @@
+# -*- coding: utf-8 -*-
from datetime import datetime
+TYPE = 0
+EDITABLE = 1
+CONTENT = 2
+
class Dump():
"""Class for mapping the debug dump to pyhon object"""
def __init__(self):
@@ -12,31 +17,31 @@ class Dump():
self.Description = None
def getUUID(self):
- return self.UUID
+ return self.UUID[CONTENT]
def getUID(self):
- return self.UID
+ return self.UID[CONTENT]
def getCount(self):
- return self.Count
+ return self.Count[CONTENT]
def getExecutable(self):
- return self.Executable
+ return self.Executable[CONTENT]
def getPackage(self):
- return self.Package
+ return self.Package[CONTENT]
def getTime(self,format):
#print format
if format:
try:
- return datetime.fromtimestamp(int(self.Time)).strftime(format)
+ return datetime.fromtimestamp(int(self.Time[CONTENT])).strftime(format)
except Exception, e:
print e
- return int(self.Time)
+ return int(self.Time[CONTENT])
def getPackageName(self):
- return self.Package[:self.Package.find("-")]
+ return self.Package[CONTENT][:self.Package[CONTENT].find("-")]
def getDescription(self):
- return self.Description
+ return self.Description[CONTENT]
diff --git a/src/Gui/CCDumpList.py b/src/Gui/CCDumpList.py
index ecc43fe8..3320af86 100644
--- a/src/Gui/CCDumpList.py
+++ b/src/Gui/CCDumpList.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import CCDBusBackend
from CCDump import Dump
@@ -19,7 +20,7 @@ class DumpList(list):
#print "DumpList adding %s:%s" % (column,row[column])
entry.__dict__[column] = row[column]
self.append(entry)
- self.ddict[entry.UUID] = entry
+ self.ddict[entry.getUUID()] = entry
except Exception, e:
print e
return
diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py
index 9f7202fb..d586c70b 100644
--- a/src/Gui/CCMainWindow.py
+++ b/src/Gui/CCMainWindow.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import sys
import os
import pwd
@@ -30,9 +31,6 @@ class MainWindow():
gui_error_message(e.message)
sys.exit()
#Set the Glade file
- # FIXME add to PATH
- # FIXME remove!
-
self.gladefile = "%s%sccgui.glade" % (sys.path[0],"/")
self.wTree = gtk.glade.XML(self.gladefile)
@@ -121,7 +119,6 @@ class MainWindow():
def hydrate(self):
n = None
self.dumpsListStore.clear()
- #self.rows = self.ccdaemon.getDumps()
try:
dumplist = getDumpList(self.ccdaemon, refresh=True)
except Exception, e:
@@ -133,7 +130,7 @@ class MainWindow():
icon = None
if os.getuid() == 0:
n = self.dumpsListStore.append([icon, entry.getPackage(), entry.getExecutable(),
- entry.getTime("%Y.%m.%d %H:%M:%S"), entry.getCount(), pwd.getpwuid(int(entry.UID))[0], entry])
+ entry.getTime("%Y.%m.%d %H:%M:%S"), entry.getCount(), pwd.getpwuid(int(entry.getUID()))[0], entry])
else:
n = self.dumpsListStore.append([icon, entry.getPackage(), entry.getExecutable(),
entry.getTime("%Y.%m.%d %H:%M:%S"), entry.getCount(), entry])
@@ -159,7 +156,6 @@ class MainWindow():
#move this to Dump class
lPackage = self.wTree.get_widget("lPackage")
self.wTree.get_widget("lDescription").set_label(dump.getDescription())
- #print self.rows[row]
def on_bDelete_clicked(self, button, treeview):
dumpsListStore, path = self.dlist.get_selection().get_selected_rows()
@@ -168,7 +164,7 @@ class MainWindow():
# this should work until we keep the row object in the last position
dump = dumpsListStore.get_value(dumpsListStore.get_iter(path[0]), dumpsListStore.get_n_columns()-1)
try:
- if self.ccdaemon.DeleteDebugDump(dump.UUID):
+ if self.ccdaemon.DeleteDebugDump(dump.getUUID()):
self.hydrate()
treeview.emit("cursor-changed")
else:
@@ -177,7 +173,6 @@ class MainWindow():
print e
def destroy(self, widget, data=None):
- #print "destroy signal occurred"
gtk.main_quit()
def on_data_changed_cb(self, *args):
@@ -233,17 +228,10 @@ class MainWindow():
return
def delete_event_cb(self, widget, event, data=None):
- # Change FALSE to TRUE and the main window will not be destroyed
- # with a "delete_event".
- #return self.on_bQuit_clicked(widget)
gtk.main_quit()
def on_bQuit_clicked(self, widget):
- # quit dialog seems to be anoying...
- #ret = gui_question_dialog("Do you really want to quit?",self.window)
- #if ret == gtk.RESPONSE_YES:
gtk.main_quit()
- # return True
def show(self):
self.window.show()
diff --git a/src/Gui/CCReport.py b/src/Gui/CCReport.py
index ea2ed75e..6077da87 100644
--- a/src/Gui/CCReport.py
+++ b/src/Gui/CCReport.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from datetime import datetime
class Report():
diff --git a/src/Gui/CCReporterDialog.py b/src/Gui/CCReporterDialog.py
index 2dc35783..6e15570f 100644
--- a/src/Gui/CCReporterDialog.py
+++ b/src/Gui/CCReporterDialog.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import pygtk
pygtk.require("2.0")
import gtk #, pango
@@ -5,11 +6,19 @@ import gtk.glade
import sys
from CC_gui_functions import *
from CCReport import Report
+import CellRenderers
#from CCDumpList import getDumpList, DumpList
+# FIXME - create method or smth that returns type|editable|content
+TYPE = 0
+EDITABLE = 1
+CONTENT = 2
+
class ReporterDialog():
"""Reporter window"""
def __init__(self, report):
+ self.editable = []
+ self.row_dict = {}
self.report = report
#Set the Glade file
# FIXME add to path
@@ -24,15 +33,9 @@ class ReporterDialog():
self.tvComment.connect("focus-in-event", self.on_comment_focus_cb)
self.comment_changed = False
- #user editable info in report
- self.editable = ["Comment", "TextData1", "TextData2"]
- #init the reports treeview
self.tvReport = self.wTree.get_widget("tvReport")
- columns = [None]*2
- columns[0] = gtk.TreeViewColumn('Item')
- columns[1] = gtk.TreeViewColumn('Value')
- self.reportListStore = gtk.ListStore(str, str, bool)
+ self.reportListStore = gtk.ListStore(str, str, bool, bool, bool)
# set filter
#self.modelfilter = self.reportListStore.filter_new()
#self.modelfilter.set_visible_func(self.filter_reports, None)
@@ -41,13 +44,21 @@ class ReporterDialog():
column = gtk.TreeViewColumn('Item', renderer, text=0)
self.tvReport.append_column(column)
- renderer = gtk.CellRendererText()
+ renderer = CellRenderers.MultilineCellRenderer()
+ renderer.props.editable = True
#renderer.props.wrap_mode = pango.WRAP_WORD
#renderer.props.wrap_width = 600
column = gtk.TreeViewColumn('Value', renderer, text=1, editable=2)
self.tvReport.append_column(column)
renderer.connect('edited',self.column_edited,self.reportListStore)
-
+ # toggle
+ toggle_renderer = gtk.CellRendererToggle()
+ toggle_renderer.set_property('activatable', True)
+ toggle_renderer.connect( 'toggled', self.on_send_toggled, self.reportListStore )
+ column = gtk.TreeViewColumn('Send', toggle_renderer)
+ column.add_attribute( toggle_renderer, "active", 3)
+ column.add_attribute( toggle_renderer, "visible", 4)
+ self.tvReport.append_column(column)
# connect the signals
self.wTree.get_widget("bApply").connect("clicked", self.on_apply_clicked, self.tvReport)
#self.wTree.get_widget("bCancel").connect("clicked", self.on_cancel_clicked, self.tvReport)
@@ -56,6 +67,9 @@ class ReporterDialog():
self.hydrate()
+ def on_send_toggled(self, cell, path, model):
+ model[path][3] = not model[path][3]
+
def on_comment_focus_cb(self, widget, event):
if not self.comment_changed:
widget.set_buffer(None)
@@ -65,19 +79,14 @@ class ReporterDialog():
# multine support
pass
#print allocation
-
+
def column_edited(self, cell, path, new_text, model):
# 1 means the second cell
model[path][1] = new_text
return
def on_apply_clicked(self, button, treeview):
- #fill the report with user changed values and return it..
- #user changed the comment, so we want to save it
- for item in self.editable:
- if item == "Comment" and self.comment_changed:
- buff = self.tvComment.get_buffer()
- self.report[item] = buff.get_text(buff.get_start_iter(),buff.get_end_iter())
+ self.dehydrate()
def on_cancel_clicked(self, button, treeview):
pass
@@ -89,7 +98,29 @@ class ReporterDialog():
buff.set_text("Brief description how to reproduce this or what you did...")
self.tvComment.set_buffer(buff)
continue
- self.reportListStore.append([item, self.report[item], item in self.editable])
+ if self.report[item][TYPE] != 's':
+ # item name 0| value 1| editable? 2| toggled? 3| visible?(attachment)4
+ if self.report[item][EDITABLE] == 'y':
+ self.editable.append(item)
+ self.row_dict[item] = self.reportListStore.append([item, self.report[item][CONTENT],
+ item in self.editable, False,
+ self.report[item][TYPE] in ['a','b']])
+
+ def dehydrate(self):
+ attributes = ["item", "content", "editable", "send", "attachment"]
+ for row in self.reportListStore:
+ rowe = dict(zip(attributes, row))
+ if not rowe["editable"] and not rowe["attachment"]:
+ self.report[rowe["item"]][CONTENT] = rowe["content"]
+ elif rowe["editable"] and not rowe["attachment"]:
+ self.report[rowe["item"]][CONTENT] = rowe["content"]
+ elif (rowe["attachment"] or (rowe["editable"] and rowe["attachment"])) and rowe["send"]:
+ self.report[rowe["item"]][CONTENT] = rowe["content"]
+ else:
+ del self.report[rowe["item"]]
+ if self.comment_changed:
+ buff = self.tvComment.get_buffer()
+ self.report["Comment"] = ['t', 'y', buff.get_text(buff.get_start_iter(),buff.get_end_iter())]
def run(self):
result = self.window.run()
diff --git a/src/Gui/CC_gui_functions.py b/src/Gui/CC_gui_functions.py
index 703ec25e..335d5c4d 100644
--- a/src/Gui/CC_gui_functions.py
+++ b/src/Gui/CC_gui_functions.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import gtk
try:
# we don't want to add dependency to rpm, but if we have it, we can use it
diff --git a/src/Gui/CellRenderers.py b/src/Gui/CellRenderers.py
new file mode 100644
index 00000000..5777a7ce
--- /dev/null
+++ b/src/Gui/CellRenderers.py
@@ -0,0 +1,65 @@
+import gtk
+
+class CellTextView(gtk.TextView, gtk.CellEditable):
+
+ __gtype_name__ = "CellTextView"
+
+ def do_editing_done(self, *args):
+ self.remove_widget()
+
+ def do_remove_widget(self, *args):
+ pass
+
+ def do_start_editing(self, *args):
+ pass
+
+ def get_text(self):
+ text_buffer = self.get_buffer()
+ bounds = text_buffer.get_bounds()
+ return text_buffer.get_text(*bounds)
+
+ def set_text(self, text):
+ self.get_buffer().set_text(text)
+
+
+class MultilineCellRenderer(gtk.CellRendererText):
+
+ __gtype_name__ = "MultilineCellRenderer"
+
+ def __init__(self):
+ gtk.CellRendererText.__init__(self)
+ self._in_editor_menu = False
+
+ def _on_editor_focus_out_event(self, editor, *args):
+ if self._in_editor_menu: return
+ editor.remove_widget()
+ self.emit("editing-canceled")
+
+ def _on_editor_key_press_event(self, editor, event):
+ if event.state & (gtk.gdk.SHIFT_MASK | gtk.gdk.CONTROL_MASK): return
+ if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
+ editor.remove_widget()
+ self.emit("edited", editor.get_data("path"), editor.get_text())
+ elif event.keyval == gtk.keysyms.Escape:
+ editor.remove_widget()
+ self.emit("editing-canceled")
+
+ def _on_editor_populate_popup(self, editor, menu):
+ self._in_editor_menu = True
+ def on_menu_unmap(menu, self):
+ self._in_editor_menu = False
+ menu.connect("unmap", on_menu_unmap, self)
+
+ def do_start_editing(self, event, widget, path, bg_area, cell_area, flags):
+ editor = CellTextView()
+ editor.modify_font(self.props.font_desc)
+ editor.set_text(self.props.text)
+ editor.set_size_request(cell_area.width, cell_area.height)
+ editor.set_border_width(min(self.props.xpad, self.props.ypad))
+ editor.set_data("path", path)
+ editor.connect("focus-out-event", self._on_editor_focus_out_event)
+ editor.connect("key-press-event", self._on_editor_key_press_event)
+ editor.connect("populate-popup", self._on_editor_populate_popup)
+ editor.show()
+ return editor
+
diff --git a/src/Gui/Makefile.am b/src/Gui/Makefile.am
index 21a4423e..e7971731 100644
--- a/src/Gui/Makefile.am
+++ b/src/Gui/Makefile.am
@@ -2,7 +2,9 @@
bin_SCRIPTS = abrt-gui
-PYTHON_FILES = CCDBusBackend.py CCDumpList.py CCDump.py CC_gui_functions.py ccgui.glade report.glade CCReporterDialog.py CCReport.py CCMainWindow.py exception.py
+PYTHON_FILES = CCDBusBackend.py CCDumpList.py CCDump.py CC_gui_functions.py \
+ ccgui.glade report.glade CCReporterDialog.py CCReport.py \
+ CCMainWindow.py exception.py CellRenderers.py
GLADE_FILES = ccgui.glade report.glade
diff --git a/src/Gui/report.glade b/src/Gui/report.glade
index 2c68f74f..10455d11 100644
--- a/src/Gui/report.glade
+++ b/src/Gui/report.glade
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Wed Mar 4 17:15:47 2009 -->
+<!--Generated with glade3 3.4.5 on Thu Apr 9 15:27:26 2009 -->
<glade-interface>
<widget class="GtkDialog" id="reporter_dialog">
<property name="border_width">5</property>
@@ -29,7 +29,7 @@
<widget class="GtkScrolledWindow" id="scrolledwindow5">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkTreeView" id="tvReport">