Code

05370d1d025ad1de1c6c472cd1dd77984e9ab8f0
[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
18 #include <glibmm/i18n.h>
19 #include "helper/window.h"
20 #include "macros.h"
21 #include "sp-anchor.h"
22 #include "sp-attribute-widget.h"
24 struct SPAttrDesc {
25     gchar const *label;
26     gchar const *attribute;
27 };
29 static const SPAttrDesc anchor_desc[] = {
30     { N_("Href:"), "xlink:href"},
31     { N_("Target:"), "target"},
32     { N_("Type:"), "xlink:type"},
33     // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/linking.html#AElementXLinkRoleAttribute
34     // Identifies the type of the related resource with an absolute URI
35     { N_("Role:"), "xlink:role"},
36     // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/linking.html#AElementXLinkArcRoleAttribute
37     // For situations where the nature/role alone isn't enough, this offers an additional URI defining the purpose of the link.
38     { N_("Arcrole:"), "xlink:arcrole"},
39     // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/linking.html#AElementXLinkTitleAttribute
40     { N_("Title:"), "xlink:title"},
41     { N_("Show:"), "xlink:show"},
42     // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/linking.html#AElementXLinkActuateAttribute
43     { N_("Actuate:"), "xlink:actuate"},
44     { NULL, NULL}
45 };
47 static const SPAttrDesc image_desc[] = {
48     { N_("URL:"), "xlink:href"},
49     { N_("X:"), "x"},
50     { N_("Y:"), "y"},
51     { N_("Width:"), "width"},
52     { N_("Height:"), "height"},
53     { NULL, NULL}
54 };
57 static void
58 object_released (GtkObject *object, GtkWidget *widget)
59 {
60     gtk_widget_destroy (widget);
61 }
65 static void
66 window_destroyed (GtkObject *window, GtkObject *object)
67 {
68     sp_signal_disconnect_by_data (object, window);
69 }
73 static void
74 sp_object_attr_show_dialog ( SPObject *object, 
75                              const SPAttrDesc *desc, 
76                              const gchar *tag )
77 {
78     const gchar **labels, **attrs;
79     gint len, i;
80     gchar *title;
81     GtkWidget *w, *t;
83     len = 0;
84     while (desc[len].label) len += 1;
86     labels = (const gchar **)alloca (len * sizeof (char *));
87     attrs = (const gchar **)alloca (len * sizeof (char *));
89     for (i = 0; i < len; i++) {
90         labels[i] = desc[i].label;
91         attrs[i] = desc[i].attribute;
92     }
94     title = g_strdup_printf (_("%s attributes"), tag);
95     w = sp_window_new (title, TRUE);
96     g_free (title);
98     t = sp_attribute_table_new (object, len, labels, attrs);
99     gtk_widget_show (t);
100     gtk_container_add (GTK_CONTAINER (w), t);
102     g_signal_connect ( G_OBJECT (w), "destroy", 
103                        G_CALLBACK (window_destroyed), object );
104                        
105     g_signal_connect ( G_OBJECT (object), "release", 
106                        G_CALLBACK (object_released), w );
108     gtk_widget_show (w);
110 } // end of sp_object_attr_show_dialog()
114 void
115 sp_object_attributes_dialog (SPObject *object, const gchar *tag)
117     g_return_if_fail (object != NULL);
118     g_return_if_fail (SP_IS_OBJECT (object));
119     g_return_if_fail (tag != NULL);
121     if (!strcmp (tag, "Link")) {
122         sp_object_attr_show_dialog (object, anchor_desc, tag);
123     } else if (!strcmp (tag, "Image")) {
124         sp_object_attr_show_dialog (object, image_desc, tag);
125     } 
127 } // end of sp_object_attributes_dialog()
131 /*
132   Local Variables:
133   mode:c++
134   c-file-style:"stroustrup"
135   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
136   indent-tabs-mode:nil
137   fill-column:99
138   End:
139 */
140 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :