gtkapplicationimpl.c 5.68 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/*
 * Copyright © 2013 Canonical Limited
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the licence, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Ryan Lortie <desrt@desrt.ca>
 */

#include "config.h"

#include "gtkapplicationprivate.h"

#ifdef GDK_WINDOWING_X11
#include <gdk/x11/gdkx.h>
#endif

#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/wayland/gdkwayland.h>
#endif

#ifdef GDK_WINDOWING_QUARTZ
#include <gdk/quartz/gdkquartz.h>
#endif

G_DEFINE_TYPE (GtkApplicationImpl, gtk_application_impl, G_TYPE_OBJECT)

static void
gtk_application_impl_init (GtkApplicationImpl *impl)
{
}

static guint do_nothing (void) { return 0; }
44
static gboolean return_false (void) { return FALSE; }
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

static void
gtk_application_impl_class_init (GtkApplicationImplClass *class)
{
  /* NB: can only 'do_nothing' for functions with integer or void return */
  class->startup = (gpointer) do_nothing;
  class->shutdown = (gpointer) do_nothing;
  class->before_emit = (gpointer) do_nothing;
  class->window_added = (gpointer) do_nothing;
  class->window_removed = (gpointer) do_nothing;
  class->active_window_changed = (gpointer) do_nothing;
  class->handle_window_realize = (gpointer) do_nothing;
  class->handle_window_map = (gpointer) do_nothing;
  class->set_app_menu = (gpointer) do_nothing;
  class->set_menubar = (gpointer) do_nothing;
  class->inhibit = (gpointer) do_nothing;
  class->uninhibit = (gpointer) do_nothing;
  class->is_inhibited = (gpointer) do_nothing;
63
  class->prefers_app_menu = (gpointer) return_false;
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
}

void
gtk_application_impl_startup (GtkApplicationImpl *impl,
                              gboolean            register_session)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->startup (impl, register_session);
}

void
gtk_application_impl_shutdown (GtkApplicationImpl *impl)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->shutdown (impl);
}

void
gtk_application_impl_before_emit (GtkApplicationImpl *impl,
                                  GVariant           *platform_data)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->before_emit (impl, platform_data);
}

void
gtk_application_impl_window_added (GtkApplicationImpl *impl,
                                   GtkWindow          *window)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->window_added (impl, window);
}

void
gtk_application_impl_window_removed (GtkApplicationImpl *impl,
                                     GtkWindow          *window)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->window_removed (impl, window);
}

void
gtk_application_impl_active_window_changed (GtkApplicationImpl *impl,
                                            GtkWindow          *window)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->active_window_changed (impl, window);
}

void
gtk_application_impl_handle_window_realize (GtkApplicationImpl *impl,
                                            GtkWindow          *window)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->handle_window_realize (impl, window);
}

void
gtk_application_impl_handle_window_map (GtkApplicationImpl *impl,
                                        GtkWindow          *window)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->handle_window_map (impl, window);
}

void
gtk_application_impl_set_app_menu (GtkApplicationImpl *impl,
                                   GMenuModel         *app_menu)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->set_app_menu (impl, app_menu);
}

void
gtk_application_impl_set_menubar (GtkApplicationImpl *impl,
                                  GMenuModel         *menubar)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->set_menubar (impl, menubar);
}

guint
gtk_application_impl_inhibit (GtkApplicationImpl         *impl,
                              GtkWindow                  *window,
                              GtkApplicationInhibitFlags  flags,
                              const gchar                *reason)
{
  return GTK_APPLICATION_IMPL_GET_CLASS (impl)->inhibit (impl, window, flags, reason);
}

void
gtk_application_impl_uninhibit (GtkApplicationImpl *impl,
                                guint               cookie)
{
  GTK_APPLICATION_IMPL_GET_CLASS (impl)->uninhibit (impl, cookie);
}

gboolean
gtk_application_impl_is_inhibited (GtkApplicationImpl         *impl,
                                   GtkApplicationInhibitFlags  flags)
{
  return GTK_APPLICATION_IMPL_GET_CLASS (impl)->is_inhibited (impl, flags);
}

158 159 160 161 162 163
gboolean
gtk_application_impl_prefers_app_menu (GtkApplicationImpl *impl)
{
  return GTK_APPLICATION_IMPL_GET_CLASS (impl)->prefers_app_menu (impl);
}

164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
GtkApplicationImpl *
gtk_application_impl_new (GtkApplication *application,
                          GdkDisplay     *display)
{
  GtkApplicationImpl *impl;
  GType impl_type;

  impl_type = gtk_application_impl_get_type ();

#ifdef GDK_WINDOWING_X11
  if (GDK_IS_X11_DISPLAY (display))
    impl_type = gtk_application_impl_x11_get_type ();
#endif

#ifdef GDK_WINDOWING_WAYLAND
  if (GDK_IS_WAYLAND_DISPLAY (display))
    impl_type = gtk_application_impl_wayland_get_type ();
#endif

#ifdef GDK_WINDOWING_QUARTZ
  if (GDK_IS_QUARTZ_DISPLAY (display))
    impl_type = gtk_application_impl_quartz_get_type ();
#endif

  impl = g_object_new (impl_type, NULL);
  impl->application = application;
  impl->display = display;

  return impl;
}