Code

Applying fixes for gcc 4.3 build issues (closes LP: #169115)
[inkscape.git] / src / dialogs / object-attributes.cpp
1 #define __SP_OBJECT_ATTRIBUTES_C__
3 /**
4  * \brief  Generic properties editor
5  *
6  * Authors:
7  *   Lauris Kaplinski <lauris@kaplinski.com>
8  *   bulia byak <buliabyak@users.sf.net>
9  *
10  * Copyright (C) 1999-2005 Authors
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #ifdef HAVE_CONFIG_H
16 # include "config.h"
17 #endif
19 #include <glibmm/i18n.h>
20 #include <string>
21 #include <cstring>
23 #include "helper/window.h"
24 #include "macros.h"
25 #include "sp-anchor.h"
26 #include "sp-attribute-widget.h"
28 #include <sigc++/connection.h>
29 #include <sigc++/functors/ptr_fun.h>
30 #include <sigc++/adaptors/bind.h>
32 struct SPAttrDesc {
33     gchar const *label;
34     gchar const *attribute;
35 };
37 static const SPAttrDesc anchor_desc[] = {
38     { N_("Href:"), "xlink:href"},
39     { N_("Target:"), "target"},
40     { N_("Type:"), "xlink:type"},
41     // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/linking.html#AElementXLinkRoleAttribute
42     // Identifies the type of the related resource with an absolute URI
43     { N_("Role:"), "xlink:role"},
44     // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/linking.html#AElementXLinkArcRoleAttribute
45     // For situations where the nature/role alone isn't enough, this offers an additional URI defining the purpose of the link.
46     { N_("Arcrole:"), "xlink:arcrole"},
47     // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/linking.html#AElementXLinkTitleAttribute
48     { N_("Title:"), "xlink:title"},
49     { N_("Show:"), "xlink:show"},
50     // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/linking.html#AElementXLinkActuateAttribute
51     { N_("Actuate:"), "xlink:actuate"},
52     { NULL, NULL}
53 };
55 static const SPAttrDesc image_desc[] = {
56     { N_("URL:"), "xlink:href"},
57     { N_("X:"), "x"},
58     { N_("Y:"), "y"},
59     { N_("Width:"), "width"},
60     { N_("Height:"), "height"},
61     { NULL, NULL}
62 };
65 static void
66 object_released( SPObject */*object*/, GtkWidget *widget )
67 {
68     gtk_widget_destroy (widget);
69 }
73 static void
74 window_destroyed( GtkObject *window, GtkObject */*object*/ )
75 {
76     sigc::connection *release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(window), "release_connection");
77     release_connection->disconnect();
78     delete release_connection;
79 }
83 static void
84 sp_object_attr_show_dialog ( SPObject *object,
85                              const SPAttrDesc *desc,
86                              const gchar *tag )
87 {
88     const gchar **labels, **attrs;
89     gint len, i;
90     gchar *title;
91     GtkWidget *w, *t;
93     len = 0;
94     while (desc[len].label) len += 1;
96     labels = (const gchar **)alloca (len * sizeof (char *));
97     attrs = (const gchar **)alloca (len * sizeof (char *));
99     for (i = 0; i < len; i++) {
100         labels[i] = desc[i].label;
101         attrs[i] = desc[i].attribute;
102     }
104     title = g_strdup_printf (_("%s Properties"), tag);
105     w = sp_window_new (title, TRUE);
106     g_free (title);
108     t = sp_attribute_table_new (object, len, labels, attrs);
109     gtk_widget_show (t);
110     gtk_container_add (GTK_CONTAINER (w), t);
112     g_signal_connect ( G_OBJECT (w), "destroy",
113                        G_CALLBACK (window_destroyed), object );
115     sigc::connection *release_connection = new sigc::connection();
116     *release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&object_released), w));
117     g_object_set_data(G_OBJECT(w), "release_connection", release_connection);
119     gtk_widget_show (w);
121 } // end of sp_object_attr_show_dialog()
125 void
126 sp_object_attributes_dialog (SPObject *object, const gchar *tag)
128     g_return_if_fail (object != NULL);
129     g_return_if_fail (SP_IS_OBJECT (object));
130     g_return_if_fail (tag != NULL);
132     if (!strcmp (tag, "Link")) {
133         sp_object_attr_show_dialog (object, anchor_desc, tag);
134     } else if (!strcmp (tag, "Image")) {
135         sp_object_attr_show_dialog (object, image_desc, tag);
136     } 
138 } // end of sp_object_attributes_dialog()
142 /*
143   Local Variables:
144   mode:c++
145   c-file-style:"stroustrup"
146   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
147   indent-tabs-mode:nil
148   fill-column:99
149   End:
150 */
151 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :