Пример #1
0
static void
gtk_application_window_real_realize (GtkWidget *widget)
{
  GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
  GtkApplication *application;
  GtkSettings *settings;

  application = gtk_window_get_application (GTK_WINDOW (window));
  settings = gtk_widget_get_settings (widget);

  g_signal_connect (settings, "notify::gtk-shell-shows-app-menu",
                    G_CALLBACK (gtk_application_window_shell_shows_app_menu_changed), window);
  g_signal_connect (settings, "notify::gtk-shell-shows-menubar",
                    G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), window);

  if (!window->priv->muxer_initialised)
    {
      g_action_muxer_insert (G_ACTION_MUXER (window->priv->muxer), "app", G_ACTION_GROUP (application));
      g_action_muxer_insert (G_ACTION_MUXER (window->priv->muxer), "win", G_ACTION_GROUP (window));
      window->priv->muxer_initialised = TRUE;
    }

  gtk_application_window_update_shell_shows_app_menu (window, settings);
  gtk_application_window_update_shell_shows_menubar (window, settings);
  gtk_application_window_update_menubar (window);
  gtk_application_window_update_accels (window);

  GTK_WIDGET_CLASS (gtk_application_window_parent_class)
    ->realize (widget);

#ifdef GDK_WINDOWING_X11
  {
    GdkWindow *gdkwindow;

    gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));

    if (GDK_IS_X11_WINDOW (gdkwindow) && window->priv->session)
      {
        gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_ID",
                                          g_application_get_application_id (G_APPLICATION (application)));

        gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_UNIQUE_BUS_NAME",
                                          g_dbus_connection_get_unique_name (window->priv->session));

        gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_OBJECT_PATH",
                                          g_application_get_dbus_object_path (G_APPLICATION (application)));

        gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_WINDOW_OBJECT_PATH",
                                          window->priv->object_path);

        gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APP_MENU_OBJECT_PATH",
                                          gtk_application_get_app_menu_object_path (application));

        gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_MENUBAR_OBJECT_PATH",
                                          gtk_application_get_menubar_object_path (application));
      }
  }
#endif
}
Пример #2
0
static void
gtk_application_window_real_realize (GtkWidget *widget)
{
    GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
    GtkApplication *application;
    GtkSettings *settings;

    application = gtk_window_get_application (GTK_WINDOW (window));
    settings = gtk_widget_get_settings (widget);

    g_signal_connect (settings, "notify::gtk-shell-shows-app-menu",
                      G_CALLBACK (gtk_application_window_shell_shows_app_menu_changed), window);
    g_signal_connect (settings, "notify::gtk-shell-shows-menubar",
                      G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), window);

    gtk_application_window_update_shell_shows_app_menu (window, settings);
    gtk_application_window_update_shell_shows_menubar (window, settings);
    gtk_application_window_update_menubar (window);

    /* Update the accelerators, and ensure we do again
     * if the accel map changes */
    gtk_application_window_update_accels (window);
    window->priv->accel_map_changed_id = g_signal_connect_swapped (gtk_accel_map_get (), "changed",
                                         G_CALLBACK (gtk_application_window_update_accels), window);

    GTK_WIDGET_CLASS (gtk_application_window_parent_class)
    ->realize (widget);

#ifdef GDK_WINDOWING_X11
    {
        GdkWindow *gdkwindow;

        gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));

        if (GDK_IS_X11_WINDOW (gdkwindow) && window->priv->session)
        {
            gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_ID",
                                              g_application_get_application_id (G_APPLICATION (application)));

            gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_UNIQUE_BUS_NAME",
                                              g_dbus_connection_get_unique_name (window->priv->session));

            gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_OBJECT_PATH",
                                              g_application_get_dbus_object_path (G_APPLICATION (application)));

            gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_WINDOW_OBJECT_PATH",
                                              window->priv->object_path);

            gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APP_MENU_OBJECT_PATH",
                                              gtk_application_get_app_menu_object_path (application));

            gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_MENUBAR_OBJECT_PATH",
                                              gtk_application_get_menubar_object_path (application));
        }
    }
#endif
}
static void
gtk_application_window_shell_shows_menubar_changed (GObject    *object,
                                                    GParamSpec *pspec,
                                                    gpointer    user_data)
{
  GtkApplicationWindow *window = user_data;

  gtk_application_window_update_shell_shows_menubar (window, GTK_SETTINGS (object));
  gtk_application_window_update_menubar (window);
}
static void
gtk_application_window_real_realize (GtkWidget *widget)
{
  GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
  GtkSettings *settings;

  settings = gtk_widget_get_settings (widget);

  g_signal_connect (settings, "notify::gtk-shell-shows-app-menu",
                    G_CALLBACK (gtk_application_window_shell_shows_app_menu_changed), window);
  g_signal_connect (settings, "notify::gtk-shell-shows-menubar",
                    G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), window);

  GTK_WIDGET_CLASS (gtk_application_window_parent_class)->realize (widget);

  gtk_application_window_update_shell_shows_app_menu (window, settings);
  gtk_application_window_update_shell_shows_menubar (window, settings);
  gtk_application_window_update_menubar (window);
}