Example #1
0
static gboolean
dialogs_actions_toolbox_exists (Gimp *gimp)
{
  GimpDialogFactory *factory       = gimp_dialog_factory_get_singleton ();
  GimpSessionInfo   *info          = NULL;
  GList             *windows       = gimp ? gimp_get_image_windows (gimp) : NULL;
  gboolean           toolbox_found = FALSE;
  GList             *iter;

  /* First look in session managed windows */
  info = gimp_dialog_factory_find_session_info (factory, "gimp-toolbox-window");
  toolbox_found = info && gimp_session_info_get_widget (info);

  /* Then in image windows */
  if (! toolbox_found)
    {
      for (iter = windows; iter; iter = g_list_next (iter))
        {
          GimpImageWindow *window = GIMP_IMAGE_WINDOW (windows->data);
      
          if (gimp_image_window_has_toolbox (window))
            {
              toolbox_found = TRUE;
              break;
            }
        }
    }

  return toolbox_found;
}
Example #2
0
gboolean
dialogs_actions_toolbox_exists (Gimp *gimp)
{
  GimpDialogFactory *factory       = gimp_dialog_factory_get_singleton ();
  gboolean           toolbox_found = FALSE;
  GList             *iter;

  /* First look in session managed windows */
  toolbox_found =
    gimp_dialog_factory_find_widget (factory, "gimp-toolbox-window") != NULL;

  /* Then in image windows */
  if (! toolbox_found)
    {
      GList *windows = gimp ? gimp_get_image_windows (gimp) : NULL;

      for (iter = windows; iter; iter = g_list_next (iter))
        {
          GimpImageWindow *window = GIMP_IMAGE_WINDOW (windows->data);

          if (gimp_image_window_has_toolbox (window))
            {
              toolbox_found = TRUE;
              break;
            }
        }

      g_list_free (windows);
    }

  return toolbox_found;
}
static GtkWidget *
gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
                                                  Gimp               *gimp,
                                                  GimpDialogFactory  *factory,
                                                  GdkMonitor         *monitor,
                                                  const gchar        *identifiers)
{
  GList           *windows = gimp_get_image_windows (gimp);
  GtkWidget       *widget  = NULL;
  GimpImageWindow *window;

  g_return_val_if_fail (windows != NULL, NULL);

  /* In single-window mode, there should only be one window... */
  window = GIMP_IMAGE_WINDOW (windows->data);

  if (strcmp ("gimp-toolbox", identifiers) == 0)
    {
      /* Only allow one toolbox... */
      if (! gimp_image_window_has_toolbox (window))
        {
          GimpDockColumns *columns;
          GimpUIManager   *ui_manager = gimp_image_window_get_ui_manager (window);

          widget = gimp_dialog_factory_dialog_new (factory, monitor,
                                                   ui_manager,
                                                   GTK_WIDGET (window),
                                                   "gimp-toolbox",
                                                   -1 /*view_size*/,
                                                   FALSE /*present*/);
          gtk_widget_show (widget);

          columns = gimp_image_window_get_left_docks (window);
          gimp_dock_columns_add_dock (columns,
                                      GIMP_DOCK (widget),
                                      -1 /*index*/);
        }
    }
  else if (gimp_dialog_factory_find_widget (factory, identifiers))
    {
      /* if the dialog is already open, simply raise it */
      return gimp_dialog_factory_dialog_raise (factory, monitor,
                                               GTK_WIDGET (window),
                                               identifiers, -1);
   }
  else
    {
      GtkWidget *dockbook;

      dockbook = gimp_image_window_get_default_dockbook (window);

      if (! dockbook)
        {
          GimpDockColumns *dock_columns;

          /* No dock, need to add one */
          dock_columns = gimp_image_window_get_right_docks (window);
          gimp_dock_columns_prepare_dockbook (dock_columns,
                                              -1 /*index*/,
                                              &dockbook);
        }

      widget = gimp_dockbook_add_from_dialog_factory (GIMP_DOCKBOOK (dockbook),
                                                      identifiers);
    }


  g_list_free (windows);

  return widget;
}