gimpdisplay-foreach.c 4.85 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
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "config.h"

#include <gtk/gtk.h>

#include "display-types.h"

#include "core/gimpimage.h"

#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
Michael Natterer's avatar
Michael Natterer committed
29
#include "gimpdisplayshell.h"
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

#include "nav_window.h"


void
gdisplays_foreach (GFunc    func, 
		   gpointer user_data)
{
  g_slist_foreach (display_list, func, user_data);
}

void
gdisplays_expose_guide (GimpImage *gimage,
			GimpGuide *guide)
{
  GimpDisplay *gdisp;
  GSList      *list;

  g_return_if_fail (GIMP_IS_IMAGE (gimage));
  g_return_if_fail (guide != NULL);

  for (list = display_list; list; list = g_slist_next (list))
    {
      gdisp = (GimpDisplay *) list->data;

      if (gdisp->gimage == gimage)
Michael Natterer's avatar
Michael Natterer committed
56 57
	gimp_display_shell_expose_guide (GIMP_DISPLAY_SHELL (gdisp->shell),
                                         guide);
58 59 60 61 62 63 64 65 66 67 68 69 70
    }
}

void
gdisplays_expose_full (void)
{
  GimpDisplay *gdisp;
  GSList      *list;

  for (list = display_list; list; list = g_slist_next (list))
    {
      gdisp = (GimpDisplay *) list->data;

Michael Natterer's avatar
Michael Natterer committed
71
      gimp_display_shell_expose_full (GIMP_DISPLAY_SHELL (gdisp->shell));
72 73 74 75 76 77
    }
}

void
gdisplays_nav_preview_resized (void)
{
Michael Natterer's avatar
Michael Natterer committed
78 79
  GimpDisplayShell *shell;
  GSList           *list;
80 81 82

  for (list = display_list; list; list = g_slist_next (list))
    {
Michael Natterer's avatar
Michael Natterer committed
83
      shell = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (list->data)->shell);
84

Michael Natterer's avatar
Michael Natterer committed
85 86
      if (shell->nav_dialog)
	nav_dialog_preview_resized (shell->nav_dialog);
87
      
Michael Natterer's avatar
Michael Natterer committed
88
      if (shell->nav_popup)
89
	{
Michael Natterer's avatar
Michael Natterer committed
90 91
	  nav_dialog_free (NULL, shell->nav_popup);
	  shell->nav_popup = NULL;
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
	}
    }
}

gboolean
gdisplays_dirty (void)
{
  gboolean  dirty = FALSE;
  GSList   *list;

  for (list = display_list; list; list = g_slist_next (list))
    {
      if (((GimpDisplay *) list->data)->gimage->dirty != 0)
	dirty = TRUE;
    }

  return dirty;
}

void
gdisplays_delete (void)
{
  GimpDisplay *gdisp;

  /*  destroying the shell removes the GimpDisplay from the list, so
   *  do a while loop "around" the first element to get them all
   */
  while (display_list)
    {
      gdisp = (GimpDisplay *) display_list->data;

      gtk_widget_destroy (gdisp->shell);
    }
}

GimpDisplay *
gdisplays_check_valid (GimpDisplay *gtest, 
		       GimpImage   *gimage)
{
  /* Give a gdisp check that it is still valid and points to the required
   * GimpImage. If not return the first gDisplay that does point to the 
   * gimage. If none found return NULL;
   */

  GimpDisplay *gdisp;
  GimpDisplay *gdisp_found = NULL;
  GSList      *list;

  for (list = display_list; list; list = g_slist_next (list))
    {
      gdisp = (GimpDisplay *) list->data;

      if (gdisp == gtest)
	return gtest;

      if (!gdisp_found && gdisp->gimage == gimage)
	gdisp_found = gdisp;
    }

  return gdisp_found;
}

Michael Natterer's avatar
Michael Natterer committed
154 155
void
gdisplays_flush (void)
156 157 158
{
  static gboolean flushing = FALSE;

Michael Natterer's avatar
Michael Natterer committed
159 160
  GSList      *list;
  GimpDisplay *gdisp;
161 162 163 164 165 166 167 168 169 170 171 172

  /*  this prevents multiple recursive calls to this procedure  */
  if (flushing == TRUE)
    {
      g_warning ("gdisplays_flush() called recursively.");
      return;
    }

  flushing = TRUE;

  for (list = display_list; list; list = g_slist_next (list))
    {
Michael Natterer's avatar
Michael Natterer committed
173 174 175
      gdisp = list->data;

      gdisplay_flush (gdisp);
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
    }

  flushing = FALSE;
}

void
gdisplays_reconnect (GimpImage *old,
		     GimpImage *new)
{
  GSList      *list;
  GimpDisplay *gdisp;

  g_return_if_fail (old != NULL);
  g_return_if_fail (GIMP_IS_IMAGE (new));
  
  for (list = display_list; list; list = g_slist_next (list))
    {
      gdisp = list->data;
      
      if (gdisp->gimage == old)
	gdisplay_reconnect (gdisp, new);
    }
}
Michael Natterer's avatar
Michael Natterer committed
199 200 201 202

void
gdisplays_set_busy (void)
{
Michael Natterer's avatar
Michael Natterer committed
203 204
  GSList           *list;
  GimpDisplayShell *shell;
Michael Natterer's avatar
Michael Natterer committed
205 206 207

  for (list = display_list; list; list = g_slist_next (list))
    {
Michael Natterer's avatar
Michael Natterer committed
208 209 210
      shell = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (list->data)->shell);

      gimp_display_shell_install_override_cursor (shell, GDK_WATCH);
Michael Natterer's avatar
Michael Natterer committed
211 212 213 214 215 216
    }
}

void
gdisplays_unset_busy (void)
{
Michael Natterer's avatar
Michael Natterer committed
217 218
  GSList           *list;
  GimpDisplayShell *shell;
Michael Natterer's avatar
Michael Natterer committed
219 220 221

  for (list = display_list; list; list = g_slist_next (list))
    {
Michael Natterer's avatar
Michael Natterer committed
222
      shell = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (list->data)->shell);
Michael Natterer's avatar
Michael Natterer committed
223
      
Michael Natterer's avatar
Michael Natterer committed
224
      gimp_display_shell_remove_override_cursor (shell);
Michael Natterer's avatar
Michael Natterer committed
225 226
    }
}