conduit r1616 - in trunk: . conduit/gtkui data
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1616 - in trunk: . conduit/gtkui data
- Date: Sat, 2 Aug 2008 07:30:32 +0000 (UTC)
Author: jstowers
Date: Sat Aug 2 07:30:32 2008
New Revision: 1616
URL: http://svn.gnome.org/viewvc/conduit?rev=1616&view=rev
Log:
Add message area
Added:
trunk/ (props changed)
- copied from r1608, /trunk/
trunk/conduit/gtkui/MsgArea.py
Modified:
trunk/conduit/gtkui/Canvas.py
trunk/conduit/gtkui/UI.py
trunk/data/conduit.glade
Modified: trunk/conduit/gtkui/Canvas.py
==============================================================================
--- /trunk/conduit/gtkui/Canvas.py (original)
+++ trunk/conduit/gtkui/Canvas.py Sat Aug 2 07:30:32 2008
@@ -163,7 +163,7 @@
]
WELCOME_MESSAGE = _("Drag a Data Provider here to continue")
- def __init__(self, parentWindow, typeConverter, syncManager, dataproviderMenu, conduitMenu):
+ def __init__(self, parentWindow, typeConverter, syncManager, dataproviderMenu, conduitMenu, msg):
"""
Draws an empty canvas of the appropriate size
"""
@@ -182,6 +182,7 @@
self.sync_manager = syncManager
self.typeConverter = typeConverter
self.parentWindow = parentWindow
+ self.msg = msg
self._setup_popup_menus(dataproviderMenu, conduitMenu)
@@ -479,6 +480,12 @@
c_w,
self._get_minimum_canvas_size()
)
+
+ self.msg.new_from_text_and_icon(
+ gtk.STOCK_INFO,
+ "Conduit Created",
+ "Add another dataprovider to synchronize",
+ timeout=4).show_all()
def on_dataprovider_removed(self, sender, dataproviderRemoved, conduitCanvasItem):
for item in self._get_child_dataprovider_canvas_items():
Added: trunk/conduit/gtkui/MsgArea.py
==============================================================================
--- (empty file)
+++ trunk/conduit/gtkui/MsgArea.py Sat Aug 2 07:30:32 2008
@@ -0,0 +1,242 @@
+# This file is part of the Hotwire Shell user interface.
+#
+# Copyright (C) 2007,2008 Colin Walters <walters verbum org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import os, sys, re, logging, string
+
+import gtk, gobject, pango
+
+#from hotssh.hotlib.logutil import log_except
+
+#_logger = logging.getLogger("hotwire.ui.MsgArea")
+
+# This file is a Python translation of gedit/gedit/gedit-message-area.c
+
+class MsgArea(gtk.HBox):
+ __gsignals__ = {
+ "response" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
+ "close" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
+ }
+
+ def __init__(self, buttons, **kwargs):
+ super(MsgArea, self).__init__(**kwargs)
+
+ self.__contents = None
+ self.__changing_style = False
+
+ self.__main_hbox = gtk.HBox(False, 16) # FIXME: use style properties
+ self.__main_hbox.show()
+ self.__main_hbox.set_border_width(8) # FIXME: use style properties
+
+ self.__action_area = gtk.HBox(True, 4); # FIXME: use style properties
+ self.__action_area.show()
+ self.__main_hbox.pack_end (self.__action_area, False, True, 0)
+
+ self.pack_start(self.__main_hbox, True, True, 0)
+
+ self.set_app_paintable(True)
+
+ self.connect("expose-event", self.__paint)
+
+ # Note that we connect to style-set on one of the internal
+ # widgets, not on the message area itself, since gtk does
+ # not deliver any further style-set signals for a widget on
+ # which the style has been forced with gtk_widget_set_style()
+ self.__main_hbox.connect("style-set", self.__on_style_set)
+
+ self.add_buttons(buttons)
+
+ def __get_response_data(self, w, create):
+ d = w.get_data('hotwire-msg-area-data')
+ if (d is None) and create:
+ d = {'respid': None}
+ w.set_data('hotwire-msg-area-data', d)
+ return d
+
+ def __find_button(self, respid):
+ children = self.__actionarea.get_children()
+ for child in children:
+ rd = self.__get_response_data(child, False)
+ if rd is not None and rd['respid'] == respid:
+ return child
+
+ def __close(self):
+ cancel = self.__find_button(gtk.RESPONSE_CANCEL)
+ if cancel is None:
+ return
+ self.response(gtk.RESPONSE_CANCEL)
+
+ def __paint(self, w, event):
+ gtk.Style.paint_flat_box(w.style,
+ w.window,
+ gtk.STATE_NORMAL,
+ gtk.SHADOW_OUT,
+ None,
+ w,
+ "tooltip",
+ w.allocation.x + 1,
+ w.allocation.y + 1,
+ w.allocation.width - 2,
+ w.allocation.height - 2)
+
+ return False
+
+ def __on_style_set(self, w, style):
+ if self.__changing_style:
+ return
+ # This is a hack needed to use the tooltip background color
+ window = gtk.Window(gtk.WINDOW_POPUP);
+ window.set_name("gtk-tooltip")
+ window.ensure_style()
+ style = window.get_style()
+
+ self.__changing_style = True
+ self.set_style(style)
+ self.__changing_style = False
+
+ window.destroy()
+
+ self.queue_draw()
+
+ def __get_response_for_widget(self, w):
+ rd = self.__get_response_data(w, False)
+ if rd is None:
+ return gtk.RESPONSE_NONE
+ return rd['respid']
+
+ def __on_action_widget_activated(self, w):
+ response_id = self.__get_response_for_widget(w)
+ self.response(response_id)
+
+ def add_action_widget(self, child, respid):
+ rd = self.__get_response_data(child, True)
+ rd['respid'] = respid
+ if not isinstance(child, gtk.Button):
+ raise ValueError("Can only pack buttons as action widgets")
+ child.connect('clicked', self.__on_action_widget_activated)
+ if respid != gtk.RESPONSE_HELP:
+ self.__action_area.pack_start(child, False, False, 0)
+ else:
+ self.__action_area.pack_end(child, False, False, 0)
+
+ def set_contents(self, contents):
+ self.__contents = contents
+ self.__main_hbox.pack_start(contents, True, True, 0)
+
+
+ def add_button(self, btext, respid):
+ button = gtk.Button(stock=btext)
+ button.set_focus_on_click(False)
+ button.set_flags(gtk.CAN_DEFAULT)
+ button.show()
+ self.add_action_widget(button, respid)
+ return button
+
+ def add_buttons(self, args):
+ #_logger.debug("init buttons: %r", args)
+ for (btext, respid) in args:
+ self.add_button(btext, respid)
+
+ def set_response_sensitive(self, respid, setting):
+ for child in self.__action_area.get_children():
+ rd = self.__get_response_data(child, False)
+ if rd is not None and rd['respid'] == respid:
+ child.set_sensitive(setting)
+ break
+
+ def set_default_response(self, respid):
+ for child in self.__action_area.get_children():
+ rd = self.__get_response_data(child, False)
+ if rd is not None and rd['respid'] == respid:
+ child.grab_default()
+ break
+
+ def response(self, respid):
+ self.emit('response', respid)
+
+ def add_stock_button_with_text(self, text, stockid, respid):
+ b = gtk.Button(label=text)
+ b.set_focus_on_click(False)
+ img = gtk.Image()
+ img.set_from_stock(stockid, gtk.ICON_SIZE_BUTTON)
+ b.set_image(img)
+ b.show_all()
+ self.add_action_widget(b, respid)
+ return b
+
+ def set_text_and_icon(self, stockid, primary_text, secondary_text=None):
+ hbox_content = gtk.HBox(False, 8)
+ hbox_content.show()
+
+ image = gtk.Image()
+ image.set_from_stock(stockid, gtk.ICON_SIZE_BUTTON)
+ image.show()
+ hbox_content.pack_start(image, False, False, 0)
+ image.set_alignment(0.5, 0.5)
+
+ vbox = gtk.VBox(False, 6)
+ vbox.show()
+ hbox_content.pack_start (vbox, True, True, 0)
+
+ primary_markup = "<b>%s</b>" % (primary_text,)
+ primary_label = gtk.Label(primary_markup)
+ primary_label.show()
+ vbox.pack_start(primary_label, True, True, 0)
+ primary_label.set_use_markup(True)
+ primary_label.set_line_wrap(True)
+ primary_label.set_alignment(0, 0.5)
+ primary_label.set_flags(gtk.CAN_FOCUS)
+ primary_label.set_selectable(True)
+
+ if secondary_text:
+ secondary_markup = "<small>%s</small>" % (secondary_text,)
+ secondary_label = gtk.Label(secondary_markup)
+ secondary_label.show()
+ vbox.pack_start(secondary_label, True, True, 0)
+ secondary_label.set_flags(gtk.CAN_FOCUS)
+ secondary_label.set_use_markup(True)
+ secondary_label.set_line_wrap(True)
+ secondary_label.set_selectable(True)
+ secondary_label.set_alignment(0, 0.5)
+
+ self.set_contents(hbox_content)
+
+class MsgAreaController(gtk.HBox):
+ def __init__(self):
+ super(MsgAreaController, self).__init__()
+
+ self.__msgarea = None
+
+ def _timeout(self):
+ self.clear()
+
+ def clear(self):
+ if self.__msgarea is not None:
+ self.remove(self.__msgarea)
+ self.__msgarea.destroy()
+ self.__msgarea = None
+
+ def new_from_text_and_icon(self, stockid, primary, secondary=None, buttons=[], timeout=0):
+ self.clear()
+ msgarea = self.__msgarea = MsgArea(buttons)
+ msgarea.set_text_and_icon(stockid, primary, secondary)
+ self.pack_start(msgarea, expand=True)
+
+ if timeout:
+ gobject.timeout_add(timeout*1000, self._timeout)
+
+ return msgarea
Modified: trunk/conduit/gtkui/UI.py
==============================================================================
--- /trunk/conduit/gtkui/UI.py (original)
+++ trunk/conduit/gtkui/UI.py Sat Aug 2 07:30:32 2008
@@ -20,6 +20,7 @@
import conduit.Web as Web
import conduit.Conduit as Conduit
import conduit.gtkui.Canvas as Canvas
+import conduit.gtkui.MsgArea as MsgArea
import conduit.gtkui.Tree as Tree
import conduit.gtkui.ConflictResolver as ConflictResolver
import conduit.gtkui.Database as Database
@@ -104,14 +105,17 @@
#Configure canvas
self.canvasSW = self.widgets.get_widget("canvasScrolledWindow")
self.hpane = self.widgets.get_widget("hpaned1")
-
+
#start up the canvas
+ msg = MsgArea.MsgAreaController()
+ self.widgets.get_widget("mainVbox").pack_start(msg, False, False)
self.canvas = Canvas.Canvas(
parentWindow=self.mainWindow,
typeConverter=self.type_converter,
syncManager=self.sync_manager,
dataproviderMenu=gtk.glade.XML(self.gladeFile, "DataProviderMenu"),
- conduitMenu=gtk.glade.XML(self.gladeFile, "ConduitMenu")
+ conduitMenu=gtk.glade.XML(self.gladeFile, "ConduitMenu"),
+ msg=msg
)
self.canvasSW.add(self.canvas)
self.canvas.connect('drag-drop', self.drop_cb)
@@ -317,11 +321,11 @@
for policyName in Conduit.CONFLICT_POLICY_NAMES:
currentValue = conduit.GLOBALS.settings.get("default_policy_%s" % policyName)
for policyValue in Conduit.CONFLICT_POLICY_VALUES:
- widgetName = "%s_%s" % (policyName,policyValue)
- widget = tree.get_widget(widgetName)
+ name = "%s_%s" % (policyName,policyValue)
+ widget = tree.get_widget(name+"_radio")
widget.set_image(
gtk.image_new_from_icon_name(
- Conduit.CONFLICT_POLICY_VALUE_ICONS[widgetName],
+ Conduit.CONFLICT_POLICY_VALUE_ICONS[name],
gtk.ICON_SIZE_MENU))
if currentValue == policyValue:
widget.set_active(True)
@@ -352,8 +356,8 @@
#save the current policy
for policyName in Conduit.CONFLICT_POLICY_NAMES:
for policyValue in Conduit.CONFLICT_POLICY_VALUES:
- widgetName = "%s_%s" % (policyName,policyValue)
- if tree.get_widget(widgetName).get_active() == True:
+ name = "%s_%s" % (policyName,policyValue)
+ if tree.get_widget(name+"_radio").get_active() == True:
conduit.GLOBALS.settings.set(
"default_policy_%s" % policyName,
policyValue)
Modified: trunk/data/conduit.glade
==============================================================================
--- /trunk/data/conduit.glade (original)
+++ trunk/data/conduit.glade Sat Aug 2 07:30:32 2008
@@ -209,13 +209,18 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
- <widget class="GtkScrolledWindow" id="canvasScrolledWindow">
+ <widget class="GtkVBox" id="mainVbox">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
- <placeholder/>
+ <widget class="GtkScrolledWindow" id="canvasScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
</child>
</widget>
<packing>
@@ -843,7 +848,7 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="deleted_ask">
+ <widget class="GtkRadioButton" id="deleted_ask_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Ask me what to do</property>
@@ -858,14 +863,14 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="deleted_replace">
+ <widget class="GtkRadioButton" id="deleted_replace_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Delete from the corresponding sink</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
- <property name="group">deleted_ask</property>
+ <property name="group">deleted_ask_radio</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -874,14 +879,14 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="deleted_skip">
+ <widget class="GtkRadioButton" id="deleted_skip_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Skip</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
- <property name="group">deleted_ask</property>
+ <property name="group">deleted_ask_radio</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -902,7 +907,7 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="conflict_ask">
+ <widget class="GtkRadioButton" id="conflict_ask_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Ask me what to do</property>
@@ -917,14 +922,14 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="conflict_replace">
+ <widget class="GtkRadioButton" id="conflict_replace_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Replace the older item</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
- <property name="group">conflict_ask</property>
+ <property name="group">conflict_ask_radio</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -933,14 +938,14 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="conflict_skip">
+ <widget class="GtkRadioButton" id="conflict_skip_radio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Skip</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
- <property name="group">conflict_ask</property>
+ <property name="group">conflict_ask_radio</property>
</widget>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]