Deprecated code

Fixing deprecated code

If you want to fix a deprecation, fill out an issue on github explaining why.

Lists

Status

DEPRECATED; use above status page

Module Status
libmate Done (1/11/12)
libmatecanvas Not Started
libmatecomponent Not Started
libmatecomponentui Not Started
libmatekbd Not Started
libmatekeyring Done (1/11/12)
libmatenotify Done (1/11/12)
libmateui Not Started
libmateweather Not Started
mate-applets Not Started
mate-calc Not Started
mate-conf Done (1/11/12)
mate-control-center Not Started
mate-corba Done (1/11/12)
mate-desktop Not Started
mate-dialogs Not Started
mate-display-manager Not Started
mate-document-viewer Not Started
mate-file-archiver Not Started
mate-file-manager Not Started
mate-image-viewer Not Started
mate-keyring Done (1/11/12)
mate-menus Done (1/11/12)
mate-notification-daemon Not Started
mate-panel Not Started
mate-polkit Not Started
mate-screensaver Not Started
mate-sensors-applet Not Started
mate-session-manager Done (2012/11/14)
mate-settings-daemon Not Started
mate-system-monitor Not Started
mate-system-tools Not Started
mate-terminal Not Started
mate-text-editor Not Started
mate-vfs Not Started
mate-window-manager Done (2012/11/20) SB

How to guide

When you find obsolete code, functions, variable names, constants, etc., you should look at the documentation to find the version in which the code became deprecated.

Why?

We want to support backwards compatibility.

Getting started

Say we have this obsolete constant, GTK_CHECK_CAST, and we need to change it to G_TYPE_CHECK_INSTANT_CAST. Since the documentation does not state the version in which the code became deprecated, we can simply change GTK_CHECK_CAST to G_TYPE_CHECK_INSTANT_CAST.

On other hand, say we have this obsolete function, g_format_size_for_display, and we want to change it to g_format_size. Since the documentation states that the code has been marked deprecated since version 2.30, we must be careful.

To support backwards compatibility, we cannot use the solution to the first example. In this case we must do something like the following:

#if GLIB_CHECK_VERSION (2, 30, 0) // greater than or equal to version 2.30
    return g_format_size(size);
#else  // less than version 2.30
    return g_format_size_for_display(size);
#endif

Now we can support both new and old versions of glib.

This is ugly!

Yes, the solution is quite ugly and not very elegant, but it helps keep track of changes in libraries and allows us to cater to a larger audience.

How to get a list of obsolete code

The following should be included at compile time, or using autogen.sh:

-DG_DISABLE_DEPRECATED
-DG_DISABLE_SINGLE_INCLUDES
-DGDK_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED
-DGDK_DISABLE_SINGLE_INCLUDES
-DGTK_DISABLE_SINGLE_INCLUDES

source: http://developer.pidgin.im/wiki/GTK3

Also see GNOME: Remove deprecated GTK+ symbols

Alternatively, if you would like to get a list of deprecated symbols without having to compile, you can use the following command:

egrep -wnr --include=*.[ch] -f ~/file-of-deprecated-symbols.txt path/to/src

Which means: Do an extended regexp search (egrep), search recursively (-r) in path/to/src (or the current directory if path ommitted), narrow the search only to files ending in '.c' or '.h' (–include=*.[ch]), using each line in the file specified as argument to '-f' as a search pattern, match whole-words only (-w), and prefix output matches with line number (-n).

The .txt files with lists of deprecated symbols can be found here.

deprecated_code.txt · Last modified: 2012/12/21 04:59 by Jasmine Hassan
 
Recent changes RSS feed Driven by DokuWiki
Hosted by First Colo