GTK3: allow copy from clipboard to embeddedlist
GTK3: convert remaining ComboboxEntry GTK3: child ref editor works svn: r20090
This commit is contained in:
parent
28a20116b5
commit
a81ec4fc74
@ -895,7 +895,7 @@ class ClipboardListView(object):
|
||||
|
||||
LOCAL_DRAG_TYPE = 'MY_TREE_MODEL_ROW'
|
||||
LOCAL_DRAG_ATOM_TYPE = Gdk.atom_intern(LOCAL_DRAG_TYPE, False)
|
||||
LOCAL_DRAG_TARGET = (LOCAL_DRAG_TYPE, Gtk.TargetFlags.SAME_WIDGET, 0)
|
||||
LOCAL_DRAG_TARGET = (LOCAL_DRAG_ATOM_TYPE, Gtk.TargetFlags.SAME_WIDGET, 0)
|
||||
|
||||
def __init__(self, dbstate, widget):
|
||||
|
||||
@ -954,7 +954,7 @@ class ClipboardListView(object):
|
||||
|
||||
targ_data = DdTargets.all_dtype()
|
||||
tglist = Gtk.TargetList.new([])
|
||||
tglist.add(ClipboardListView.LOCAL_DRAG_ATOM_TYPE,
|
||||
tglist.add(ClipboardListView.LOCAL_DRAG_TARGET[0],
|
||||
ClipboardListView.LOCAL_DRAG_TARGET[1],
|
||||
ClipboardListView.LOCAL_DRAG_TARGET[2])
|
||||
for tg in targ_data:
|
||||
@ -1128,7 +1128,7 @@ class ClipboardListView(object):
|
||||
tree_selection = self._widget.get_selection()
|
||||
model, paths = tree_selection.get_selected_rows()
|
||||
if len(paths) > 1:
|
||||
targets = [(DdTargets.RAW_LIST.drag_type, Gtk.TargetFlags.SAME_WIDGET, 0),
|
||||
targets = [(DdTargets.RAW_LIST.atom_drag_type, Gtk.TargetFlags.SAME_WIDGET, 0),
|
||||
ClipboardListView.LOCAL_DRAG_TARGET]
|
||||
else:
|
||||
targets = [ClipboardListView.LOCAL_DRAG_TARGET]
|
||||
@ -1136,11 +1136,16 @@ class ClipboardListView(object):
|
||||
node = model.get_iter(path)
|
||||
if node is not None:
|
||||
o = model.get_value(node,1)
|
||||
targets += [target.target_data() for target in o.__class__.DROP_TARGETS]
|
||||
targets += [target.target_data_atom() for target in o.__class__.DROP_TARGETS]
|
||||
|
||||
#TODO GTK3: wourkaround here for bug https://bugzilla.gnome.org/show_bug.cgi?id=680638
|
||||
self._widget.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
|
||||
targets,
|
||||
[],
|
||||
Gdk.DragAction.COPY | Gdk.DragAction.MOVE)
|
||||
tglist = Gtk.TargetList.new([])
|
||||
for tg in targets:
|
||||
tglist.add(tg[0], tg[1], tg[2])
|
||||
self._widget.drag_source_set_target_list(tglist)
|
||||
|
||||
def object_drag_begin(self, widget, drag_context):
|
||||
""" Handle the beginning of a drag operation. """
|
||||
@ -1153,18 +1158,19 @@ class ClipboardListView(object):
|
||||
def object_drag_data_get(self, widget, context, sel_data, info, time):
|
||||
tree_selection = widget.get_selection()
|
||||
model, paths = tree_selection.get_selected_rows()
|
||||
tgs = context.list_targets()
|
||||
if len(paths) == 1:
|
||||
path = paths[0]
|
||||
node = model.get_iter(path)
|
||||
o = model.get_value(node,1)
|
||||
sel_data.set(sel_data.target, 8, o.pack())
|
||||
sel_data.set(tgs[0], 8, o.pack())
|
||||
elif len(paths) > 1:
|
||||
raw_list = []
|
||||
for path in paths:
|
||||
node = model.get_iter(path)
|
||||
o = model.get_value(node,1)
|
||||
raw_list.append(o.pack())
|
||||
sel_data.set(sel_data.target, 8, pickle.dumps(raw_list))
|
||||
sel_data.set(tgs[0], 8, pickle.dumps(raw_list))
|
||||
|
||||
def object_drag_data_received(self, widget, context, x, y, selection, info,
|
||||
time, title=None, value=None, dbid=None,
|
||||
|
@ -100,6 +100,13 @@ class _DdType:
|
||||
"""
|
||||
return [self.drag_type, self.target_flags, self.app_id]
|
||||
|
||||
def target_data_atom(self):
|
||||
"""
|
||||
Return the target information as a list in the format required by
|
||||
Gtk3 functions.
|
||||
"""
|
||||
return [self.atom_drag_type, self.target_flags, self.app_id]
|
||||
|
||||
class _DdTargets(object):
|
||||
"""A single class that manages all the drag and drop targets."""
|
||||
|
||||
|
@ -180,16 +180,24 @@ class EmbeddedList(ButtonTab):
|
||||
"""
|
||||
|
||||
if self._DND_EXTRA:
|
||||
dnd_types = [self._DND_TYPE.target_data(),
|
||||
self._DND_EXTRA.target_data()]
|
||||
dnd_types = [self._DND_TYPE,
|
||||
self._DND_EXTRA]
|
||||
else:
|
||||
dnd_types = [self._DND_TYPE.target_data()]
|
||||
dnd_types = [self._DND_TYPE]
|
||||
|
||||
self.tree.enable_model_drag_dest(dnd_types,
|
||||
Gdk.DragAction.COPY)
|
||||
self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
|
||||
[self._DND_TYPE.target_data()],
|
||||
Gdk.DragAction.COPY)
|
||||
#TODO GTK3: wourkaround here for bug https://bugzilla.gnome.org/show_bug.cgi?id=680638
|
||||
self.tree.enable_model_drag_dest([], Gdk.DragAction.COPY)
|
||||
self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [],
|
||||
Gdk.DragAction.COPY)
|
||||
tglist = Gtk.TargetList.new([])
|
||||
for tg in dnd_types:
|
||||
tglist.add(tg.atom_drag_type, tg.target_flags, tg.app_id)
|
||||
self.tree.drag_dest_set_target_list(tglist)
|
||||
tglist = Gtk.TargetList.new([])
|
||||
tglist.add(self._DND_TYPE.atom_drag_type, self._DND_TYPE.target_flags,
|
||||
self._DND_TYPE.app_id)
|
||||
self.tree.drag_source_set_target_list(tglist)
|
||||
|
||||
self.tree.connect('drag_data_get', self.drag_data_get)
|
||||
if not self.dbstate.db.readonly:
|
||||
self.tree.connect('drag_data_received', self.drag_data_received)
|
||||
@ -220,7 +228,7 @@ class EmbeddedList(ButtonTab):
|
||||
data = pickle.dumps(value)
|
||||
|
||||
# pass as a string (8 bits)
|
||||
sel_data.set(sel_data.target, 8, data)
|
||||
sel_data.set(self._DND_TYPE.atom_drag_type, 8, data)
|
||||
|
||||
def drag_data_received(self, widget, context, x, y, sel_data, info, time):
|
||||
"""
|
||||
@ -229,8 +237,8 @@ class EmbeddedList(ButtonTab):
|
||||
If the selection data is defined, extract the value from sel_data.data,
|
||||
and decide if this is a move or a reorder.
|
||||
"""
|
||||
if sel_data and sel_data.data:
|
||||
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.data)
|
||||
if sel_data and sel_data.get_data():
|
||||
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.get_data())
|
||||
|
||||
# make sure this is the correct DND type for this object
|
||||
if mytype == self._DND_TYPE.drag_type:
|
||||
|
@ -148,7 +148,7 @@ class GroupEmbeddedList(EmbeddedList):
|
||||
data = pickle.dumps(value)
|
||||
|
||||
# pass as a string (8 bits)
|
||||
sel_data.set(sel_data.target, 8, data)
|
||||
sel_data.set(self._DND_TYPE.atom_drag_type, 8, data)
|
||||
|
||||
def drag_data_received(self, widget, context, x, y, sel_data, info, time):
|
||||
"""
|
||||
@ -157,8 +157,8 @@ class GroupEmbeddedList(EmbeddedList):
|
||||
If the selection data is define, extract the value from sel_data.data,
|
||||
and decide if this is a move or a reorder.
|
||||
"""
|
||||
if sel_data and sel_data.data:
|
||||
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.data)
|
||||
if sel_data and sel_data.get_data():
|
||||
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.get_data())
|
||||
|
||||
# make sure this is the correct DND type for this object
|
||||
if mytype == self._DND_TYPE.drag_type:
|
||||
|
@ -161,7 +161,7 @@ class EditChildRef(EditSecondary):
|
||||
|
||||
self._setup_notebook_tabs( notebook)
|
||||
notebook.show_all()
|
||||
self.top.get_object('vbox').pack_start(notebook,True)
|
||||
self.top.get_object('vbox').pack_start(notebook, True, True, 0)
|
||||
|
||||
def _post_init(self):
|
||||
self.ok_button.grab_focus()
|
||||
|
@ -73,8 +73,15 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxEntry" id="frel">
|
||||
<object class="GtkComboBox" id="frel">
|
||||
<property name="visible">True</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="frel-entry">
|
||||
<property name="can_focus">True</property>
|
||||
<property name="overwrite_mode">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -76,8 +76,15 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxEntry" id="new">
|
||||
<object class="GtkComboBox" id="new">
|
||||
<property name="visible">True</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="new-entry">
|
||||
<property name="can_focus">True</property>
|
||||
<property name="overwrite_mode">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
@ -89,8 +96,15 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxEntry" id="original">
|
||||
<object class="GtkComboBox" id="original">
|
||||
<property name="visible">True</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="original-entry">
|
||||
<property name="can_focus">True</property>
|
||||
<property name="overwrite_mode">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -69,8 +69,15 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">3</property>
|
||||
<child>
|
||||
<object class="GtkComboBoxEntry" id="tagcombo">
|
||||
<object class="GtkComboBox" id="tagcombo">
|
||||
<property name="visible">True</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="tagcombo-entry">
|
||||
<property name="can_focus">True</property>
|
||||
<property name="overwrite_mode">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="T" signal="grab_focus" modifiers="GDK_MOD1_MASK"/>
|
||||
</object>
|
||||
<packing>
|
||||
|
@ -76,8 +76,15 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxEntry" id="name_list">
|
||||
<object class="GtkComboBox" id="name_list">
|
||||
<property name="visible">True</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="name_list-entry">
|
||||
<property name="can_focus">True</property>
|
||||
<property name="overwrite_mode">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
Loading…
Reference in New Issue
Block a user