diff options
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 68 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-quick-add.c | 8 | ||||
-rw-r--r-- | addressbook/gui/contact-list-editor/e-contact-list-editor.c | 39 | ||||
-rw-r--r-- | addressbook/gui/merging/eab-contact-merging.c | 12 | ||||
-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 |
11 files changed, 138 insertions, 118 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 8e126d0260..bf6cf9e47a 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -217,14 +217,19 @@ e_contact_editor_contact_added (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) 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)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error adding contact"), error); + window = eab_editor_get_window (editor); + message = _("Error adding contact"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -232,14 +237,19 @@ e_contact_editor_contact_modified (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) 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)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error modifying contact"), error); + window = eab_editor_get_window (editor); + message = _("Error modifying contact"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -247,14 +257,19 @@ e_contact_editor_contact_deleted (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) 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)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error removing contact"), error); + window = eab_editor_get_window (editor); + message = _("Error removing contact"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -3063,22 +3078,27 @@ init_all (EContactEditor *editor) } if (requisition.width > 0 && requisition.height > 0) { - GtkWindow *window; + GtkWidget *window; GdkScreen *screen; GdkRectangle monitor_area; gint x = 0, y = 0, monitor, width, height; - window = GTK_WINDOW (e_builder_get_widget (editor->builder, "contact editor")); + window = e_builder_get_widget ( + editor->builder, "contact editor"); - gtk_widget_get_preferred_size (GTK_WIDGET (window), &tab_req, NULL); + gtk_widget_get_preferred_size (window, &tab_req, NULL); width = tab_req.width - 320 + 24; height = tab_req.height - 240 + 24; - screen = gtk_window_get_screen (window); - gtk_window_get_position (window, &x, &y); + screen = gtk_window_get_screen (GTK_WINDOW (window)); + gtk_window_get_position (GTK_WINDOW (window), &x, &y); monitor = gdk_screen_get_monitor_at_point (screen, x, y); - if (monitor < 0 || monitor >= gdk_screen_get_n_monitors (screen)) + + if (monitor < 0) + monitor = 0; + + if (monitor >= gdk_screen_get_n_monitors (screen)) monitor = 0; gdk_screen_get_monitor_workarea (screen, monitor, &monitor_area); @@ -3090,7 +3110,10 @@ init_all (EContactEditor *editor) requisition.height = monitor_area.height - height; if (requisition.width > 0 && requisition.height > 0) - gtk_window_set_default_size (window, width + requisition.width, height + requisition.height); + gtk_window_set_default_size ( + GTK_WINDOW (window), + width + requisition.width, + height + requisition.height); } } @@ -3114,8 +3137,7 @@ contact_editor_get_client_cb (GObject *source_object, ((client != NULL) && (error == NULL)) || ((client == NULL) && (error != NULL))); - 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_warn_if_fail (client == NULL); g_error_free (error); goto exit; @@ -3547,7 +3569,7 @@ contact_removed_cb (GObject *source_object, sensitize_all (ce); } - if (error) + if (error != NULL) g_error_free (error); g_object_unref (ce); @@ -3635,7 +3657,7 @@ contact_modified_ready_cb (GObject *source_object, contact_modified_cb (book_client, error, user_data); - if (error) + if (error != NULL) g_error_free (error); } diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c index 5814205c4d..638bac68e9 100644 --- a/addressbook/gui/contact-editor/e-contact-quick-add.c +++ b/addressbook/gui/contact-editor/e-contact-quick-add.c @@ -137,8 +137,7 @@ merge_cb (GObject *source_object, ((client == NULL) && (error != NULL))); /* Ignore cancellations. */ - 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_warn_if_fail (client == NULL); g_error_free (error); return; @@ -239,7 +238,7 @@ ce_have_contact (EBookClient *book_client, { QuickAdd *qa = (QuickAdd *) closure; - if (error) { + if (error != NULL) { if (book_client) g_object_unref (book_client); g_warning ( @@ -305,8 +304,7 @@ ce_have_book (GObject *source_object, ((client == NULL) && (error != NULL))); /* Ignore cancellations. */ - 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_warn_if_fail (client == NULL); g_error_free (error); return; diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 2eac787950..4f5e397f88 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -1584,14 +1584,19 @@ contact_list_editor_contact_added (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) 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)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error adding list"), error); + window = eab_editor_get_window (editor); + message = _("Error adding list"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -1599,14 +1604,19 @@ contact_list_editor_contact_modified (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) 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)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error modifying list"), error); + window = eab_editor_get_window (editor); + message = _("Error modifying list"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -1614,14 +1624,19 @@ contact_list_editor_contact_deleted (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) 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)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error removing list"), error); + window = eab_editor_get_window (editor); + message = _("Error removing list"); + + eab_error_dialog (NULL, window, message, error); } static void diff --git a/addressbook/gui/merging/eab-contact-merging.c b/addressbook/gui/merging/eab-contact-merging.c index fb11e37629..56fef2bc40 100644 --- a/addressbook/gui/merging/eab-contact-merging.c +++ b/addressbook/gui/merging/eab-contact-merging.c @@ -197,7 +197,7 @@ modify_contact_ready_cb (GObject *source_object, else final_cb (book_client, error, lookup); - if (error) + if (error != NULL) g_error_free (error); } @@ -214,12 +214,11 @@ add_contact_ready_cb (GObject *source_object, g_return_if_fail (book_client != NULL); g_return_if_fail (lookup != NULL); - if (!e_book_client_add_contact_finish (book_client, result, &uid, &error)) - uid = NULL; + e_book_client_add_contact_finish (book_client, result, &uid, &error); final_id_cb (book_client, error, uid, lookup); - if (error) + if (error != NULL) g_error_free (error); } @@ -239,7 +238,10 @@ doit (EContactMergingLookup *lookup, static void cancelit (EContactMergingLookup *lookup) { - GError *error = e_client_error_create (E_CLIENT_ERROR_CANCELLED, NULL); + GError *error; + + error = g_error_new_literal ( + G_IO_ERROR, G_IO_ERROR_CANCELLED, _("Cancelled")); if (lookup->op == E_CONTACT_MERGING_ADD) { final_id_cb (lookup->book_client, error, NULL, lookup); 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); |