Ejemplo n.º 1
0
gint
gimp_widget_get_monitor (GtkWidget *widget)
{
    GdkWindow     *window;
    GdkScreen     *screen;
    GtkAllocation  allocation;
    gint           x, y;

    g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);

    window = gtk_widget_get_window (widget);

    if (! window)
        return gimp_get_monitor_at_pointer (&screen);

    screen = gtk_widget_get_screen (widget);

    gdk_window_get_origin (window, &x, &y);
    gtk_widget_get_allocation (widget, &allocation);

    if (! gtk_widget_get_has_window (widget))
    {
        x += allocation.x;
        y += allocation.y;
    }

    x += allocation.width  / 2;
    y += allocation.height / 2;

    return gdk_screen_get_monitor_at_point (screen, x, y);
}
Ejemplo n.º 2
0
GdkMonitor *
gimp_widget_get_monitor (GtkWidget *widget)
{
  GdkWindow     *window;
  GtkAllocation  allocation;
  gint           x, y;

  g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);

  window = gtk_widget_get_window (widget);

  if (! window)
    return gimp_get_monitor_at_pointer ();

  gdk_window_get_origin (window, &x, &y);
  gtk_widget_get_allocation (widget, &allocation);

  if (! gtk_widget_get_has_window (widget))
    {
      x += allocation.x;
      y += allocation.y;
    }

  x += allocation.width  / 2;
  y += allocation.height / 2;

  return gdk_display_get_monitor_at_point (gdk_display_get_default (), x, y);
}
Ejemplo n.º 3
0
static gboolean
gui_exit_callback (Gimp     *gimp,
                   gboolean  force)
{
  GimpGuiConfig  *gui_config = GIMP_GUI_CONFIG (gimp->config);

  if (gimp->be_verbose)
    g_print ("EXIT: %s\n", G_STRFUNC);

  if (! force && gimp_displays_dirty (gimp))
    {
      GdkScreen *screen;
      gint       monitor;

      monitor = gimp_get_monitor_at_pointer (&screen);

      gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
                                        screen, monitor,
                                        "gimp-quit-dialog", -1);

      return TRUE; /* stop exit for now */
    }

  gimp->message_handler = GIMP_CONSOLE;

  gui_unique_exit ();

  if (gui_config->save_session_info)
    session_save (gimp, FALSE);

  color_history_save (gimp);

  if (gui_config->save_accels)
    menus_save (gimp, FALSE);

  if (gui_config->save_device_status)
    gimp_devices_save (gimp, FALSE);

  if (TRUE /* gui_config->save_controllers */)
    gimp_controllers_save (gimp);

  g_signal_handlers_disconnect_by_func (gimp_get_user_context (gimp),
                                        gui_display_changed,
                                        gimp);

  gimp_displays_delete (gimp);

  gimp_tools_save (gimp, gui_config->save_tool_options, FALSE);
  gimp_tools_exit (gimp);

  gimp_language_store_parser_clean ();

  return FALSE; /* continue exiting */
}
Ejemplo n.º 4
0
static GtkWidget *
global_error_dialog (void)
{
    GdkScreen *screen;
    gint       monitor;

    monitor = gimp_get_monitor_at_pointer (&screen);

    return gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
                                           screen, monitor,
                                           NULL /*ui_manager*/,
                                           "gimp-error-dialog", -1,
                                           FALSE);
}
Ejemplo n.º 5
0
static gboolean
gui_message_error_console (Gimp                *gimp,
                           GimpMessageSeverity  severity,
                           const gchar         *domain,
                           const gchar         *message)
{
    GtkWidget *dockable = NULL;

    /* try to avoid raising the error console for not so severe messages */
    if (severity < GIMP_MESSAGE_ERROR)
    {
        GtkWidget *widget =
            gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
                                             "gimp-error-console");
        if (GIMP_IS_DOCKABLE (widget))
            dockable = widget;
    }

    if (! dockable)
    {
        GdkScreen *screen;
        gint       monitor;

        monitor = gimp_get_monitor_at_pointer (&screen);

        dockable =
            gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
                    gimp,
                    gimp_dialog_factory_get_singleton (),
                    screen, monitor,
                    "gimp-error-console");
    }

    if (dockable)
    {
        GtkWidget *child = gtk_bin_get_child (GTK_BIN (dockable));

        gimp_error_console_add (GIMP_ERROR_CONSOLE (child),
                                severity, domain, message);

        return TRUE;
    }

    return FALSE;
}
Ejemplo n.º 6
0
GimpInitStatusFunc
gui_init (Gimp     *gimp,
          gboolean  no_splash)
{
  GimpInitStatusFunc  status_callback = NULL;
  gchar              *abort_message;

  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
  g_return_val_if_fail (the_gui_gimp == NULL, NULL);

  abort_message = gui_sanity_check ();
  if (abort_message)
    gui_abort (abort_message);

  the_gui_gimp = gimp;

  /* TRANSLATORS: there is no need to translate this in GIMP. This uses
   * "gtk20" domain as a special trick to determine language direction,
   * but xgettext extracts it anyway mistakenly into GIMP po files.
   * Leave an empty string as translation. It does not matter.
   */
  if (g_strcmp0 (dgettext ("gtk20", "default:LTR"), "default:RTL") == 0)
    /* Normally this should have been taken care of during command line
     * parsing as a post-parse hook of gtk_get_option_group(), using the
     * system locales.
     * But user config may have overriden the language, therefore we must
     * check the widget directions again.
     */
    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
  else
    gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR);

  gui_unique_init (gimp);
  gimp_language_store_parser_init ();

  gimp_widgets_init (gui_help_func,
                     gui_get_foreground_func,
                     gui_get_background_func,
                     NULL);

  g_type_class_ref (GIMP_TYPE_COLOR_SELECT);

  /*  disable automatic startup notification  */
  gtk_window_set_auto_startup_notification (FALSE);

  gimp_dnd_init (gimp);

  themes_init (gimp);

  initial_monitor = gimp_get_monitor_at_pointer (&initial_screen);
  gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (initial_screen));

  if (! no_splash)
    {
      splash_create (gimp->be_verbose, initial_screen, initial_monitor);
      status_callback = splash_update;
    }

  g_signal_connect_after (gimp, "initialize",
                          G_CALLBACK (gui_initialize_after_callback),
                          NULL);

  g_signal_connect (gimp, "restore",
                    G_CALLBACK (gui_restore_callback),
                    NULL);
  g_signal_connect_after (gimp, "restore",
                          G_CALLBACK (gui_restore_after_callback),
                          NULL);

  g_signal_connect (gimp, "exit",
                    G_CALLBACK (gui_exit_callback),
                    NULL);
  g_signal_connect_after (gimp, "exit",
                          G_CALLBACK (gui_exit_after_callback),
                          NULL);

  return status_callback;
}