Hello, This patch replaces the old completion widgets (GTK+ 1.x) by new ones, GTK+ 2.x, standalone widgets. I wrote two different widgets : one with a GtkTable, one with a GtkNotebook, which needs to be debugged. Nicolas Centa "HappyPeng" The tarball countains the new files, the patch countains the modification to existing ones.
Attachment:
completion-widget.tar.gz
Description: application/compressed-tar
? mlview ? test.diff ? src/mlview-completion-helpers.c ? src/mlview-completion-helpers.h ? src/mlview-completion-notebook.c ? src/mlview-completion-notebook.h ? src/mlview-completion-table.c ? src/mlview-completion-table.h ? src/mlview-icompletion-widget.c ? src/mlview-icompletion-widget.h Index: src/Makefile.am =================================================================== RCS file: /cvs/gnome/mlview/src/Makefile.am,v retrieving revision 1.30 diff -a -u -r1.30 Makefile.am --- src/Makefile.am 24 Nov 2003 23:18:05 -0000 1.30 +++ src/Makefile.am 25 Dec 2003 23:22:19 -0000 @@ -54,8 +54,15 @@ mlview-icon-tree.c \ mlview-icon-tree.h \ mlview-xslt-utils.c \ - mlview-xslt-utils.h - + mlview-xslt-utils.h \ + mlview-completion-table.c \ + mlview-completion-table.h \ + mlview-icompletion-widget.c \ + mlview-icompletion-widget.h \ + mlview-completion-helpers.c \ + mlview-completion-helpers.h \ + mlview-completion-notebook.c \ + mlview-completion-notebook.h bin_PROGRAMS = mlv mlv_SOURCES = main.c Index: src/mlview-tree-view.c =================================================================== RCS file: /cvs/gnome/mlview/src/mlview-tree-view.c,v retrieving revision 1.16 diff -a -u -r1.16 mlview-tree-view.c --- src/mlview-tree-view.c 20 Dec 2003 23:52:27 -0000 1.16 +++ src/mlview-tree-view.c 25 Dec 2003 23:22:23 -0000 @@ -24,10 +24,15 @@ */ #include <string.h> + #include <glade/glade.h> + #include "mlview-tree-view.h" #include "mlview-tree-editor2.h" #include "mlview-icon-tree.h" +#include "mlview-completion-table.h" +#include "mlview-completion-notebook.h" +#include "mlview-icompletion-widget.h" /** * file @@ -48,10 +53,7 @@ /*The main paned that divides the view in two main parts */ GtkPaned *main_paned; GtkPaned *upper_paned1; - GtkCList *feasible_children; - GtkCList *feasible_prev_siblings; - GtkCList *feasible_next_siblings; - GtkCList *feasible_attributes ; + MlViewICompletionWidget *feasible; guint main_paned_percentage; gboolean dispose_has_run; } ; @@ -80,36 +82,21 @@ static void toggle_expand_to_leaves_cb (GtkToggleButton * a_toggle_button, gpointer * a_depth_entry); -static void update_feasible_attributes_list_cb (MlViewTreeEditor2 * a_editor, - GtkTreeRowReference *a_ref, - gpointer a_user_data) ; - -static void update_feasible_next_siblings_list_cb (MlViewTreeEditor2 * a_editor, - GtkTreeRowReference * a_ref, - gpointer a_user_data); - -static void update_feasible_prev_siblings_list_cb (MlViewTreeEditor2 * a_editor, - GtkTreeRowReference * a_ref, - gpointer a_user_data); - -static void update_feasible_children_list_cb (MlViewTreeEditor2 * a_editor, - GtkTreeRowReference *a_ref, - gpointer a_user_data); - -static void selected_a_possible_child_cb (GtkCList * a_possible_children, - gint a_row, gint a_column, - GdkEventButton * event, - gpointer a_user_data); - -static void selected_a_possible_next_sibling_cb (GtkCList * a_possible_next_siblings, - gint a_row, gint a_column, - GdkEventButton * event, - gpointer a_user_data); - -static void selected_a_possible_prev_sibling_cb (GtkCList * a_possible_prev_siblings, - gint a_row, gint a_column, - GdkEventButton * event, - gpointer a_user_data); +static void update_feasible_lists_cb (MlViewTreeEditor2 * a_editor, + GtkTreeRowReference *a_ref, + gpointer a_user_data); + +static void selected_a_possible_child_cb (MlViewICompletionWidget *a_widget, + gchar *a_text, gpointer a_data); + +static void selected_a_possible_prev_sibling_cb (MlViewICompletionWidget *a_widget, + gchar *a_text, gpointer a_data); + +static void selected_a_possible_next_sibling_cb (MlViewICompletionWidget *a_widget, + gchar *a_text, gpointer a_data); + +static void selected_a_possible_attribute_cb (MlViewICompletionWidget *a_widget, + gchar *a_text, gpointer a_data); static void doc_path_changed_cb (MlViewXMLDocument * a_xml_doc, gpointer a_xml_doc_tree_view); @@ -419,445 +406,185 @@ (a_depth_entry), TRUE); } -/** - *This callback is invoked when the user selects a visual xml node. - *It's a callback function for the "node-selected" signal of - *#MlViewTreeEditor2. - * - */ -void -update_feasible_children_list_cb (MlViewTreeEditor2 * a_editor, - GtkTreeRowReference * a_ref, - gpointer a_user_data) -{ - MlViewTreeView *view = NULL; - xmlNode *xml_node = NULL; - GList *children_name_list = NULL; - gint nb_of_names = 0; - GtkTreeView *tree_view=NULL ; - - g_return_if_fail (a_editor - && MLVIEW_IS_TREE_EDITOR2 (a_editor) - && a_ref && a_user_data - && MLVIEW_IS_TREE_VIEW - (a_user_data)); - tree_view = mlview_tree_editor2_get_tree_view (a_editor) ; - g_return_if_fail (tree_view - && GTK_IS_TREE_VIEW (tree_view)) ; - view = MLVIEW_TREE_VIEW (a_user_data); - g_return_if_fail (PRIVATE (view) != NULL); - gtk_clist_clear (PRIVATE (view)->feasible_children); - xml_node = mlview_tree_editor2_get_xml_node2 (a_editor, - a_ref) ; - g_return_if_fail (xml_node) ; - if (xml_node->type == XML_ELEMENT_NODE) { - - nb_of_names = - mlview_parsing_utils_build_element_name_completion_list - (PRIVATE (view)->app_context, - ADD_CHILD, - xml_node, &children_name_list); - - } - if (nb_of_names > 0) { - gchar *clist_text[1] = { NULL }; - gchar *cur_name = - (gchar *) children_name_list->data; - GList *cur = children_name_list; - - while (cur_name) { - clist_text[0] = cur_name; - gtk_clist_append (PRIVATE (view)-> - feasible_children, - clist_text); - - cur = (cur->next) ? cur->next : NULL; - cur_name = - (cur) ? (gchar *) cur-> - data : NULL; - } - } -} - -/** - *This callback is invoked when the user selects a visual xml node. - *It is a callback of the "node-selected" signal. - */ -static void -update_feasible_prev_siblings_list_cb (MlViewTreeEditor2 *a_editor, - GtkTreeRowReference *a_ref, - gpointer a_user_data) -{ - MlViewTreeView *view = NULL; - xmlNode *xml_node = NULL; - GList *children_name_list = NULL; - gint nb_of_names = 0; - GtkTreeView *tree_view=NULL ; - - g_return_if_fail (a_editor - && MLVIEW_IS_TREE_EDITOR2 (a_editor) - && PRIVATE (a_editor) - && a_ref - && a_user_data) ; - tree_view = mlview_tree_editor2_get_tree_view (a_editor) ; - g_return_if_fail (tree_view) ; - view = MLVIEW_TREE_VIEW (a_user_data); - g_return_if_fail (PRIVATE (view) != NULL); - - gtk_clist_clear (PRIVATE (view)->feasible_prev_siblings); - xml_node = - mlview_tree_editor2_get_xml_node2 (a_editor, - a_ref) ; - g_return_if_fail (xml_node); - if (xml_node->type == XML_ELEMENT_NODE) { - nb_of_names = - mlview_parsing_utils_build_element_name_completion_list - (PRIVATE (view)->app_context, - INSERT_BEFORE, - xml_node, &children_name_list); - } - if (nb_of_names > 0) { - gchar *clist_text[1] = { NULL }; - gchar *cur_name = - (gchar *) children_name_list->data; - GList *cur = children_name_list; - - while (cur_name) { - clist_text[0] = cur_name; - gtk_clist_append - (PRIVATE (view)-> - feasible_prev_siblings, - clist_text); - cur = (cur->next) ? cur->next : NULL; - cur_name = - (cur) ? (gchar *) cur-> - data : NULL; - } - } -} - - -/** - *This callback is invoked when the user selects a visual xml node. - *This is a callback for the "node-selected" signal. - */ -static void -update_feasible_next_siblings_list_cb (MlViewTreeEditor2 *a_editor, - GtkTreeRowReference *a_ref, - gpointer a_user_data) -{ - MlViewTreeView *view = NULL; - xmlNode *xml_node = NULL; - GList *children_name_list = NULL; - gint nb_of_names = 0; - GtkTreeView *tree_view=NULL ; - - g_return_if_fail (a_editor - && MLVIEW_IS_TREE_EDITOR2 (a_editor) - && PRIVATE (a_editor) - && a_ref - && a_user_data) ; - tree_view = mlview_tree_editor2_get_tree_view (a_editor) ; - g_return_if_fail (tree_view) ; - view = MLVIEW_TREE_VIEW (a_user_data); - g_return_if_fail (PRIVATE (view) != NULL); - gtk_clist_clear (PRIVATE (view)->feasible_next_siblings); - xml_node = - mlview_tree_editor2_get_xml_node2 (a_editor, a_ref) ; - g_return_if_fail (xml_node != NULL); - if (xml_node->type == XML_ELEMENT_NODE) { - nb_of_names = - mlview_parsing_utils_build_element_name_completion_list - (PRIVATE (view)->app_context, - INSERT_AFTER, xml_node, - &children_name_list); - } - if (nb_of_names > 0) { - gchar *clist_text[1] = { NULL }; - gchar *cur_name = - (gchar *) children_name_list->data; - GList *cur = children_name_list; - - while (cur_name) { - clist_text[0] = cur_name; - gtk_clist_append - (PRIVATE (view)-> - feasible_next_siblings, - clist_text); - cur = (cur->next) ? cur->next : NULL; - cur_name = - (cur) ? (gchar *) cur-> - data : NULL; - } - } -} - - -/** - *This callback is invoked when the user selects a visual xml node. - * - */ - -static void -update_feasible_attributes_list_cb (MlViewTreeEditor2 * a_editor, - GtkTreeRowReference *a_ref, - gpointer a_user_data) -{ - MlViewTreeView *view = NULL; - xmlNode *xml_node = NULL; - GList *children_name_list = NULL; - gint nb_of_names = 0; - GtkTreeView *tree_view=NULL ; - - g_return_if_fail (a_editor - && MLVIEW_IS_TREE_EDITOR2 (a_editor) - && PRIVATE (a_editor) - && a_ref - && a_user_data) ; - g_return_if_fail (MLVIEW_IS_TREE_VIEW - (a_user_data)); - - tree_view = mlview_tree_editor2_get_tree_view (a_editor) ; - g_return_if_fail (tree_view) ; - view = MLVIEW_TREE_VIEW (a_user_data); - g_return_if_fail (PRIVATE (view) != NULL); - gtk_clist_clear (PRIVATE (view)->feasible_attributes); - xml_node = mlview_tree_editor2_get_xml_node2 (a_editor, - a_ref) ; - g_return_if_fail (xml_node != NULL); - if (xml_node->type == XML_ELEMENT_NODE) { - nb_of_names = - mlview_parsing_utils_build_attribute_name_completion_list - (PRIVATE (view)->app_context, xml_node, - &children_name_list, FALSE); - } - if (nb_of_names > 0) { - gchar *clist_text[1] = { NULL }; - gchar *cur_name = - (gchar *) children_name_list->data; - GList *cur = children_name_list; - - while (cur_name) { - clist_text[0] = cur_name; - gtk_clist_append (PRIVATE (view)-> - feasible_attributes, - clist_text); - cur = (cur->next) ? cur->next : NULL; - cur_name = - (cur) ? (gchar *) cur-> - data : NULL; - } - } +static void +update_feasible_lists_cb (MlViewTreeEditor2 *a_editor, + GtkTreeRowReference *a_ref, + gpointer a_user_data) +{ + MlViewTreeView *view = NULL; + xmlNode *xml_node = NULL; + GList *list = NULL; + GtkTreeView *tree_view=NULL ; + + g_return_if_fail (a_editor + && MLVIEW_IS_TREE_EDITOR2 (a_editor) + && a_ref && a_user_data + && MLVIEW_IS_TREE_VIEW + (a_user_data)); + tree_view = mlview_tree_editor2_get_tree_view (a_editor) ; + g_return_if_fail (tree_view + && GTK_IS_TREE_VIEW (tree_view)) ; + view = MLVIEW_TREE_VIEW (a_user_data); + g_return_if_fail (PRIVATE (view) != NULL); + xml_node = mlview_tree_editor2_get_xml_node2 (a_editor, + a_ref) ; + g_return_if_fail (xml_node) ; + if (xml_node->type == XML_ELEMENT_NODE) { + mlview_parsing_utils_build_element_name_completion_list + (PRIVATE (view)->app_context, + ADD_CHILD, + xml_node, &list); + mlview_icompletion_widget_update_feasible_children_list + (PRIVATE (view)->feasible, list); + g_list_free (list); + list = NULL; + mlview_parsing_utils_build_element_name_completion_list + (PRIVATE (view)->app_context, + INSERT_BEFORE, + xml_node, &list); + mlview_icompletion_widget_update_feasible_prev_siblings_list + (PRIVATE (view)->feasible, list); + g_list_free (list); + list = NULL; + mlview_parsing_utils_build_element_name_completion_list + (PRIVATE (view)->app_context, + INSERT_AFTER, + xml_node, &list); + mlview_icompletion_widget_update_feasible_next_siblings_list + (PRIVATE (view)->feasible, list); + g_list_free (list); + list = NULL; + mlview_parsing_utils_build_attribute_name_completion_list + (PRIVATE (view)->app_context, xml_node, + &list, FALSE); + mlview_icompletion_widget_update_feasible_attributes_list + (PRIVATE (view)->feasible, list); + g_list_free (list); + list = NULL; + } + else + mlview_icompletion_widget_clear_lists (PRIVATE (view)->feasible); } - -static void -selected_a_possible_child_cb (GtkCList * a_possible_children, - gint a_row, gint a_column, - GdkEventButton * event, - gpointer a_user_data) +static void selected_a_possible_child_cb (MlViewICompletionWidget *a_widget, + gchar *a_text, gpointer a_data) { MlViewTreeView *doc_tree_view = NULL; - GtkTreeIter cur_sel_start={0} ; - gchar *element_name = NULL; - gint ret_code = 0; enum MlViewStatus status = MLVIEW_OK ; + xmlNode *new_node = NULL; + GtkTreeIter cur_sel_start = {0}; - g_return_if_fail (a_possible_children != NULL); - g_return_if_fail (GTK_IS_CLIST (a_possible_children)); - g_return_if_fail (a_user_data != NULL); - g_return_if_fail (MLVIEW_IS_TREE_VIEW - (a_user_data)); - - doc_tree_view = MLVIEW_TREE_VIEW (a_user_data); - g_return_if_fail (PRIVATE (doc_tree_view) != NULL); - g_return_if_fail (PRIVATE (doc_tree_view)->tree_editor != - NULL); + g_return_if_fail (a_widget && a_data && a_text && MLVIEW_IS_TREE_VIEW (a_data)); + doc_tree_view = MLVIEW_TREE_VIEW (a_data); + g_return_if_fail (PRIVATE (doc_tree_view) && PRIVATE (doc_tree_view)->tree_editor); status = mlview_tree_editor2_get_cur_sel_start_iter (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start) ; - g_return_if_fail (status == MLVIEW_OK) ; - /*do not free element_name!! */ - ret_code = gtk_clist_get_text (a_possible_children, - a_row, a_column, - &element_name); - if (ret_code == 1) { - /*text retrieved ! */ - xmlNode *new_node = NULL; - - if (strcmp (element_name, "#PCDATA") == 0) { - new_node = xmlNewNode (NULL, "text"); - new_node->type = XML_TEXT_NODE; - } else { - new_node = - xmlNewNode (NULL, element_name); - } - mlview_tree_editor2_add_child_node - (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start, new_node) ; - } + &cur_sel_start); + g_return_if_fail (status == MLVIEW_OK); + + if (strcmp (a_text, "#PCDATA") == 0) { + new_node = xmlNewNode (NULL, "text"); + new_node->type = XML_TEXT_NODE; + } else + new_node = xmlNewNode (NULL, a_text); + status = mlview_tree_editor2_add_child_node (PRIVATE (doc_tree_view)->tree_editor, + &cur_sel_start, new_node); + g_return_if_fail (status == MLVIEW_OK); } -static void -selected_a_possible_prev_sibling_cb (GtkCList * a_possible_prev_siblings, - gint a_row, gint a_column, - GdkEventButton * event, - gpointer a_user_data) +static void selected_a_possible_prev_sibling_cb (MlViewICompletionWidget *a_widget, + gchar *a_text, gpointer a_data) { MlViewTreeView *doc_tree_view = NULL; - enum MlViewStatus stat = MLVIEW_OK ; - GtkTreeIter cur_sel_start = {0} ; - gchar *element_name = NULL; - gint ret_code = 0; + enum MlViewStatus status = MLVIEW_OK ; + xmlNode *new_node = NULL; + GtkTreeIter cur_sel_start = {0}; - g_return_if_fail (a_possible_prev_siblings != NULL); - g_return_if_fail (GTK_IS_CLIST - (a_possible_prev_siblings)); - g_return_if_fail (a_user_data != NULL); - g_return_if_fail (MLVIEW_IS_TREE_VIEW - (a_user_data)); - doc_tree_view = MLVIEW_TREE_VIEW (a_user_data); - g_return_if_fail (PRIVATE (doc_tree_view) != NULL); - g_return_if_fail (PRIVATE (doc_tree_view)->tree_editor != - NULL); - stat = mlview_tree_editor2_get_cur_sel_start_iter + g_return_if_fail (a_widget && a_data && a_text && MLVIEW_IS_TREE_VIEW (a_data)); + doc_tree_view = MLVIEW_TREE_VIEW (a_data); + g_return_if_fail (PRIVATE (doc_tree_view) && PRIVATE (doc_tree_view)->tree_editor); + status = mlview_tree_editor2_get_cur_sel_start_iter (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start) ; - g_return_if_fail (stat == MLVIEW_OK) ; - /*do not free element_name!! */ - ret_code = gtk_clist_get_text (a_possible_prev_siblings, - a_row, a_column, - &element_name); - if (ret_code == 1) { - /*text retrieved ! */ - xmlNode *new_node = NULL; - if (strcmp (element_name, "#PCDATA") == 0) { - new_node = xmlNewNode (NULL, "text"); - new_node->type = XML_TEXT_NODE; - } else { - new_node = - xmlNewNode (NULL, element_name); - } - stat = mlview_tree_editor2_insert_sibling_node - (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start, new_node, TRUE) ; - g_return_if_fail (stat == MLVIEW_OK); - } -} + &cur_sel_start); + g_return_if_fail (status == MLVIEW_OK); + if (strcmp (a_text, "#PCDATA") == 0) { + new_node = xmlNewNode (NULL, "text"); + new_node->type = XML_TEXT_NODE; + } else + new_node = xmlNewNode (NULL, a_text); + status = mlview_tree_editor2_insert_sibling_node (PRIVATE (doc_tree_view)->tree_editor, + &cur_sel_start, new_node, TRUE); + g_return_if_fail (status == MLVIEW_OK); +} -static void -selected_a_possible_next_sibling_cb (GtkCList * a_possible_next_siblings, - gint a_row, gint a_column, - GdkEventButton * event, - gpointer a_user_data) +static void selected_a_possible_next_sibling_cb (MlViewICompletionWidget *a_widget, + gchar *a_text, gpointer a_data) { MlViewTreeView *doc_tree_view = NULL; - GtkTreeIter cur_sel_start = {0} ; - enum MlViewStatus stat = MLVIEW_OK ; - gchar *element_name = NULL; - gint ret_code = 0; + enum MlViewStatus status = MLVIEW_OK ; + xmlNode *new_node = NULL; + GtkTreeIter cur_sel_start = {0}; - g_return_if_fail (a_possible_next_siblings != NULL); - g_return_if_fail (GTK_IS_CLIST - (a_possible_next_siblings)); - g_return_if_fail (a_user_data != NULL); - g_return_if_fail (MLVIEW_IS_TREE_VIEW - (a_user_data)); - doc_tree_view = MLVIEW_TREE_VIEW (a_user_data); - g_return_if_fail (PRIVATE (doc_tree_view) != NULL); - g_return_if_fail (PRIVATE (doc_tree_view)->tree_editor != - NULL); - stat = mlview_tree_editor2_get_cur_sel_start_iter + g_return_if_fail (a_widget && a_data && a_text && MLVIEW_IS_TREE_VIEW (a_data)); + doc_tree_view = MLVIEW_TREE_VIEW (a_data); + g_return_if_fail (PRIVATE (doc_tree_view) && PRIVATE (doc_tree_view)->tree_editor); + status = mlview_tree_editor2_get_cur_sel_start_iter (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start) ; - g_return_if_fail (stat == MLVIEW_OK) ; - /*do not free element_name!! */ - ret_code = gtk_clist_get_text (a_possible_next_siblings, - a_row, a_column, - &element_name); - if (ret_code == 1) { - /*text retrieved ! */ - xmlNode *new_node = NULL; - if (strcmp (element_name, "#PCDATA") == 0) { - new_node = xmlNewNode (NULL, "text"); - new_node->type = XML_TEXT_NODE; - } else { - new_node = - xmlNewNode (NULL, element_name); - } - stat = mlview_tree_editor2_insert_sibling_node - (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start, new_node, FALSE) ; - } -} + &cur_sel_start); + g_return_if_fail (status == MLVIEW_OK); + if (strcmp (a_text, "#PCDATA") == 0) { + new_node = xmlNewNode (NULL, "text"); + new_node->type = XML_TEXT_NODE; + } else + new_node = xmlNewNode (NULL, a_text); + status = mlview_tree_editor2_insert_sibling_node (PRIVATE (doc_tree_view)->tree_editor, + &cur_sel_start, new_node, FALSE); + g_return_if_fail (status == MLVIEW_OK); +} -/** - * - */ -static void -selected_a_possible_attribute_cb (GtkCList * a_possible_attributes, - gint a_row, gint a_column, - GdkEventButton * a_event, - gpointer a_user_data) +static void selected_a_possible_attribute_cb (MlViewICompletionWidget *a_widget, + gchar *a_text, gpointer a_data) { MlViewTreeView *doc_tree_view = NULL; MlViewXMLDocument *mlview_xml_doc = NULL; enum MlViewStatus stat = MLVIEW_OK ; GtkTreeIter cur_sel_start = {0} ; GtkTreeView *visual_tree = NULL; - gchar *attribute_name = NULL; - gint ret_code = 0; - - g_return_if_fail (a_possible_attributes != NULL); - g_return_if_fail (GTK_IS_CLIST (a_possible_attributes)); - g_return_if_fail (a_user_data != NULL); - g_return_if_fail (MLVIEW_IS_TREE_VIEW - (a_user_data)); - - doc_tree_view = MLVIEW_TREE_VIEW (a_user_data); + xmlNode *xml_node = NULL; + xmlAttr *attr = NULL; - g_return_if_fail (PRIVATE (doc_tree_view) != NULL); - g_return_if_fail (MLVIEW_IS_TREE_VIEW - (doc_tree_view)); - g_return_if_fail (PRIVATE (doc_tree_view)->tree_editor != - NULL); - g_return_if_fail (PRIVATE (doc_tree_view)->node_editor != - NULL); + g_return_if_fail (a_data && MLVIEW_IS_TREE_VIEW (a_data)); + doc_tree_view = MLVIEW_TREE_VIEW (a_data); + g_return_if_fail (PRIVATE (doc_tree_view) + && PRIVATE (doc_tree_view)->tree_editor + && PRIVATE (doc_tree_view)->node_editor); mlview_iview_get_document (MLVIEW_IVIEW (doc_tree_view), &mlview_xml_doc); - g_return_if_fail (mlview_xml_doc != NULL); + g_return_if_fail (mlview_xml_doc); stat = mlview_tree_editor2_get_cur_sel_start_iter (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start) ; - g_return_if_fail (stat == MLVIEW_OK) ; - + &cur_sel_start); + g_return_if_fail (stat == MLVIEW_OK); visual_tree = mlview_tree_editor2_get_tree_view (PRIVATE (doc_tree_view)->tree_editor) ; - g_return_if_fail (visual_tree != NULL); - ret_code = gtk_clist_get_text - (a_possible_attributes, a_row, - a_column, &attribute_name); /*do not free attribute_name!! */ - if (ret_code == 1) { - /*text retrieved ! */ - xmlNode *xml_node = NULL; - xmlAttr *attr = NULL; - xml_node = mlview_tree_editor2_get_xml_node - (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start) ; - g_return_if_fail (xml_node != NULL); - attr = xmlNewProp (xml_node, - attribute_name, - "value"); - stat = mlview_tree_editor2_update_visual_node - (PRIVATE (doc_tree_view)->tree_editor, - &cur_sel_start) ; - g_return_if_fail (stat == MLVIEW_OK) ; - mlview_node_editor_edit_xml_node - (PRIVATE (doc_tree_view)->node_editor, - mlview_xml_doc, xml_node) ; - } + g_return_if_fail (visual_tree); + + xml_node = mlview_tree_editor2_get_xml_node + (PRIVATE (doc_tree_view)->tree_editor, + &cur_sel_start) ; + g_return_if_fail (xml_node); + attr = xmlNewProp (xml_node, + a_text, + "value"); + stat = mlview_tree_editor2_update_visual_node + (PRIVATE (doc_tree_view)->tree_editor, + &cur_sel_start) ; + g_return_if_fail (stat == MLVIEW_OK) ; + mlview_node_editor_edit_xml_node + (PRIVATE (doc_tree_view)->node_editor, + mlview_xml_doc, xml_node) ; } /** @@ -1319,7 +1046,7 @@ gchar * a_name, MlViewAppContext *a_app_context) { - GtkWidget *table = NULL, + GtkWidget *compl = NULL, *scrolled = NULL; MlViewTreeEditor2 *raw_xml = NULL; MlViewTreeEditor2 *elements = NULL; @@ -1393,97 +1120,32 @@ GTK_WIDGET (raw_xml), gtk_label_new (_("Raw XML"))); - /*the table with the feasible children, siblings and attributes */ - PRIVATE (a_this)->feasible_children = - GTK_CLIST (gtk_clist_new_with_titles - (1, (gchar**)feasible_children_titles)); - - g_signal_connect (G_OBJECT - (PRIVATE (a_this)-> - feasible_children), "select-row", - G_CALLBACK - (selected_a_possible_child_cb), - a_this); + /* The widget with the feasible children, siblings and attributes */ + + compl = g_object_new (MLVIEW_TYPE_COMPLETION_TABLE, NULL); + //compl = g_object_new (MLVIEW_TYPE_COMPLETION_NOTEBOOK, NULL); + PRIVATE (a_this)->feasible = MLVIEW_ICOMPLETION_WIDGET (compl); - PRIVATE (a_this)->feasible_prev_siblings = - GTK_CLIST (gtk_clist_new_with_titles - (1, (gchar**)feasible_prev_siblings_titles)); + gtk_paned_pack2 (GTK_PANED + (PRIVATE (a_this)->upper_paned1), + GTK_WIDGET (PRIVATE (a_this)->feasible), FALSE, TRUE); - g_signal_connect (G_OBJECT - (PRIVATE (a_this)-> - feasible_prev_siblings), "select-row", - G_CALLBACK - (selected_a_possible_prev_sibling_cb), + g_signal_connect (G_OBJECT (PRIVATE (a_this)->feasible), + "selected-a-possible-child", + G_CALLBACK (selected_a_possible_child_cb), a_this); - - PRIVATE (a_this)->feasible_next_siblings = - GTK_CLIST (gtk_clist_new_with_titles - (1, (gchar**) feasible_next_siblings_titles)); - - g_signal_connect (G_OBJECT - (PRIVATE (a_this)-> - feasible_next_siblings), "select-row", - G_CALLBACK - (selected_a_possible_next_sibling_cb), + g_signal_connect (G_OBJECT (PRIVATE (a_this)->feasible), + "selected-a-possible-prev-sibling", + G_CALLBACK (selected_a_possible_prev_sibling_cb), a_this); - - PRIVATE (a_this)->feasible_attributes = - GTK_CLIST - (gtk_clist_new_with_titles - (1, (gchar**)feasible_attributes_titles)); - - g_signal_connect (G_OBJECT - (PRIVATE (a_this)-> - feasible_attributes), "select-row", - GTK_SIGNAL_FUNC - (selected_a_possible_attribute_cb), + g_signal_connect (G_OBJECT (PRIVATE (a_this)->feasible), + "selected-a-possible-next-sibling", + G_CALLBACK (selected_a_possible_next_sibling_cb), + a_this); + g_signal_connect (G_OBJECT (PRIVATE (a_this)->feasible), + "selected-a-possible-attribute", + G_CALLBACK (selected_a_possible_attribute_cb), a_this); - - table = gtk_table_new (2, 2, TRUE); - - scrolled = gtk_scrolled_window_new (NULL, NULL); - - gtk_container_add - (GTK_CONTAINER (scrolled), - GTK_WIDGET (PRIVATE (a_this)-> - feasible_children)); - - gtk_table_attach_defaults (GTK_TABLE (table), scrolled, - 0, 1, 0, 1); - - scrolled = gtk_scrolled_window_new (NULL, NULL); - - gtk_container_add (GTK_CONTAINER (scrolled), - GTK_WIDGET - (PRIVATE (a_this)-> - feasible_prev_siblings)); - - gtk_table_attach_defaults (GTK_TABLE (table), scrolled, - 1, 2, 0, 1); - - scrolled = gtk_scrolled_window_new (NULL, NULL); - - gtk_container_add (GTK_CONTAINER (scrolled), - GTK_WIDGET - (PRIVATE (a_this)-> - feasible_next_siblings)); - - gtk_table_attach_defaults (GTK_TABLE (table), scrolled, - 1, 2, 1, 2); - - scrolled = gtk_scrolled_window_new (NULL, NULL); - - gtk_container_add (GTK_CONTAINER (scrolled), - GTK_WIDGET - (PRIVATE (a_this)-> - feasible_attributes)); - - gtk_table_attach_defaults (GTK_TABLE (table), scrolled, - 0, 1, 1, 2); - - gtk_paned_pack2 (GTK_PANED - (PRIVATE (a_this)->upper_paned1), - table, FALSE, TRUE); /*The node editor */ PRIVATE (a_this)->node_editor = @@ -1526,32 +1188,12 @@ G_CALLBACK (visual_node_selected_cb), a_this); */ - g_signal_connect (G_OBJECT - (tree_editor), - "node-selected", - G_CALLBACK - (update_feasible_children_list_cb), - a_this); - - g_signal_connect (G_OBJECT + g_signal_connect (G_OBJECT (tree_editor), "node-selected", - G_CALLBACK - (update_feasible_prev_siblings_list_cb), - a_this); - g_signal_connect (G_OBJECT - (tree_editor), - "node-selected", - G_CALLBACK - (update_feasible_next_siblings_list_cb), - a_this); - g_signal_connect (GTK_OBJECT - (tree_editor), - "node-selected", - G_CALLBACK - (update_feasible_attributes_list_cb), - a_this); - + G_CALLBACK + (update_feasible_lists_cb), + a_this); } g_signal_connect (G_OBJECT (a_mlview_xml_doc), "file-path-changed",