[dots/remove-assistant: 38/38] Make dialogs transients for parent window
- From: Fernando Herrera de las Heras <fherrera src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dots/remove-assistant: 38/38] Make dialogs transients for parent window
- Date: Thu, 15 Jul 2010 21:10:10 +0000 (UTC)
commit 55b2c198e7170205b2c35d82932b6e96fc022b77
Author: Fernando Herrera <fherrera onirica com>
Date: Thu Jul 15 16:32:01 2010 +0200
Make dialogs transients for parent window
bin/dotstableeditor | 78 +++++++++++++++++++++++++++-----------------------
dots/app_window.py | 5 ++-
2 files changed, 46 insertions(+), 37 deletions(-)
---
diff --git a/bin/dotstableeditor b/bin/dotstableeditor
index 77eb4c0..d7e0c51 100755
--- a/bin/dotstableeditor
+++ b/bin/dotstableeditor
@@ -322,40 +322,7 @@ class EditDialog(gtk.Dialog):
entry.emit_stop_by_name("insert-text")
-def row_clicked(view, event):
- if event.type != gtk.gdk._2BUTTON_PRESS:
- return
-
- selection = view.get_selection();
- model, iter = selection.get_selected()
- opcode = model.get_value (iter, 0)
- operands = model.get_value (iter, 1)
- dialog = EditDialog (opcode, operands)
-
- response = dialog.run()
- if response == gtk.RESPONSE_ACCEPT:
- opcode, operands = dialog.get_contents()
- model.set_value (iter, 0, opcode)
- model.set_value (iter, 1, operands)
- dialog.destroy()
-
-def add_clicked(button, view):
- dialog = EditDialog (None, None)
- response = dialog.run()
- if response == gtk.RESPONSE_ACCEPT:
- model = view.get_model()
- iter = model.append((dialog.get_opcode(), dialog.get_operands()))
- selection = view.get_selection()
- selection.select_iter(iter)
- view.scroll_to_cell(model.get_path(iter))
- dialog.destroy()
-
-def remove_clicked(button, view):
- selection = view.get_selection();
- model, iter = selection.get_selected()
- model.remove(iter)
-
class TableEditor(gtk.Window):
def __init__(self, type=gtk.WINDOW_TOPLEVEL):
@@ -377,7 +344,7 @@ class TableEditor(gtk.Window):
tvcolumn.pack_start(cell, True)
tvcolumn.add_attribute(cell, 'text', 1)
- treeview.connect("button-press-event", row_clicked)
+ treeview.connect("button-press-event", self.row_clicked)
scrolledwindow = gtk.ScrolledWindow ()
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
@@ -387,10 +354,10 @@ class TableEditor(gtk.Window):
buttonbox = gtk.HButtonBox()
buttonbox.set_layout(gtk.BUTTONBOX_START)
button = gtk.Button("Add")
- button.connect("clicked", add_clicked, treeview)
+ button.connect("clicked", self.add_clicked, treeview)
buttonbox.pack_start(button, False, False, 6)
button = gtk.Button("Remove")
- button.connect("clicked", remove_clicked, treeview)
+ button.connect("clicked", self.remove_clicked, treeview)
buttonbox.pack_start(button, False, False, 6)
uimanager = gtk.UIManager()
@@ -465,6 +432,45 @@ class TableEditor(gtk.Window):
return
def quit_cb(self, item):
gtk.main_quit()
+
+ def add_clicked(self,button, view):
+ dialog = EditDialog (None, None)
+ dialog.set_transient_for(self)
+ response = dialog.run()
+ if response == gtk.RESPONSE_ACCEPT:
+ model = view.get_model()
+ iter = model.append((dialog.get_opcode(), dialog.get_operands()))
+ selection = view.get_selection()
+ selection.select_iter(iter)
+ view.scroll_to_cell(model.get_path(iter))
+ dialog.destroy()
+
+
+ def remove_clicked(self,button, view):
+ selection = view.get_selection();
+ model, iter = selection.get_selected()
+ model.remove(iter)
+
+ def row_clicked(self, view, event):
+ if event.type != gtk.gdk._2BUTTON_PRESS:
+ return
+
+ selection = view.get_selection();
+ model, iter = selection.get_selected()
+ opcode = model.get_value (iter, 0)
+ operands = model.get_value (iter, 1)
+ dialog = EditDialog (opcode, operands)
+ dialog.set_transient_for(self)
+
+ response = dialog.run()
+ if response == gtk.RESPONSE_ACCEPT:
+ opcode, operands = dialog.get_contents()
+ model.set_value (iter, 0, opcode)
+ model.set_value (iter, 1, operands)
+ dialog.destroy()
+
+
+
diff --git a/dots/app_window.py b/dots/app_window.py
index b9bc17b..bb9b169 100644
--- a/dots/app_window.py
+++ b/dots/app_window.py
@@ -42,6 +42,7 @@ class AppWindow(object):
self.main_xml.add_from_file (
os.path.join(host_settings.gtkbuilder_dir, 'app_window.xml'))
self.window = self.main_xml.get_object('window1')
+ self.window.set_icon_name('dots')
self.main_xml.connect_signals(self)
self.config_builder = ConfigBuilder()
self.client = gconf.client_get_default ()
@@ -88,6 +89,7 @@ class AppWindow(object):
def _OnTranslationFormatActivate(self, item):
dialog = self.conf_xml.get_object('format_dialog')
+ dialog.set_transient_for(self.window)
radiotop = self.conf_xml.get_object('page_top')
radiobottom = self.conf_xml.get_object('page_bottom')
radionone = self.conf_xml.get_object('page_none')
@@ -250,7 +252,7 @@ class AppWindow(object):
self.project.buffer.set_modified(False)
def _onSaveAs(self, action):
- dialog = gtk.FileChooserDialog(
+ dialog = gtk.FileChooserDialog(parent=self.window,
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
@@ -279,6 +281,7 @@ class AppWindow(object):
def _onPrint(self, action):
dialog = gtkunixprint.PrintUnixDialog()
+ dialog.set_transient_for(self.window)
response = dialog.run()
if response == gtk.RESPONSE_OK:
printer = dialog.get_selected_printer()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]