~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/actions/window-commands.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <string.h>
 
22
 
 
23
#include <gtk/gtk.h>
 
24
 
 
25
#include "libgimpwidgets/gimpwidgets.h"
 
26
 
 
27
#include "actions-types.h"
 
28
 
 
29
#include "widgets/gimpmessagebox.h"
 
30
#include "widgets/gimpmessagedialog.h"
 
31
 
 
32
#include "actions.h"
 
33
#include "window-commands.h"
 
34
 
 
35
 
 
36
/*  public functions  */
 
37
 
 
38
void
 
39
window_close_cmd_callback (GtkAction *action,
 
40
                           gpointer   data)
 
41
{
 
42
  GtkWidget *widget;
 
43
  return_if_no_widget (widget, data);
 
44
 
 
45
  if (! GTK_WIDGET_TOPLEVEL (widget))
 
46
    widget = gtk_widget_get_toplevel (widget);
 
47
 
 
48
  if (widget && widget->window)
 
49
    {
 
50
      GdkEvent *event = gdk_event_new (GDK_DELETE);
 
51
 
 
52
      event->any.window     = g_object_ref (widget->window);
 
53
      event->any.send_event = TRUE;
 
54
 
 
55
      gtk_main_do_event (event);
 
56
      gdk_event_free (event);
 
57
    }
 
58
}
 
59
 
 
60
void
 
61
window_open_display_cmd_callback (GtkAction *action,
 
62
                                  gpointer   data)
 
63
{
 
64
  GtkWidget *widget;
 
65
  GtkWidget *dialog;
 
66
  GtkWidget *entry;
 
67
  return_if_no_widget (widget, data);
 
68
 
 
69
  dialog = gimp_message_dialog_new ("Open Display", GIMP_STOCK_WILBER_EEK,
 
70
                                    widget, GTK_DIALOG_MODAL,
 
71
                                    NULL, NULL,
 
72
 
 
73
                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 
74
                                    GTK_STOCK_OK,     GTK_RESPONSE_OK,
 
75
 
 
76
                                    NULL);
 
77
 
 
78
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
79
 
 
80
  gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
 
81
                                     "Experimental multi-display stuff!\n"
 
82
                                     "Click OK and have fun crashing GIMP...");
 
83
 
 
84
  gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
 
85
                             "Please enter the name of the new display:");
 
86
 
 
87
  entry = gtk_entry_new ();
 
88
  gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
 
89
  gtk_container_add (GTK_CONTAINER (GIMP_MESSAGE_DIALOG (dialog)->box), entry);
 
90
 
 
91
  gtk_widget_grab_focus (entry);
 
92
  gtk_widget_show_all (dialog);
 
93
 
 
94
  while (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
 
95
    {
 
96
      gchar *screen_name;
 
97
 
 
98
      screen_name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
 
99
 
 
100
      if (strcmp (screen_name, ""))
 
101
        {
 
102
          GdkDisplay *display;
 
103
 
 
104
          gtk_widget_set_sensitive (dialog, FALSE);
 
105
 
 
106
          display = gdk_display_open (screen_name);
 
107
 
 
108
          if (! display)
 
109
            gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
 
110
                                       "Can't open display '%s'. "
 
111
                                       "Please try another one:",
 
112
                                       screen_name);
 
113
 
 
114
          g_free (screen_name);
 
115
 
 
116
          gtk_widget_set_sensitive (dialog, TRUE);
 
117
 
 
118
          if (display)
 
119
            break;
 
120
        }
 
121
 
 
122
      gtk_widget_grab_focus (entry);
 
123
    }
 
124
 
 
125
  gtk_widget_destroy (dialog);
 
126
}
 
127
 
 
128
void
 
129
window_move_to_screen_cmd_callback (GtkAction *action,
 
130
                                    GtkAction *current,
 
131
                                    gpointer   data)
 
132
{
 
133
  GtkWidget *widget;
 
134
  GdkScreen *screen;
 
135
  return_if_no_widget (widget, data);
 
136
 
 
137
  if (! GTK_WIDGET_TOPLEVEL (widget))
 
138
    widget = gtk_widget_get_toplevel (widget);
 
139
 
 
140
  screen = g_object_get_data (G_OBJECT (current), "screen");
 
141
 
 
142
  if (GDK_IS_SCREEN (screen) && screen != gtk_widget_get_screen (widget))
 
143
    {
 
144
      gtk_window_set_screen (GTK_WINDOW (widget), screen);
 
145
    }
 
146
}