diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/ChangeLog | 21 | ||||
-rw-r--r-- | widgets/misc/e-activity-handler.c | 22 | ||||
-rw-r--r-- | widgets/misc/e-activity-handler.h | 2 | ||||
-rw-r--r-- | widgets/misc/e-combo-button.c | 7 | ||||
-rw-r--r-- | widgets/misc/e-info-label.c | 6 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.c | 1 | ||||
-rw-r--r-- | widgets/misc/e-send-options.c | 12 | ||||
-rw-r--r-- | widgets/misc/e-task-widget.c | 73 | ||||
-rw-r--r-- | widgets/misc/e-task-widget.h | 49 | ||||
-rw-r--r-- | widgets/misc/e-url-entry.c | 3 | ||||
-rw-r--r-- | widgets/misc/test-info-label.c | 3 | ||||
-rw-r--r-- | widgets/table/ChangeLog | 47 | ||||
-rw-r--r-- | widgets/table/e-tree-table-adapter.c | 93 | ||||
-rw-r--r-- | widgets/table/e-tree-table-adapter.h | 8 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 26 | ||||
-rw-r--r-- | widgets/table/e-tree.h | 6 |
16 files changed, 212 insertions, 167 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 6833cf44d6..15f82821c4 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,24 @@ +2008-08-14 Matthew Barnes <mbarnes@redhat.com> + + * e-multi-config-dialog.c: + * e-send-options.c: + Use e_display_help() for displaying help. + +2008-08-11 Matthew Barnes <mbarnes@redhat.com> + + ** Fixes part of bug #546892 + + * e-combo-button.c: + * e-info-label.c: + * e-url-entry.c: + * e-task-widget.c: + Prefer gtk_image_new_from_stock() over e_icon_factory_get_image(). + + * e-activity-handler.c: + * e-task-widget.c: + Purge the GdkPixbuf arguments from the API. We've been ignoring + them since the spinner icon was added. + 2008-07-23 Milan Crha <mcrha@redhat.com> ** Part of fix for bug #543943 diff --git a/widgets/misc/e-activity-handler.c b/widgets/misc/e-activity-handler.c index 04861b1b8f..d7972ac336 100644 --- a/widgets/misc/e-activity-handler.c +++ b/widgets/misc/e-activity-handler.c @@ -39,7 +39,6 @@ struct _ActivityInfo { char *component_id; - GdkPixbuf *icon_pixbuf; int error_type; guint id; char *information; @@ -131,7 +130,6 @@ task_widget_button_press_event_callback (GtkWidget *widget, static ActivityInfo * activity_info_new (const char *component_id, guint id, - GdkPixbuf *icon, const char *information, gboolean cancellable) { @@ -140,7 +138,6 @@ activity_info_new (const char *component_id, info = g_new (ActivityInfo, 1); info->component_id = g_strdup (component_id); info->id = id; - info->icon_pixbuf = icon ? g_object_ref (icon): NULL; info->information = g_strdup (information); info->cancellable = cancellable; info->progress = -1.0; /* (Unknown) */ @@ -155,9 +152,6 @@ static void activity_info_free (ActivityInfo *info) { g_free (info->component_id); - - if (info->icon_pixbuf) - g_object_unref (info->icon_pixbuf); g_free (info->information); if (info->menu != NULL) @@ -172,9 +166,11 @@ task_widget_new_from_activity_info (ActivityInfo *activity_info) GtkWidget *widget; ETaskWidget *etw; - widget = e_task_widget_new_with_cancel (activity_info->icon_pixbuf, - activity_info->component_id, - activity_info->information, activity_info->cancel_func, activity_info->data); + widget = e_task_widget_new_with_cancel ( + activity_info->component_id, + activity_info->information, + activity_info->cancel_func, + activity_info->data); etw = (ETaskWidget *) widget; etw->id = activity_info->id; gtk_widget_show (widget); @@ -411,7 +407,6 @@ cancel_wrapper (gpointer pdata) /* CORBA methods. */ guint e_activity_handler_cancelable_operation_started (EActivityHandler *activity_handler, const char *component_id, - GdkPixbuf *icon_pixbuf, const char *information, gboolean cancellable, void (*cancel_func)(gpointer), @@ -426,7 +421,7 @@ guint e_activity_handler_cancelable_operation_started (EActivityHandler *activ priv = activity_handler->priv; activity_id = get_new_activity_id (activity_handler); - activity_info = activity_info_new (component_id, activity_id, icon_pixbuf, information, cancellable); + activity_info = activity_info_new (component_id, activity_id, information, cancellable); data = g_new(struct _cancel_wdata, 1); data->handler = activity_handler; @@ -457,7 +452,6 @@ guint e_activity_handler_cancelable_operation_started (EActivityHandler *activ guint e_activity_handler_operation_started (EActivityHandler *activity_handler, const char *component_id, - GdkPixbuf *icon_pixbuf, const char *information, gboolean cancellable) { @@ -470,7 +464,7 @@ e_activity_handler_operation_started (EActivityHandler *activity_handler, activity_id = get_new_activity_id (activity_handler); - activity_info = activity_info_new (component_id, activity_id, icon_pixbuf, information, cancellable); + activity_info = activity_info_new (component_id, activity_id, information, cancellable); for (p = priv->task_bars; p != NULL; p = p->next) { ETaskWidget *tw = task_widget_new_from_activity_info (activity_info); @@ -558,7 +552,7 @@ e_activity_handler_make_error (EActivityHandler *activity_handler, priv = activity_handler->priv; activity_id = get_new_activity_id (activity_handler); - activity_info = activity_info_new (component_id, activity_id, NULL, information, TRUE); + activity_info = activity_info_new (component_id, activity_id, information, TRUE); activity_info->error = error; activity_info->error_time = time (NULL); activity_info->error_type = error_type; diff --git a/widgets/misc/e-activity-handler.h b/widgets/misc/e-activity-handler.h index 49f7742026..8b6a857569 100644 --- a/widgets/misc/e-activity-handler.h +++ b/widgets/misc/e-activity-handler.h @@ -71,12 +71,10 @@ void e_activity_handler_unset_message (EActivityHandler *activity_handler); guint e_activity_handler_operation_started (EActivityHandler *activity_handler, const char *component_id, - GdkPixbuf *icon_pixbuf, const char *information, gboolean cancellable); guint e_activity_handler_cancelable_operation_started (EActivityHandler *activity_handler, const char *component_id, - GdkPixbuf *icon_pixbuf, const char *information, gboolean cancellable, void (*cancel_func)(gpointer), diff --git a/widgets/misc/e-combo-button.c b/widgets/misc/e-combo-button.c index 65014900c6..6fc0fec57e 100644 --- a/widgets/misc/e-combo-button.c +++ b/widgets/misc/e-combo-button.c @@ -26,7 +26,6 @@ #include "e-combo-button.h" #include "ea-widgets.h" -#include <e-util/e-icon-factory.h> struct _EComboButtonPrivate { GdkPixbuf *icon; @@ -461,7 +460,8 @@ e_combo_button_pack_hbox (EComboButton *combo_button) gtk_container_add (GTK_CONTAINER (combo_button), priv->hbox); gtk_widget_show (priv->hbox); - priv->icon_image = e_icon_factory_get_image (NULL, E_ICON_SIZE_MENU); + priv->icon_image = gtk_image_new_from_stock ( + GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->icon_image, TRUE, TRUE, 0); gtk_widget_show (priv->icon_image); @@ -498,7 +498,8 @@ e_combo_button_pack_vbox (EComboButton *combo_button) priv->vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (priv->vbox); - priv->icon_image = e_icon_factory_get_image (NULL, E_ICON_SIZE_MENU); + priv->icon_image = gtk_image_new_from_stock ( + GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (priv->vbox), priv->icon_image, TRUE, TRUE, 0); gtk_widget_show (priv->icon_image); diff --git a/widgets/misc/e-info-label.c b/widgets/misc/e-info-label.c index 3e8691972d..4c3c04069f 100644 --- a/widgets/misc/e-info-label.c +++ b/widgets/misc/e-info-label.c @@ -27,8 +27,6 @@ #include "e-info-label.h" -#include <e-util/e-icon-factory.h> - static GtkHBoxClass *el_parent; static void @@ -184,10 +182,8 @@ e_info_label_new(const char *icon) { EInfoLabel *el = g_object_new(e_info_label_get_type(), NULL); GtkWidget *image; - char *name = e_icon_factory_get_icon_filename (icon, E_ICON_SIZE_MENU); - image = gtk_image_new_from_file(name); - g_free(name); + image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU); gtk_misc_set_padding((GtkMisc *)image, 6, 6); gtk_box_pack_start((GtkBox *)el, image, FALSE, TRUE, 0); gtk_widget_show(image); diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c index ffef719f17..bd8ba20072 100644 --- a/widgets/misc/e-search-bar.c +++ b/widgets/misc/e-search-bar.c @@ -45,7 +45,6 @@ #include "e-search-bar.h" #include "e-util/e-util.h" #include "e-util/e-util-marshal.h" -#include "e-util/e-icon-factory.h" enum { diff --git a/widgets/misc/e-send-options.c b/widgets/misc/e-send-options.c index 32eb33b484..33c80d6917 100644 --- a/widgets/misc/e-send-options.c +++ b/widgets/misc/e-send-options.c @@ -23,11 +23,11 @@ #endif #include <string.h> -#include <libgnome/libgnome.h> #include <glib/gi18n.h> #include <glade/glade.h> #include <time.h> +#include "e-util/e-util.h" #include "e-util/e-util-private.h" #include "e-dateedit.h" @@ -586,7 +586,6 @@ static void e_send_options_cb (GtkDialog *dialog, gint state, gpointer func_data { ESendOptionsDialogPrivate *priv; ESendOptionsDialog *sod; - GError *error = NULL; sod = func_data; priv = sod->priv; @@ -600,12 +599,9 @@ static void e_send_options_cb (GtkDialog *dialog, gint state, gpointer func_data g_object_unref (priv->xml); break; case GTK_RESPONSE_HELP: - gnome_help_display ( - "evolution.xml", priv->help_section, &error); - if (error != NULL) { - g_warning ("%s", error->message); - g_error_free (error); - } + e_display_help ( + GTK_WINDOW (priv->main), + priv->help_section); break; } diff --git a/widgets/misc/e-task-widget.c b/widgets/misc/e-task-widget.c index 74b0ba6891..bb2ec2747e 100644 --- a/widgets/misc/e-task-widget.c +++ b/widgets/misc/e-task-widget.c @@ -26,7 +26,6 @@ #include "e-task-widget.h" #include "e-spinner.h" -#include <e-util/e-icon-factory.h> #include <glib/gi18n.h> @@ -36,7 +35,6 @@ struct _ETaskWidgetPrivate { char *component_id; - GdkPixbuf *icon_pixbuf; GtkWidget *label; GtkWidget *box; GtkWidget *image; @@ -50,24 +48,6 @@ G_DEFINE_TYPE (ETaskWidget, e_task_widget, GTK_TYPE_EVENT_BOX) /* GObject methods. */ static void -impl_dispose (GObject *object) -{ - ETaskWidget *task_widget; - ETaskWidgetPrivate *priv; - - task_widget = E_TASK_WIDGET (object); - - priv = task_widget->priv; - - if (priv->icon_pixbuf != NULL) { - g_object_unref (priv->icon_pixbuf); - priv->icon_pixbuf = NULL; - } - - (* G_OBJECT_CLASS (e_task_widget_parent_class)->dispose) (object); -} - -static void impl_finalize (GObject *object) { ETaskWidget *task_widget; @@ -88,7 +68,6 @@ e_task_widget_class_init (ETaskWidgetClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->dispose = impl_dispose; object_class->finalize = impl_finalize; } @@ -100,7 +79,6 @@ e_task_widget_init (ETaskWidget *task_widget) priv = g_new (ETaskWidgetPrivate, 1); priv->component_id = NULL; - priv->icon_pixbuf = NULL; priv->label = NULL; priv->image = NULL; priv->box = NULL; @@ -137,15 +115,12 @@ prepare_popup (ETaskWidget *widget, GdkEventButton *event) void e_task_widget_construct (ETaskWidget *task_widget, - GdkPixbuf *icon_pixbuf, const char *component_id, const char *information, void (*cancel_func) (gpointer data), gpointer data) { ETaskWidgetPrivate *priv; - /*GdkPixmap *pixmap; - GdkBitmap *mask;*/ GtkWidget *box; GtkWidget *frame; @@ -169,15 +144,10 @@ e_task_widget_construct (ETaskWidget *task_widget, gtk_widget_set_size_request (box, 1, -1); - /* FIXME: Experimenting Spinner widget instead of an image. REWORK THIS */ - /* priv->icon_pixbuf = g_object_ref (icon_pixbuf); */ - - /* gdk_pixbuf_render_pixmap_and_mask (icon_pixbuf, &pixmap, &mask, 128); */ priv->box = gtk_hbox_new (FALSE, 0); priv->image = e_spinner_new (); e_spinner_set_size (E_SPINNER (priv->image), GTK_ICON_SIZE_SMALL_TOOLBAR); e_spinner_start (E_SPINNER (priv->image)); - /* gtk_image_new_from_pixmap (pixmap, mask); */ gtk_widget_show (priv->image); gtk_widget_show (priv->box); gtk_box_pack_start (GTK_BOX (priv->box), priv->image, FALSE, TRUE, 0); @@ -187,9 +157,16 @@ e_task_widget_construct (ETaskWidget *task_widget, gtk_widget_show (priv->label); gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0); if (cancel_func) { - GtkWidget *image = e_icon_factory_get_image ("gtk-stop", E_ICON_SIZE_MENU); + GdkPixbuf *pixbuf; + GtkWidget *image; GtkWidget *tool; + pixbuf = gtk_icon_theme_load_icon ( + gtk_icon_theme_get_default (), + "gtk-stop", 16, 0, NULL); + image = gtk_image_new_from_pixbuf (pixbuf); + g_object_unref (pixbuf); + tool = (GtkWidget *) gtk_tool_button_new (image, NULL); gtk_box_pack_end (GTK_BOX (box), tool, FALSE, TRUE, 0); gtk_widget_show_all (tool); @@ -198,9 +175,6 @@ e_task_widget_construct (ETaskWidget *task_widget, priv->cancel_func = cancel_func; priv->data = data; g_signal_connect (tool, "clicked", G_CALLBACK (button_press_event_cb), task_widget); - /* g_object_unref (pixmap); - if (mask) - g_object_unref (mask); */ g_signal_connect (task_widget, "button-press-event", G_CALLBACK (prepare_popup), task_widget); } @@ -209,34 +183,31 @@ e_task_widget_construct (ETaskWidget *task_widget, } GtkWidget * -e_task_widget_new_with_cancel (GdkPixbuf *icon_pixbuf, - const char *component_id, - const char *information, - void (*cancel_func) (gpointer data), - gpointer data) +e_task_widget_new_with_cancel (const char *component_id, + const char *information, + void (*cancel_func) (gpointer data), + gpointer data) { ETaskWidget *task_widget; g_return_val_if_fail (information != NULL, NULL); task_widget = g_object_new (e_task_widget_get_type (), NULL); - e_task_widget_construct (task_widget, icon_pixbuf, component_id, information, cancel_func, data); + e_task_widget_construct (task_widget, component_id, information, cancel_func, data); return GTK_WIDGET (task_widget); } GtkWidget * -e_task_widget_new (GdkPixbuf *icon_pixbuf, - const char *component_id, +e_task_widget_new (const char *component_id, const char *information) { ETaskWidget *task_widget; - g_return_val_if_fail (icon_pixbuf != NULL, NULL); g_return_val_if_fail (information != NULL, NULL); task_widget = g_object_new (e_task_widget_get_type (), NULL); - e_task_widget_construct (task_widget, icon_pixbuf, component_id, information, NULL, NULL); + e_task_widget_construct (task_widget, component_id, information, NULL, NULL); return GTK_WIDGET (task_widget); } @@ -245,14 +216,20 @@ GtkWidget * e_task_widget_update_image (ETaskWidget *task_widget, const char *stock, const char *text) { - GtkWidget *img, *tool; + GtkWidget *image, *tool; + GdkPixbuf *pixbuf; + + pixbuf = gtk_icon_theme_load_icon ( + gtk_icon_theme_get_default (), + stock, 16, 0, NULL); + image = gtk_image_new_from_pixbuf (pixbuf); + g_object_unref (pixbuf); - img = e_icon_factory_get_image (stock, E_ICON_SIZE_MENU); - tool = (GtkWidget *) gtk_tool_button_new (img, NULL); + tool = (GtkWidget *) gtk_tool_button_new (image, NULL); gtk_box_pack_start (GTK_BOX(task_widget->priv->box), tool, FALSE, TRUE, 0); gtk_widget_show_all (task_widget->priv->box); gtk_widget_hide (task_widget->priv->image); - task_widget->priv->image = img; + task_widget->priv->image = image; gtk_label_set_text (GTK_LABEL (task_widget->priv->label), text); return tool; diff --git a/widgets/misc/e-task-widget.h b/widgets/misc/e-task-widget.h index d82d053b8a..cb63b27379 100644 --- a/widgets/misc/e-task-widget.h +++ b/widgets/misc/e-task-widget.h @@ -53,34 +53,27 @@ struct _ETaskWidgetClass { }; -GType e_task_widget_get_type (void); -void e_task_widget_construct (ETaskWidget *task_widget, - GdkPixbuf *icon_pixbuf, - const char *component_id, - const char *information, - void (*cancel_func) (gpointer data), - gpointer data); -GtkWidget *e_task_widget_new (GdkPixbuf *icon_pixbuf, - const char *component_id, - const char *information); -GtkWidget * -e_task_widget_new_with_cancel (GdkPixbuf *icon_pixbuf, - const char *component_id, - const char *information, - void (*cancel_func) (gpointer data), - gpointer data); - -void e_task_widget_update (ETaskWidget *task_widget, - const char *information, - double completion); -GtkWidget * -e_task_widget_update_image (ETaskWidget *task_widget, - const char *stock, const char *text); - -void e_task_wiget_alert (ETaskWidget *task_widget); -void e_task_wiget_unalert (ETaskWidget *task_widget); - -const char *e_task_widget_get_component_id (ETaskWidget *task_widget); +GType e_task_widget_get_type (void); +void e_task_widget_construct (ETaskWidget *task_widget, + const char *component_id, + const char *information, + void (*cancel_func) (gpointer data), + gpointer data); +GtkWidget * e_task_widget_new (const char *component_id, + const char *information); +GtkWidget * e_task_widget_new_with_cancel (const char *component_id, + const char *information, + void (*cancel_func) (gpointer data), + gpointer data); +void e_task_widget_update (ETaskWidget *task_widget, + const char *information, + double completion); +GtkWidget * e_task_widget_update_image (ETaskWidget *task_widget, + const char *stock, + const char *text); +void e_task_wiget_alert (ETaskWidget *task_widget); +void e_task_wiget_unalert (ETaskWidget *task_widget); +const char * e_task_widget_get_component_id (ETaskWidget *task_widget); #ifdef __cplusplus } diff --git a/widgets/misc/e-url-entry.c b/widgets/misc/e-url-entry.c index f0ae7c5c4a..9db87b3ecd 100644 --- a/widgets/misc/e-url-entry.c +++ b/widgets/misc/e-url-entry.c @@ -29,7 +29,6 @@ #include <libgnome/gnome-url.h> #include <glib/gi18n.h> #include "e-url-entry.h" -#include <e-util/e-icon-factory.h> struct _EUrlEntryPrivate { GtkWidget *entry; @@ -105,7 +104,7 @@ init (EUrlEntry *url_entry) gtk_widget_set_sensitive (priv->button, FALSE); gtk_box_pack_start (GTK_BOX (url_entry), priv->button, FALSE, FALSE, 0); atk_object_set_name (gtk_widget_get_accessible (priv->button), _("Click here to go to URL")); - pixmap = e_icon_factory_get_image ("go-jump", E_ICON_SIZE_BUTTON); + pixmap = gtk_image_new_from_icon_name ("go-jump", GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (priv->button), pixmap); gtk_widget_show (pixmap); diff --git a/widgets/misc/test-info-label.c b/widgets/misc/test-info-label.c index 70b47f9488..890dfc2082 100644 --- a/widgets/misc/test-info-label.c +++ b/widgets/misc/test-info-label.c @@ -27,7 +27,6 @@ #include <gtk/gtk.h> #include <libgnomeui/gnome-app.h> #include <libgnomeui/gnome-ui-init.h> -#include <e-util/e-icon-factory.h> #include "e-info-label.h" static void @@ -36,7 +35,6 @@ delete_event_cb (GtkWidget *widget, gpointer data) { gtk_main_quit (); - e_icon_factory_shutdown (); } int @@ -50,7 +48,6 @@ main (int argc, char **argv) gnome_program_init ( "test-title-bar", "0.0", LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_NONE); - e_icon_factory_init (); app = gnome_app_new ("Test", "Test"); gtk_window_set_default_size (GTK_WINDOW (app), 400, 400); diff --git a/widgets/table/ChangeLog b/widgets/table/ChangeLog index d5fe462ccd..cf632fc517 100644 --- a/widgets/table/ChangeLog +++ b/widgets/table/ChangeLog @@ -1,3 +1,50 @@ +2008-08-11 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #352695 + + * e-tree-table-adapter.c: (e_tree_table_adapter_load_expanded_state), + (e_tree_table_adapter_load_expanded_state_xml): + Call the e_table_model_changed in the proper function, to prevent + lock of the model caused by previous commit to this bug. + +2008-08-11 Milan Crha <mcrha@redhat.com> + + ** Part of fix for bug #519292 + + * e-tree.h: (e_tree_load_all_expanded_state): + * e-tree.c: (e_tree_load_all_expanded_state): + * e-tree-table-adapter.h: + (e_tree_table_adapter_load_all_expanded_state): + * e-tree-table-adapter.c: + (e_tree_table_adapter_load_all_expanded_state), + (set_expanded_state_func), (set_collapsed_state_func): + Drop functions in favor of new functions. + * e-tree.h: (e_tree_force_expanded_state): + * e-tree.c: (e_tree_force_expanded_state): + * e-tree-table-adapter.h: (e_tree_table_adapter_force_expanded_state): + * e-tree-table-adapter.c: (e_tree_table_adapter_force_expanded_state), + (struct ETreeTableAdapterPriv), (create_gnode), (etta_init): + Use either default value of the model to expanded state of new node or + use the one which has been set (forced) by new functions. + +2008-08-11 Milan Crha <mcrha@redhat.com> + + ** Part of fix for bug #352695 + + * e-tree-table-adapter.h: + (e_tree_table_adapter_save_expanded_state_xml), + (e_tree_table_adapter_load_expanded_state_xml): + * e-tree-table-adapter.c: + (e_tree_table_adapter_save_expanded_state_xml), + (e_tree_table_adapter_save_expanded_state), + (e_tree_table_adapter_load_expanded_state_xml), + (e_tree_table_adapter_load_expanded_state): + * e-tree.h: (e_tree_save_expanded_state_xml), + (e_tree_load_expanded_state_xml): + * e-tree.c: (e_tree_save_expanded_state_xml), + (e_tree_load_expanded_state_xml): + Be able to store expanded state also in memory, not only on the disk. + 2008-07-15 Milan Crha <mcrha@redhat.com> ** Part of fix for bug #329821 diff --git a/widgets/table/e-tree-table-adapter.c b/widgets/table/e-tree-table-adapter.c index 579b231bb3..7953440b57 100644 --- a/widgets/table/e-tree-table-adapter.c +++ b/widgets/table/e-tree-table-adapter.c @@ -82,6 +82,8 @@ struct ETreeTableAdapterPriv { int sort_info_changed_id; guint resort_idle_id; + + int force_expanded_state; /* use this instead of model's default if not 0; <0 ... collapse, >0 ... expand */ }; static void etta_sort_info_changed (ETableSortInfo *sort_info, ETreeTableAdapter *etta); @@ -322,7 +324,7 @@ create_gnode(ETreeTableAdapter *etta, ETreePath path) node = g_new0(node_t, 1); node->path = path; node->index = -1; - node->expanded = e_tree_model_get_expanded_default(etta->priv->source); + node->expanded = etta->priv->force_expanded_state == 0 ? e_tree_model_get_expanded_default (etta->priv->source) : etta->priv->force_expanded_state > 0; node->expandable = e_tree_model_node_is_expandable(etta->priv->source, path); node->expandable_set = 1; node->num_visible_children = 0; @@ -737,6 +739,7 @@ etta_init (ETreeTableAdapter *etta) etta->priv->node_request_collapse_id = 0; etta->priv->resort_idle_id = 0; + etta->priv->force_expanded_state = 0; } static void @@ -912,14 +915,14 @@ save_expanded_state_func (gpointer keyp, gpointer value, gpointer data) } } -void -e_tree_table_adapter_save_expanded_state (ETreeTableAdapter *etta, const char *filename) +xmlDoc * +e_tree_table_adapter_save_expanded_state_xml (ETreeTableAdapter *etta) { TreeAndRoot tar; xmlDocPtr doc; xmlNode *root; - g_return_if_fail(etta != NULL); + g_return_val_if_fail (etta != NULL, NULL); doc = xmlNewDoc ((const unsigned char *)"1.0"); root = xmlNewDocNode (doc, NULL, (const unsigned char *)"expanded_state", NULL); @@ -934,8 +937,21 @@ e_tree_table_adapter_save_expanded_state (ETreeTableAdapter *etta, const char *f g_hash_table_foreach (etta->priv->nodes, save_expanded_state_func, &tar); - e_xml_save_file (filename, doc); - xmlFreeDoc (doc); + return doc; +} + +void +e_tree_table_adapter_save_expanded_state (ETreeTableAdapter *etta, const char *filename) +{ + xmlDoc *doc; + + g_return_if_fail (etta != NULL); + + doc = e_tree_table_adapter_save_expanded_state_xml (etta); + if (doc) { + e_xml_save_file (filename, doc); + xmlFreeDoc (doc); + } } static xmlDoc * @@ -983,57 +999,24 @@ open_file (ETreeTableAdapter *etta, const char *filename) return doc; } -static void -set_expanded_state_func (gpointer keyp, gpointer value, gpointer data) -{ - ETreePath path = keyp; - node_t *node = ((GNode *)value)->data; - ETreeTableAdapter *etta = (ETreeTableAdapter *) data; - - if (node->expanded != TRUE) { - e_tree_table_adapter_node_set_expanded_recurse (etta, path, TRUE); - node->expanded = TRUE; - } -} - -static void -set_collapsed_state_func (gpointer keyp, gpointer value, gpointer data) -{ - ETreePath path = keyp; - node_t *node = ((GNode *)value)->data; - ETreeTableAdapter *etta = (ETreeTableAdapter *) data; - - if (node->expanded != FALSE) { - e_tree_table_adapter_node_set_expanded_recurse (etta, path, FALSE); - node->expanded = FALSE; - } -} - +/* state: <0 ... collapse; 0 ... use default; >0 ... expand */ void -e_tree_table_adapter_load_all_expanded_state (ETreeTableAdapter *etta, gboolean state) +e_tree_table_adapter_force_expanded_state (ETreeTableAdapter *etta, int state) { + g_return_if_fail (etta != NULL); - g_return_if_fail(etta != NULL); - - if (state) - g_hash_table_foreach (etta->priv->nodes, set_expanded_state_func, etta); - else - g_hash_table_foreach (etta->priv->nodes, set_collapsed_state_func, etta); + etta->priv->force_expanded_state = state; } void -e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta, const char *filename) +e_tree_table_adapter_load_expanded_state_xml (ETreeTableAdapter *etta, xmlDoc *doc) { - xmlDoc *doc; xmlNode *root, *child; gboolean model_default; gboolean file_default = FALSE; - g_return_if_fail(etta != NULL); - - doc = open_file(etta, filename); - if (!doc) - return; + g_return_if_fail (etta != NULL); + g_return_if_fail (doc != NULL); root = xmlDocGetRootElement (doc); @@ -1084,12 +1067,26 @@ e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta, const char *f g_free (id); } - xmlFreeDoc (doc); - e_table_model_changed (E_TABLE_MODEL (etta)); } void +e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta, const char *filename) +{ + xmlDoc *doc; + + g_return_if_fail(etta != NULL); + + doc = open_file(etta, filename); + if (!doc) + return; + + e_tree_table_adapter_load_expanded_state_xml (etta, doc); + + xmlFreeDoc (doc); +} + +void e_tree_table_adapter_root_node_set_visible (ETreeTableAdapter *etta, gboolean visible) { int size; diff --git a/widgets/table/e-tree-table-adapter.h b/widgets/table/e-tree-table-adapter.h index cd23ba06bb..4d792f7451 100644 --- a/widgets/table/e-tree-table-adapter.h +++ b/widgets/table/e-tree-table-adapter.h @@ -30,6 +30,7 @@ #include <table/e-tree-model.h> #include <table/e-table-sort-info.h> #include <table/e-table-header.h> +#include <libxml/tree.h> G_BEGIN_DECLS @@ -71,8 +72,8 @@ void e_tree_table_adapter_node_set_expanded (ETreeTableAdapter void e_tree_table_adapter_node_set_expanded_recurse (ETreeTableAdapter *etta, ETreePath path, gboolean expanded); -void e_tree_table_adapter_load_all_expanded_state (ETreeTableAdapter *etta, - gboolean state); +void e_tree_table_adapter_force_expanded_state (ETreeTableAdapter *etta, + int state); void e_tree_table_adapter_root_node_set_visible (ETreeTableAdapter *etta, gboolean visible); ETreePath e_tree_table_adapter_node_at_row (ETreeTableAdapter *etta, @@ -89,6 +90,9 @@ void e_tree_table_adapter_save_expanded_state (ETreeTableAdapter void e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta, const char *filename); +xmlDoc *e_tree_table_adapter_save_expanded_state_xml (ETreeTableAdapter *etta); +void e_tree_table_adapter_load_expanded_state_xml (ETreeTableAdapter *etta, xmlDoc *doc); + void e_tree_table_adapter_set_sort_info (ETreeTableAdapter *etta, ETableSortInfo *sort_info); diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 8b685a724b..6d375cdfc1 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -2069,10 +2069,32 @@ e_tree_load_expanded_state (ETree *et, char *filename) e_tree_table_adapter_load_expanded_state (et->priv->etta, filename); } +xmlDoc * +e_tree_save_expanded_state_xml (ETree *et) +{ + g_return_val_if_fail (et != NULL, NULL); + g_return_val_if_fail (E_IS_TREE (et), NULL); + + return e_tree_table_adapter_save_expanded_state_xml (et->priv->etta); +} + +void +e_tree_load_expanded_state_xml (ETree *et, xmlDoc *doc) +{ + g_return_if_fail (et != NULL); + g_return_if_fail (E_IS_TREE (et)); + g_return_if_fail (doc != NULL); + + e_tree_table_adapter_load_expanded_state_xml (et->priv->etta, doc); +} + +/* state: <0 ... collapse; 0 ... no force - use default; >0 ... expand; + when using this, be sure to reset to 0 once no forcing is required + anymore, aka the build of the tree is done */ void -e_tree_load_all_expanded_state (ETree *et, gboolean state) +e_tree_force_expanded_state (ETree *et, int state) { - e_tree_table_adapter_load_all_expanded_state (et->priv->etta, state); + e_tree_table_adapter_force_expanded_state (et->priv->etta, state); } gint diff --git a/widgets/table/e-tree.h b/widgets/table/e-tree.h index 6e736f1a0e..3093855e4b 100644 --- a/widgets/table/e-tree.h +++ b/widgets/table/e-tree.h @@ -286,9 +286,13 @@ void e_tree_save_expanded_state (ETree *et, char *filename); void e_tree_load_expanded_state (ETree *et, char *filename); + +xmlDoc *e_tree_save_expanded_state_xml (ETree *et); +void e_tree_load_expanded_state_xml (ETree *et, xmlDoc *doc); + int e_tree_row_count (ETree *et); GtkWidget *e_tree_get_tooltip (ETree *et); -void e_tree_load_all_expanded_state (ETree *et, gboolean state); +void e_tree_force_expanded_state (ETree *et, int state); typedef enum { E_TREE_FIND_NEXT_BACKWARD = 0, |