diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-12-10 21:09:59 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-12-13 03:33:43 +0800 |
commit | d09d8de870b6697c8a8b262e7e077b871a69b315 (patch) | |
tree | 3b718882e7a0bb0a996daf2967a033d91714c9b5 /widgets/misc/e-source-config-dialog.c | |
parent | b61331ed03ac1c7a9b8614e25510040b9c60ae02 (diff) | |
download | gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.gz gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.bz2 gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.lz gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.xz gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.tar.zst gsoc2013-evolution-d09d8de870b6697c8a8b262e7e077b871a69b315.zip |
Consolidate base utility libraries into libeutil.
Evolution consists of entirely too many small utility libraries, which
increases linking and loading time, places a burden on higher layers of
the application (e.g. modules) which has to remember to link to all the
small in-tree utility libraries, and makes it difficult to generate API
documentation for these utility libraries in one Gtk-Doc module.
Merge the following utility libraries under the umbrella of libeutil,
and enforce a single-include policy on libeutil so we can reorganize
the files as desired without disrupting its pseudo-public API.
libemail-utils/libemail-utils.la
libevolution-utils/libevolution-utils.la
filter/libfilter.la
widgets/e-timezone-dialog/libetimezonedialog.la
widgets/menus/libmenus.la
widgets/misc/libemiscwidgets.la
widgets/table/libetable.la
widgets/text/libetext.la
This also merges libedataserverui from the Evolution-Data-Server module,
since Evolution is its only consumer nowadays, and I'd like to make some
improvements to those APIs without concern for backward-compatibility.
And finally, start a Gtk-Doc module for libeutil. It's going to be a
project just getting all the symbols _listed_ much less _documented_.
But the skeletal structure is in place and I'm off to a good start.
Diffstat (limited to 'widgets/misc/e-source-config-dialog.c')
-rw-r--r-- | widgets/misc/e-source-config-dialog.c | 394 |
1 files changed, 0 insertions, 394 deletions
diff --git a/widgets/misc/e-source-config-dialog.c b/widgets/misc/e-source-config-dialog.c deleted file mode 100644 index 437027e498..0000000000 --- a/widgets/misc/e-source-config-dialog.c +++ /dev/null @@ -1,394 +0,0 @@ -/* - * e-source-config-dialog.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - */ - -#include "e-source-config-dialog.h" - -#include <libevolution-utils/e-alert-dialog.h> -#include <libevolution-utils/e-alert-sink.h> -#include <misc/e-alert-bar.h> - -#define E_SOURCE_CONFIG_DIALOG_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_SOURCE_CONFIG_DIALOG, ESourceConfigDialogPrivate)) - -struct _ESourceConfigDialogPrivate { - ESourceConfig *config; - ESourceRegistry *registry; - - GtkWidget *alert_bar; - gulong alert_bar_visible_handler_id; -}; - -enum { - PROP_0, - PROP_CONFIG -}; - -/* Forward Declarations */ -static void e_source_config_dialog_alert_sink_init - (EAlertSinkInterface *interface); - -G_DEFINE_TYPE_WITH_CODE ( - ESourceConfigDialog, - e_source_config_dialog, - GTK_TYPE_DIALOG, - G_IMPLEMENT_INTERFACE ( - E_TYPE_ALERT_SINK, - e_source_config_dialog_alert_sink_init)) - -static void -source_config_dialog_commit_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - ESourceConfig *config; - ESourceConfigDialog *dialog; - GdkWindow *gdk_window; - GError *error = NULL; - - config = E_SOURCE_CONFIG (object); - dialog = E_SOURCE_CONFIG_DIALOG (user_data); - - /* Set the cursor back to normal. */ - gdk_window = gtk_widget_get_window (GTK_WIDGET (dialog)); - gdk_window_set_cursor (gdk_window, NULL); - - /* Allow user interaction with window content. */ - gtk_widget_set_sensitive (GTK_WIDGET (dialog), TRUE); - - e_source_config_commit_finish (config, result, &error); - - /* Ignore cancellations. */ - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_object_unref (dialog); - g_error_free (error); - - } else if (error != NULL) { - e_alert_submit ( - E_ALERT_SINK (dialog), - "system:simple-error", - error->message, NULL); - g_object_unref (dialog); - g_error_free (error); - - } else { - gtk_widget_destroy (GTK_WIDGET (dialog)); - } -} - -static void -source_config_dialog_commit (ESourceConfigDialog *dialog) -{ - GdkCursor *gdk_cursor; - GdkWindow *gdk_window; - ESourceConfig *config; - - config = e_source_config_dialog_get_config (dialog); - - /* Clear any previous alerts. */ - e_alert_bar_clear (E_ALERT_BAR (dialog->priv->alert_bar)); - - /* Make the cursor appear busy. */ - gdk_cursor = gdk_cursor_new (GDK_WATCH); - gdk_window = gtk_widget_get_window (GTK_WIDGET (dialog)); - gdk_window_set_cursor (gdk_window, gdk_cursor); - g_object_unref (gdk_cursor); - - /* Prevent user interaction with window content. */ - gtk_widget_set_sensitive (GTK_WIDGET (dialog), FALSE); - - /* XXX This operation is not cancellable. */ - e_source_config_commit ( - config, NULL, - source_config_dialog_commit_cb, - g_object_ref (dialog)); -} - -static void -source_config_dialog_source_removed_cb (ESourceRegistry *registry, - ESource *removed_source, - ESourceConfigDialog *dialog) -{ - ESourceConfig *config; - ESource *original_source; - - /* If the ESource being edited is removed, cancel the dialog. */ - - config = e_source_config_dialog_get_config (dialog); - original_source = e_source_config_get_original_source (config); - - if (original_source == NULL) - return; - - if (!e_source_equal (original_source, removed_source)) - return; - - gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); -} - -static void -source_config_alert_bar_visible_cb (EAlertBar *alert_bar, - GParamSpec *pspec, - ESourceConfigDialog *dialog) -{ - e_source_config_resize_window (dialog->priv->config); -} - -static void -source_config_dialog_set_config (ESourceConfigDialog *dialog, - ESourceConfig *config) -{ - ESourceRegistry *registry; - - g_return_if_fail (E_IS_SOURCE_CONFIG (config)); - g_return_if_fail (dialog->priv->config == NULL); - - dialog->priv->config = g_object_ref (config); - - registry = e_source_config_get_registry (config); - dialog->priv->registry = g_object_ref (registry); - - g_signal_connect ( - registry, "source-removed", - G_CALLBACK (source_config_dialog_source_removed_cb), dialog); -} - -static void -source_config_dialog_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_CONFIG: - source_config_dialog_set_config ( - E_SOURCE_CONFIG_DIALOG (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -source_config_dialog_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_CONFIG: - g_value_set_object ( - value, - e_source_config_dialog_get_config ( - E_SOURCE_CONFIG_DIALOG (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -source_config_dialog_dispose (GObject *object) -{ - ESourceConfigDialogPrivate *priv; - - priv = E_SOURCE_CONFIG_DIALOG_GET_PRIVATE (object); - - if (priv->config != NULL) { - g_object_unref (priv->config); - priv->config = NULL; - } - - if (priv->registry != NULL) { - g_signal_handlers_disconnect_matched ( - priv->registry, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, object); - g_object_unref (priv->registry); - priv->registry = NULL; - } - - if (priv->alert_bar != NULL) { - g_signal_handler_disconnect ( - priv->alert_bar, - priv->alert_bar_visible_handler_id); - g_object_unref (priv->alert_bar); - priv->alert_bar = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (e_source_config_dialog_parent_class)->dispose (object); -} - -static void -source_config_dialog_constructed (GObject *object) -{ - ESourceConfigDialogPrivate *priv; - GtkWidget *content_area; - GtkWidget *config; - GtkWidget *widget; - gulong handler_id; - - priv = E_SOURCE_CONFIG_DIALOG_GET_PRIVATE (object); - - config = GTK_WIDGET (priv->config); - - widget = gtk_dialog_get_widget_for_response ( - GTK_DIALOG (object), GTK_RESPONSE_OK); - - gtk_container_set_border_width (GTK_CONTAINER (object), 5); - gtk_container_set_border_width (GTK_CONTAINER (config), 5); - - content_area = gtk_dialog_get_content_area (GTK_DIALOG (object)); - gtk_box_pack_start (GTK_BOX (content_area), config, TRUE, TRUE, 0); - gtk_widget_show (config); - - /* Don't use G_BINDING_SYNC_CREATE here. The ESourceConfig widget - * is not ready to run check_complete() until after it's realized. */ - g_object_bind_property ( - config, "complete", - widget, "sensitive", - G_BINDING_DEFAULT); - - widget = e_alert_bar_new (); - gtk_box_pack_start (GTK_BOX (content_area), widget, FALSE, FALSE, 0); - priv->alert_bar = g_object_ref (widget); - /* EAlertBar controls its own visibility. */ - - handler_id = g_signal_connect ( - priv->alert_bar, "notify::visible", - G_CALLBACK (source_config_alert_bar_visible_cb), object); - - priv->alert_bar_visible_handler_id = handler_id; -} - -static void -source_config_dialog_response (GtkDialog *dialog, - gint response_id) -{ - /* Do not chain up. GtkDialog does not implement this method. */ - - switch (response_id) { - case GTK_RESPONSE_OK: - source_config_dialog_commit ( - E_SOURCE_CONFIG_DIALOG (dialog)); - break; - case GTK_RESPONSE_CANCEL: - gtk_widget_destroy (GTK_WIDGET (dialog)); - break; - default: - break; - } -} - -static void -source_config_dialog_submit_alert (EAlertSink *alert_sink, - EAlert *alert) -{ - ESourceConfigDialogPrivate *priv; - EAlertBar *alert_bar; - GtkWidget *dialog; - GtkWindow *parent; - - priv = E_SOURCE_CONFIG_DIALOG_GET_PRIVATE (alert_sink); - - switch (e_alert_get_message_type (alert)) { - case GTK_MESSAGE_INFO: - case GTK_MESSAGE_WARNING: - case GTK_MESSAGE_ERROR: - alert_bar = E_ALERT_BAR (priv->alert_bar); - e_alert_bar_add_alert (alert_bar, alert); - break; - - default: - parent = GTK_WINDOW (alert_sink); - dialog = e_alert_dialog_new (parent, alert); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - break; - } -} - -static void -e_source_config_dialog_class_init (ESourceConfigDialogClass *class) -{ - GObjectClass *object_class; - GtkDialogClass *dialog_class; - - g_type_class_add_private (class, sizeof (ESourceConfigDialogPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = source_config_dialog_set_property; - object_class->get_property = source_config_dialog_get_property; - object_class->dispose = source_config_dialog_dispose; - object_class->constructed = source_config_dialog_constructed; - - dialog_class = GTK_DIALOG_CLASS (class); - dialog_class->response = source_config_dialog_response; - - g_object_class_install_property ( - object_class, - PROP_CONFIG, - g_param_spec_object ( - "config", - "Config", - "The ESourceConfig instance", - E_TYPE_SOURCE_CONFIG, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); -} - -static void -e_source_config_dialog_alert_sink_init (EAlertSinkInterface *interface) -{ - interface->submit_alert = source_config_dialog_submit_alert; -} - -static void -e_source_config_dialog_init (ESourceConfigDialog *dialog) -{ - dialog->priv = E_SOURCE_CONFIG_DIALOG_GET_PRIVATE (dialog); - - gtk_dialog_add_buttons ( - GTK_DIALOG (dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_dialog_set_default_response ( - GTK_DIALOG (dialog), GTK_RESPONSE_OK); -} - -GtkWidget * -e_source_config_dialog_new (ESourceConfig *config) -{ - g_return_val_if_fail (E_IS_SOURCE_CONFIG (config), NULL); - - return g_object_new ( - E_TYPE_SOURCE_CONFIG_DIALOG, - "config", config, NULL); -} - -ESourceConfig * -e_source_config_dialog_get_config (ESourceConfigDialog *dialog) -{ - g_return_val_if_fail (E_IS_SOURCE_CONFIG_DIALOG (dialog), NULL); - - return dialog->priv->config; -} |