~ubuntu-branches/ubuntu/precise/gtkmm3.0/precise

« back to all changes in this revision

Viewing changes to gtk/src/treedragsource.ccg

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-17 00:12:44 UTC
  • Revision ID: james.westby@ubuntu.com-20110617001244-9hl5an15hiaaahi6
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
/* $Id: treedragsource.ccg,v 1.4 2006/05/11 11:40:24 murrayc Exp $ */
 
3
 
 
4
/* Copyright 1998-2002 The gtkmm Development Team
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2.1 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this library; if not, write to the Free
 
18
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 */
 
20
 
 
21
#include <gtkmm/treepath.h>
 
22
#include <gtkmm/selectiondata_private.h> //For SelectionData_WithoutOwnership
 
23
#include <gtk/gtk.h>
 
24
 
 
25
 
 
26
namespace Gtk
 
27
{
 
28
 
 
29
//This vfunc wrapper is manually written, so that we can use a temporary instance for the SelectionData& output parameter:
 
30
 
 
31
gboolean TreeDragSource_Class::drag_data_get_vfunc_callback(GtkTreeDragSource* self, GtkTreePath* path, GtkSelectionData* selection_data)
 
32
{
 
33
  CppObjectType *const obj = dynamic_cast<CppObjectType*>(
 
34
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 
35
 
 
36
  // Non-gtkmmproc-generated custom classes implicitly call the default
 
37
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 
38
  // generated classes can use this optimisation, which avoids the unnecessary
 
39
  // parameter conversions if there is no possibility of the virtual function
 
40
  // being overridden:
 
41
  if(obj && obj->is_derived_())
 
42
  {
 
43
    try // Trap C++ exceptions which would normally be lost because this is a C callback.
 
44
    {
 
45
      // Call the virtual member method, which derived classes might override.
 
46
      SelectionData_WithoutOwnership temp_instance(selection_data);
 
47
      return static_cast<int>(obj->drag_data_get_vfunc(Gtk::TreePath(path, true), temp_instance));
 
48
    }
 
49
    catch(...)
 
50
    {
 
51
      Glib::exception_handlers_invoke();
 
52
    }
 
53
  }
 
54
  else
 
55
  {
 
56
    BaseClassType *const base = static_cast<BaseClassType*>(
 
57
        g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
 
58
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
 
59
)    );
 
60
 
 
61
    // Call the original underlying C function:
 
62
    if(base && base->drag_data_get)
 
63
      return (*base->drag_data_get)(self, path, selection_data);
 
64
  }
 
65
 
 
66
  typedef gboolean RType;
 
67
  return RType();
 
68
}
 
69
 
 
70
bool Gtk::TreeDragSource::drag_data_get_vfunc(const TreeModel::Path& path, SelectionData& selection_data) const
 
71
{
 
72
  BaseClassType *const base = static_cast<BaseClassType*>(
 
73
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
 
74
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
 
75
)  );
 
76
 
 
77
  if(base && base->drag_data_get)
 
78
    return (*base->drag_data_get)(const_cast<GtkTreeDragSource*>(gobj()),const_cast<GtkTreePath*>((path).gobj()), selection_data.gobj());
 
79
 
 
80
  typedef bool RType;
 
81
  return RType();
 
82
}
 
83
 
 
84
} //namespace Gtk
 
85