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

« back to all changes in this revision

Viewing changes to app/dialogs/image-properties-dialog.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
 * image-properties-dialog.c
 
5
 * Copyright (C) 2005 Michael Natterer <mitch@gimp.org>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#include <gtk/gtk.h>
 
25
 
 
26
#include "libgimpbase/gimpbase.h"
 
27
#include "libgimpwidgets/gimpwidgets.h"
 
28
 
 
29
#include "dialogs-types.h"
 
30
 
 
31
#include "core/gimpcontext.h"
 
32
#include "core/gimpimage.h"
 
33
 
 
34
#include "widgets/gimphelp-ids.h"
 
35
#include "widgets/gimpimagepropview.h"
 
36
#include "widgets/gimpimageprofileview.h"
 
37
#include "widgets/gimpviewabledialog.h"
 
38
 
 
39
#include "image-properties-dialog.h"
 
40
 
 
41
#include "gimp-intl.h"
 
42
 
 
43
 
 
44
static void  image_comment_update (GtkWidget *page,
 
45
                                   GtkWidget *label);
 
46
 
 
47
 
 
48
/*  public functions  */
 
49
 
 
50
GtkWidget *
 
51
image_properties_dialog_new (GimpImage   *image,
 
52
                             GimpContext *context,
 
53
                             GtkWidget   *parent)
 
54
{
 
55
  GtkWidget *dialog;
 
56
  GtkWidget *notebook;
 
57
  GtkWidget *view;
 
58
  GtkWidget *label;
 
59
 
 
60
  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
 
61
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
 
62
  g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
 
63
 
 
64
  dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (image), context,
 
65
                                     _("Image Properties"),
 
66
                                     "gimp-image-properties",
 
67
                                     GTK_STOCK_INFO,
 
68
                                     _("Image Properties"),
 
69
                                     parent,
 
70
                                     gimp_standard_help_func,
 
71
                                     GIMP_HELP_IMAGE_PROPERTIES,
 
72
 
 
73
                                     GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
 
74
 
 
75
                                     NULL);
 
76
 
 
77
  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
 
78
 
 
79
  g_signal_connect (dialog, "response",
 
80
                    G_CALLBACK (gtk_widget_destroy),
 
81
                    NULL);
 
82
 
 
83
  notebook = gtk_notebook_new ();
 
84
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook,
 
85
                      FALSE, FALSE, 0);
 
86
  gtk_widget_show (notebook);
 
87
 
 
88
  view = gimp_image_prop_view_new (image);
 
89
  gtk_container_set_border_width (GTK_CONTAINER (view), 12);
 
90
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
 
91
                            view, gtk_label_new (_("Properties")));
 
92
  gtk_widget_show (view);
 
93
 
 
94
  view = gimp_image_profile_view_new (image);
 
95
  gtk_container_set_border_width (GTK_CONTAINER (view), 12);
 
96
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
 
97
                            view, gtk_label_new (_("Color Profile")));
 
98
  gtk_widget_show (view);
 
99
 
 
100
  view = gimp_image_parasite_view_new (image, "gimp-comment");
 
101
  gtk_container_set_border_width (GTK_CONTAINER (view), 12);
 
102
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
 
103
                            view, gtk_label_new (_("Comment")));
 
104
 
 
105
  label = g_object_new (GTK_TYPE_LABEL,
 
106
                        "wrap",       TRUE,
 
107
                        "justify",    GTK_JUSTIFY_LEFT,
 
108
                        "xalign",     0.0,
 
109
                        "yalign",     0.0,
 
110
                        "selectable", TRUE,
 
111
                        NULL);
 
112
  gtk_container_add (GTK_CONTAINER (view), label);
 
113
  gtk_widget_show (label);
 
114
 
 
115
  g_signal_connect (view, "update",
 
116
                    G_CALLBACK (image_comment_update),
 
117
                    label);
 
118
 
 
119
  image_comment_update (view, label);
 
120
 
 
121
  return dialog;
 
122
}
 
123
 
 
124
static void
 
125
image_comment_update (GtkWidget *page,
 
126
                      GtkWidget *label)
 
127
{
 
128
  GimpImageParasiteView *view = GIMP_IMAGE_PARASITE_VIEW (page);
 
129
  const GimpParasite    *parasite;
 
130
 
 
131
  parasite = gimp_image_parasite_view_get_parasite (view);
 
132
 
 
133
  if (parasite)
 
134
    {
 
135
      gchar *text = g_strndup (gimp_parasite_data (parasite),
 
136
                               gimp_parasite_data_size (parasite));
 
137
 
 
138
      if (! g_utf8_validate (text, -1, NULL))
 
139
        {
 
140
          gchar *tmp = gimp_any_to_utf8 (text, -1, NULL);
 
141
 
 
142
          g_free (text);
 
143
          text = tmp;
 
144
        }
 
145
 
 
146
      gtk_label_set_text (GTK_LABEL (label), text);
 
147
      g_free (text);
 
148
 
 
149
      gtk_widget_show (page);
 
150
    }
 
151
  else
 
152
    {
 
153
      gtk_widget_hide (page);
 
154
      gtk_label_set_text (GTK_LABEL (label), NULL);
 
155
    }
 
156
}