diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-09-08 00:31:19 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-09-08 07:08:54 +0800 |
commit | 3da4948c0fc1f2c21b163f0ec456b2d99c881258 (patch) | |
tree | 479d6153d31e03cb7a65990683b5271402e5ec29 /addressbook/gui/widgets | |
parent | 2e5031cb4538b4819e5fce5d717668c3445df80a (diff) | |
download | gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.gz gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.bz2 gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.lz gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.xz gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.zst gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.zip |
Miscellaneous cleanups.
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.c | 14 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-table-adapter.c | 5 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 12 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-contact-map-window.c | 3 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-contact-map.c | 6 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-contact-marker.c | 58 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-gui-util.c | 31 |
7 files changed, 56 insertions, 73 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index 683eed3499..1cd13294a0 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -360,11 +360,17 @@ client_view_ready_cb (GObject *source_object, EAddressbookModel *model = user_data; GError *error = NULL; - if (!e_book_client_get_view_finish (book_client, result, &client_view, &error)) - client_view = NULL; + e_book_client_get_view_finish ( + book_client, result, &client_view, &error); - if (error) { - eab_error_dialog (NULL, NULL, _("Error getting book view"), error); + /* Sanity check. */ + g_return_if_fail ( + ((client_view != NULL) && (error == NULL)) || + ((client_view == NULL) && (error != NULL))); + + if (error != NULL) { + eab_error_dialog ( + NULL, NULL, _("Error getting book view"), error); g_error_free (error); return; } diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index a7f1f6bb5b..b539b602b2 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -199,8 +199,9 @@ contact_modified_cb (EBookClient *book_client, const GError *error, gpointer user_data) { - if (error) - eab_error_dialog (NULL, NULL, _("Error modifying card"), error); + if (error != NULL) + eab_error_dialog ( + NULL, NULL, _("Error modifying card"), error); } static void diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 38d7196217..f7261d338c 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -1238,8 +1238,7 @@ report_and_free_error_if_any (GError *error) if (!error) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_error_free (error); return; } @@ -1538,8 +1537,8 @@ all_contacts_ready_cb (GObject *source_object, g_return_if_fail (book_client != NULL); g_return_if_fail (tcd != NULL); - if (!e_book_client_get_contacts_finish (book_client, result, &contacts, &error)) - contacts = NULL; + e_book_client_get_contacts_finish ( + book_client, result, &contacts, &error); shell_view = e_addressbook_view_get_shell_view (tcd->view); shell_content = e_shell_view_get_shell_content (shell_view); @@ -1548,12 +1547,13 @@ all_contacts_ready_cb (GObject *source_object, model = e_addressbook_view_get_model (tcd->view); client_cache = e_addressbook_model_get_client_cache (model); - if (error) { + if (error != NULL) { e_alert_submit ( alert_sink, "addressbook:search-error", error->message, NULL); g_error_free (error); - } else if (contacts) { + + } else if (contacts != NULL) { ESourceRegistry *registry; registry = e_client_cache_ref_registry (client_cache); diff --git a/addressbook/gui/widgets/e-contact-map-window.c b/addressbook/gui/widgets/e-contact-map-window.c index 1dbe694d50..483dde7ea1 100644 --- a/addressbook/gui/widgets/e-contact-map-window.c +++ b/addressbook/gui/widgets/e-contact-map-window.c @@ -87,8 +87,7 @@ book_contacts_received_cb (GObject *source_object, GSList *contacts = NULL, *p; GError *error = NULL; - if (!e_book_client_get_contacts_finish (client, result, &contacts, &error)) - contacts = NULL; + e_book_client_get_contacts_finish (client, result, &contacts, &error); if (error != NULL) { g_warning ( diff --git a/addressbook/gui/widgets/e-contact-map.c b/addressbook/gui/widgets/e-contact-map.c index 57e7e55b97..15b512fa47 100644 --- a/addressbook/gui/widgets/e-contact-map.c +++ b/addressbook/gui/widgets/e-contact-map.c @@ -91,7 +91,6 @@ contact_map_address_resolved_cb (GObject *source, AsyncContext *async_context = user_data; ChamplainMarkerLayer *marker_layer; ChamplainMarker *marker; - GError *error = NULL; g_return_if_fail (async_context != NULL); g_return_if_fail (E_IS_CONTACT_MAP (async_context->map)); @@ -109,13 +108,12 @@ contact_map_address_resolved_cb (GObject *source, goto exit; resolved = geocode_object_resolve_finish ( - GEOCODE_OBJECT (source), result, &error); + GEOCODE_OBJECT (source), result, NULL); if (resolved == NULL || !geocode_object_get_coords (resolved, &longitude, &latitude)) { const gchar *name; - if (error) - g_error_free (error); + name = champlain_label_get_text (CHAMPLAIN_LABEL (marker)); g_signal_emit ( async_context->map, diff --git a/addressbook/gui/widgets/e-contact-marker.c b/addressbook/gui/widgets/e-contact-marker.c index 9ac9417c9f..9d7863785d 100644 --- a/addressbook/gui/widgets/e-contact-marker.c +++ b/addressbook/gui/widgets/e-contact-marker.c @@ -122,53 +122,31 @@ texture_new_from_pixbuf (GdkPixbuf *pixbuf, static ClutterActor * contact_photo_to_texture (EContactPhoto *photo) { - GdkPixbuf *pixbuf; + ClutterActor *texture = NULL; + GdkPixbuf *pixbuf = NULL; if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { - GError *error = NULL; - GdkPixbufLoader *loader = gdk_pixbuf_loader_new (); + gdk_pixbuf_loader_write ( loader, photo->data.inlined.data, photo->data.inlined.length, NULL); gdk_pixbuf_loader_close (loader, NULL); pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (pixbuf) + if (pixbuf != NULL) g_object_ref (pixbuf); g_object_unref (loader); - if (error) { - g_error_free (error); - return NULL; - } } else if (photo->type == E_CONTACT_PHOTO_TYPE_URI) { - GError *error = NULL; - - pixbuf = gdk_pixbuf_new_from_file (photo->data.uri, &error); - - if (error) { - g_error_free (error); - return NULL; - } - } else - return NULL; - - if (pixbuf) { - ClutterActor *texture; - GError *error = NULL; - - texture = texture_new_from_pixbuf (pixbuf, &error); - if (error) { - g_error_free (error); - g_object_unref (pixbuf); - return NULL; - } + pixbuf = gdk_pixbuf_new_from_file (photo->data.uri, NULL); + } + if (pixbuf != NULL) { + texture = texture_new_from_pixbuf (pixbuf, NULL); g_object_unref (pixbuf); - return texture; } - return NULL; + return texture; } static void @@ -177,15 +155,15 @@ draw_box (cairo_t *cr, gint height, gint point) { - cairo_move_to (cr, RADIUS, 0); - cairo_line_to (cr, width - RADIUS, 0); - cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0); - cairo_line_to (cr, width, height - RADIUS); - cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS - 1, 0, M_PI / 2.0); - cairo_line_to (cr, point, height); - cairo_line_to (cr, 0, height + point); - cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0); - cairo_close_path (cr); + cairo_move_to (cr, RADIUS, 0); + cairo_line_to (cr, width - RADIUS, 0); + cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0); + cairo_line_to (cr, width, height - RADIUS); + cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS - 1, 0, M_PI / 2.0); + cairo_line_to (cr, point, height); + cairo_line_to (cr, 0, height + point); + cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0); + cairo_close_path (cr); } static void diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index 5f155ad1b1..70e5682bbc 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -77,7 +77,7 @@ typedef enum { void eab_error_dialog (EAlertSink *alert_sink, - GtkWindow *parent, + GtkWindow *parent, const gchar *msg, const GError *error) { @@ -166,12 +166,14 @@ eab_load_error_dialog (GtkWidget *parent, "is unreachable."); } - if (can_detail_error) { - /* do not show repository offline message, it's kind of generic error */ - if (error && !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE)) { - label = g_strconcat (label_string, "\n\n", _("Detailed error message:"), " ", error->message, NULL); - label_string = label; - } + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE)) { + /* Do not show a detailed message; too generic. */ + } else if (can_detail_error && error != NULL) { + label = g_strconcat ( + label_string, "\n\n", + _("Detailed error message:"), + " ", error->message, NULL); + label_string = label; } if (alert_sink) { @@ -492,15 +494,14 @@ contact_added_cb (EBookClient *book_client, { ContactCopyProcess *process = user_data; - if (error && !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) && - !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { process->book_status = FALSE; - eab_error_dialog (process->alert_sink, NULL, _("Error adding contact"), error); - } else if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + } else if (error != NULL) { process->book_status = FALSE; - } - else { + eab_error_dialog ( + process->alert_sink, NULL, + _("Error adding contact"), error); + } else { /* success */ process->book_status = TRUE; } @@ -803,7 +804,7 @@ get_address_format (AddressFormat address_format, error = NULL; key_file = g_key_file_new (); g_key_file_load_from_file (key_file, EVOLUTION_RULEDIR "/address_formats.dat", 0, &error); - if (error) { + if (error != NULL) { g_warning ("%s: Failed to load address_formats.dat file: %s", G_STRFUNC, error->message); *format = g_strdup (ADDRESS_DEFAULT_FORMAT); *country_position = g_strdup (ADDRESS_DEFAULT_COUNTRY_POSITION); |