GNOME Bugzilla – Bug 429422
Massive code cleanup
Last modified: 2007-07-27 21:17:09 UTC
More cleanup work for Evolution. This patch makes significant progress towards migrating off deprecated symbols in the GTK+ and GNOME libraries. I'm also killing off several utility functions and macros that have become redundant or unused over the years. Here's the checklist: - Fix all implicit function declarations. - Port evolution-addressbook-export from popt to GOption. - Drop GnomePropertyBox support in e-dialog-widgets.c (no longer needed). - Migrate to non-deprecated symbols: GNOME_STOCK_xxx --> GTK_STOCK_xxx GTK_OBJECT_FLOATING() --> g_object_is_floating() GTK_OBJECT_SET_FLAGS() --> g_object_force_floating() GnomeDialog --> GtkDialog GnomeFileEntry --> GtkFileChooserButton GnomeIconTheme --> GtkIconTheme GnomeMessageBox --> GtkMessageDialog g_concat_dir_and_file() --> g_build_filename() g_object_ref(), gtk_object_sink() --> g_object_ref_sink() gnome_date_edit_get_date() --> gnome_date_edit_get_time() gnome_init() --> gnome_program_init() gnome_window_set_icon_from_file() --> gtk_window_set_icon_from_file() gtk_accel_group_unref() --> g_object_unref() gtk_button_box_set_child_ipadding() --> (nothing, use style properties) gtk_button_box_set_child_size() --> (nothing, use style properties) gtk_button_box_set_spacing() --> gtk_box_set_spacing() gtk_cell_renderer_editing_canceled() --> gtk_cell_renderer_stop_editing() gtk_draw_shadow() --> gtk_paint_shadow() gtk_entry_set_editable() --> gtk_editable_set_editable() gtk_idle_add() --> g_idle_add() gtk_idle_remove() --> g_source_remove() gtk_label_get() --> gtk_label_get_text() gtk_layout_freeze() --> (nothing) gtk_layout_thaw() --> (nothing) gtk_marshal_NONE__INT --> g_cclosure_marshal_VOID__INT gtk_menu_append() --> gtk_menu_shell_append() gtk_notebook_set_page() --> gtk_notebook_set_current_page() gtk_radio_menu_item_group() --> gtk_radio_menu_item_get_group() gtk_signal_connect_object() --> g_signal_connect_swapped() gtk_timeout_add() --> g_timeout_add() gtk_timeout_remove() --> g_source_remove() gtk_type_new() --> g_object_new() gtk_widget_draw() --> (use GTK's implementation) gtk_widget_ref() --> g_object_ref() gtk_widget_set_usize() --> gtk_widget_set_size_request() gtk_widget_unref() --> g_object_unref() - Remove some unused utilities and macros: E_MAKE_X_TYPE E_OBJECT_CLASS_ADD_SIGNALS GET_DUPLICATED_STRING_ARRAY_FROM_ELLIPSIS GET_STRING_ARRAY_FROM_ELLIPSIS e_create_image_widget() e_make_widget_backing_stored() e_read_file() e_signal_connect_full_while_alive() e_signal_connect_while_alive() e_strsplit() e_write_file() e_writh_file_mkstemp() - Remove some obsolete or unnecessary utilities: - E_OBJECT_CLASS_TYPE Replace with G_TYPE_FROM_CLASS. - e_strdup_strip() Replace with g_strstrip (g_strdup (str)). - e_free_object_list() / e_free_object_slist() Replace with: g_list_foreach (list, (GFunc) g_object_unref, NULL); g_list_free (list); Similarly for e_free_object_slist(). - e_free_string_list() / e_free_string_slist() Replace with: g_list_foreach (list, (GFunc) g_free, NULL); g_list_free (list); Similarly for e_free_string_slist(). - e_sort() Replace with g_qsort_with_data (). - e_button_new_with_stock_icon() / e_gtk_button_new_with_icon() Replace with gtk_button_new_from_stock(), or: button = gtk_button_new_with_mnemonic (label); image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON); gtk_button_set_image (button, image); - e_create_directory() / e_util_mkdir_hier() Replace with g_mkdir_with_parents(). A side-effect of this cleanup effort is that I was able to pin down the remaining deprecated widgets and functions that Evolution is still using. Migrating away from them will be more involved than the cases addressed by this bug, so I plan on dealing with each of them on a case-by-case basis. Here's a list of the major deprecated items that Evolution is still using: gnome-config (migrate to GKeyFile) GnomeDialog (migrate to GtkDialog) GnomeDruid (migrate to GtkAssistant) GnomeIconList (migrate to GtkIconView) GtkCombo (migrate to GtkComboBoxEntry) GtkOptionMenu (migrate to GtkComboBox) The old GTK+ object system (migrate to libgobject)
Created attachment 86302 [details] [review] Proposed patch Sorry to keep submitting these massive patches for review...
I strongly recommend using a graphical diff viewer like Meld [1] to review these changes. Apply the patch to a clean Subversion checkout and use Meld's version control browser. [1] http://meld.sourceforge.net/
Matthew, most of the patch looks fine to me. Except a few. 1. I wasnt very clear of the changes you have done in hook_WIDGETS function of e-dialog-utils (?) . 2. I noticed that gnome_warning_dialog/other types weren't marked with respective GTK_MESSAGE_ at a few places. It is fine in other places. Apart from these two, the patch look fine to me. /me wants matthew to attach with smaller patches rather than MASSIVE ones like this :) Anyways, great job Matthew :)
(In reply to comment #3) > 1. I wasnt very clear of the changes you have done in hook_WIDGETS function of > e-dialog-utils (?) . I was dropping support for GnomePropertyBox, which is deprecated in libgnomeui and is not (or no longer) used anywhere else in Evolution or Evolution-Exchange. > 2. I noticed that gnome_warning_dialog/other types weren't marked with > respective GTK_MESSAGE_ at a few places. It is fine in other places. Some cases will be eliminated by my print cleanup patch (bug #426816), so I purposely skipped them here. I'll pick off any remaining cases after the dust from these two massive patches settles. > /me wants matthew to attach with smaller patches rather than MASSIVE ones like > this :) Yeah, sorry about that. I'll try to break them into more managable pieces in the future. You're a trouper for reviewing them. I appreciate it. :)
> Some cases will be eliminated by my print cleanup patch (bug #426816), so I > purposely skipped them here. I'll pick off any remaining cases after the dust > from these two massive patches settles. I go by your words :). Please commit.
Committed to Subversion trunk (revision 33432).
Matthew, I think gtk_signal_xx() functions and E_MAKE_TYPE should be rewritten.
Created attachment 91958 [details] [review] A patch for widgets/text.
Can somebody reopen this bug?
Created attachment 91959 [details] [review] revised patch Sorry, my previous patch does not remove g_type_class_ref().
Created attachment 91960 [details] [review] A patch for widgets/misc
Created attachment 91982 [details] [review] unified patch for widgets directory except widgets/table I will post another patch for widgets/table directory because the directory has its own ChangeLog file.
Created attachment 92017 [details] [review] A patch for widgets/table
Created attachment 92018 [details] [review] A patch for e-util.
E_MAKE_TYPE has now eliminated.
Created attachment 92024 [details] [review] revised patch for widgets/table. Sorry, the previous patch has a horrible typo. E_SELECTION_MODEL_TYPE -> E_SELECTION_MODEL_ARRAY_TYPE
Matthew, Can you review this for 2.11.6 and push it accordingly?
Looks good, nice cleanup! Committed to Subversion trunk (revision 33864).