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_TYPE = 'MY_TREE_MODEL_ROW'
|
||||||
LOCAL_DRAG_ATOM_TYPE = Gdk.atom_intern(LOCAL_DRAG_TYPE, False)
|
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):
|
def __init__(self, dbstate, widget):
|
||||||
|
|
||||||
@ -954,7 +954,7 @@ class ClipboardListView(object):
|
|||||||
|
|
||||||
targ_data = DdTargets.all_dtype()
|
targ_data = DdTargets.all_dtype()
|
||||||
tglist = Gtk.TargetList.new([])
|
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[1],
|
||||||
ClipboardListView.LOCAL_DRAG_TARGET[2])
|
ClipboardListView.LOCAL_DRAG_TARGET[2])
|
||||||
for tg in targ_data:
|
for tg in targ_data:
|
||||||
@ -1128,7 +1128,7 @@ class ClipboardListView(object):
|
|||||||
tree_selection = self._widget.get_selection()
|
tree_selection = self._widget.get_selection()
|
||||||
model, paths = tree_selection.get_selected_rows()
|
model, paths = tree_selection.get_selected_rows()
|
||||||
if len(paths) > 1:
|
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]
|
ClipboardListView.LOCAL_DRAG_TARGET]
|
||||||
else:
|
else:
|
||||||
targets = [ClipboardListView.LOCAL_DRAG_TARGET]
|
targets = [ClipboardListView.LOCAL_DRAG_TARGET]
|
||||||
@ -1136,11 +1136,16 @@ class ClipboardListView(object):
|
|||||||
node = model.get_iter(path)
|
node = model.get_iter(path)
|
||||||
if node is not None:
|
if node is not None:
|
||||||
o = model.get_value(node,1)
|
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,
|
self._widget.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
|
||||||
targets,
|
[],
|
||||||
Gdk.DragAction.COPY | Gdk.DragAction.MOVE)
|
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):
|
def object_drag_begin(self, widget, drag_context):
|
||||||
""" Handle the beginning of a drag operation. """
|
""" 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):
|
def object_drag_data_get(self, widget, context, sel_data, info, time):
|
||||||
tree_selection = widget.get_selection()
|
tree_selection = widget.get_selection()
|
||||||
model, paths = tree_selection.get_selected_rows()
|
model, paths = tree_selection.get_selected_rows()
|
||||||
|
tgs = context.list_targets()
|
||||||
if len(paths) == 1:
|
if len(paths) == 1:
|
||||||
path = paths[0]
|
path = paths[0]
|
||||||
node = model.get_iter(path)
|
node = model.get_iter(path)
|
||||||
o = model.get_value(node,1)
|
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:
|
elif len(paths) > 1:
|
||||||
raw_list = []
|
raw_list = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
node = model.get_iter(path)
|
node = model.get_iter(path)
|
||||||
o = model.get_value(node,1)
|
o = model.get_value(node,1)
|
||||||
raw_list.append(o.pack())
|
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,
|
def object_drag_data_received(self, widget, context, x, y, selection, info,
|
||||||
time, title=None, value=None, dbid=None,
|
time, title=None, value=None, dbid=None,
|
||||||
|
@ -100,6 +100,13 @@ class _DdType:
|
|||||||
"""
|
"""
|
||||||
return [self.drag_type, self.target_flags, self.app_id]
|
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):
|
class _DdTargets(object):
|
||||||
"""A single class that manages all the drag and drop targets."""
|
"""A single class that manages all the drag and drop targets."""
|
||||||
|
|
||||||
|
@ -180,16 +180,24 @@ class EmbeddedList(ButtonTab):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if self._DND_EXTRA:
|
if self._DND_EXTRA:
|
||||||
dnd_types = [self._DND_TYPE.target_data(),
|
dnd_types = [self._DND_TYPE,
|
||||||
self._DND_EXTRA.target_data()]
|
self._DND_EXTRA]
|
||||||
else:
|
else:
|
||||||
dnd_types = [self._DND_TYPE.target_data()]
|
dnd_types = [self._DND_TYPE]
|
||||||
|
|
||||||
self.tree.enable_model_drag_dest(dnd_types,
|
#TODO GTK3: wourkaround here for bug https://bugzilla.gnome.org/show_bug.cgi?id=680638
|
||||||
Gdk.DragAction.COPY)
|
self.tree.enable_model_drag_dest([], Gdk.DragAction.COPY)
|
||||||
self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
|
self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [],
|
||||||
[self._DND_TYPE.target_data()],
|
|
||||||
Gdk.DragAction.COPY)
|
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)
|
self.tree.connect('drag_data_get', self.drag_data_get)
|
||||||
if not self.dbstate.db.readonly:
|
if not self.dbstate.db.readonly:
|
||||||
self.tree.connect('drag_data_received', self.drag_data_received)
|
self.tree.connect('drag_data_received', self.drag_data_received)
|
||||||
@ -220,7 +228,7 @@ class EmbeddedList(ButtonTab):
|
|||||||
data = pickle.dumps(value)
|
data = pickle.dumps(value)
|
||||||
|
|
||||||
# pass as a string (8 bits)
|
# 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):
|
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,
|
If the selection data is defined, extract the value from sel_data.data,
|
||||||
and decide if this is a move or a reorder.
|
and decide if this is a move or a reorder.
|
||||||
"""
|
"""
|
||||||
if sel_data and sel_data.data:
|
if sel_data and sel_data.get_data():
|
||||||
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.data)
|
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.get_data())
|
||||||
|
|
||||||
# make sure this is the correct DND type for this object
|
# make sure this is the correct DND type for this object
|
||||||
if mytype == self._DND_TYPE.drag_type:
|
if mytype == self._DND_TYPE.drag_type:
|
||||||
|
@ -148,7 +148,7 @@ class GroupEmbeddedList(EmbeddedList):
|
|||||||
data = pickle.dumps(value)
|
data = pickle.dumps(value)
|
||||||
|
|
||||||
# pass as a string (8 bits)
|
# 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):
|
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,
|
If the selection data is define, extract the value from sel_data.data,
|
||||||
and decide if this is a move or a reorder.
|
and decide if this is a move or a reorder.
|
||||||
"""
|
"""
|
||||||
if sel_data and sel_data.data:
|
if sel_data and sel_data.get_data():
|
||||||
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.data)
|
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.get_data())
|
||||||
|
|
||||||
# make sure this is the correct DND type for this object
|
# make sure this is the correct DND type for this object
|
||||||
if mytype == self._DND_TYPE.drag_type:
|
if mytype == self._DND_TYPE.drag_type:
|
||||||
|
@ -161,7 +161,7 @@ class EditChildRef(EditSecondary):
|
|||||||
|
|
||||||
self._setup_notebook_tabs( notebook)
|
self._setup_notebook_tabs( notebook)
|
||||||
notebook.show_all()
|
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):
|
def _post_init(self):
|
||||||
self.ok_button.grab_focus()
|
self.ok_button.grab_focus()
|
||||||
|
@ -73,8 +73,15 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBoxEntry" id="frel">
|
<object class="GtkComboBox" id="frel">
|
||||||
<property name="visible">True</property>
|
<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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
@ -76,8 +76,15 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBoxEntry" id="new">
|
<object class="GtkComboBox" id="new">
|
||||||
<property name="visible">True</property>
|
<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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
@ -89,8 +96,15 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBoxEntry" id="original">
|
<object class="GtkComboBox" id="original">
|
||||||
<property name="visible">True</property>
|
<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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
@ -69,8 +69,15 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="spacing">3</property>
|
<property name="spacing">3</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBoxEntry" id="tagcombo">
|
<object class="GtkComboBox" id="tagcombo">
|
||||||
<property name="visible">True</property>
|
<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"/>
|
<accelerator key="T" signal="grab_focus" modifiers="GDK_MOD1_MASK"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -76,8 +76,15 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBoxEntry" id="name_list">
|
<object class="GtkComboBox" id="name_list">
|
||||||
<property name="visible">True</property>
|
<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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user