Commit fa043157 authored by John Sullivan's avatar John Sullivan

Defined and deployed macros for signals that must be overridden by

subclass; also deployed Darin's other boilerplate-reducing macros
in fm-directory-view-icons.c and fm-directory-view-list.c
parent 35d40686
2000-01-13 John Sullivan <sullivan@eazel.com>
* libnautilus/nautilus-gtk-macros.h: Defined macros
for use when a signal must be overridden by subclasses.
* src/file-manager/fm-directory-view.c: Deployed these
new macros for the "clear" signal.
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL is outside any
function, and
(class_init): NAUTILUS_MUST_OVERRIDE_SIGNAL is in here.
(fm_directory_view_real_clear): Eliminated this in favor
of the above macros.
* src/file-manager/fm-directory-view-icons.c:
(fm_directory_view_icons_get_type): Replaced function with
NAUTILUS_DEFINE_GET_TYPE_FUNCTION macro.
(fm_directory_view_icons_init): Renamed to
fm_directory_view_icons_initialize and standardized parameters
to work with NAUTILUS_DEFINE_GET_TYPE_FUNCTION macro.
(fm_directory_view_icons_class_init): Renamed to
fm_directory_view_icons_initialize_class and standardized
parameters to work with NAUTILUS_DEFINE_GET_TYPE_FUNCTION macro.
(fm_directory_view_icons_destroy): Deployed
NAUTILUS_CALL_PARENT_CLASS macro.
* src/file-manager/fm-directory-view-list.c:
(fm_directory_view_list_get_type): Replaced function with
NAUTILUS_DEFINE_GET_TYPE_FUNCTION macro.
(fm_directory_view_list_init): Renamed to
fm_directory_view_list_initialize and standardized parameters
to work with NAUTILUS_DEFINE_GET_TYPE_FUNCTION macro.
(fm_directory_view_list_class_init): Renamed to
fm_directory_view_list_initialize_class and standardized
parameters to work with NAUTILUS_DEFINE_GET_TYPE_FUNCTION macro.
(fm_directory_view_list_destroy): Deployed
NAUTILUS_CALL_PARENT_CLASS macro.
2000-01-12 John Sullivan <sullivan@eazel.com>
More work at pushing appropriate fm_directory_view code
......
......@@ -73,4 +73,45 @@ G_STMT_START { \
(* parent_class_cast_macro (parent_class)->signal) parameters; \
} G_STMT_END
#ifndef G_DISABLE_ASSERT
/* Define a signal that is not implemented by this class but must be
* implemented by subclasses. This macro should be used inside the
* class initialization function. The companion macro NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL
* must be used earlier in the file. Called like this:
*
* NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (FM_DIRECTORY_VIEW_CLASS,
* class,
* fm_directory_view,
* clear);
*/
#define NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL(class_cast_macro, class_pointer, class_name_in_function_format, signal) \
\
* (void (**)(void)) &class_cast_macro (class_pointer)->signal = class_name_in_function_format##_unimplemented_##signal;
/* Provide a debug-only implementation of a signal that must be implemented
* by subclasses. The debug-only implementation fires a warning if it is called.
* This macro should be placed as if it were a function, earlier in the file
* than the class initialization function. Called like this:
*
* NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear);
*/
#define NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL(class_name_in_function_format, signal) \
\
static void \
class_name_in_function_format##_unimplemented_##signal (void) \
{ \
g_warning ("Failed to override signal %s->%s", #class_name_in_function_format, #signal); \
}
#else
#define NAUTILUS_DEFINE_MUST_OVERRIDE_SIGNAL(class_cast_macro, class_pointer, class_name_in_function_format, signal)
#define NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL(class_name_in_function_format, signal)
#endif /* G_DISABLE_ASSERT */
#endif /* NAUTILUS_GTK_MACROS_H */
......@@ -73,4 +73,45 @@ G_STMT_START { \
(* parent_class_cast_macro (parent_class)->signal) parameters; \
} G_STMT_END
#ifndef G_DISABLE_ASSERT
/* Define a signal that is not implemented by this class but must be
* implemented by subclasses. This macro should be used inside the
* class initialization function. The companion macro NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL
* must be used earlier in the file. Called like this:
*
* NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (FM_DIRECTORY_VIEW_CLASS,
* class,
* fm_directory_view,
* clear);
*/
#define NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL(class_cast_macro, class_pointer, class_name_in_function_format, signal) \
\
* (void (**)(void)) &class_cast_macro (class_pointer)->signal = class_name_in_function_format##_unimplemented_##signal;
/* Provide a debug-only implementation of a signal that must be implemented
* by subclasses. The debug-only implementation fires a warning if it is called.
* This macro should be placed as if it were a function, earlier in the file
* than the class initialization function. Called like this:
*
* NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear);
*/
#define NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL(class_name_in_function_format, signal) \
\
static void \
class_name_in_function_format##_unimplemented_##signal (void) \
{ \
g_warning ("Failed to override signal %s->%s", #class_name_in_function_format, #signal); \
}
#else
#define NAUTILUS_DEFINE_MUST_OVERRIDE_SIGNAL(class_cast_macro, class_pointer, class_name_in_function_format, signal)
#define NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL(class_name_in_function_format, signal)
#endif /* G_DISABLE_ASSERT */
#endif /* NAUTILUS_GTK_MACROS_H */
......@@ -73,4 +73,45 @@ G_STMT_START { \
(* parent_class_cast_macro (parent_class)->signal) parameters; \
} G_STMT_END
#ifndef G_DISABLE_ASSERT
/* Define a signal that is not implemented by this class but must be
* implemented by subclasses. This macro should be used inside the
* class initialization function. The companion macro NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL
* must be used earlier in the file. Called like this:
*
* NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (FM_DIRECTORY_VIEW_CLASS,
* class,
* fm_directory_view,
* clear);
*/
#define NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL(class_cast_macro, class_pointer, class_name_in_function_format, signal) \
\
* (void (**)(void)) &class_cast_macro (class_pointer)->signal = class_name_in_function_format##_unimplemented_##signal;
/* Provide a debug-only implementation of a signal that must be implemented
* by subclasses. The debug-only implementation fires a warning if it is called.
* This macro should be placed as if it were a function, earlier in the file
* than the class initialization function. Called like this:
*
* NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear);
*/
#define NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL(class_name_in_function_format, signal) \
\
static void \
class_name_in_function_format##_unimplemented_##signal (void) \
{ \
g_warning ("Failed to override signal %s->%s", #class_name_in_function_format, #signal); \
}
#else
#define NAUTILUS_DEFINE_MUST_OVERRIDE_SIGNAL(class_cast_macro, class_pointer, class_name_in_function_format, signal)
#define NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL(class_name_in_function_format, signal)
#endif /* G_DISABLE_ASSERT */
#endif /* NAUTILUS_GTK_MACROS_H */
......@@ -28,6 +28,8 @@
#include <gnome.h>
#include <libnautilus/nautilus-gtk-macros.h>
#include "fm-directory-view.h"
#include "fm-directory-view-icons.h"
......@@ -52,19 +54,18 @@ static void icon_container_selection_changed_cb (GnomeIconContainer *container,
static void
fm_directory_view_icons_destroy (GtkObject *object)
{
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
static void
fm_directory_view_icons_class_init (FMDirectoryViewIconsClass *class)
fm_directory_view_icons_initialize_class (gpointer klass)
{
GtkObjectClass *object_class;
FMDirectoryViewClass *fm_directory_view_class;
object_class = GTK_OBJECT_CLASS (class);
fm_directory_view_class = FM_DIRECTORY_VIEW_CLASS (class);
object_class = GTK_OBJECT_CLASS (klass);
fm_directory_view_class = FM_DIRECTORY_VIEW_CLASS (klass);
parent_class = gtk_type_class (gtk_type_parent(object_class->type));
......@@ -73,46 +74,23 @@ fm_directory_view_icons_class_init (FMDirectoryViewIconsClass *class)
}
static void
fm_directory_view_icons_init (FMDirectoryViewIcons *directory_view)
fm_directory_view_icons_initialize (gpointer object, gpointer klass)
{
GnomeIconContainer *icon_container;
g_return_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (directory_view));
g_return_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (object));
/* FIXME: eventually get rid of set_mode call entirely. */
fm_directory_view_set_mode (FM_DIRECTORY_VIEW (directory_view),
fm_directory_view_set_mode (FM_DIRECTORY_VIEW (object),
FM_DIRECTORY_VIEW_MODE_ICONS);
g_assert (GTK_BIN (directory_view)->child == NULL);
icon_container = create_icon_container (directory_view);
g_assert (GTK_BIN (object)->child == NULL);
icon_container = create_icon_container (object);
gnome_icon_container_set_icon_mode
(icon_container, GNOME_ICON_CONTAINER_NORMAL_ICONS);
}
GtkType
fm_directory_view_icons_get_type (void)
{
static GtkType directory_view_icons_type = 0;
if (directory_view_icons_type == 0) {
static GtkTypeInfo directory_view_icons_info = {
"FMDirectoryViewIcons",
sizeof (FMDirectoryViewIcons),
sizeof (FMDirectoryViewIconsClass),
(GtkClassInitFunc) fm_directory_view_icons_class_init,
(GtkObjectInitFunc) fm_directory_view_icons_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
directory_view_icons_type
= gtk_type_unique (fm_directory_view_get_type (),
&directory_view_icons_info);
}
return directory_view_icons_type;
}
NAUTILUS_DEFINE_GET_TYPE_FUNCTION (FMDirectoryViewIcons, fm_directory_view_icons, FM_TYPE_DIRECTORY_VIEW);
GtkWidget *
fm_directory_view_icons_new (void)
......
......@@ -29,6 +29,7 @@
#include <gnome.h>
#include <libnautilus/gtkflist.h>
#include <libnautilus/nautilus-gtk-macros.h>
#include "fm-directory-view.h"
#include "fm-directory-view-list.h"
......@@ -54,19 +55,18 @@ static void fm_directory_view_list_clear (FMDirectoryView *view);
static void
fm_directory_view_list_destroy (GtkObject *object)
{
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
static void
fm_directory_view_list_class_init (FMDirectoryViewListClass *class)
fm_directory_view_list_initialize_class (gpointer klass)
{
GtkObjectClass *object_class;
FMDirectoryViewClass *fm_directory_view_class;
object_class = GTK_OBJECT_CLASS (class);
fm_directory_view_class = FM_DIRECTORY_VIEW_CLASS (class);
object_class = GTK_OBJECT_CLASS (klass);
fm_directory_view_class = FM_DIRECTORY_VIEW_CLASS (klass);
parent_class = gtk_type_class (gtk_type_parent(object_class->type));
......@@ -75,42 +75,19 @@ fm_directory_view_list_class_init (FMDirectoryViewListClass *class)
}
static void
fm_directory_view_list_init (FMDirectoryViewList *directory_view)
fm_directory_view_list_initialize (gpointer object, gpointer klass)
{
g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (directory_view));
g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (object));
/* FIXME: eventually get rid of set_mode call entirely. */
fm_directory_view_set_mode (FM_DIRECTORY_VIEW (directory_view),
fm_directory_view_set_mode (FM_DIRECTORY_VIEW (object),
FM_DIRECTORY_VIEW_MODE_DETAILED);
g_assert (GTK_BIN (directory_view)->child == NULL);
create_flist (directory_view);
g_assert (GTK_BIN (object)->child == NULL);
create_flist (object);
}
GtkType
fm_directory_view_list_get_type (void)
{
static GtkType directory_view_list_type = 0;
if (directory_view_list_type == 0) {
static GtkTypeInfo directory_view_list_info = {
"FMDirectoryViewList",
sizeof (FMDirectoryViewList),
sizeof (FMDirectoryViewListClass),
(GtkClassInitFunc) fm_directory_view_list_class_init,
(GtkObjectInitFunc) fm_directory_view_list_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
directory_view_list_type
= gtk_type_unique (fm_directory_view_get_type (),
&directory_view_list_info);
}
return directory_view_list_type;
}
NAUTILUS_DEFINE_GET_TYPE_FUNCTION (FMDirectoryViewList, fm_directory_view_list, FM_TYPE_DIRECTORY_VIEW);
GtkWidget *
fm_directory_view_list_new (void)
......
......@@ -31,6 +31,7 @@
#include <libnautilus/libnautilus.h>
#include <libnautilus/gnome-icon-container.h>
#include <libnautilus/gtkflist.h>
#include <libnautilus/nautilus-gtk-macros.h>
#include "fm-directory-view.h"
#include "fm-icon-cache.h"
......@@ -56,9 +57,6 @@ static GtkScrolledWindowClass *parent_class = NULL;
*/
static FMIconCache *icm = NULL;
/* forward declarations */
static void fm_directory_view_real_clear (FMDirectoryView *view);
void
display_selection_info (FMDirectoryView *view,
GList *selection)
......@@ -306,6 +304,8 @@ destroy (GtkObject *object)
}
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear);
static void
class_init (FMDirectoryViewClass *class)
{
......@@ -324,7 +324,10 @@ class_init (FMDirectoryViewClass *class)
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
class->clear = fm_directory_view_real_clear;
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (FM_DIRECTORY_VIEW_CLASS,
class,
fm_directory_view,
clear);
}
static void
......@@ -678,15 +681,6 @@ fm_directory_view_clear (FMDirectoryView *view)
gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[CLEAR]);
}
static void
fm_directory_view_real_clear (FMDirectoryView *view)
{
/* FIXME: Create and deploy macros to handle this common debug-only error
* such that nondebug code doesn't have any function at all.
*/
g_warning("Bogus! Subclass should've replaced this default signal handler");
}
void
fm_directory_view_load_uri (FMDirectoryView *view,
const char *uri)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment