diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2007-04-20 02:53:33 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2007-04-20 02:53:33 +0800 |
commit | 64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6 (patch) | |
tree | 4ebe95239bef43cb97c0e46aa8194d44e6c88be6 /addressbook | |
parent | bb05f6e6d0541bf29c8dde4e264cc7c23ba52fbb (diff) | |
download | gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.gz gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.bz2 gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.lz gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.xz gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.zst gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.zip |
Massive code cleanup (bug #429422)
svn path=/trunk/; revision=33432
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 40 | ||||
-rw-r--r-- | addressbook/conduit/address-conduit.c | 8 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.c | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-table-adapter.c | 1 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 30 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-gui-util.c | 9 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-vcard-control.c | 15 | ||||
-rw-r--r-- | addressbook/printing/e-contact-print-style-editor.c | 3 | ||||
-rw-r--r-- | addressbook/printing/e-contact-print.c | 2 | ||||
-rw-r--r-- | addressbook/tools/evolution-addressbook-export.c | 113 |
11 files changed, 147 insertions, 78 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 210a531008..1dae147ff8 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,43 @@ +2007-04-19 Matthew Barnes <mbarnes@redhat.com> + + ** Fixes part of bug #429422 + + * tools/evolution-address-export.c: + Migrate from popt to GOption. + + * gui/contact-editor/e-contact-editor.c (e_contact_editor_init): + Use gtk_window_set_icon_from_file() instead of + gnome_window_icon_set_from_file(). + + * gui/widgets/e-addressbook-table-adapter.c: + * gui/widgets/e-addressbook-model.c: + * gui/widgets/eab-gui-util.c: + Include missing header file(s). + + * gui/widgets/eab-vcard-control.c (pstream_load), (book_open_cb), + (free_struct): + * gui/widgets/eab-gui-util.c (process_unref): + * gui/widgets/e-addressbook-view.c (eab_view_print), + (eab_view_print_preview), (eab_view_delete_selection), + (eab_view_save_as), (eab_view_view), (eab_view_send), + (eab_view_send_to): + e_free_object_list() is dead; just do it manually. + + * gui/widgets/e-addressbook-view.c (eab_view_print), + (eab_view_print_preview): + * conduit/address-conduit.c (addrconduit_load_configuration): + Use g_object_ref_sink() instead of gtk_object_sink(). + + * conduit/address-conduit.c (e_addr_gui_new): + Use gtk_menu_shell_append() instead of gtk_menu_append(). + + * printing/e-contact-print.c (e_contact_build_style): + Use g_build_filename() instead of g_concat_dir_and_file(). + + * printing/e-contact-print-style-editor.c + (e_contact_print_style_editor_new): + Use g_object_new() instead of gtk_type_new(). + 2007-04-18 Srinivasa Ragavan <sragavan@novell.com> ** Committed Contact Merging patch from Ebby Wiselyn diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c index 293df8c79d..b2a5e3730c 100644 --- a/addressbook/conduit/address-conduit.c +++ b/addressbook/conduit/address-conduit.c @@ -168,11 +168,9 @@ addrconduit_load_configuration (guint32 pilot_id) c->pilot_id = pilot_id; management = gnome_pilot_conduit_management_new ("e_address_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); - gtk_object_ref (GTK_OBJECT (management)); - gtk_object_sink (GTK_OBJECT (management)); + g_object_ref_sink (management); config = gnome_pilot_conduit_config_new (management, pilot_id); - gtk_object_ref (GTK_OBJECT (config)); - gtk_object_sink (GTK_OBJECT (config)); + g_object_ref_sink (config); if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type)) c->sync_type = GnomePilotConduitSyncTypeNotSet; gtk_object_unref (GTK_OBJECT (config)); @@ -307,7 +305,7 @@ e_addr_gui_new (EPilotSettings *ps) item = gtk_menu_item_new_with_label (items[i]); gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); } gtk_widget_show (menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (gui->default_address), menu); diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 1f857e593a..4a6262ec39 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -3348,7 +3348,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor) /* set the icon */ icon_path = g_build_filename (EVOLUTION_IMAGESDIR, "evolution-contacts-mini.png", NULL); - gnome_window_icon_set_from_file (GTK_WINDOW (e_contact_editor->app), icon_path); + gtk_window_set_icon_from_file (GTK_WINDOW (e_contact_editor->app), icon_path, NULL); g_free (icon_path); /* show window */ diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index edd824302b..85fa854324 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -8,6 +8,8 @@ */ #include <config.h> +#include <string.h> +#include <glib/gi18n.h> #include "eab-marshal.h" #include "e-addressbook-model.h" #include <libxml/tree.h> diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index a11f749523..65a82d03c9 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ #include <config.h> +#include <glib/gi18n.h> #include "e-addressbook-model.h" #include "e-addressbook-table-adapter.h" #include "eab-contact-merging.h" diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 5410bef787..282f142a77 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -1859,7 +1859,8 @@ eab_view_print(EABView *view, int preview) e_contact_print_response (print, GTK_RESPONSE_APPLY, NULL); g_free (query); - e_free_object_list (list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); } else if (view->view_type == EAB_VIEW_TABLE) { GtkWidget *dialog; @@ -1872,8 +1873,7 @@ eab_view_print(EABView *view, int preview) g_object_get(view->widget, "table", &etable, NULL); printable = e_table_get_printable(etable); - g_object_ref (printable); - gtk_object_sink (GTK_OBJECT (printable)); + g_object_ref_sink (printable); g_object_unref(etable); g_object_ref (view->widget); @@ -1916,7 +1916,8 @@ eab_view_print_preview(EABView *view) else dialog = e_contact_print_dialog_new (book, query, list); e_contact_print_response (dialog, GTK_RESPONSE_APPLY, NULL); - e_free_object_list (list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); g_free (query); }else if (view->view_type == EAB_VIEW_TABLE) { GtkWidget *dialog; @@ -1929,8 +1930,7 @@ eab_view_print_preview(EABView *view) g_object_get(view->widget, "table", &etable, NULL); printable = e_table_get_printable(etable); - g_object_ref (printable); - gtk_object_sink (GTK_OBJECT (printable)); + g_object_ref_sink (printable); g_object_unref(etable); g_object_ref (view->widget); @@ -2003,7 +2003,8 @@ eab_view_delete_selection(EABView *view, gboolean is_delete) !eab_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(view->widget)), plural, is_list, name)) { g_free (name); - e_free_object_list(list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); return; } @@ -2062,7 +2063,8 @@ eab_view_delete_selection(EABView *view, gboolean is_delete) row = e_table_view_to_model_row (E_TABLE (etable), select); e_table_set_cursor_row (E_TABLE (etable), row); } - e_free_object_list(list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); } static void @@ -2177,7 +2179,8 @@ eab_view_save_as (EABView *view, gboolean all) } if (list) eab_contact_list_save (_("Save as VCard..."), list, NULL); - e_free_object_list(list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); } void @@ -2185,7 +2188,8 @@ eab_view_view (EABView *view) { GList *list = get_selected_contacts (view); eab_show_multiple_contacts (view->book, list, view->editable); - e_free_object_list(list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); } void @@ -2194,7 +2198,8 @@ eab_view_send (EABView *view) GList *list = get_selected_contacts (view); if (list) eab_send_contact_list (list, EAB_DISPOSITION_AS_ATTACHMENT); - e_free_object_list(list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); } void @@ -2203,7 +2208,8 @@ eab_view_send_to (EABView *view) GList *list = get_selected_contacts (view); if (list) eab_send_contact_list (list, EAB_DISPOSITION_AS_TO); - e_free_object_list(list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); } void diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index 64685bf6ff..ccfbac8ada 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -26,6 +26,7 @@ #include <errno.h> #include <string.h> +#include <glib/gi18n.h> #include <libedataserver/e-data-server-util.h> #include <libedataserverui/e-source-selector.h> #include <e-util/e-util.h> @@ -687,10 +688,12 @@ process_unref (ContactCopyProcess *process) { process->count --; if (process->count == 0) { - if (process->done_cb) { + if (process->done_cb) process->done_cb (process); - } - e_free_object_list(process->contacts); + g_list_foreach ( + process->contacts, + (GFunc) g_object_unref, NULL); + g_list_free (process->contacts); g_object_unref (process->source); g_object_unref (process->destination); g_free (process); diff --git a/addressbook/gui/widgets/eab-vcard-control.c b/addressbook/gui/widgets/eab-vcard-control.c index b015f865f5..df45562fb8 100644 --- a/addressbook/gui/widgets/eab-vcard-control.c +++ b/addressbook/gui/widgets/eab-vcard-control.c @@ -125,7 +125,11 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, return; } - e_free_object_list (vcard_control->card_list); + g_list_foreach ( + vcard_control->card_list, + (GFunc) g_object_unref, NULL); + g_list_free (vcard_control->card_list); + list = eab_contact_list_from_string (vcard); g_free(vcard); vcard_control->card_list = list; @@ -192,7 +196,8 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure) } if (book) g_object_unref (book); - e_free_object_list (list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); } static void @@ -236,7 +241,11 @@ static void free_struct (gpointer data, GObject *where_object_was) { EABVCardControl *vcard_control = data; - e_free_object_list (vcard_control->card_list); + + g_list_foreach ( + vcard_control->card_list, + (GFunc) g_object_unref, NULL); + g_list_free (vcard_control->card_list); g_free (vcard_control); } diff --git a/addressbook/printing/e-contact-print-style-editor.c b/addressbook/printing/e-contact-print-style-editor.c index f5ac90bae0..3f945e28fe 100644 --- a/addressbook/printing/e-contact-print-style-editor.c +++ b/addressbook/printing/e-contact-print-style-editor.c @@ -128,8 +128,7 @@ e_contact_print_style_editor_destroy (GtkObject *object) GtkWidget* e_contact_print_style_editor_new (char *filename) { - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_print_style_editor_get_type ())); - return widget; + return g_object_new (e_contact_print_style_editor_get_type (), NULL); } static void diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c index e3899b8992..32098689d9 100644 --- a/addressbook/printing/e-contact-print.c +++ b/addressbook/printing/e-contact-print.c @@ -651,7 +651,7 @@ e_contact_build_style(EContactPrintStyle *style, GtkPrintSettings *config) style->center_footer = g_strdup(""); style->right_footer = g_strdup(""); style->reverse_on_even_pages = FALSE; - filename = g_concat_dir_and_file(EVOLUTION_ECPSDIR, "medbook.ecps"); + filename = g_build_filename(EVOLUTION_ECPSDIR, "medbook.ecps", NULL); styledoc = e_xml_parse_file (filename); g_free(filename); if (styledoc) { diff --git a/addressbook/tools/evolution-addressbook-export.c b/addressbook/tools/evolution-addressbook-export.c index ee157b74df..b99925d279 100644 --- a/addressbook/tools/evolution-addressbook-export.c +++ b/addressbook/tools/evolution-addressbook-export.c @@ -23,7 +23,9 @@ #include <config.h> +#include <string.h> #include <glib.h> +#include <glib/gi18n.h> #include <bonobo-activation/bonobo-activation.h> #include <bonobo/bonobo-main.h> #include <gnome.h> @@ -32,62 +34,71 @@ #include "evolution-addressbook-export.h" +/* Command-Line Options */ +static gchar *opt_output_file = NULL; +static gboolean opt_list_folders_mode = FALSE; +static gchar *opt_output_format = NULL; +static gchar *opt_addressbook_folder_uri = NULL; +static gboolean opt_async_mode = FALSE; +static gint opt_file_size = 0; +static gchar **opt_remaining = NULL; + +static GOptionEntry entries[] = { + { "output", '\0', G_OPTION_FLAG_FILENAME, + G_OPTION_ARG_STRING, &opt_output_file, + N_("Specify the output file instead of standard output"), + N_("OUTPUTFILE") }, + { "list-addressbook-folders", 'l', 0, + G_OPTION_ARG_NONE, &opt_list_folders_mode, + N_("List local addressbook folders") }, + { "format", '\0', 0, + G_OPTION_ARG_STRING, &opt_output_format, + N_("Show cards as vcard or csv file"), + N_("[vcard|csv]") }, + { "async", 'a', 0, + G_OPTION_ARG_NONE, &opt_async_mode, + N_("Export in asynchronous mode") }, + { "size", '\0', 0, + G_OPTION_ARG_INT, &opt_file_size, + N_("The number of cards in out output file in asynchronous mode, " + "default size 100."), + N_("NUMBER") }, + { G_OPTION_REMAINING, '\0', 0, + G_OPTION_ARG_STRING_ARRAY, &opt_remaining }, + { NULL } +}; + int main (int argc, char **argv) { ActionContext actctx; GnomeProgram *program; - poptContext context; - const gchar **argvn; + GOptionContext *context; int current_action = ACTION_NOTHING; int IsCSV = FALSE; int IsVCard = FALSE; - /*** popttable */ - char *output_file = NULL; - int list_folders_mode = FALSE; - char *output_format = NULL; - char *addressbook_folder_uri = NULL; - int async_mode = FALSE; - int file_size = 0; - - struct poptOption options[] = { - {"output", '\0', POPT_ARG_STRING, &output_file, 0, N_("Specify the output file instead of standard output"), - N_("OUTPUTFILE")}, - {"list-addressbook-folders", 'l', POPT_ARG_NONE, &list_folders_mode, 0, N_("List local addressbook folders"), - NULL}, - {"format", '\0', POPT_ARG_STRING, &output_format, 0, N_("Show cards as vcard or csv file"), N_("[vcard|csv]")}, - {"async", 'a', POPT_ARG_NONE, &async_mode, 0, N_("Export in asynchronous mode"), NULL}, - {"size", '\0', POPT_ARG_INT, &file_size, 0, - N_("The number of cards in one output file in asynchronous mode, default size 100."), N_("NUMBER")}, - {NULL, '\0', 0, NULL, 0, NULL, NULL} - }; - /* popttable end ** */ - /*i18n-lize */ bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); - program = - gnome_program_init (PACKAGE, VERSION, GNOME_BONOBO_MODULE, argc, argv, GNOME_PARAM_POPT_TABLE, options, - GNOME_PARAM_NONE); + context = g_option_context_new (NULL); + g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); + program = gnome_program_init ( + PACKAGE, VERSION, GNOME_BONOBO_MODULE, argc, argv, + GNOME_PARAM_GOPTION_CONTEXT, context, + GNOME_PARAM_NONE); /* Parsing Parameter */ - g_object_get (program, "popt-context", &context, NULL); - argvn = poptGetArgs (context); - if (!argvn) { - addressbook_folder_uri = NULL; - } else { /* there at lease is a one argument, and that should be addressbook folder uri */ - addressbook_folder_uri = g_strdup (*argvn); - } - poptFreeContext (context); + if (g_strv_length (opt_remaining) > 0) + opt_addressbook_folder_uri = g_strdup (opt_remaining[0]); - if (list_folders_mode != FALSE) { + if (opt_list_folders_mode != FALSE) { current_action = ACTION_LIST_FOLDERS; /* check there should not be addressbook-folder-uri , and async and size , output_format */ - if (addressbook_folder_uri != NULL || async_mode != FALSE || output_format != NULL || file_size != 0) { + if (opt_addressbook_folder_uri != NULL || opt_async_mode != FALSE || opt_output_format != NULL || opt_file_size != 0) { g_warning (_("Command line arguments error, please use --help option to see the usage.")); exit (-1); } @@ -96,11 +107,11 @@ main (int argc, char **argv) current_action = ACTION_LIST_CARDS; /* check the output format */ - if (output_format == NULL) { + if (opt_output_format == NULL) { IsVCard = TRUE; } else { - IsCSV = !strcmp (output_format, "csv"); - IsVCard = !strcmp (output_format, "vcard"); + IsCSV = !strcmp (opt_output_format, "csv"); + IsVCard = !strcmp (opt_output_format, "vcard"); if (IsCSV == FALSE && IsVCard == FALSE) { g_warning (_("Only support csv or vcard format.")); exit (-1); @@ -108,17 +119,17 @@ main (int argc, char **argv) } /*check async and output file */ - if (async_mode == TRUE) { + if (opt_async_mode == TRUE) { /* check have to output file , set default file_size */ - if (output_file == NULL) { + if (opt_output_file == NULL) { g_warning (_("In async mode, output must be file.")); exit (-1); } - if (file_size == 0) - file_size = DEFAULT_SIZE_NUMBER; + if (opt_file_size == 0) + opt_file_size = DEFAULT_SIZE_NUMBER; } else { /*check no file_size */ - if (file_size != 0) { + if (opt_file_size != 0) { g_warning (_("In normal mode, there is no need for the size option.")); exit (-1); } @@ -128,24 +139,24 @@ main (int argc, char **argv) /* do actions */ if (current_action == ACTION_LIST_FOLDERS) { actctx.action_type = current_action; - if (output_file == NULL) { + if (opt_output_file == NULL) { actctx.action_list_folders.output_file = NULL; } else { - actctx.action_list_folders.output_file = g_strdup (output_file); + actctx.action_list_folders.output_file = g_strdup (opt_output_file); } action_list_folders_init (&actctx); } else if (current_action == ACTION_LIST_CARDS) { actctx.action_type = current_action; - if (output_file == NULL) { + if (opt_output_file == NULL) { actctx.action_list_cards.output_file = NULL; } else { - actctx.action_list_cards.output_file = g_strdup (output_file); + actctx.action_list_cards.output_file = g_strdup (opt_output_file); } actctx.action_list_cards.IsCSV = IsCSV; actctx.action_list_cards.IsVCard = IsVCard; - actctx.action_list_cards.addressbook_folder_uri = g_strdup (addressbook_folder_uri); - actctx.action_list_cards.async_mode = async_mode; - actctx.action_list_cards.file_size = file_size; + actctx.action_list_cards.addressbook_folder_uri = g_strdup (opt_addressbook_folder_uri); + actctx.action_list_cards.async_mode = opt_async_mode; + actctx.action_list_cards.file_size = opt_file_size; action_list_cards_init (&actctx); |