Style editor improvements

svn: r1324
This commit is contained in:
Don Allingham 2003-03-04 05:48:36 +00:00
parent ce77a02144
commit 49000e9695
5 changed files with 660 additions and 667 deletions

View File

@ -30,6 +30,7 @@ __version__ = "$Revision$"
# GNOME/GTK modules # GNOME/GTK modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import gobject
import gtk import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -70,7 +71,8 @@ class StyleListDisplay:
"on_edit_clicked" : self.on_edit_clicked "on_edit_clicked" : self.on_edit_clicked
}) })
self.list = ListModel.ListModel(self.top.get_widget("list"),[('Style',-1,10)]) self.list = ListModel.ListModel(self.top.get_widget("list"),
[('Style',-1,10)],)
self.redraw() self.redraw()
def redraw(self): def redraw(self):
@ -126,7 +128,7 @@ class StyleListDisplay:
StyleEditor(name,style,self) StyleEditor(name,style,self)
def on_delete_clicked(self,obj): def on_delete_clicked(self,obj):
"""Deletes teh selected style.""" """Deletes the selected style."""
store,iter = self.list.selection.get_selected() store,iter = self.list.selection.get_selected()
if not iter: if not iter:
return return
@ -153,7 +155,6 @@ class StyleEditor:
self.style = TextDoc.StyleSheet(style) self.style = TextDoc.StyleSheet(style)
self.parent = parent self.parent = parent
self.top = gtk.glade.XML(const.stylesFile,"editor") self.top = gtk.glade.XML(const.stylesFile,"editor")
self.current_p = None
self.top.signal_autoconnect({ self.top.signal_autoconnect({
"on_save_style_clicked" : self.on_save_style_clicked, "on_save_style_clicked" : self.on_save_style_clicked,
@ -161,25 +162,19 @@ class StyleEditor:
}) })
self.window = self.top.get_widget("editor") self.window = self.top.get_widget("editor")
self.pnames = self.top.get_widget("name") self.first = 1
titles = [(_('Paragraph'),0,130)]
self.plist = ListModel.ListModel(self.top.get_widget("ptree"),titles,
self.change_display)
self.top.get_widget('color').connect('color-set',self.fg_color_set) self.top.get_widget('color').connect('color-set',self.fg_color_set)
self.top.get_widget('bgcolor').connect('color-set',self.bg_color_set) self.top.get_widget('bgcolor').connect('color-set',self.bg_color_set)
self.top.get_widget("style_name").set_text(name) self.top.get_widget("style_name").set_text(name)
myMenu = gtk.Menu()
first = 0
for p_name in self.style.get_names(): for p_name in self.style.get_names():
p = self.style.get_style(p_name) self.plist.add([p_name],self.style.get_style(p_name))
if first == 0: self.plist.select_row(0)
self.draw(p)
first = 1
menuitem = gtk.MenuItem(p_name)
menuitem.set_data("o",p)
menuitem.connect("activate",self.change_display)
menuitem.show()
myMenu.append(menuitem)
self.pnames.set_menu(myMenu)
def draw(self,p): def draw(self,p):
"""Updates the display with the selected paragraph.""" """Updates the display with the selected paragraph."""
@ -211,14 +206,19 @@ class StyleEditor:
self.top.get_widget("bborder").set_active(p.get_bottom_border()) self.top.get_widget("bborder").set_active(p.get_bottom_border())
self.fg_color = font.get_color() self.fg_color = font.get_color()
self.top.get_widget("color").set_i8(self.fg_color[0],self.fg_color[1],self.fg_color[2],0) self.top.get_widget("color").set_i8(self.fg_color[0],self.fg_color[1],self.fg_color[2],0)
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
self.bg_color = p.get_background_color() self.bg_color = p.get_background_color()
self.top.get_widget("bgcolor").set_i8(self.bg_color[0],self.bg_color[1],self.bg_color[2],0) self.top.get_widget("bgcolor").set_i8(self.bg_color[0],self.bg_color[1],self.bg_color[2],0)
self.top.get_widget('bgcolor_code').set_text("#%02X%02X%02X" % self.bg_color)
def bg_color_set(self,x,r,g,b,a): def bg_color_set(self,x,r,g,b,a):
self.bg_color = (r >> 8, g >> 8, b >> 8) self.bg_color = (r >> 8, g >> 8, b >> 8)
self.top.get_widget('bgcolor_code').set_text("#%02X%02X%02X" % self.bg_color)
def fg_color_set(self,x,r,g,b,a): def fg_color_set(self,x,r,g,b,a):
self.fg_color = (r >> 8, g >> 8, b >> 8) self.fg_color = (r >> 8, g >> 8, b >> 8)
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
def save_paragraph(self,p): def save_paragraph(self,p):
"""Saves the current paragraph displayed on the dialog""" """Saves the current paragraph displayed on the dialog"""
@ -271,10 +271,10 @@ class StyleEditor:
"""Called when the paragraph selection has been changed. Saves the """Called when the paragraph selection has been changed. Saves the
old paragraph, then draws the newly selected paragraph""" old paragraph, then draws the newly selected paragraph"""
style = obj.get_data("o") objs = self.plist.get_selected_objects()
self.save_paragraph(self.current_p) if self.first == 0:
self.draw(style) self.save_paragraph(self.current_p)
else:
self.first = 0
self.current_p = objs[0]
self.draw(self.current_p)

View File

@ -748,7 +748,7 @@ class StyleSheetList:
Saves the current StyleSheet definitions to the associated file. Saves the current StyleSheet definitions to the associated file.
""" """
f = open(self.file,"w") f = open(self.file,"w")
f.write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n") f.write("<?xml version=\"1.0\"?>\n")
f.write('<stylelist>\n') f.write('<stylelist>\n')
for name in self.map.keys(): for name in self.map.keys():
if name == "default": if name == "default":

View File

@ -39,6 +39,7 @@ Preferences dialog under the Settings menu.</property>
<property name="background_color">#e1e1dbdbc5c5</property> <property name="background_color">#e1e1dbdbc5c5</property>
<property name="logo_background_color">#e1e1dcdcc5c5</property> <property name="logo_background_color">#e1e1dcdcc5c5</property>
<property name="textbox_color">#ffffffffffff</property> <property name="textbox_color">#ffffffffffff</property>
<property name="logo">gramps.png</property>
</widget> </widget>
</child> </child>
@ -47,9 +48,9 @@ Preferences dialog under the Settings menu.</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Researcher Information</property> <property name="title" translatable="yes">Researcher Information</property>
<property name="title_foreground">#53e00817c71b</property> <property name="title_foreground">#53e00817c71b</property>
<property name="background">#53e00817e818</property> <property name="background">#53e00817e118</property>
<property name="logo_background">#d7a440c2e808</property> <property name="logo_background">#d7a440c2e108</property>
<property name="logo">gramps.xpm</property> <property name="logo">gramps.png</property>
<child internal-child="vbox"> <child internal-child="vbox">
<widget class="GtkVBox" id="druid-vbox1"> <widget class="GtkVBox" id="druid-vbox1">
@ -93,21 +94,21 @@ files, you may leave it blank.</property>
<property name="n_rows">8</property> <property name="n_rows">8</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">6</property>
<property name="column_spacing">0</property> <property name="column_spacing">12</property>
<child> <child>
<widget class="GtkLabel" id="label133"> <widget class="GtkLabel" id="label133">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Name</property> <property name="label" translatable="yes">Name:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">1</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">5</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
@ -123,15 +124,15 @@ files, you may leave it blank.</property>
<child> <child>
<widget class="GtkLabel" id="label134"> <widget class="GtkLabel" id="label134">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Address</property> <property name="label" translatable="yes">Address:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">1</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">5</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
@ -147,15 +148,15 @@ files, you may leave it blank.</property>
<child> <child>
<widget class="GtkLabel" id="label135"> <widget class="GtkLabel" id="label135">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">City</property> <property name="label" translatable="yes">City:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">1</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">5</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
@ -171,15 +172,15 @@ files, you may leave it blank.</property>
<child> <child>
<widget class="GtkLabel" id="label136"> <widget class="GtkLabel" id="label136">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">State/Province</property> <property name="label" translatable="yes">State/Province:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">1</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">5</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
@ -195,15 +196,15 @@ files, you may leave it blank.</property>
<child> <child>
<widget class="GtkLabel" id="label137"> <widget class="GtkLabel" id="label137">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Country</property> <property name="label" translatable="yes">Country:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">1</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">5</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
@ -219,15 +220,15 @@ files, you may leave it blank.</property>
<child> <child>
<widget class="GtkLabel" id="label138"> <widget class="GtkLabel" id="label138">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">email</property> <property name="label" translatable="yes">Email:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">1</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">5</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
@ -243,15 +244,15 @@ files, you may leave it blank.</property>
<child> <child>
<widget class="GtkLabel" id="label139"> <widget class="GtkLabel" id="label139">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">ZIP/Postal Code</property> <property name="label" translatable="yes">ZIP/Postal code:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">1</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">5</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
@ -267,15 +268,15 @@ files, you may leave it blank.</property>
<child> <child>
<widget class="GtkLabel" id="label140"> <widget class="GtkLabel" id="label140">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Phone</property> <property name="label" translatable="yes">Phone:</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">1</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">5</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
@ -306,8 +307,6 @@ files, you may leave it blank.</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="bottom_attach">1</property> <property name="bottom_attach">1</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -330,8 +329,6 @@ files, you may leave it blank.</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="bottom_attach">2</property> <property name="bottom_attach">2</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -354,8 +351,6 @@ files, you may leave it blank.</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">2</property> <property name="top_attach">2</property>
<property name="bottom_attach">3</property> <property name="bottom_attach">3</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -378,8 +373,6 @@ files, you may leave it blank.</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">3</property> <property name="top_attach">3</property>
<property name="bottom_attach">4</property> <property name="bottom_attach">4</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -402,8 +395,6 @@ files, you may leave it blank.</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">4</property> <property name="top_attach">4</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">5</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -426,8 +417,6 @@ files, you may leave it blank.</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">5</property> <property name="top_attach">5</property>
<property name="bottom_attach">6</property> <property name="bottom_attach">6</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -450,8 +439,6 @@ files, you may leave it blank.</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">6</property> <property name="top_attach">6</property>
<property name="bottom_attach">7</property> <property name="bottom_attach">7</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -474,8 +461,6 @@ files, you may leave it blank.</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">7</property> <property name="top_attach">7</property>
<property name="bottom_attach">8</property> <property name="bottom_attach">8</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -503,8 +488,8 @@ files, you may leave it blank.</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Numerical Date Formats</property> <property name="title" translatable="yes">Numerical Date Formats</property>
<property name="title_foreground">#53e00817c71b</property> <property name="title_foreground">#53e00817c71b</property>
<property name="background">#53e00817e818</property> <property name="background">#53e00817e118</property>
<property name="logo_background">#d7a440c2e808</property> <property name="logo_background">#d7a440c2e108</property>
<property name="logo">gramps.xpm</property> <property name="logo">gramps.xpm</property>
<child internal-child="vbox"> <child internal-child="vbox">
@ -651,8 +636,8 @@ numerical dates</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Alternate Calendar Support</property> <property name="title" translatable="yes">Alternate Calendar Support</property>
<property name="title_foreground">#53e00817c71b</property> <property name="title_foreground">#53e00817c71b</property>
<property name="background">#53e00817e818</property> <property name="background">#53e00817e118</property>
<property name="logo_background">#d7a440c2e808</property> <property name="logo_background">#d7a440c2e108</property>
<property name="logo">gramps.xpm</property> <property name="logo">gramps.xpm</property>
<child internal-child="vbox"> <child internal-child="vbox">
@ -748,8 +733,8 @@ more of these alternate calendars, enable alternate calendar support.</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">LDS Extensions</property> <property name="title" translatable="yes">LDS Extensions</property>
<property name="title_foreground">#53e00817c71b</property> <property name="title_foreground">#53e00817c71b</property>
<property name="background">#53e00817e818</property> <property name="background">#53e00817e118</property>
<property name="logo_background">#d7a440c2e808</property> <property name="logo_background">#d7a440c2e108</property>
<property name="logo">gramps.xpm</property> <property name="logo">gramps.xpm</property>
<child internal-child="vbox"> <child internal-child="vbox">

View File

@ -199,6 +199,8 @@
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property> <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property> <property name="modal">False</property>
<property name="default_width">450</property>
<property name="default_height">350</property>
<property name="resizable">True</property> <property name="resizable">True</property>
<property name="destroy_with_parent">False</property> <property name="destroy_with_parent">False</property>
<property name="icon">gramps.png</property> <property name="icon">gramps.png</property>
@ -259,7 +261,7 @@
<child> <child>
<widget class="GtkLabel" id="label247"> <widget class="GtkLabel" id="label247">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">&lt;span weight=&quot;bold&quot; size=&quot;larger&quot;&gt;Revert to an older revision&lt;/span&gt;</property> <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot; size=&quot;larger&quot;&gt;Select an older revision&lt;/span&gt;</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>

File diff suppressed because it is too large Load Diff