anjuta r4639 - trunk/plugins/glade
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4639 - trunk/plugins/glade
- Date: Mon, 26 Jan 2009 13:55:54 +0000 (UTC)
Author: jhs
Date: Mon Jan 26 13:55:53 2009
New Revision: 4639
URL: http://svn.gnome.org/viewvc/anjuta?rev=4639&view=rev
Log:
Added missing files
Added:
trunk/plugins/glade/anjuta-glade-marshallers.list
trunk/plugins/glade/anjuta-glade.glade
trunk/plugins/glade/designer-associations-item.c
trunk/plugins/glade/designer-associations-item.h
trunk/plugins/glade/designer-associations.c
trunk/plugins/glade/designer-associations.h
Added: trunk/plugins/glade/anjuta-glade-marshallers.list
==============================================================================
--- (empty file)
+++ trunk/plugins/glade/anjuta-glade-marshallers.list Mon Jan 26 13:55:53 2009
@@ -0,0 +1 @@
+VOID:OBJECT,INT
Added: trunk/plugins/glade/anjuta-glade.glade
==============================================================================
--- (empty file)
+++ trunk/plugins/glade/anjuta-glade.glade Mon Jan 26 13:55:53 2009
@@ -0,0 +1,467 @@
+<?xml version="1.0"?>
+<interface>
+ <!--requires-->
+ <object class="GtkWindow" id="associations_dialog">
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="default_width">400</property>
+ <property name="default_height">400</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkFrame" id="frame2">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">3</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Editor</property>
+ </object>
+ <packing>
+ <property name="x_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Designer</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="editors_list">
+ <property name="visible">True</property>
+ <property name="items" translatable="yes"></property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="designers_list">
+ <property name="visible">True</property>
+ <property name="items" translatable="yes"></property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="associate_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">Associate</property>
+ <signal name="clicked" handler="associations_dialog_button_associate_cb"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">10</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>New association</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame3">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">4</property>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeView" id="treeview_associations">
+ <property name="height_request">20</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="fixed_height_mode">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTable" id="table_options">
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">5</property>
+ <property name="column_spacing">2</property>
+ <property name="row_spacing">2</property>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">22</property>
+ <property name="label" translatable="yes">Position type</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_spec_regexp">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Special regexp</property>
+ <signal name="toggled" handler="associations_dialog_spec_regexp_toggled"/>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="position_type">
+ <property name="visible">True</property>
+ <signal name="changed" handler="associations_dialog_position_type_changed_cb"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options">GTK_EXPAND</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_widget_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Widget name</property>
+ <signal name="toggled" handler="associations_dialog_widget_name_toggled"/>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_delete">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="associations_dialog_button_delete_cb"/>
+ <child>
+ <object class="GtkImage" id="image5">
+ <property name="visible">True</property>
+ <property name="stock">gtk-remove</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVSeparator" id="vseparator1">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="options_revert">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="associations_dialog_options_revert_cb"/>
+ <child>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="stock">gtk-cancel</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="options_save">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="associations_dialog_options_save_cb"/>
+ <child>
+ <object class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="stock">gtk-apply</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="spec_regexp">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <signal name="changed" handler="associations_dialog_spec_regexp_changed"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="widget_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <signal name="changed" handler="associations_dialog_widget_name_changed"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">4</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
+ <child>
+ <object class="GtkButton" id="button_close">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-close</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="associations_dialog_button_close_cb"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-save</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="associations_dialog_button_save_cb"/>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ <property name="padding">6</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Manage associations</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkWindow" id="window1">
+ <child>
+ <object class="GtkVBox" id="preferences_page">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkCheckButton" id="insert_handler_on_edit">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Insert handler on edit</property>
+ <signal name="toggled" handler="on_insert_handler_on_edit_toggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="separated_designer_layout">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Separated designer layout</property>
+ <signal name="toggled" handler="on_separated_designer_layout_toggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="auto_add_resource">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Automatically add resources</property>
+ <signal name="toggled" handler="on_auto_add_resource_toggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment4">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkEntry" id="default_resource_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <signal name="focus_out_event" handler="on_preferences_default_resource_entry_focus_out"/>
+ <signal name="activate" handler="on_preferences_default_resource_entry_activate"/>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkRadioButton" id="handler_template_button0">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">on_widget_signal</property>
+ <property name="active">True</property>
+ <signal name="toggled" handler="on_set_default_data_signal_template0"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="handler_template_button1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">widget_signal_cb</property>
+ <property name="active">True</property>
+ <property name="group">handler_template_button0</property>
+ <signal name="toggled" handler="on_set_default_data_signal_template1"/>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Handler template</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">4</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
Added: trunk/plugins/glade/designer-associations-item.c
==============================================================================
--- (empty file)
+++ trunk/plugins/glade/designer-associations-item.c Mon Jan 26 13:55:53 2009
@@ -0,0 +1,529 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * You may 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.
+ *
+ * anjuta 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 anjuta. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "designer-associations.h"
+#include "designer-associations-item.h"
+
+static gchar *
+claim_xml_string (xmlChar *str)
+{
+ gchar *new_str = NULL;
+
+
+ if (xmlStrcmp (str, BAD_CAST ("")) != 0)
+ new_str = g_strdup ((gchar *) str);
+ xmlFree (str);
+ return new_str;
+}
+
+/* DesignerAssociationsItem */
+
+G_DEFINE_TYPE (DesignerAssociationsItem, designer_associations_item, G_TYPE_OBJECT);
+
+static GObjectClass *parent_class = NULL;
+
+static void
+designer_associations_item_init (DesignerAssociationsItem *self)
+{
+
+}
+
+static void
+designer_associations_item_finalize (GObject *object)
+{
+ GList *node;
+ DesignerAssociationsItem *self = DESIGNER_ASSOCIATIONS_ITEM (object);
+
+ if (self->designer)
+ g_object_unref (self->designer);
+ g_free (self->widget_name);
+ if (self->editor)
+ g_object_unref (self->editor);
+
+ node = self->options;
+ while (node)
+ {
+ DesignerAssociationsOption *option = node->data;
+ designer_associations_option_free (option);
+
+ node = node->next;
+ }
+ g_list_free (self->options);
+ self->options = NULL;
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+designer_associations_item_class_init (DesignerAssociationsItemClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+
+ object_class->finalize = designer_associations_item_finalize;
+
+}
+
+DesignerAssociationsItem *
+designer_associations_item_new (void)
+{
+ return g_object_new (DESIGNER_TYPE_ASSOCIATIONS_ITEM, NULL);
+}
+
+DesignerAssociationsItem *
+designer_associations_item_from_data (GFile *editor, const gchar *widget_name,
+ GFile *designer, GList *options,
+ GFile *project_root)
+{
+ DesignerAssociationsItem *retval;
+
+ retval = g_object_new (DESIGNER_TYPE_ASSOCIATIONS_ITEM, NULL);
+ retval->editor = editor;
+ g_object_ref (editor);
+ retval->widget_name = g_strdup (widget_name);
+ retval->designer = designer;
+ g_object_ref (designer);
+ retval->options = options;
+ return retval;
+}
+
+GList *
+designer_associations_item_get_option_node (DesignerAssociationsItem *self,
+ const gchar *name)
+{
+ DesignerAssociationsOption *option;
+ GList *node;
+
+ g_return_val_if_fail (DESIGNER_IS_ASSOCIATIONS_ITEM (self), NULL);
+ node = self->options;
+ while (node)
+ {
+ option = node->data;
+ if (g_str_equal (name, option->name))
+ return node;
+
+ node = node->next;
+ }
+
+ return NULL;
+}
+
+void
+designer_associations_item_set_option (DesignerAssociationsItem *self,
+ const gchar *name, const gchar *value)
+{
+ DesignerAssociationsOption *option;
+ GList *node;
+
+ node = designer_associations_item_get_option_node (self, name);
+ if (node)
+ {
+ option = node->data;
+ g_free (option->value);
+ option->value = value ? g_strdup (value) : NULL;
+ }
+ else
+ {
+ option = designer_associations_option_new ();
+ option->name = g_strdup (name);
+ option->value = g_strdup (value);
+ self->options = g_list_prepend (self->options, option);
+ }
+}
+
+gchar *
+designer_associations_item_get_option (DesignerAssociationsItem *self,
+ const gchar *name)
+{
+ GList *node;
+
+ g_return_val_if_fail (DESIGNER_IS_ASSOCIATIONS_ITEM (self), NULL);
+
+ node = designer_associations_item_get_option_node (self, name);
+ if (node)
+ return g_strdup (((DesignerAssociationsOption *)node->data)->value);
+ else
+ return NULL;
+}
+
+void
+designer_associations_item_set_widget_name (DesignerAssociationsItem *self,
+ const gchar *value)
+{
+ g_return_if_fail (DESIGNER_IS_ASSOCIATIONS_ITEM (self));
+
+ g_free (self->widget_name);
+ self->widget_name = g_strdup (value);
+}
+
+gint
+designer_associations_item_get_option_as_int (DesignerAssociationsItem *self,
+ const gchar *name, const gchar **descriptions)
+{
+ gchar *str;
+ gint i;
+
+ str = designer_associations_item_get_option (self, name);
+ if (!str)
+ return 0;
+
+ if (descriptions)
+ {
+ gint i = 0;
+
+ while (descriptions[i])
+ {
+ if (g_str_equal (descriptions[i], str))
+ {
+ g_free (str);
+ return i;
+ }
+
+ i++;
+ }
+ }
+
+ i = g_ascii_strtoll (str, NULL, 10);
+ g_free (str);
+ return i;
+}
+
+xmlNodePtr
+search_child (xmlNodePtr node, const gchar *name)
+{
+ xmlNodePtr child_node;
+
+ for (child_node = node->children; child_node;
+ child_node = child_node->next)
+ {
+ if (!xmlStrcmp (child_node->name, BAD_CAST (name)))
+ return child_node;
+ }
+ return NULL;
+}
+
+DesignerAssociationsItem *
+designer_associations_item_from_xml (DesignerAssociationsItem *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root,
+ GError **error)
+{
+ GError *nested_error = NULL;
+ DesignerAssociationsOption *option;
+ xmlNodePtr child_node;
+
+ g_return_val_if_fail (error == NULL || *error == NULL, self);
+ g_return_val_if_fail (xml_doc, self);
+ g_return_val_if_fail (node, self);
+
+ /* self->designer */
+ child_node = search_child (node, DA_XML_TAG_DESIGNER);
+ if (!child_node)
+ {
+ g_set_error (error,
+ DESIGNER_ASSOCIATIONS_ERROR,
+ DESIGNER_ASSOCIATIONS_ERROR_LOADING,
+ _("association item has no designer"));
+ return self;
+ }
+ self->designer = associations_file_from_xml (xml_doc, child_node,
+ project_root, &nested_error);
+ if (nested_error)
+ {
+ g_propagate_error (error, nested_error);
+ return self;
+ }
+
+ /* self->widget_name */
+ child_node = search_child (node, DA_XML_TAG_WIDGET);
+ if (child_node)
+ {
+ self->widget_name = claim_xml_string (xmlGetProp (child_node, BAD_CAST (DA_XML_PROP_OPTION_NAME)));
+ }
+
+ /* self->editor */
+ child_node = search_child (node, DA_XML_TAG_EDITOR);
+ if (!child_node)
+ {
+ g_set_error (error,
+ DESIGNER_ASSOCIATIONS_ERROR,
+ DESIGNER_ASSOCIATIONS_ERROR_LOADING,
+ _("association item has no editor"));
+ return self;
+ }
+ self->editor = associations_file_from_xml (xml_doc, child_node,
+ project_root, &nested_error);
+ if (nested_error)
+ {
+ g_propagate_error (error, nested_error);
+ return self;
+ }
+
+ /* options */
+ child_node = node->children;
+ while (child_node)
+ {
+ if (!xmlStrcmp (child_node->name, BAD_CAST (DA_XML_TAG_OPTION)))
+ {
+ option = designer_associations_option_new ();
+ designer_associations_option_from_xml (option, xml_doc, child_node,
+ &nested_error);
+ if (nested_error)
+ {
+ designer_associations_option_free (option);
+ g_propagate_error (error, nested_error);
+ return self;
+ }
+ self->options = g_list_append (self->options, option);
+ }
+ child_node = child_node->next;
+ }
+
+ return self;
+}
+
+void
+designer_associations_item_to_xml (DesignerAssociationsItem *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root)
+{
+ xmlNodePtr child_node;
+
+ child_node = xmlNewDocNode (xml_doc, NULL, BAD_CAST (DA_XML_TAG_DESIGNER), NULL);
+ xmlAddChild (node, child_node);
+ associations_file_to_xml (self->designer, xml_doc, child_node, project_root);
+
+ child_node = xmlNewDocNode (xml_doc, NULL, BAD_CAST (DA_XML_TAG_WIDGET), NULL);
+ xmlAddChild (node, child_node);
+ xmlSetProp (child_node, BAD_CAST (DA_XML_PROP_WIDGET), BAD_CAST (self->widget_name));
+
+ child_node = xmlNewDocNode (xml_doc, NULL, BAD_CAST (DA_XML_TAG_EDITOR), NULL);
+ xmlAddChild (node, child_node);
+ associations_file_to_xml (self->editor, xml_doc, child_node, project_root);
+
+ designer_associations_options_to_xml (self->options, xml_doc, node);
+}
+
+void
+designer_associations_options_to_xml (GList *options,
+ xmlDocPtr xml_doc, xmlNodePtr node)
+{
+ GList *item;
+ DesignerAssociationsOption *option;
+ xmlNodePtr option_node;
+
+ item = options;
+ while (item)
+ {
+ option = item->data;
+
+ if (option->name && option->value)
+ {
+ option_node = xmlNewDocNode (xml_doc, NULL, BAD_CAST (DA_XML_TAG_OPTION), NULL);
+ xmlAddChild (node, option_node);
+ xmlSetProp (option_node, BAD_CAST (DA_XML_PROP_OPTION_NAME), BAD_CAST (option->name));
+ xmlSetProp (option_node, BAD_CAST (DA_XML_PROP_OPTION_VALUE), BAD_CAST (option->value));
+ }
+
+ item = item->next;
+ }
+
+ return;
+}
+
+DesignerAssociationsOption *
+designer_associations_option_from_xml (DesignerAssociationsOption *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GError **error)
+{
+ xmlChar *name = NULL;
+ xmlChar *value = NULL;
+
+ g_return_val_if_fail (error == NULL || *error == NULL, self);
+ g_return_val_if_fail (xml_doc, self);
+ g_return_val_if_fail (node, self);
+
+ name = xmlGetProp (node, BAD_CAST (DA_XML_PROP_OPTION_NAME));
+ value = xmlGetProp (node, BAD_CAST (DA_XML_PROP_OPTION_VALUE));
+
+ if (!name || !value)
+ {
+ g_set_error (error,
+ DESIGNER_ASSOCIATIONS_ERROR,
+ DESIGNER_ASSOCIATIONS_ERROR_LOADING,
+ _("bad association item option in the node %s"),
+ node->name);
+ xmlFree (name);
+ xmlFree (value);
+ return self;
+ }
+
+ g_free (self->name);
+ g_free (self->value);
+ self->name = claim_xml_string (name);
+ self->value = claim_xml_string (value);
+
+ return self;
+}
+
+gchar *
+designer_associations_options_to_string (GList *options, gchar *value_delimiter,
+ gchar *option_delimiter)
+{
+ GList *item;
+ DesignerAssociationsOption *option;
+ gchar **str_array;
+ guint count;
+ gchar *retval;
+ guint i;
+
+ count = g_list_length (options);
+ if (count == 0)
+ return NULL;
+
+ str_array = g_new0 (gchar *, count + 1);
+ item = options;
+ i = 0;
+ while (item)
+ {
+ option = item->data;
+
+ if (option->name && option->value)
+ {
+ str_array[i] = g_strconcat (option->name, value_delimiter, option->value, NULL);
+ i++;
+ }
+ item = item->next;
+ }
+ str_array[i] = NULL;
+
+ retval = g_strjoinv (option_delimiter, str_array);
+
+ for (i=0; i<count; i++)
+ {
+ g_free (str_array[i]);
+ }
+ g_free (str_array);
+
+ return retval;
+}
+
+DesignerAssociationsOption *designer_associations_option_new (void)
+{
+ return (DesignerAssociationsOption *) g_new0 (DesignerAssociationsOption, 1);
+}
+
+void
+designer_associations_option_free (DesignerAssociationsOption *self)
+{
+ g_free (self->name);
+ g_free (self->value);
+}
+
+/* AssociationsFilename */
+
+GFile *
+associations_file_from_xml (xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root, GError **error)
+{
+ xmlChar *value;
+ xmlNodePtr filename_node;
+ gboolean is_relative = FALSE;
+ GFile *retval;
+
+ filename_node = search_child (node, DA_XML_TAG_FILENAME);
+ if (!filename_node)
+ {
+ g_set_error (error,
+ DESIGNER_ASSOCIATIONS_ERROR,
+ DESIGNER_ASSOCIATIONS_ERROR_LOADING,
+ _("no filename found in the node %s"), node->name);
+ return NULL;
+ }
+
+ value = xmlGetProp (filename_node, BAD_CAST (DA_XML_PROP_FILENAME_IS_RELATIVE));
+ if (value)
+ {
+ gint i;
+
+ if (!xmlStrcmp (value, BAD_CAST (DA_XML_PROP_VALUE_TRUE)))
+ is_relative = TRUE;
+ else if (!xmlStrcmp (value, BAD_CAST (DA_XML_PROP_VALUE_FALSE)))
+ is_relative = FALSE;
+ else
+ {
+ i = g_ascii_strtoll ((gchar *)value, NULL, 10);
+ if (errno != 0)
+ {
+ g_set_error (error,
+ DESIGNER_ASSOCIATIONS_ERROR,
+ DESIGNER_ASSOCIATIONS_ERROR_LOADING,
+ _("invalid %s property value"),
+ DA_XML_PROP_FILENAME_IS_RELATIVE);
+ xmlFree (value);
+ return NULL;
+ }
+
+ is_relative = i ? TRUE : FALSE;
+ }
+
+ xmlFree (value);
+ }
+
+ value = xmlGetProp (filename_node, BAD_CAST (DA_XML_PROP_FILENAME_PATH));
+ if (!value)
+ {
+ g_set_error (error,
+ DESIGNER_ASSOCIATIONS_ERROR,
+ DESIGNER_ASSOCIATIONS_ERROR_LOADING,
+ _("association item filename has no path"));
+
+ return NULL;
+ }
+ if (is_relative)
+ retval = g_file_resolve_relative_path (project_root, (gchar*)value);
+ else
+ retval = g_file_new_for_uri ((gchar*)value);
+ xmlFree (value);
+
+ return retval;
+}
+
+void
+associations_file_to_xml (GFile *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root)
+{
+ xmlNodePtr filename_node;
+ gchar *path;
+
+ path = g_file_get_relative_path (project_root, self);
+
+ filename_node = xmlNewDocNode (xml_doc, NULL, BAD_CAST (DA_XML_TAG_FILENAME), NULL);
+ xmlAddChild (node, filename_node);
+
+ xmlSetProp (filename_node, BAD_CAST (DA_XML_PROP_FILENAME_IS_RELATIVE),
+ path ? BAD_CAST (DA_XML_PROP_VALUE_TRUE) : BAD_CAST (DA_XML_PROP_VALUE_FALSE));
+ if (!path)
+ path = g_file_get_uri (self);
+
+ xmlSetProp (filename_node, BAD_CAST (DA_XML_PROP_FILENAME_PATH),
+ path ? BAD_CAST (path) : BAD_CAST (""));
+}
Added: trunk/plugins/glade/designer-associations-item.h
==============================================================================
--- (empty file)
+++ trunk/plugins/glade/designer-associations-item.h Mon Jan 26 13:55:53 2009
@@ -0,0 +1,159 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * You may 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.
+ *
+ * anjuta 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 anjuta. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _DESIGNER_ASSOCIATIONS_ITEM_H_
+#define _DESIGNER_ASSOCIATIONS_ITEM_H_
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <libxml/tree.h>
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define DESIGNER_TYPE_ASSOCIATIONS_ITEM (designer_associations_item_get_type ())
+#define DESIGNER_ASSOCIATIONS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DESIGNER_TYPE_ASSOCIATIONS_ITEM, DesignerAssociationsItem))
+#define DESIGNER_ASSOCIATIONS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DESIGNER_TYPE_ASSOCIATIONS_ITEM, DesignerAssociationsItemClass))
+#define DESIGNER_IS_ASSOCIATIONS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DESIGNER_TYPE_ASSOCIATIONS_ITEM))
+#define DESIGNER_IS_ASSOCIATIONS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DESIGNER_TYPE_ASSOCIATIONS_ITEM))
+#define DESIGNER_ASSOCIATIONS_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DESIGNER_TYPE_ASSOCIATIONS_ITEM, DesignerAssociationsItemClass))
+
+typedef struct _DesignerAssociationsItemClass DesignerAssociationsItemClass;
+typedef struct _DesignerAssociationsItem DesignerAssociationsItem;
+
+typedef struct _DesignerAssociationsOption DesignerAssociationsOption;
+typedef struct _AssociationsFilename AssociationsFilename;
+
+struct _DesignerAssociationsItemClass
+{
+ GObjectClass parent_class;
+};
+
+struct _AssociationsFilename
+{
+ gboolean is_relative;
+ gchar *relative_path;
+ GFile *file;
+};
+
+struct _DesignerAssociationsItem
+{
+ GObject parent_instance;
+ guint id;
+ GFile *designer;
+ gchar *widget_name;
+ GFile *editor;
+ GList *options;
+};
+
+struct _DesignerAssociationsOption
+{
+ gchar *name;
+ gchar *value;
+};
+
+#define DA_XML_TAG_ROOT "associations"
+#define DA_XML_TAG_ITEM "item"
+#define DA_XML_TAG_DESIGNER "designer"
+#define DA_XML_TAG_WIDGET "widget"
+#define DA_XML_PROP_WIDGET "name"
+#define DA_XML_TAG_EDITOR "editor"
+#define DA_XML_TAG_OPTION "option"
+#define DA_XML_PROP_OPTION_NAME "name"
+#define DA_XML_PROP_OPTION_VALUE "value"
+#define DA_XML_TAG_FILENAME "filename"
+#define DA_XML_PROP_FILENAME_IS_RELATIVE "is_relative"
+#define DA_XML_PROP_FILENAME_PATH "path"
+#define DA_XML_PROP_VALUE_TRUE "true"
+#define DA_XML_PROP_VALUE_FALSE "false"
+
+/* AnjutaDesignerAssociationItem */
+
+GType designer_associations_item_get_type (void) G_GNUC_CONST;
+
+DesignerAssociationsItem *designer_associations_item_new (void);
+
+DesignerAssociationsItem *
+designer_associations_item_from_data (GFile *editor, const gchar *widget_name,
+ GFile *designer, GList *options,
+ GFile *project_root);
+DesignerAssociationsItem *
+designer_associations_item_from_xml (DesignerAssociationsItem *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root,
+ GError **error);
+void
+designer_associations_item_to_xml (DesignerAssociationsItem *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root);
+gchar *
+designer_associations_item_get_option (DesignerAssociationsItem *self,
+ const gchar *name);
+gint
+designer_associations_item_get_option_as_int (DesignerAssociationsItem *self,
+ const gchar *name,
+ const gchar **descriptions);
+GList *
+designer_associations_item_get_option_node (DesignerAssociationsItem *self,
+ const gchar *name);
+void
+designer_associations_item_set_option (DesignerAssociationsItem *self,
+ const gchar *name, const gchar *value);
+void
+designer_associations_item_set_widget_name (DesignerAssociationsItem *self,
+ const gchar *value);
+void
+designer_associations_item_free (DesignerAssociationsItem *self);
+
+/* DesignerAssociationsOption */
+
+DesignerAssociationsOption *designer_associations_option_new (void);
+
+void designer_associations_option_free (DesignerAssociationsOption *self);
+
+DesignerAssociationsOption *
+designer_associations_option_from_xml (DesignerAssociationsOption *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GError **error);
+void
+designer_associations_options_to_xml (GList *options,
+ xmlDocPtr xml_doc, xmlNodePtr node);
+gchar *
+designer_associations_options_to_string (GList *options, gchar *value_delimiter,
+ gchar *option_delimiter);
+
+/* AssociationsFilename */
+
+GFile *
+associations_file_from_xml (xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root,
+ GError **error);
+void
+associations_file_to_xml (GFile *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root);
+
+
+xmlNodePtr
+search_child (xmlNodePtr node, const gchar *name);
+
+G_END_DECLS
+
+#endif /* _DESIGNER_ASSOCIATIONS_ITEM_H_ */
Added: trunk/plugins/glade/designer-associations.c
==============================================================================
--- (empty file)
+++ trunk/plugins/glade/designer-associations.c Mon Jan 26 13:55:53 2009
@@ -0,0 +1,354 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * You may 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.
+ *
+ * anjuta 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 anjuta. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <stdlib.h>
+#include "designer-associations.h"
+#include "anjuta-glade-marshallers.h"
+
+/* DesignerAssociations */
+
+G_DEFINE_TYPE (DesignerAssociations, designer_associations, G_TYPE_OBJECT);
+
+struct _DesignerAssociationsPrivate
+{
+ guint last_id;
+ gint notification_lock;
+ gboolean notification_pending;
+};
+
+#define DESIGNER_ASSOCIATION_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), DESIGNER_TYPE_ASSOCIATIONS, DesignerAssociationsPrivate))
+
+enum
+{
+ ITEM_NOTIFY,
+ LAST_SIGNAL
+};
+
+static guint designer_associations_signals[LAST_SIGNAL] = {0};
+
+static GObjectClass *parent_class = NULL;
+
+GQuark
+designer_associations_error_quark (void)
+{
+ static GQuark error_quark = 0;
+
+ if (error_quark == 0)
+ error_quark = g_quark_from_static_string ("designer-associations-error");
+
+ return error_quark;
+}
+
+static void
+designer_associations_init (DesignerAssociations *self)
+{
+ self->priv = DESIGNER_ASSOCIATION_GET_PRIVATE (self);
+}
+
+static void
+designer_associations_finalize (GObject *object)
+{
+ DesignerAssociations *self = DESIGNER_ASSOCIATIONS (object);
+
+ designer_associations_clear (self);
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+designer_associations_class_init(DesignerAssociationsClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+
+ object_class->finalize = designer_associations_finalize;
+
+ g_type_class_add_private (klass, sizeof (DesignerAssociationsPrivate));
+
+ designer_associations_signals[ITEM_NOTIFY] =
+ g_signal_new ("item-notify",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ G_STRUCT_OFFSET (DesignerAssociationsClass, item_notify),
+ NULL, NULL,
+ anjuta_glade_marshallers_VOID__OBJECT_INT,
+ G_TYPE_NONE,
+ 2,
+ DESIGNER_TYPE_ASSOCIATIONS_ITEM,
+ DESIGNER_TYPE_ASSOCIATIONS_ACTION);
+}
+
+DesignerAssociations *designer_associations_new (void)
+{
+ return g_object_new (DESIGNER_TYPE_ASSOCIATIONS, NULL);
+}
+
+void
+designer_associations_save_to_xml (DesignerAssociations *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root)
+{
+ GList *item;
+ guint i;
+ xmlNodePtr item_node;
+
+
+ item = self->associations;
+ i = 0;
+ while (item)
+ {
+ item_node = xmlNewDocNode (xml_doc, NULL, BAD_CAST ("item"), NULL);
+ xmlAddChild (node, item_node);
+ designer_associations_item_to_xml ((DesignerAssociationsItem *) item->data,
+ xml_doc, item_node, project_root);
+ i ++;
+ item = item->next;
+ }
+}
+
+static guint
+designer_associations_make_id (DesignerAssociations *self)
+{
+ return ++ self->priv->last_id;
+}
+
+DesignerAssociations *
+designer_associations_load_from_xml (DesignerAssociations *self,
+ xmlDocPtr xml_doc,
+ xmlNodePtr node,
+ GFile *project_root,
+ GError **error)
+{
+ DesignerAssociationsItem *item;
+ GError *nested_error = NULL;
+ xmlNodePtr child_node;
+
+ g_return_val_if_fail (error == NULL || *error == NULL, self);
+ g_return_val_if_fail (xml_doc, self);
+ g_return_val_if_fail (node, self);
+
+ designer_associations_lock_notification (self);
+
+ designer_associations_clear (self);
+
+ child_node = node->children;
+ while (child_node)
+ {
+ if (!xmlStrcmp (BAD_CAST (DA_XML_TAG_ITEM), child_node->name))
+ {
+ item = designer_associations_item_from_xml (designer_associations_item_new (),
+ xml_doc, child_node, project_root,
+ &nested_error);
+ if (nested_error)
+ {
+ g_object_unref (G_OBJECT (item));
+ g_propagate_error (error, nested_error);
+ break;
+ }
+ g_assert (((GObject*)item)->ref_count == 1);
+ designer_associations_add_item (self, item);
+ }
+ child_node = child_node->next;
+ }
+ self->associations = g_list_reverse (self->associations);
+
+ designer_associations_unlock_notification (self);
+
+ return self;
+}
+
+void designer_associations_clear (DesignerAssociations *self)
+{
+ GList *node;
+
+ for (node = self->associations; node;
+ node = node->next)
+ {
+ g_object_unref (G_OBJECT (node->data));
+ }
+ g_list_free (self->associations);
+ self->associations = NULL;
+ self->priv->last_id = 0;
+
+ designer_associations_notify_loaded (self);
+}
+
+static gboolean
+designer_associations_check_lock (DesignerAssociations *self)
+{
+ if (self->priv->notification_lock <= 0)
+ return TRUE;
+ else
+ {
+ self->priv->notification_pending = TRUE;
+ return FALSE;
+ }
+}
+
+void
+designer_associations_notify_added (DesignerAssociations *self,
+ DesignerAssociationsItem *item)
+{
+ if (designer_associations_check_lock (self))
+ g_signal_emit (self, designer_associations_signals[ITEM_NOTIFY],
+ g_quark_from_static_string (DESIGNER_ASSOCIATIONS_DETAIL_ADDED),
+ item, DESIGNER_ASSOCIATIONS_ADDED);
+}
+
+void
+designer_associations_notify_changed (DesignerAssociations *self,
+ DesignerAssociationsItem *item)
+{
+ if (designer_associations_check_lock (self))
+ g_signal_emit (self, designer_associations_signals[ITEM_NOTIFY],
+ g_quark_from_static_string (DESIGNER_ASSOCIATIONS_DETAIL_CHANGED),
+ item, DESIGNER_ASSOCIATIONS_CHANGED);
+
+}
+
+void
+designer_associations_notify_removed (DesignerAssociations *self,
+ DesignerAssociationsItem *item)
+{
+ if (designer_associations_check_lock (self))
+ g_signal_emit (self, designer_associations_signals[ITEM_NOTIFY],
+ g_quark_from_static_string (DESIGNER_ASSOCIATIONS_DETAIL_REMOVED),
+ item, DESIGNER_ASSOCIATIONS_REMOVED);
+
+}
+
+void
+designer_associations_notify_loaded (DesignerAssociations *self)
+{
+ if (designer_associations_check_lock (self))
+ g_signal_emit (self, designer_associations_signals[ITEM_NOTIFY],
+ g_quark_from_static_string (DESIGNER_ASSOCIATIONS_DETAIL_LOADED),
+ NULL, DESIGNER_ASSOCIATIONS_LOADED);
+
+}
+
+gint
+designer_associations_lock_notification (DesignerAssociations *self)
+{
+ return self->priv->notification_lock ++;
+}
+
+gint
+designer_associations_unlock_notification (DesignerAssociations *self)
+{
+ self->priv->notification_lock --;
+ if (self->priv->notification_lock < 0)
+ g_critical ("Unbalanced lock stack detected in %s\n",
+ G_GNUC_PRETTY_FUNCTION);
+ if (self->priv->notification_lock == 0 && self->priv->notification_pending)
+ g_signal_emit (self, designer_associations_signals[ITEM_NOTIFY],
+ g_quark_from_static_string (DESIGNER_ASSOCIATIONS_DETAIL_LOADED),
+ NULL, DESIGNER_ASSOCIATIONS_LOADED);
+ return self->priv->notification_lock;
+}
+
+guint
+designer_associations_add_item (DesignerAssociations *self,
+ DesignerAssociationsItem *item)
+{
+ g_return_val_if_fail (item, 0);
+
+ g_object_ref (G_OBJECT (item));
+ item->id = designer_associations_make_id (self);
+ self->associations = g_list_prepend (self->associations, item);
+ designer_associations_notify_added (self, item);
+ return item->id;
+}
+
+void
+designer_associations_remove_item_by_id (DesignerAssociations *self, guint id)
+{
+ GList *node;
+ GList *del_node = NULL;
+ DesignerAssociationsItem *item;
+
+ node = self->associations;
+
+ while (node)
+ {
+ item = node->data;
+
+ if (item->id == id)
+ del_node = node;
+
+ node = node->next;
+
+ if (del_node)
+ {
+ self->associations = g_list_delete_link (self->associations, del_node);
+ designer_associations_notify_removed (self, item);
+ g_object_unref (G_OBJECT (item));
+ del_node = NULL;
+ }
+ }
+}
+
+DesignerAssociationsItem *
+designer_associations_search_item (DesignerAssociations *self, GFile *editor,
+ GFile *designer)
+{
+ GList *node;
+ DesignerAssociationsItem *item;
+
+ for (node = self->associations;
+ node; node = node->next)
+ {
+ item = node->data;
+
+ if (g_file_equal (editor, item->editor) &&
+ g_file_equal (designer, item->designer))
+ {
+ return item;
+ }
+ }
+
+ return NULL;
+}
+
+/* DesignerAssociationsAction */
+
+GType
+designer_associations_action_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue values[] = {
+ { DESIGNER_ASSOCIATIONS_ADDED, "DESIGNER_ASSOCIATIONS_ADDED",
+ "designer-associations-added" },
+ { DESIGNER_ASSOCIATIONS_CHANGED, "DESIGNER_ASSOCIATIONS_CHANGED",
+ "designer-associations-changed" },
+ { DESIGNER_ASSOCIATIONS_REMOVED, "DESIGNER_ASSOCIATIONS_REMOVED",
+ "designer-associations-removed" },
+ { DESIGNER_ASSOCIATIONS_LOADED, "DESIGNER_ASSOCIATIONS_LOADED",
+ "designer-associations-loaded" },
+ { 0, NULL, NULL }
+ };
+
+ etype = g_enum_register_static ("DesignerAssociationsAction", values);
+ }
+ return etype;
+}
+
Added: trunk/plugins/glade/designer-associations.h
==============================================================================
--- (empty file)
+++ trunk/plugins/glade/designer-associations.h Mon Jan 26 13:55:53 2009
@@ -0,0 +1,131 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * You may 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.
+ *
+ * anjuta 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 anjuta. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _DESIGNER_ASSOCIATIONS_H_
+#define _DESIGNER_ASSOCIATIONS_H_
+
+#include <glib.h>
+#include <glib-object.h>
+#include <libanjuta/anjuta-shell.h>
+#include <libxml/tree.h>
+
+#include "designer-associations-item.h"
+
+G_BEGIN_DECLS
+
+#define DESIGNER_TYPE_ASSOCIATIONS (designer_associations_get_type ())
+#define DESIGNER_ASSOCIATIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DESIGNER_TYPE_ASSOCIATIONS, DesignerAssociations))
+#define DESIGNER_ASSOCIATIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DESIGNER_TYPE_ASSOCIATIONS, DesignerAssociationsClass))
+#define DESIGNER_IS_ASSOCIATIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DESIGNER_TYPE_ASSOCIATIONS))
+#define DESIGNER_IS_ASSOCIATIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DESIGNER_TYPE_ASSOCIATIONS))
+#define DESIGNER_ASSOCIATIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DESIGNER_TYPE_ASSOCIATIONS, DesignerAssociationsClass))
+
+typedef struct _DesignerAssociationsClass DesignerAssociationsClass;
+typedef struct _DesignerAssociations DesignerAssociations;
+typedef struct _DesignerAssociationsPrivate DesignerAssociationsPrivate;
+
+#define DESIGNER_ASSOCIATIONS_ERROR designer_associations_error_quark ()
+
+typedef enum
+{
+ DESIGNER_ASSOCIATIONS_ERROR_LOADING
+} DesignerAssociationsError;
+
+#define DESIGNER_ASSOCIATIONS_DETAIL_ADDED "added"
+#define DESIGNER_ASSOCIATIONS_DETAIL_CHANGED "changed"
+#define DESIGNER_ASSOCIATIONS_DETAIL_REMOVED "removed"
+#define DESIGNER_ASSOCIATIONS_DETAIL_LOADED "loaded"
+
+typedef enum {
+ DESIGNER_ASSOCIATIONS_ADDED,
+ DESIGNER_ASSOCIATIONS_CHANGED,
+ DESIGNER_ASSOCIATIONS_REMOVED,
+ DESIGNER_ASSOCIATIONS_LOADED
+} DesignerAssociationsAction;
+
+#define DESIGNER_TYPE_ASSOCIATIONS_ACTION (designer_associations_action_get_type())
+GType designer_associations_action_get_type (void) G_GNUC_CONST;
+
+struct _DesignerAssociationsClass
+{
+ GObjectClass parent_class;
+
+ void (*item_notify) (DesignerAssociations *self, DesignerAssociationsItem *item,
+ DesignerAssociationsAction action);
+};
+
+struct _DesignerAssociations
+{
+ GObject parent_instance;
+ GList *associations;
+ DesignerAssociationsPrivate *priv;
+};
+
+/* DesignerAssociations */
+
+GQuark designer_associations_error_quark (void) G_GNUC_CONST;
+
+GType designer_associations_get_type (void) G_GNUC_CONST;
+
+DesignerAssociations *designer_associations_new (void);
+
+void
+designer_associations_save_to_xml (DesignerAssociations *self,
+ xmlDocPtr xml_doc, xmlNodePtr node,
+ GFile *project_root);
+DesignerAssociations *
+designer_associations_load_from_xml (DesignerAssociations *self,
+ xmlDocPtr xml_doc,
+ xmlNodePtr node,
+ GFile *project_root,
+ GError **error);
+void
+designer_associations_clear (DesignerAssociations *self);
+
+guint
+designer_associations_add_item (DesignerAssociations *self,
+ DesignerAssociationsItem *item);
+void
+designer_associations_remove_item_by_id (DesignerAssociations *self, guint id);
+
+void
+designer_associations_notify_added (DesignerAssociations *self,
+ DesignerAssociationsItem *item);
+void
+designer_associations_notify_changed (DesignerAssociations *self,
+ DesignerAssociationsItem *item);
+void
+designer_associations_notify_removed (DesignerAssociations *self,
+ DesignerAssociationsItem *item);
+void
+designer_associations_notify_loaded (DesignerAssociations *self);
+
+gint
+designer_associations_lock_notification (DesignerAssociations *self);
+
+gint
+designer_associations_unlock_notification (DesignerAssociations *self);
+
+DesignerAssociationsItem *
+designer_associations_search_item (DesignerAssociations *self, GFile *editor,
+ GFile *designer);
+
+G_END_DECLS
+
+#endif /* _DESIGNER_ASSOCIATIONS_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]