Commit ee663410 authored by Stephen Kennedy's avatar Stephen Kennedy

Updated.

parent 6f6557dc
......@@ -9,37 +9,37 @@ VERSION := $(shell grep "^version" meldapp.py | cut -d \" -f 2)
RELEASE := meld-$(VERSION)
MELD_CMD := ./meld #--profile
TESTNUM := 1
DEVELOPER := 0
DEVELOPER := 1
SPECIALS := meld paths.py
ifeq ($(DEVELOPER), 1)
.PHONY:rundiff
rundiff: check
echo $(prefix)
$(MELD_CMD) . ../meld #?.txt
#$(MELD_CMD) ntest/file$(TESTNUM)*
#$(MELD_CMD) GNUmakefile ../branch-0.9/GNUmakefile #?.txt
$(MELD_CMD) test/file$(TESTNUM)*
endif
.PHONY:all
all: $(addsuffix .install,$(SPECIALS)) meld.desktop
all:
$(MAKE) -C data
$(MAKE) -C po
$(MAKE) -C help
.PHONY:clean
clean:
-rm -f *.pyc *.install meld.desktop *.bak glade2/*.bak
-rm -f *.pyc *.bak glade2/*.bak
$(MAKE) -C data clean
$(MAKE) -C po clean
$(MAKE) -C help clean
.PHONY:install
install: $(addsuffix .install,$(SPECIALS)) meld.desktop
install:
mkdir -m 755 -p \
$(DESTDIR)$(bindir) \
$(DESTDIR)$(libdir_) \
$(DESTDIR)$(sharedir_)/glade2/pixmaps \
$(DESTDIR)$(docdir_) \
$(DESTDIR)$(sharedir)/applications \
$(DESTDIR)$(sharedir)/application-registry \
$(DESTDIR)$(sharedir)/pixmaps
install -m 755 meld.install \
$(DESTDIR)$(bindir)/meld
......@@ -47,10 +47,6 @@ install: $(addsuffix .install,$(SPECIALS)) meld.desktop
$(DESTDIR)$(libdir_)
install -m 644 paths.py.install \
$(DESTDIR)$(libdir_)/paths.py
install -m 644 meld.applications \
$(DESTDIR)$(sharedir)/application-registry/meld.applications
install -m 644 meld.desktop \
$(DESTDIR)$(sharedir)/applications
python -c 'import compileall; compileall.compile_dir("$(DESTDIR)$(libdir_)")'
python -O -c 'import compileall; compileall.compile_dir("$(DESTDIR)$(libdir_)")'
install -m 644 \
......@@ -62,12 +58,10 @@ install: $(addsuffix .install,$(SPECIALS)) meld.desktop
$(DESTDIR)$(sharedir_)/glade2/pixmaps
install -m 644 glade2/pixmaps/icon.png \
$(DESTDIR)$(sharedir)/pixmaps/meld.png
$(MAKE) -C data install
$(MAKE) -C po install
$(MAKE) -C help install
meld.desktop: meld.desktop.in
intltool-merge -d po meld.desktop.in meld.desktop
%.install: %
python tools/install_paths \
libdir=$(libdir_) \
......@@ -83,8 +77,8 @@ uninstall:
$(docdir_) \
$(libdir_) \
$(bindir)/meld \
$(sharedir)/applications/meld.desktop \
$(sharedir)/pixmaps/meld.png
$(MAKE) -C data uninstall
$(MAKE) -C po uninstall
$(MAKE) -C help uninstall
......
This diff is collapsed.
include ../INSTALL
.PHONY:all
all: meld.desktop meld.schemas
meld.schemas : meld.schemas.in
intltool-merge -d po $^ $@
meld.schemas.in : meld.schemas.csv
../tools/csv_to_schema $^ $@
meld.desktop: meld.desktop.in
intltool-merge -d po $^ $@
.PHONY:clean
clean:
-rm -f meld.desktop *.bak meld.schemas.in meld.schemas
.PHONY: install
install: meld.desktop meld.schemas
mkdir -m 755 -p \
$(DESTDIR)$(sharedir)/applications \
$(DESTDIR)$(sharedir)/application-registry \
$(DESTDIR)$(sharedir)/gconf/schemas
install -m 644 meld.desktop \
$(DESTDIR)$(sharedir)/applications
install -m 644 meld.applications \
$(DESTDIR)$(sharedir)/application-registry/meld.applications
install -m 644 meld.schemas \
$(DESTDIR)$(sharedir)/gconf/schemas/meld.schemas
.PHONY: uninstall
uninstall:
-rm -rf \
$(sharedir)/applications/meld.desktop
.PHONY: reinstall-schemas
reinstall-schemas : meld.schemas
gconftool-2 --recursive-unset /schemas/apps/meld
gconftool-2 --recursive-unset /apps/meld
gconftool-2 --install-schema-file meld.schemas
meld
command=meld
name=Meld
can_open_multiple_files=true
expects_uris=false
requires_terminal=false
mime_types=x-directory/normal
### Copyright (C) 2002-2004 Stephen Kennedy <stevek@gnome.org>
### Copyright (C) 2002-2005 Stephen Kennedy <stevek@gnome.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
......@@ -287,11 +287,13 @@ class Differ(object):
elif len(sequences)==3:
diffs = [[], []]
for i in range(2):
matcher = IncrementalSequenceMatcher(None, sequences[1], sequences[i*2])
work = matcher.initialise()
while work.next() == None:
yield None
diffs[i] = matcher.get_difference_opcodes()
if len(sequences[i*2]) != 0 and len(sequences[i*2][0]) != 0:
print 1, i*2
matcher = IncrementalSequenceMatcher(None, sequences[1], sequences[i*2])
work = matcher.initialise()
while work.next() == None:
yield None
diffs[i] = matcher.get_difference_opcodes()
else:
raise "Bad number of arguments to Differ constructor (%i)" % len(sequences)
self.diffs = diffs
......
### Copyright (C) 2002-2004 Stephen Kennedy <stevek@gnome.org>
### Copyright (C) 2002-2005 Stephen Kennedy <stevek@gnome.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
......
### Copyright (C) 2002-2005 Stephen Kennedy <stevek@gnome.org>
class Object:
### 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
"""Do-nothing stubs which match the dbus api.
"""
class Fake:
def __init__(self, *args):
print args
class Service:
pass
Object = Fake
Service = Fake
SessionBus = Fake
class dbus_bindings:
class DBusException(Exception):
pass
This diff is collapsed.
### Copyright (C) 2002-2004 Stephen Kennedy <stevek@gnome.org>
### Copyright (C) 2002-2005 Stephen Kennedy <stevek@gnome.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
......
### Copyright (C) 2002-2004 Stephen Kennedy <stevek@gnome.org>
### Copyright (C) 2002-2005 Stephen Kennedy <stevek@gnome.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
......@@ -58,8 +58,8 @@ class FindReplaceDialog(gobject.GObject, glade.Component):
active = self.gconf.get_bool(key)
widget.connect("toggled", lambda b,k=key : self.gconf.set_bool(k, b.get_active()) )
widget.set_active(active)
gtk.idle_add( lambda : self.entry_replace_with.select_region(0,-1) )
gtk.idle_add( lambda : self.entry_search_for.select_region(0,-1) )
gobject.idle_add( lambda : self.entry_replace_with.select_region(0,-1) )
gobject.idle_add( lambda : self.entry_search_for.select_region(0,-1) )
def update_history(self):
for entry,history_id in ( (self.entry_search_for,"search_for"),
......
### Copyright (C) 2002-2004 Stephen Kennedy <stevek@gnome.org>
### Copyright (C) 2002-2005 Stephen Kennedy <stevek@gnome.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
......@@ -18,6 +18,8 @@
"""
__metaclass__ = type
import gconf
import gettext
import glade
......@@ -28,10 +30,18 @@ import gtk.glade
import os
import paths
import re
import sys
DEBUG = lambda x : None
DEBUG = lambda x : sys.stdout.write(x+"\n")
RE_ON_HANDLER = re.compile(r"on_(.+?)__(.+)")
RE_AFTER_HANDLER = re.compile(r"after_(.+?)__(.+)")
class struct:
def __init__(self, **args):
self.__dict__.update(args)
def connect_signal_handlers(self):
"""Connect method named on_<widget>__<event> or after_<widget>__<event>
to the relevant widget events
......@@ -72,7 +82,7 @@ def connect_signal_handlers(self):
print attr, type(attr)
assert 0
class Component(object):
class Component:
"""Base class for all glade objects.
The handle to the xml file is stored in 'self.glade_xml'. The
......@@ -143,17 +153,22 @@ class Component(object):
if len(action)==5:
handler = getattr(self, "action_%s__activate"%action[0])
normal_actions.append( action + (handler,) )
elif isinstance(action[-1], type(True)):
elif len(action)==6:
assert isinstance(action[-1], type(True))
handler = getattr(self, "action_%s__toggled"%action[0])
toggle_actions.append( action[:-1] + (handler,action[-1]) )
elif isinstance(action[-1], type(0)):
handler = getattr(self, "action_%s__changed"%action[0])
radio_actions.append( action + (handler,) )
elif len(action)==7:
assert isinstance(action[-2], type(0))
radio_actions.append( action )
else:
assert 0
actiongroup.add_actions( normal_actions )
actiongroup.add_toggle_actions( toggle_actions )
actiongroup.add_radio_actions( radio_actions )
for i in range(len(radio_actions)):
if i+1==len(radio_actions) or radio_actions[i] != radio_actions[i+1]:
handler = getattr(self, "action_%s__changed"%radio_actions[i][-1])
actions = [a[:-1] for a in radio_actions]
actiongroup.add_radio_actions( actions, -1, handler )
for action in actiondefs:
setattr(self, "action_"+action[0], actiongroup.get_action(action[0]))
......@@ -208,22 +223,28 @@ class GtkApp(Component):
"""
gtk.main_quit()
def _load_close_pixbuf():
image = gtk.Image()
image.set_from_file( paths.share_dir("glade2/pixmaps/button_delete.xpm") )
image.set_from_pixbuf( image.get_pixbuf().scale_simple(9, 9, 2) )
return image.get_pixbuf()
class CloseLabel(gtk.HBox):
__gsignals__ = {
'closed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()),
}
CLOSE_ICON_PIXBUF = _load_close_pixbuf()
def __init__(self, iconname, text=""):
gtk.HBox.__init__(self)
self.label = gtk.Label(text)
self.label.set_padding(3,0)
self.button = gtk.Button()
icon = gtk.Image()
icon.set_from_file( paths.share_dir("glade2/pixmaps/%s" % iconname) )
icon.set_from_pixbuf( icon.get_pixbuf().scale_simple(15, 15, 2) ) #TODO font height
image = gtk.Image()
image.set_from_file( paths.share_dir("glade2/pixmaps/button_delete.xpm") )
image.set_from_pixbuf( image.get_pixbuf().scale_simple(9, 9, 2) ) #TODO font height
self.button.add( image )
close = gtk.Image()
close.set_from_pixbuf(self.CLOSE_ICON_PIXBUF)
self.button.add( close )
icon = gtk.image_new_from_stock( iconname, gtk.ICON_SIZE_SMALL_TOOLBAR )
self.pack_start( icon )
self.pack_start( self.label )
self.pack_start( self.button, expand=0 )
......@@ -237,48 +258,59 @@ class CloseLabel(gtk.HBox):
self.label.set_markup(markup)
gobject.type_register(CloseLabel)
class BaseEntry(gtk.HBox):
class BaseEntry(gobject.GObject):
ROOT_KEY = "/apps/meld/state"
def __init__(self, history_id=None):
__gsignals__ = {
"activate" : ( gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, () )
}
def __init__(self, comboentry, button, history_id=None):
self.__gobject_init__()
self.combo = gtk.combo_box_entry_new_text()
self.combo = comboentry
self.combo.set_model( gtk.ListStore(type("")) )
self.combo.set_text_column(0)
self.entry = self.combo.child
self.button = gtk.Button(_("_Browse..."))
self.pack_start(self.combo)
self.pack_start(self.button, expand=False)
self.set_spacing(3)
self.button = button
# history
self.gconf = gconf.client_get_default()
self.history_id = history_id
self.add_history(None)
self.history_id = history_id or comboentry.get_name()
self.set_filename(None)
# completion
self.completion = gtk.EntryCompletion()
model = gtk.ListStore(type(""))
self.completion.set_model( model )
self.completion.set_model(gtk.ListStore(gobject.TYPE_STRING))
self.completion.set_text_column(0)
self.entry.set_completion(self.completion)
glade.connect_signal_handlers(self)
self.show_all()
def on_button__clicked(self, button):
buttons = gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK
dialog = gtk.FileChooserDialog(parent=self.get_toplevel(), action=self.FILE_CHOOSER_ACTION, buttons=buttons)
dialog = gtk.FileChooserDialog(parent=button.get_toplevel(), action=self.FILE_CHOOSER_ACTION, buttons=buttons)
if dialog.run() == gtk.RESPONSE_OK:
self.entry.set_text(dialog.get_filename())
self.set_filename(dialog.get_filename())
self.entry.emit("activate")
dialog.destroy()
def on_entry__changed(self, entry):
model = entry.get_completion().get_model()
model.clear()
loc = entry.get_text()
if os.path.isdir(loc) and loc != "/":
loc += "/"
completions = [x for x in glob.glob( loc+"*" ) if self.COMPLETION_FILTER(x)]
def add_slash(p):
if os.path.isdir(p) and p != "/":
return p + "/"
return p
loc = add_slash(entry.get_text())
completions = [add_slash(x) for x in glob.glob( loc+"*" ) if self.COMPLETION_FILTER(x)]
for m in completions[:10]:
model.append( [m] )
def add_history(self, name):
def on_entry__activate(self, entry):
self.set_filename(entry.get_text())
self.emit("activate")
def get_filename(self):
return self.entry.get_text()
def set_filename(self, name):
history = self.gconf.get_list("%s/%s" % (self.ROOT_KEY, self.history_id), gconf.VALUE_STRING )
try:
history.remove(name)
......@@ -293,15 +325,15 @@ class BaseEntry(gtk.HBox):
for h in history:
model.append([h])
if name:
self.combo.set_active(0)
self.entry.set_text(name)
self.gconf.set_list("%s/%s" % (self.ROOT_KEY, self.history_id), gconf.VALUE_STRING, history )
gobject.type_register(BaseEntry)
class FileEntry(BaseEntry):
FILE_CHOOSER_ACTION = gtk.FILE_CHOOSER_ACTION_OPEN
COMPLETION_FILTER = lambda s,x: True
def __init__(self, history_id=None):
BaseEntry.__init__(self, history_id)
def __init__(self, comboentry, button, history_id=None):
BaseEntry.__init__(self, comboentry, button, history_id)
class DirEntry(BaseEntry):
......@@ -353,18 +385,16 @@ def run_dialog( maintext, parent=None, messagetype=gtk.MESSAGE_WARNING, buttonst
d.destroy()
return ret
def url_show(url, parent=None):
try:
return gnome.url_show(url)
except gobject.GError, e:
misc.run_dialog(_("Could not open '%s'.\n%s")%(url,e), parent)
def tie_to_gconf(rootkey, *widgets):
conf = gconf.client_get_default()
get_name = gtk.glade.get_widget_name
def connect( widget ):
name = get_name(widget)
def get_name(w):
return gtk.glade.get_widget_name(w) or w.__class__.__name__.lower()
def _name_to_enum(enum, val):
for k,v in enum.__enum_values__.items():
if v.value_nick == val: return v
return v
def connect( widget, name ):
key = "%s/%s" % (rootkey, name)
if isinstance( widget, gtk.RadioButton ):
# radio widgets must be named <keyname>_<value>
......@@ -383,18 +413,82 @@ def tie_to_gconf(rootkey, *widgets):
conf.set_string("%s/%s" %(rootkey,rkey), val )
for w in group:
w.connect("toggled", toggled)
elif isinstance( widget, gtk.ToggleButton ):
elif isinstance( widget, gtk.ToggleButton ) or isinstance( widget, gtk.ToggleToolButton ):
# toggles are named as their glade widget
active = conf.get_bool(key)
widget.set_active(active)
widget.connect("toggled", lambda b,k=key : conf.set_bool(k, b.get_active()) )
elif isinstance( widget, gtk.Toolbar ):
# toolbars are named as their glade widget
widget.connect("style-changed", lambda t,s,k=key : conf.set_string(key, s.value_nick))
widget.set_style( _name_to_enum(gtk.ToolbarStyle, conf.get_string(key) ) )
elif isinstance( widget, gtk.Window ):
# save window pos and size
keys = struct(width="%s_width"% key, height="%s_height"% key,x="%s_x"% key,y="%s_y"% key)
def configure_event(window, rect):
conf.set_int(keys.width, rect.width)
conf.set_int(keys.height, rect.height)
x,y = window.get_position()
conf.set_int(keys.x, x)
conf.set_int(keys.y, y)
widget.connect("configure-event", configure_event)
orig_size = conf.get_int(keys.width) or 600, conf.get_int(keys.height) or 400
orig_pos = conf.get_int(keys.x), conf.get_int(keys.y)
widget.set_default_size(*orig_size)
widget.move(*orig_pos)
elif isinstance( widget, gtk.SpinButton ):
# spinbuttons are named as their glade widget
value = conf.get_int(key)
widget.set_value(value)
widget.connect("changed", lambda b,k=key : conf.set_int(k, b.get_value_as_int()) )
elif isinstance( widget, gtk.ComboBox ):
# comboboxes are named as their glade widget
value = conf.get_string(key)
model = widget.get_model()
idx, iter = 0, model.get_iter_first()
while iter:
if value == model.get_value(iter,0):
widget.set_active(idx)
break
idx, iter = idx+1, model.iter_next(iter)
def changed(c,k=key):
m = c.get_model()
conf.set_string(k, m.get_value( m.get_iter(c.get_active()), 0))
widget.connect("changed", changed)
elif isinstance( widget, gtk.Entry ):
# entries are named as their glade widget
value = conf.get_string(key)
widget.set_text(value)
widget.connect("changed", lambda b,k=key : conf.set_string(k, b.get_text()) )
elif isinstance( widget, gtk.FontButton ):
# fontbuttons are named as their glade widget
value = conf.get_string(key)
widget.set_font_name(value)
widget.connect("font-set", lambda b,k=key : conf.set_string(k, b.get_font_name()) )
else:
print "Fixme", widget, type(widget)
print "Fixme connect to gconf for", widget, type(widget)
raise ""
for widget in widgets:
if isinstance( widget, list ):
if isinstance( widget, tuple):
assert len(widget) == 2
connect( widget[0], widget[1] )
elif isinstance( widget, list ):
for w in widget:
connect( w )
connect( w, get_name(w) )
else:
connect(widget)
connect( widget, get_name(widget) )
def url_show(url):
conf = gconf.client_get_default()
if url.startswith("ghelp:"):
prog = conf.get_string('/desktop/gnome/url-handlers/ghelp/command') or 'gnome-help "%s"'
elif url.startswith("file:") or url.startswith("http:") or url.startswith("https:"):
prog = conf.get_string('/desktop/gnome/url-handlers/http/command') or 'galeon "%s"'
else:
assert 0
args = (prog % url).split() # shell split
args = [a.strip('"\'') for a in args] # strip shell quotes
os.spawnvp(os.P_NOWAIT, args[0], args)
This diff is collapsed.
This diff is collapsed.
......@@ -2,6 +2,7 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<requires lib="gnome"/>
<widget class="GtkWindow" id="container">
<property name="visible">True</property>
......@@ -18,7 +19,7 @@
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<child>
<widget class="GtkVBox" id="cvsview">
<widget class="GtkVBox" id="wocoview">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
......@@ -921,6 +922,7 @@
<property name="local_only">True</property>
<property name="select_multiple">False</property>
<property name="show_hidden">False</property>
<property name="title" translatable="yes">Choose Directory - Meld</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="modal">False</property>
......
......@@ -4,7 +4,7 @@
<glade-project>
<name>Glade2</name>
<program_name>glade2</program_name>
<backup_source_files>FALSE</backup_source_files>
<gnome_support>FALSE</gnome_support>
<translatable_strings_file>cvsview.strings</translatable_strings_file>
<backup_source_files>FALSE</backup_source_files>
<translatable_strings_file>wocoview.strings</translatable_strings_file>
</glade-project>
......@@ -55,10 +55,7 @@ if sys.version_info[:2] < pyver:
try:
import pygtk
except ImportError, e:
print e
print _("Meld requires a recent version of pygtk.")
print _("pygtk-%s or higher is recommended.") % ver2str(pygtkver)
sys.exit(1)
pass # catch gtk version later
else:
pygtk.require("2.0")
......@@ -67,7 +64,9 @@ else:
#
import gtk
if gtk.pygtk_version < pygtkver:
print _("Meld requires pygtk-%s or higher. (found %s)") % (ver2str(pygtkver), ver2str(gtk.pygtk_version))
print _("Meld requires pygtk-%s or higher. (found %s)") % (
ver2str(pygtkver), ver2str(gtk.pygtk_version))
sys.exit(1)
#
# main
......
### Copyright (C) 2002-2004 Stephen Kennedy <stevek@gnome.org>
### Copyright (C) 2002-2005 Stephen Kennedy <stevek@gnome.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
......@@ -18,7 +18,8 @@
import sys
import os
# gnome
# gtk
import gobject
import gtk
# project
......@@ -29,10 +30,8 @@ import task
import stock
import filediff
import dirdiff
import cvsview
import wocoview
import prefs
import prefsui
try:
import dbus
......@@ -67,6 +66,7 @@ class MeldApp(glade.GtkApp, dbus.Object):
</menubar>
<toolbar name="ToolBar">
<toolitem action="new"/>
<separator/>
</toolbar>
</ui>
"""
......@@ -95,7 +95,7 @@ class MeldApp(glade.GtkApp, dbus.Object):
# init
#
def __init__(self, dbus_service):
glade.GtkApp.__init__(self, paths.share_dir("glade2/meldapp.glade"), "meldapp")
glade.GtkApp.__init__(self, paths.share_dir("glade2/meldapp.glade"), "window")
self.uimanager = gtk.UIManager()
self.toplevel.add_accel_group( self.uimanager.get_accel_group() )
......@@ -112,18 +112,29 @@ class MeldApp(glade.GtkApp, dbus.Object):
self.vbox.reorder_child(self.toolbar, 1)
self.connect_signal_handlers()
self.prefs = prefsui.MeldPreferences()
self.prefs = prefs.Preferences("/apps/meld")
glade.tie_to_gconf("/apps/meld/state/app", self.toplevel)
self.toolbar.set_style( self.prefs.get_toolbar_style() )
self.prefs.notify_add( self.on_preference_changed )
self.idle_hooked = 0
self.scheduler = task.LifoScheduler()
self.scheduler.connect("runnable", self.on_scheduler_runnable )
self.toplevel.set_default_size(self.prefs.window_size_x, self.prefs.window_size_y)
self.toplevel.show()
print self.toplevel.get_name()
if dbus_service:
dbus.Object.__init__(self, "/App", dbus_service,
[self.action_about__activate] )
[self.action_about__activate,
self.save_snapshot] )
def save_snapshot(self, message, filename, x=0, y=0, width=-1, height=-1):
win = self.toplevel.window
if width == -1:
width = win.get_size()[0]
if height == -1:
height = win.get_size()[1]
pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width,height)
pix.get_from_drawable( win, win.get_colormap(), x,y, 0,0, width,height )
pix.save(filename, "png")
def _set_doc_status(self, status):
self.doc_status.pop(1)
......@@ -157,11 +168,7 @@ class MeldApp(glade.GtkApp, dbus.Object):
def on_scheduler_runnable(self, sched):
if not self.idle_hooked:
self.idle_hooked = 1
gtk.idle_add( self.on_idle )
def on_preference_changed(self, key, value):
if key == "toolbar_style":
self.toolbar.set_style( self.prefs.get_toolbar_style() )
gobject.idle_add( self.on_idle )
#
# General events and callbacks
......@@ -169,24 +176,45 @@ class MeldApp(glade.GtkApp, dbus.Object):
def on_toplevel__delete_event(self, *extra):
return self.action_quit__activate()
def on_toplevel__size_allocate(self, window, rect):
self.prefs.window_size_x = rect.width
self.prefs.window_size_y = rect.height
def on_notebook__switch_page(self, notebook, page, which):
newdoc = notebook.get_nth_page(which).get_data("pyobject")
get_doc = lambda i : notebook.get_nth_page(i).get_data("pyobject")
if notebook.get_current_page() >= 0:
old_doc = get_doc( notebook.get_current_page() )
old_doc.on_container_switch_out_event(self.uimanager)
newdoc = get_doc(which)