diff options
Diffstat (limited to 'mail')
38 files changed, 983 insertions, 1218 deletions
diff --git a/mail/Makefile.am b/mail/Makefile.am index 0a14a19ee9..0859c55c06 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -46,17 +46,13 @@ libevolution_mail_la_CPPFLAGS = \ mailinclude_HEADERS = \ e-mail.h \ - e-mail-view.h \ - e-mail-folder-pane.h \ - e-mail-message-pane.h \ - e-mail-paned-view.h \ - e-mail-notebook-view.h \ e-mail-attachment-bar.h \ e-mail-backend.h \ e-mail-browser.h \ e-mail-display.h \ e-mail-enums.h \ e-mail-enumtypes.h \ + e-mail-folder-pane.h \ e-mail-folder-utils.h \ e-mail-junk-filter.h \ e-mail-junk-options.h \ @@ -66,15 +62,19 @@ mailinclude_HEADERS = \ e-mail-label-manager.h \ e-mail-label-tree-view.h \ e-mail-local.h \ + e-mail-message-pane.h \ e-mail-migrate.h \ - e-mail-reader.h \ + e-mail-notebook-view.h \ + e-mail-paned-view.h \ e-mail-reader-utils.h \ - e-mail-session.h \ + e-mail-reader.h \ e-mail-session-utils.h \ + e-mail-session.h \ e-mail-sidebar.h \ - e-mail-store.h \ e-mail-store-utils.h \ + e-mail-store.h \ e-mail-tag-editor.h \ + e-mail-view.h \ em-account-editor.h \ em-composer-utils.h \ em-config.h \ @@ -85,15 +85,15 @@ mailinclude_HEADERS = \ em-filter-rule.h \ em-filter-source-element.h \ em-folder-properties.h \ - em-folder-selector.h \ em-folder-selection-button.h \ - em-folder-tree.h \ + em-folder-selector.h \ em-folder-tree-model.h \ + em-folder-tree.h \ em-folder-utils.h \ em-format-hook.h \ - em-format-html.h \ em-format-html-display.h \ em-format-html-print.h \ + em-format-html.h \ em-html-stream.h \ em-search-context.h \ em-subscription-editor.h \ @@ -121,16 +121,12 @@ mailinclude_HEADERS += \ endif libevolution_mail_la_SOURCES = \ - e-mail-view.c \ - e-mail-folder-pane.c \ - e-mail-message-pane.c \ - e-mail-paned-view.c \ - e-mail-notebook-view.c \ e-mail-attachment-bar.c \ e-mail-backend.c \ e-mail-browser.c \ e-mail-display.c \ e-mail-enumtypes.c \ + e-mail-folder-pane.c \ e-mail-folder-utils.c \ e-mail-junk-filter.c \ e-mail-junk-options.c \ @@ -140,15 +136,19 @@ libevolution_mail_la_SOURCES = \ e-mail-label-manager.c \ e-mail-label-tree-view.c \ e-mail-local.c \ + e-mail-message-pane.c \ e-mail-migrate.c \ - e-mail-reader.c \ + e-mail-notebook-view.c \ + e-mail-paned-view.c \ e-mail-reader-utils.c \ - e-mail-session.c \ + e-mail-reader.c \ e-mail-session-utils.c \ + e-mail-session.c \ e-mail-sidebar.c \ - e-mail-store.c \ e-mail-store-utils.c \ + e-mail-store.c \ e-mail-tag-editor.c \ + e-mail-view.c \ em-account-editor.c \ em-composer-utils.c \ em-config.c \ @@ -159,15 +159,15 @@ libevolution_mail_la_SOURCES = \ em-filter-rule.c \ em-filter-source-element.c \ em-folder-properties.c \ - em-folder-selector.c \ em-folder-selection-button.c \ - em-folder-tree.c \ + em-folder-selector.c \ em-folder-tree-model.c \ + em-folder-tree.c \ em-folder-utils.c \ em-format-hook.c \ - em-format-html.c \ em-format-html-display.c \ em-format-html-print.c \ + em-format-html.c \ em-html-stream.c \ em-search-context.c \ em-subscription-editor.c \ diff --git a/mail/e-mail-attachment-bar.c b/mail/e-mail-attachment-bar.c index 17a7ae1421..a48ca30f29 100644 --- a/mail/e-mail-attachment-bar.c +++ b/mail/e-mail-attachment-bar.c @@ -33,6 +33,10 @@ #include "e-attachment-icon-view.h" #include "e-attachment-tree-view.h" +#define E_MAIL_ATTACHMENT_BAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_ATTACHMENT_BAR, EMailAttachmentBarPrivate)) + #define NUM_VIEWS 2 struct _EMailAttachmentBarPrivate { @@ -61,7 +65,17 @@ enum { PROP_EXPANDED }; -static gpointer parent_class; +/* Forward Declarations */ +static void e_mail_attachment_bar_interface_init + (EAttachmentViewInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( + EMailAttachmentBar, + e_mail_attachment_bar, + GTK_TYPE_VBOX, + G_IMPLEMENT_INTERFACE ( + E_TYPE_ATTACHMENT_VIEW, + e_mail_attachment_bar_interface_init)) static void mail_attachment_bar_update_status (EMailAttachmentBar *bar) @@ -186,10 +200,11 @@ mail_attachment_bar_dispose (GObject *object) { EMailAttachmentBarPrivate *priv; - priv = E_MAIL_ATTACHMENT_BAR (object)->priv; + priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (object); if (priv->model != NULL) { - e_attachment_store_remove_all (E_ATTACHMENT_STORE (priv->model)); + e_attachment_store_remove_all ( + E_ATTACHMENT_STORE (priv->model)); g_object_unref (priv->model); priv->model = NULL; } @@ -250,7 +265,7 @@ mail_attachment_bar_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_mail_attachment_bar_parent_class)->dispose (object); } static void @@ -260,7 +275,7 @@ mail_attachment_bar_constructed (GObject *object) GConfBridge *bridge; const gchar *key; - priv = E_MAIL_ATTACHMENT_BAR (object)->priv; + priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (object); bridge = gconf_bridge_get (); @@ -320,16 +335,16 @@ mail_attachment_bar_constructed (GObject *object) gconf_bridge_bind_property (bridge, key, object, "active-view"); /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); + G_OBJECT_CLASS (e_mail_attachment_bar_parent_class)->constructed (object); } static EAttachmentViewPrivate * mail_attachment_bar_get_private (EAttachmentView *view) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); return e_attachment_view_get_private (view); } @@ -337,10 +352,10 @@ mail_attachment_bar_get_private (EAttachmentView *view) static EAttachmentStore * mail_attachment_bar_get_store (EAttachmentView *view) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); return e_attachment_view_get_store (view); } @@ -350,10 +365,10 @@ mail_attachment_bar_get_path_at_pos (EAttachmentView *view, gint x, gint y) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); return e_attachment_view_get_path_at_pos (view, x, y); } @@ -361,10 +376,10 @@ mail_attachment_bar_get_path_at_pos (EAttachmentView *view, static GList * mail_attachment_bar_get_selected_paths (EAttachmentView *view) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); return e_attachment_view_get_selected_paths (view); } @@ -373,10 +388,10 @@ static gboolean mail_attachment_bar_path_is_selected (EAttachmentView *view, GtkTreePath *path) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); return e_attachment_view_path_is_selected (view, path); } @@ -385,10 +400,10 @@ static void mail_attachment_bar_select_path (EAttachmentView *view, GtkTreePath *path) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); e_attachment_view_select_path (view, path); } @@ -397,10 +412,10 @@ static void mail_attachment_bar_unselect_path (EAttachmentView *view, GtkTreePath *path) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); e_attachment_view_unselect_path (view, path); } @@ -408,10 +423,10 @@ mail_attachment_bar_unselect_path (EAttachmentView *view, static void mail_attachment_bar_select_all (EAttachmentView *view) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); e_attachment_view_select_all (view); } @@ -419,10 +434,10 @@ mail_attachment_bar_select_all (EAttachmentView *view) static void mail_attachment_bar_unselect_all (EAttachmentView *view) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); e_attachment_view_unselect_all (view); } @@ -430,20 +445,19 @@ mail_attachment_bar_unselect_all (EAttachmentView *view) static void mail_attachment_bar_update_actions (EAttachmentView *view) { - EMailAttachmentBarPrivate *priv; + EMailAttachmentBar *bar; - priv = E_MAIL_ATTACHMENT_BAR (view)->priv; - view = E_ATTACHMENT_VIEW (priv->icon_view); + bar = E_MAIL_ATTACHMENT_BAR (view); + view = E_ATTACHMENT_VIEW (bar->priv->icon_view); e_attachment_view_update_actions (view); } static void -mail_attachment_bar_class_init (EMailAttachmentBarClass *class) +e_mail_attachment_bar_class_init (EMailAttachmentBarClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailAttachmentBarPrivate)); object_class = G_OBJECT_CLASS (class); @@ -484,7 +498,7 @@ mail_attachment_bar_class_init (EMailAttachmentBarClass *class) } static void -mail_attachment_bar_interface_init (EAttachmentViewInterface *interface) +e_mail_attachment_bar_interface_init (EAttachmentViewInterface *interface) { interface->get_private = mail_attachment_bar_get_private; interface->get_store = mail_attachment_bar_get_store; @@ -499,7 +513,7 @@ mail_attachment_bar_interface_init (EAttachmentViewInterface *interface) } static void -mail_attachment_bar_init (EMailAttachmentBar *bar) +e_mail_attachment_bar_init (EMailAttachmentBar *bar) { EAttachmentView *view; GtkSizeGroup *size_group; @@ -507,8 +521,7 @@ mail_attachment_bar_init (EMailAttachmentBar *bar) GtkWidget *widget; GtkAction *action; - bar->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - bar, E_TYPE_MAIL_ATTACHMENT_BAR, EMailAttachmentBarPrivate); + bar->priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (bar); bar->priv->model = e_attachment_store_new (); gtk_box_set_spacing (GTK_BOX (bar), 6); @@ -644,41 +657,6 @@ mail_attachment_bar_init (EMailAttachmentBar *bar) g_object_unref (size_group); } -GType -e_mail_attachment_bar_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailAttachmentBarClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_attachment_bar_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailAttachmentBar), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_attachment_bar_init, - NULL /* value_table */ - }; - - static const GInterfaceInfo interface_info = { - (GInterfaceInitFunc) mail_attachment_bar_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - - type = g_type_register_static ( - GTK_TYPE_VBOX, "EMailAttachmentBar", &type_info, 0); - - g_type_add_interface_static ( - type, E_TYPE_ATTACHMENT_VIEW, &interface_info); - } - - return type; -} - GtkWidget * e_mail_attachment_bar_new (void) { diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c index fe8b8984f3..29ddf3df09 100644 --- a/mail/e-mail-browser.c +++ b/mail/e-mail-browser.c @@ -45,6 +45,10 @@ #include "mail/em-format-html-display.h" #include "mail/message-list.h" +#define E_MAIL_BROWSER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_BROWSER, EMailBrowserPrivate)) + #define MAIL_BROWSER_GCONF_PREFIX "/apps/evolution/mail/mail_browser" #define ACTION_GROUP_STANDARD "action-group-standard" @@ -482,7 +486,7 @@ mail_browser_dispose (GObject *object) { EMailBrowserPrivate *priv; - priv = E_MAIL_BROWSER (object)->priv; + priv = E_MAIL_BROWSER_GET_PRIVATE (object); if (priv->backend != NULL) { g_object_unref (priv->backend); @@ -542,7 +546,7 @@ mail_browser_dispose (GObject *object) static void mail_browser_constructed (GObject *object) { - EMailBrowserPrivate *priv; + EMailBrowser *browser; EMFormatHTML *formatter; EMailReader *reader; EMailBackend *backend; @@ -566,7 +570,7 @@ mail_browser_constructed (GObject *object) /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (parent_class)->constructed (object); - priv = E_MAIL_BROWSER (object)->priv; + browser = E_MAIL_BROWSER (object); reader = E_MAIL_READER (object); backend = e_mail_reader_get_backend (reader); @@ -577,7 +581,7 @@ mail_browser_constructed (GObject *object) ui_manager = e_ui_manager_new (); e_shell_configure_ui_manager (shell, E_UI_MANAGER (ui_manager)); - priv->ui_manager = ui_manager; + browser->priv->ui_manager = ui_manager; domain = GETTEXT_PACKAGE; gtk_application_add_window ( @@ -589,15 +593,15 @@ mail_browser_constructed (GObject *object) /* The message list is a widget, but it is not shown in the browser. * Unfortunately, the widget is inseparable from its model, and the * model is all we need. */ - priv->message_list = message_list_new (backend); - g_object_ref_sink (priv->message_list); + browser->priv->message_list = message_list_new (backend); + g_object_ref_sink (browser->priv->message_list); g_signal_connect_swapped ( - priv->message_list, "message-selected", + browser->priv->message_list, "message-selected", G_CALLBACK (mail_browser_message_selected_cb), object); g_signal_connect_swapped ( - priv->message_list, "message-list-built", + browser->priv->message_list, "message-list-built", G_CALLBACK (mail_browser_message_list_built_cb), object); g_signal_connect_swapped ( @@ -662,7 +666,7 @@ mail_browser_constructed (GObject *object) e_focus_tracker_set_paste_clipboard_action (focus_tracker, action); action = e_mail_reader_get_action (reader, "select-all"); e_focus_tracker_set_select_all_action (focus_tracker, action); - priv->focus_tracker = focus_tracker; + browser->priv->focus_tracker = focus_tracker; /* Construct window widgets. */ @@ -675,17 +679,17 @@ mail_browser_constructed (GObject *object) /* Create the status bar before connecting proxy widgets. */ widget = gtk_statusbar_new (); gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0); - priv->statusbar = g_object_ref (widget); + browser->priv->statusbar = g_object_ref (widget); gtk_widget_show (widget); widget = gtk_ui_manager_get_widget (ui_manager, "/main-menu"); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - priv->main_menu = g_object_ref (widget); + browser->priv->main_menu = g_object_ref (widget); gtk_widget_show (widget); widget = gtk_ui_manager_get_widget (ui_manager, "/main-toolbar"); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - priv->main_toolbar = g_object_ref (widget); + browser->priv->main_toolbar = g_object_ref (widget); gtk_widget_show (widget); gtk_style_context_add_class ( @@ -694,7 +698,7 @@ mail_browser_constructed (GObject *object) widget = e_alert_bar_new (); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - priv->alert_bar = g_object_ref (widget); + browser->priv->alert_bar = g_object_ref (widget); /* EAlertBar controls its own visibility. */ gtk_widget_show (GTK_WIDGET (web_view)); @@ -704,11 +708,12 @@ mail_browser_constructed (GObject *object) gtk_widget_show (widget); search_bar = e_preview_pane_get_search_bar (E_PREVIEW_PANE (widget)); - priv->search_bar = g_object_ref (search_bar); + browser->priv->search_bar = g_object_ref (search_bar); g_signal_connect_swapped ( search_bar, "changed", - G_CALLBACK (em_format_queue_redraw), priv->formatter); + G_CALLBACK (em_format_queue_redraw), + browser->priv->formatter); /* Bind GObject properties to GConf keys. */ @@ -745,18 +750,18 @@ static void mail_browser_submit_alert (EAlertSink *alert_sink, EAlert *alert) { - EMailBrowserPrivate *priv; + EMailBrowser *browser; EAlertBar *alert_bar; GtkWidget *dialog; GtkWindow *parent; - priv = E_MAIL_BROWSER (alert_sink)->priv; + browser = E_MAIL_BROWSER (alert_sink); + alert_bar = E_ALERT_BAR (browser->priv->alert_bar); switch (e_alert_get_message_type (alert)) { case GTK_MESSAGE_INFO: case GTK_MESSAGE_WARNING: case GTK_MESSAGE_ERROR: - alert_bar = E_ALERT_BAR (priv->alert_bar); e_alert_bar_add_alert (alert_bar, alert); break; @@ -798,11 +803,11 @@ mail_browser_get_alert_sink (EMailReader *reader) static EMailBackend * mail_browser_get_backend (EMailReader *reader) { - EMailBrowserPrivate *priv; + EMailBrowser *browser; - priv = E_MAIL_BROWSER (reader)->priv; + browser = E_MAIL_BROWSER (reader); - return priv->backend; + return browser->priv->backend; } static gboolean @@ -818,21 +823,21 @@ mail_browser_get_hide_deleted (EMailReader *reader) static EMFormatHTML * mail_browser_get_formatter (EMailReader *reader) { - EMailBrowserPrivate *priv; + EMailBrowser *browser; - priv = E_MAIL_BROWSER (reader)->priv; + browser = E_MAIL_BROWSER (reader); - return EM_FORMAT_HTML (priv->formatter); + return EM_FORMAT_HTML (browser->priv->formatter); } static GtkWidget * mail_browser_get_message_list (EMailReader *reader) { - EMailBrowserPrivate *priv; + EMailBrowser *browser; - priv = E_MAIL_BROWSER (reader)->priv; + browser = E_MAIL_BROWSER (reader); - return priv->message_list; + return browser->priv->message_list; } static GtkMenu * @@ -886,11 +891,11 @@ mail_browser_set_message (EMailReader *reader, static void mail_browser_show_search_bar (EMailReader *reader) { - EMailBrowserPrivate *priv; + EMailBrowser *browser; - priv = E_MAIL_BROWSER (reader)->priv; + browser = E_MAIL_BROWSER (reader); - gtk_widget_show (priv->search_bar); + gtk_widget_show (browser->priv->search_bar); } static void @@ -988,9 +993,7 @@ e_mail_browser_init (EMailBrowser *browser) GConfBridge *bridge; const gchar *prefix; - browser->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - browser, E_TYPE_MAIL_BROWSER, EMailBrowserPrivate); - + browser->priv = E_MAIL_BROWSER_GET_PRIVATE (browser); browser->priv->formatter = em_format_html_display_new (); bridge = gconf_bridge_get (); diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index aa3c4bd3d2..7461e595f3 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -32,6 +32,10 @@ #include "mail/em-composer-utils.h" #include "mail/em-utils.h" +#define E_MAIL_DISPLAY_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_DISPLAY, EMailDisplayPrivate)) + struct _EMailDisplayPrivate { EMFormatHTML *formatter; }; @@ -41,8 +45,6 @@ enum { PROP_FORMATTER }; -static gpointer parent_class; - static const gchar *ui = "<ui>" " <popup name='context'>" @@ -99,6 +101,8 @@ static GtkActionEntry mailto_entries[] = { NULL } }; +G_DEFINE_TYPE (EMailDisplay, e_mail_display, E_TYPE_WEB_VIEW) + static void mail_display_update_formatter_colors (EMailDisplay *display) { @@ -179,7 +183,7 @@ mail_display_dispose (GObject *object) { EMailDisplayPrivate *priv; - priv = E_MAIL_DISPLAY (object)->priv; + priv = E_MAIL_DISPLAY_GET_PRIVATE (object); if (priv->formatter) { g_object_unref (priv->formatter); @@ -187,14 +191,14 @@ mail_display_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_mail_display_parent_class)->dispose (object); } static void mail_display_realize (GtkWidget *widget) { /* Chain up to parent's realize() method. */ - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (e_mail_display_parent_class)->realize (widget); mail_display_update_formatter_colors (E_MAIL_DISPLAY (widget)); } @@ -205,10 +209,11 @@ mail_display_style_set (GtkWidget *widget, { EMailDisplayPrivate *priv; - priv = E_MAIL_DISPLAY (widget)->priv; + priv = E_MAIL_DISPLAY_GET_PRIVATE (widget); /* Chain up to parent's style_set() method. */ - GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style); + GTK_WIDGET_CLASS (e_mail_display_parent_class)-> + style_set (widget, previous_style); mail_display_update_formatter_colors (E_MAIL_DISPLAY (widget)); em_format_queue_redraw (EM_FORMAT (priv->formatter)); @@ -220,14 +225,15 @@ mail_display_load_string (EWebView *web_view, { EMailDisplayPrivate *priv; - priv = E_MAIL_DISPLAY (web_view)->priv; + priv = E_MAIL_DISPLAY_GET_PRIVATE (web_view); g_return_if_fail (priv->formatter != NULL); if (em_format_busy (EM_FORMAT (priv->formatter))) return; /* Chain up to parent's load_string() method. */ - E_WEB_VIEW_CLASS (parent_class)->load_string (web_view, string); + E_WEB_VIEW_CLASS (e_mail_display_parent_class)-> + load_string (web_view, string); } static void @@ -253,7 +259,7 @@ mail_display_process_mailto (EWebView *web_view, CamelFolder *folder = NULL; EShell *shell; - priv = E_MAIL_DISPLAY (web_view)->priv; + priv = E_MAIL_DISPLAY_GET_PRIVATE (web_view); g_return_val_if_fail (priv->formatter != NULL, FALSE); format = EM_FORMAT (priv->formatter); @@ -277,7 +283,7 @@ mail_display_link_clicked (GtkHTML *html, { EMailDisplayPrivate *priv; - priv = E_MAIL_DISPLAY (html)->priv; + priv = E_MAIL_DISPLAY_GET_PRIVATE (html); g_return_if_fail (priv->formatter != NULL); if (g_str_has_prefix (uri, "##")) { @@ -331,19 +337,19 @@ mail_display_link_clicked (GtkHTML *html, else { /* Chain up to parent's link_clicked() method. */ - GTK_HTML_CLASS (parent_class)->link_clicked (html, uri); + GTK_HTML_CLASS (e_mail_display_parent_class)-> + link_clicked (html, uri); } } static void -mail_display_class_init (EMailDisplayClass *class) +e_mail_display_class_init (EMailDisplayClass *class) { GObjectClass *object_class; GtkWidgetClass *widget_class; EWebViewClass *web_view_class; GtkHTMLClass *html_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailDisplayPrivate)); object_class = G_OBJECT_CLASS (class); @@ -375,7 +381,7 @@ mail_display_class_init (EMailDisplayClass *class) } static void -mail_display_init (EMailDisplay *display) +e_mail_display_init (EMailDisplay *display) { EWebView *web_view; GtkUIManager *ui_manager; @@ -384,8 +390,7 @@ mail_display_init (EMailDisplay *display) web_view = E_WEB_VIEW (display); - display->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - display, E_TYPE_MAIL_DISPLAY, EMailDisplayPrivate); + display->priv = E_MAIL_DISPLAY_GET_PRIVATE (display); /* EWebView's action groups are added during its instance * initialization function (like what we're in now), so it @@ -407,32 +412,6 @@ mail_display_init (EMailDisplay *display) g_error ("%s", error->message); } -GType -e_mail_display_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailDisplayClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_display_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailDisplay), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_display_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_WEB_VIEW, "EMailDisplay", &type_info, 0); - } - - return type; -} - EMFormatHTML * e_mail_display_get_formatter (EMailDisplay *display) { diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c index 4642bd71b1..277228071e 100644 --- a/mail/e-mail-folder-pane.c +++ b/mail/e-mail-folder-pane.c @@ -44,6 +44,10 @@ #include "mail/mail-tools.h" #include "mail/message-list.h" +#define E_MAIL_FOLDER_PANE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_FOLDER_PANE, EMailFolderPanePrivate)) + struct _EMailFolderPanePrivate { gint placeholder; }; @@ -165,10 +169,9 @@ e_mail_folder_pane_class_init (EMailFolderPaneClass *class) } static void -e_mail_folder_pane_init (EMailFolderPane *browser) +e_mail_folder_pane_init (EMailFolderPane *folder_pane) { - browser->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - browser, E_TYPE_MAIL_FOLDER_PANE, EMailFolderPanePrivate); + folder_pane->priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (folder_pane); } EMailView * diff --git a/mail/e-mail-label-action.c b/mail/e-mail-label-action.c index 0eb1dc9a91..b7d38a99a9 100644 --- a/mail/e-mail-label-action.c +++ b/mail/e-mail-label-action.c @@ -25,11 +25,15 @@ #include "e-mail-label-action.h" +#define E_MAIL_LABEL_ACTION_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_LABEL_ACTION, EMailLabelActionPrivate)) + struct _EMailLabelActionPrivate { gint placeholder; }; -static gpointer parent_class; +G_DEFINE_TYPE (EMailLabelAction, e_mail_label_action, GTK_TYPE_TOGGLE_ACTION) static void mail_label_action_menu_item_realize_cb (GtkWidget *menu_item) @@ -92,11 +96,10 @@ mail_label_action_create_menu_item (GtkAction *action) } static void -mail_label_action_class_init (EMailLabelActionClass *class) +e_mail_label_action_class_init (EMailLabelActionClass *class) { GtkActionClass *action_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailLabelActionPrivate)); action_class = GTK_ACTION_CLASS (class); @@ -104,37 +107,9 @@ mail_label_action_class_init (EMailLabelActionClass *class) } static void -mail_label_action_init (EMailLabelAction *action) -{ - action->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - action, E_TYPE_MAIL_LABEL_ACTION, EMailLabelActionPrivate); -} - -GType -e_mail_label_action_get_type (void) +e_mail_label_action_init (EMailLabelAction *action) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailLabelActionClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_label_action_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailLabelAction), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_label_action_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_TOGGLE_ACTION, - "EMailLabelAction", &type_info, 0); - } - - return type; + action->priv = E_MAIL_LABEL_ACTION_GET_PRIVATE (action); } EMailLabelAction * diff --git a/mail/e-mail-label-dialog.c b/mail/e-mail-label-dialog.c index cb29cc6932..15222cc7b4 100644 --- a/mail/e-mail-label-dialog.c +++ b/mail/e-mail-label-dialog.c @@ -27,6 +27,10 @@ #include <glib/gi18n.h> +#define E_MAIL_LABEL_DIALOG_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_LABEL_DIALOG, EMailLabelDialogPrivate)) + struct _EMailLabelDialogPrivate { GtkWidget *entry; GtkWidget *colorsel; @@ -38,7 +42,7 @@ enum { PROP_LABEL_NAME }; -static gpointer parent_class; +G_DEFINE_TYPE (EMailLabelDialog, e_mail_label_dialog, GTK_TYPE_DIALOG) static void mail_label_dialog_entry_changed_cb (EMailLabelDialog *dialog) @@ -106,7 +110,7 @@ mail_label_dialog_dispose (GObject *object) { EMailLabelDialogPrivate *priv; - priv = E_MAIL_LABEL_DIALOG (object)->priv; + priv = E_MAIL_LABEL_DIALOG_GET_PRIVATE (object); if (priv->entry != NULL) { g_object_unref (priv->entry); @@ -119,7 +123,7 @@ mail_label_dialog_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_mail_label_dialog_parent_class)->dispose (object); } static void @@ -140,15 +144,14 @@ mail_label_dialog_constructed (GObject *object) gtk_container_set_border_width (GTK_CONTAINER (content_area), 0); /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); + G_OBJECT_CLASS (e_mail_label_dialog_parent_class)->constructed (object); } static void -mail_label_dialog_class_init (EMailLabelDialogClass *class) +e_mail_label_dialog_class_init (EMailLabelDialogClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailLabelDialogPrivate)); object_class = G_OBJECT_CLASS (class); @@ -179,14 +182,13 @@ mail_label_dialog_class_init (EMailLabelDialogClass *class) } static void -mail_label_dialog_init (EMailLabelDialog *dialog) +e_mail_label_dialog_init (EMailLabelDialog *dialog) { GtkWidget *content_area; GtkWidget *container; GtkWidget *widget; - dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - dialog, E_TYPE_MAIL_LABEL_DIALOG, EMailLabelDialogPrivate); + dialog->priv = E_MAIL_LABEL_DIALOG_GET_PRIVATE (dialog); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); @@ -234,32 +236,6 @@ mail_label_dialog_init (EMailLabelDialog *dialog) gtk_widget_show (widget); } -GType -e_mail_label_dialog_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailLabelDialogClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_label_dialog_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailLabelDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_label_dialog_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_DIALOG, "EMailLabelDialog", &type_info, 0); - } - - return type; -} - GtkWidget * e_mail_label_dialog_new (GtkWindow *parent) { diff --git a/mail/e-mail-label-list-store.c b/mail/e-mail-label-list-store.c index f604893bb3..bcc915ccc4 100644 --- a/mail/e-mail-label-list-store.c +++ b/mail/e-mail-label-list-store.c @@ -29,6 +29,10 @@ #include <camel/camel.h> #include "e-util/gconf-bridge.h" +#define E_MAIL_LABEL_LIST_STORE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_LABEL_LIST_STORE, EMailLabelListStorePrivate)) + struct _EMailLabelListStorePrivate { GHashTable *tag_index; }; @@ -45,7 +49,17 @@ static struct { { N_("_Later"), "#75507B", "$Labellater" } /* purple */ }; -static gpointer parent_class; +/* Forward Declarations */ +static void e_mail_label_list_store_interface_init + (GtkTreeModelIface *interface); + +G_DEFINE_TYPE_WITH_CODE ( + EMailLabelListStore, + e_mail_label_list_store, + GTK_TYPE_LIST_STORE, + G_IMPLEMENT_INTERFACE ( + GTK_TYPE_TREE_MODEL, + e_mail_label_list_store_interface_init)) static gchar * mail_label_list_store_tag_from_name (const gchar *label_name) @@ -157,12 +171,13 @@ mail_label_list_store_finalize (GObject *object) { EMailLabelListStorePrivate *priv; - priv = E_MAIL_LABEL_LIST_STORE (object)->priv; + priv = E_MAIL_LABEL_LIST_STORE_GET_PRIVATE (object); g_hash_table_destroy (priv->tag_index); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_mail_label_list_store_parent_class)-> + finalize (object); } static void @@ -182,7 +197,8 @@ mail_label_list_store_constructed (GObject *object) mail_label_list_store_ensure_defaults (store); /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); + G_OBJECT_CLASS (e_mail_label_list_store_parent_class)-> + constructed (object); } static void @@ -212,11 +228,10 @@ mail_label_list_store_row_inserted (GtkTreeModel *model, } static void -mail_label_list_store_class_init (EMailLabelListStoreClass *class) +e_mail_label_list_store_class_init (EMailLabelListStoreClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailLabelListStorePrivate)); object_class = G_OBJECT_CLASS (class); @@ -228,7 +243,13 @@ mail_label_list_store_class_init (EMailLabelListStoreClass *class) } static void -mail_label_list_store_init (EMailLabelListStore *store) +e_mail_label_list_store_interface_init (GtkTreeModelIface *interface) +{ + interface->row_inserted = mail_label_list_store_row_inserted; +} + +static void +e_mail_label_list_store_init (EMailLabelListStore *store) { GHashTable *tag_index; GType type = G_TYPE_STRING; @@ -238,9 +259,7 @@ mail_label_list_store_init (EMailLabelListStore *store) (GDestroyNotify) g_free, (GDestroyNotify) gtk_tree_row_reference_free); - store->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - store, E_TYPE_MAIL_LABEL_LIST_STORE, - EMailLabelListStorePrivate); + store->priv = E_MAIL_LABEL_LIST_STORE_GET_PRIVATE (store); store->priv->tag_index = tag_index; /* XXX While it may seem awkward to cram the label name and color @@ -253,48 +272,6 @@ mail_label_list_store_init (EMailLabelListStore *store) gtk_list_store_set_column_types (GTK_LIST_STORE (store), 1, &type); } -static void -mail_label_list_store_iface_init (GtkTreeModelIface *iface) -{ - iface->row_inserted = mail_label_list_store_row_inserted; -} - -GType -e_mail_label_list_store_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailLabelListStoreClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_label_list_store_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailLabelListStore), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_label_list_store_init, - NULL /* vaule_table */ - }; - - static const GInterfaceInfo iface_info = { - (GInterfaceInitFunc) mail_label_list_store_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - - type = g_type_register_static ( - GTK_TYPE_LIST_STORE, "EMailLabelListStore", - &type_info, 0); - - g_type_add_interface_static ( - type, GTK_TYPE_TREE_MODEL, &iface_info); - } - - return type; -} - EMailLabelListStore * e_mail_label_list_store_new (void) { diff --git a/mail/e-mail-label-manager.c b/mail/e-mail-label-manager.c index e5fd6ebcc2..5b2990bd84 100644 --- a/mail/e-mail-label-manager.c +++ b/mail/e-mail-label-manager.c @@ -29,6 +29,10 @@ #include "e-mail-label-dialog.h" #include "e-mail-label-tree-view.h" +#define E_MAIL_LABEL_MANAGER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_LABEL_MANAGER, EMailLabelManagerPrivate)) + struct _EMailLabelManagerPrivate { GtkWidget *tree_view; GtkWidget *add_button; @@ -48,9 +52,10 @@ enum { LAST_SIGNAL }; -static gpointer parent_class; static guint signals[LAST_SIGNAL]; +G_DEFINE_TYPE (EMailLabelManager, e_mail_label_manager, GTK_TYPE_TABLE) + static void mail_label_manager_selection_changed_cb (EMailLabelManager *manager, GtkTreeSelection *selection) @@ -121,7 +126,7 @@ mail_label_manager_dispose (GObject *object) { EMailLabelManagerPrivate *priv; - priv = E_MAIL_LABEL_MANAGER (object)->priv; + priv = E_MAIL_LABEL_MANAGER_GET_PRIVATE (object); if (priv->tree_view != NULL) { g_object_unref (priv->tree_view); @@ -144,7 +149,7 @@ mail_label_manager_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_mail_label_manager_parent_class)->dispose (object); } static void @@ -248,11 +253,10 @@ mail_label_manager_remove_label (EMailLabelManager *manager) } static void -mail_label_manager_class_init (EMailLabelManagerClass *class) +e_mail_label_manager_class_init (EMailLabelManagerClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailLabelManagerPrivate)); object_class = G_OBJECT_CLASS (class); @@ -303,14 +307,13 @@ mail_label_manager_class_init (EMailLabelManagerClass *class) } static void -mail_label_manager_init (EMailLabelManager *manager) +e_mail_label_manager_init (EMailLabelManager *manager) { GtkTreeSelection *selection; GtkWidget *container; GtkWidget *widget; - manager->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - manager, E_TYPE_MAIL_LABEL_MANAGER, EMailLabelManagerPrivate); + manager->priv = E_MAIL_LABEL_MANAGER_GET_PRIVATE (manager); gtk_table_resize (GTK_TABLE (manager), 2, 2); gtk_table_set_col_spacings (GTK_TABLE (manager), 6); @@ -394,32 +397,6 @@ mail_label_manager_init (EMailLabelManager *manager) G_CALLBACK (e_mail_label_manager_remove_label), manager); } -GType -e_mail_label_manager_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailLabelManagerClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_label_manager_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailLabelManager), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_label_manager_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_TABLE, "EMailLabelManager", &type_info, 0); - } - - return type; -} - GtkWidget * e_mail_label_manager_new (void) { diff --git a/mail/e-mail-label-tree-view.c b/mail/e-mail-label-tree-view.c index e5a8e50832..62589b4028 100644 --- a/mail/e-mail-label-tree-view.c +++ b/mail/e-mail-label-tree-view.c @@ -28,11 +28,15 @@ #include <glib/gi18n.h> #include "e-mail-label-list-store.h" +#define E_MAIL_LABEL_TREE_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_LABEL_TREE_VIEW, EMailLabelTreeViewPrivate)) + struct _EMailLabelTreeViewPrivate { gint placeholder; }; -static gpointer parent_class; +G_DEFINE_TYPE (EMailLabelTreeView, e_mail_label_tree_view, GTK_TYPE_TREE_VIEW) static void mail_label_tree_view_render_pixbuf (GtkTreeViewColumn *column, @@ -67,21 +71,18 @@ mail_label_tree_view_render_text (GtkTreeViewColumn *column, } static void -mail_label_tree_view_class_init (EMailLabelTreeViewClass *class) +e_mail_label_tree_view_class_init (EMailLabelTreeViewClass *class) { - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailLabelTreeViewPrivate)); } static void -mail_label_tree_view_init (EMailLabelTreeView *tree_view) +e_mail_label_tree_view_init (EMailLabelTreeView *tree_view) { GtkTreeViewColumn *column; GtkCellRenderer *renderer; - tree_view->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - tree_view, E_TYPE_MAIL_LABEL_TREE_VIEW, - EMailLabelTreeViewPrivate); + tree_view->priv = E_MAIL_LABEL_TREE_VIEW_GET_PRIVATE (tree_view); column = gtk_tree_view_column_new (); renderer = gtk_cell_renderer_pixbuf_new (); @@ -104,33 +105,6 @@ mail_label_tree_view_init (EMailLabelTreeView *tree_view) mail_label_tree_view_render_text, tree_view, NULL); } -GType -e_mail_label_tree_view_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailLabelTreeViewClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_label_tree_view_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailLabelTreeView), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_label_tree_view_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_TREE_VIEW, "EMailLabelTreeView", - &type_info, 0); - } - - return type; -} - GtkWidget * e_mail_label_tree_view_new (void) { diff --git a/mail/e-mail-message-pane.c b/mail/e-mail-message-pane.c index ed2e3a3337..bae8e85af9 100644 --- a/mail/e-mail-message-pane.c +++ b/mail/e-mail-message-pane.c @@ -30,6 +30,10 @@ #include "mail/e-mail-reader.h" +#define E_MAIL_MESSAGE_PANE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_MESSAGE_PANE, EMailMessagePanePrivate)) + struct _EMailMessagePanePrivate { gint placeholder; }; @@ -76,10 +80,9 @@ e_mail_message_pane_class_init (EMailMessagePaneClass *class) } static void -e_mail_message_pane_init (EMailMessagePane *browser) +e_mail_message_pane_init (EMailMessagePane *message_pane) { - browser->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - browser, E_TYPE_MAIL_MESSAGE_PANE, EMailMessagePanePrivate); + message_pane->priv = E_MAIL_MESSAGE_PANE_GET_PRIVATE (message_pane); } EMailView * diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c index aa6b373eaa..2e515f7315 100644 --- a/mail/e-mail-notebook-view.c +++ b/mail/e-mail-notebook-view.c @@ -45,6 +45,10 @@ #include "e-mail-tab-picker.h" #endif +#define E_MAIL_NOTEBOOK_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_NOTEBOOK_VIEW, EMailNotebookViewPrivate)) + struct _EMailNotebookViewPrivate { GtkNotebook *book; EMailView *current_view; @@ -124,7 +128,7 @@ mnv_page_changed (GtkNotebook *book, EMailView *mview; CamelFolder *folder; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + priv = E_MAIL_NOTEBOOK_VIEW_GET_PRIVATE (view); shell_view = e_mail_view_get_shell_view (view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); @@ -518,7 +522,7 @@ mail_notebook_view_constructed (GObject *object) ClutterTimeline *timeline; #endif - priv = E_MAIL_NOTEBOOK_VIEW (object)->priv; + priv = E_MAIL_NOTEBOOK_VIEW_GET_PRIVATE (object); container = GTK_WIDGET (object); @@ -638,26 +642,28 @@ mail_notebook_view_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (object)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (object); + current_view = notebook_view->priv->current_view; switch (property_id) { case PROP_FORWARD_STYLE: e_mail_reader_set_forward_style ( - E_MAIL_READER (priv->current_view), + E_MAIL_READER (current_view), g_value_get_enum (value)); return; case PROP_GROUP_BY_THREADS: e_mail_reader_set_group_by_threads ( - E_MAIL_READER (priv->current_view), + E_MAIL_READER (current_view), g_value_get_boolean (value)); return; case PROP_REPLY_STYLE: e_mail_reader_set_reply_style ( - E_MAIL_READER (priv->current_view), + E_MAIL_READER (current_view), g_value_get_enum (value)); return; } @@ -671,30 +677,32 @@ mail_notebook_view_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (object)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (object); + current_view = notebook_view->priv->current_view; switch (property_id) { case PROP_FORWARD_STYLE: g_value_set_enum ( value, e_mail_reader_get_forward_style ( - E_MAIL_READER (priv->current_view))); + E_MAIL_READER (current_view))); return; case PROP_GROUP_BY_THREADS: g_value_set_boolean ( value, e_mail_reader_get_group_by_threads ( - E_MAIL_READER (priv->current_view))); + E_MAIL_READER (current_view))); return; case PROP_REPLY_STYLE: g_value_set_enum ( value, e_mail_reader_get_reply_style ( - E_MAIL_READER (priv->current_view))); + E_MAIL_READER (current_view))); return; } @@ -705,118 +713,136 @@ static void mail_notebook_view_set_search_strings (EMailView *view, GSList *search_strings) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - e_mail_view_set_search_strings (priv->current_view, search_strings); + e_mail_view_set_search_strings (current_view, search_strings); } static GalViewInstance * mail_notebook_view_get_view_instance (EMailView *view) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return NULL; - return e_mail_view_get_view_instance (priv->current_view); + return e_mail_view_get_view_instance (current_view); } static void mail_notebook_view_update_view_instance (EMailView *view) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return; - e_mail_view_update_view_instance (priv->current_view); + e_mail_view_update_view_instance (current_view); } static void mail_notebook_view_set_orientation (EMailView *view, GtkOrientation orientation) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return; - e_mail_view_set_orientation (priv->current_view, orientation); + e_mail_view_set_orientation (current_view, orientation); } static GtkOrientation mail_notebook_view_get_orientation (EMailView *view) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return GTK_ORIENTATION_VERTICAL; - return e_mail_view_get_orientation (priv->current_view); + return e_mail_view_get_orientation (current_view); } static gboolean mail_notebook_view_get_show_deleted (EMailView *view) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return FALSE; - return e_mail_view_get_show_deleted (priv->current_view); + return e_mail_view_get_show_deleted (current_view); } static void mail_notebook_view_set_show_deleted (EMailView *view, gboolean show_deleted) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return; - e_mail_view_set_show_deleted (priv->current_view, show_deleted); + e_mail_view_set_show_deleted (current_view, show_deleted); } static gboolean mail_notebook_view_get_preview_visible (EMailView *view) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return FALSE; - return e_mail_view_get_preview_visible (priv->current_view); + return e_mail_view_get_preview_visible (current_view); } static void mail_notebook_view_set_preview_visible (EMailView *view, gboolean preview_visible) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (view)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (view); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return; - e_mail_view_set_preview_visible (priv->current_view, preview_visible); + e_mail_view_set_preview_visible (current_view, preview_visible); } static GtkActionGroup * @@ -877,27 +903,33 @@ mail_notebook_view_get_backend (EMailReader *reader) static EMFormatHTML * mail_notebook_view_get_formatter (EMailReader *reader) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (reader); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return NULL; - return e_mail_reader_get_formatter (E_MAIL_READER (priv->current_view)); + reader = E_MAIL_READER (current_view); + + return e_mail_reader_get_formatter (reader); } static gboolean mail_notebook_view_get_hide_deleted (EMailReader *reader) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (reader); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return FALSE; - reader = E_MAIL_READER (priv->current_view); + reader = E_MAIL_READER (current_view); return e_mail_reader_get_hide_deleted (reader); } @@ -905,14 +937,16 @@ mail_notebook_view_get_hide_deleted (EMailReader *reader) static GtkWidget * mail_notebook_view_get_message_list (EMailReader *reader) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (reader); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return NULL; - reader = E_MAIL_READER (priv->current_view); + reader = E_MAIL_READER (current_view); return e_mail_reader_get_message_list (reader); } @@ -920,14 +954,16 @@ mail_notebook_view_get_message_list (EMailReader *reader) static GtkMenu * mail_notebook_view_get_popup_menu (EMailReader *reader) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (reader); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return NULL; - reader = E_MAIL_READER (priv->current_view); + reader = E_MAIL_READER (current_view); return e_mail_reader_get_popup_menu (reader); } @@ -1166,7 +1202,7 @@ mail_notebook_view_set_folder (EMailReader *reader, if (folder == NULL) return; - priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + priv = E_MAIL_NOTEBOOK_VIEW_GET_PRIVATE (reader); folder_uri = e_mail_folder_uri_from_folder (folder); new_view = g_hash_table_lookup (priv->views, folder_uri); @@ -1318,14 +1354,16 @@ mail_notebook_view_set_folder (EMailReader *reader, static void mail_notebook_view_show_search_bar (EMailReader *reader) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (reader); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return; - reader = E_MAIL_READER (priv->current_view); + reader = E_MAIL_READER (current_view); e_mail_reader_show_search_bar (reader); } @@ -1333,25 +1371,33 @@ mail_notebook_view_show_search_bar (EMailReader *reader) static gboolean mail_notebook_view_enable_show_folder (EMailReader *reader) { - EMailNotebookViewPrivate *priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - if (!priv->current_view) + notebook_view = E_MAIL_NOTEBOOK_VIEW (reader); + current_view = notebook_view->priv->current_view; + + if (current_view == NULL) return FALSE; - return e_mail_reader_get_enable_show_folder (E_MAIL_READER (priv->current_view)); + reader = E_MAIL_READER (current_view); + + return e_mail_reader_get_enable_show_folder (reader); } static guint mail_notebook_view_open_selected_mail (EMailReader *reader) { - EMailNotebookViewPrivate *priv; + EMailNotebookView *notebook_view; + EMailView *current_view; - priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv; + notebook_view = E_MAIL_NOTEBOOK_VIEW (reader); + current_view = notebook_view->priv->current_view; - if (priv->current_view == NULL) + if (current_view == NULL) return 0; - reader = E_MAIL_READER (priv->current_view); + reader = E_MAIL_READER (current_view); return e_mail_reader_open_selected_mail (reader); } @@ -1419,9 +1465,7 @@ e_mail_notebook_view_reader_init (EMailReaderInterface *interface) static void e_mail_notebook_view_init (EMailNotebookView *view) { - view->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - view, E_TYPE_MAIL_NOTEBOOK_VIEW, EMailNotebookViewPrivate); - + view->priv = E_MAIL_NOTEBOOK_VIEW_GET_PRIVATE (view); view->priv->inited = FALSE; view->priv->views = g_hash_table_new (g_str_hash, g_str_equal); } diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c index 84e7894fd5..542a15d420 100644 --- a/mail/e-mail-paned-view.c +++ b/mail/e-mail-paned-view.c @@ -46,6 +46,10 @@ #include "e-mail-folder-utils.h" #include "e-mail-reader-utils.h" +#define E_MAIL_PANED_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_PANED_VIEW, EMailPanedViewPrivate)) + #define E_SHELL_WINDOW_ACTION_GROUP_MAIL(window) \ E_SHELL_WINDOW_ACTION_GROUP ((window), "mail") @@ -129,7 +133,7 @@ mail_paned_view_message_list_built_cb (EMailView *view, EShellWindow *shell_window; GKeyFile *key_file; - priv = E_MAIL_PANED_VIEW (view)->priv; + priv = E_MAIL_PANED_VIEW_GET_PRIVATE (view); g_signal_handler_disconnect ( message_list, priv->message_list_built_id); @@ -216,22 +220,19 @@ mail_paned_view_restore_state_cb (EShellWindow *shell_window, EShellView *shell_view, EMailPanedView *view) { - EMailPanedViewPrivate *priv; GConfBridge *bridge; GObject *object; const gchar *key; - priv = E_MAIL_PANED_VIEW (view)->priv; - /* Bind GObject properties to GConf keys. */ bridge = gconf_bridge_get (); - object = G_OBJECT (priv->paned); + object = G_OBJECT (view->priv->paned); key = "/apps/evolution/mail/display/hpaned_size"; gconf_bridge_bind_property (bridge, key, object, "hposition"); - object = G_OBJECT (priv->paned); + object = G_OBJECT (view->priv->paned); key = "/apps/evolution/mail/display/paned_size"; gconf_bridge_bind_property (bridge, key, object, "vposition"); } @@ -330,7 +331,7 @@ mail_paned_view_dispose (GObject *object) { EMailPanedViewPrivate *priv; - priv = E_MAIL_PANED_VIEW (object)->priv; + priv = E_MAIL_PANED_VIEW_GET_PRIVATE (object); if (priv->paned != NULL) { g_object_unref (priv->paned); @@ -424,11 +425,11 @@ mail_paned_view_get_backend (EMailReader *reader) static EMFormatHTML * mail_paned_view_get_formatter (EMailReader *reader) { - EMailPanedViewPrivate *priv; + EMailPanedView *paned_view; - priv = E_MAIL_PANED_VIEW (reader)->priv; + paned_view = E_MAIL_PANED_VIEW (reader); - return EM_FORMAT_HTML (priv->formatter); + return EM_FORMAT_HTML (paned_view->priv->formatter); } static gboolean @@ -440,11 +441,11 @@ mail_paned_view_get_hide_deleted (EMailReader *reader) static GtkWidget * mail_paned_view_get_message_list (EMailReader *reader) { - EMailPanedViewPrivate *priv; + EMailPanedView *paned_view; - priv = E_MAIL_PANED_VIEW (reader)->priv; + paned_view = E_MAIL_PANED_VIEW (reader); - return priv->message_list; + return paned_view->priv->message_list; } static GtkMenu * @@ -499,7 +500,7 @@ mail_paned_view_set_folder (EMailReader *reader, gboolean value; GError *error = NULL; - priv = E_MAIL_PANED_VIEW (reader)->priv; + priv = E_MAIL_PANED_VIEW_GET_PRIVATE (reader); view = E_MAIL_VIEW (reader); shell_view = e_mail_view_get_shell_view (view); @@ -576,28 +577,35 @@ exit: static void mail_paned_view_show_search_bar (EMailReader *reader) { - EMailPanedViewPrivate *priv; + EMailPanedView *paned_view; - priv = E_MAIL_PANED_VIEW (reader)->priv; + paned_view = E_MAIL_PANED_VIEW (reader); - gtk_widget_show (priv->search_bar); + gtk_widget_show (paned_view->priv->search_bar); } static guint mail_paned_view_reader_open_selected_mail (EMailReader *reader) { - return E_MAIL_PANED_VIEW_GET_CLASS (reader)-> - open_selected_mail (E_MAIL_PANED_VIEW (reader)); + EMailPanedView *paned_view; + EMailPanedViewClass *class; + + paned_view = E_MAIL_PANED_VIEW (reader); + + class = E_MAIL_PANED_VIEW_GET_CLASS (paned_view); + g_return_val_if_fail (class->open_selected_mail != NULL, 0); + + return class->open_selected_mail (paned_view); } static gboolean mail_paned_view_enable_show_folder (EMailReader *reader) { - EMailPanedViewPrivate *priv; + EMailPanedView *paned_view; - priv = E_MAIL_PANED_VIEW (reader)->priv; + paned_view = E_MAIL_PANED_VIEW (reader); - return priv->enable_show_folder ? TRUE : FALSE; + return paned_view->priv->enable_show_folder; } static void @@ -617,7 +625,7 @@ mail_paned_view_constructed (GObject *object) GtkWidget *widget; EWebView *web_view; - priv = E_MAIL_PANED_VIEW (object)->priv; + priv = E_MAIL_PANED_VIEW_GET_PRIVATE (object); priv->formatter = em_format_html_display_new (); view = E_MAIL_VIEW (object); @@ -732,13 +740,13 @@ static void mail_paned_view_set_search_strings (EMailView *view, GSList *search_strings) { - EMailPanedViewPrivate *priv; + EMailPanedView *paned_view; ESearchBar *search_bar; ESearchingTokenizer *tokenizer; - priv = E_MAIL_PANED_VIEW (view)->priv; + paned_view = E_MAIL_PANED_VIEW (view); - search_bar = E_SEARCH_BAR (priv->search_bar); + search_bar = E_SEARCH_BAR (paned_view->priv->search_bar); tokenizer = e_search_bar_get_tokenizer (search_bar); e_searching_tokenizer_set_secondary_case_sensitivity (tokenizer, FALSE); @@ -756,11 +764,11 @@ mail_paned_view_set_search_strings (EMailView *view, static GalViewInstance * mail_paned_view_get_view_instance (EMailView *view) { - EMailPanedViewPrivate *priv; + EMailPanedView *paned_view; - priv = E_MAIL_PANED_VIEW (view)->priv; + paned_view = E_MAIL_PANED_VIEW (view); - return priv->view_instance; + return paned_view->priv->view_instance; } static void @@ -782,7 +790,7 @@ mail_paned_view_update_view_instance (EMailView *view) gboolean show_vertical_view; gchar *view_id; - priv = E_MAIL_PANED_VIEW (view)->priv; + priv = E_MAIL_PANED_VIEW_GET_PRIVATE (view); shell_view = e_mail_view_get_shell_view (view); shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); @@ -1017,8 +1025,7 @@ e_mail_paned_view_reader_init (EMailReaderInterface *interface) static void e_mail_paned_view_init (EMailPanedView *view) { - view->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - view, E_TYPE_MAIL_PANED_VIEW, EMailPanedViewPrivate); + view->priv = E_MAIL_PANED_VIEW_GET_PRIVATE (view); view->priv->enable_show_folder = FALSE; g_signal_connect ( diff --git a/mail/e-mail-tab-picker.c b/mail/e-mail-tab-picker.c index cc257284dc..8732d4a9c1 100644 --- a/mail/e-mail-tab-picker.c +++ b/mail/e-mail-tab-picker.c @@ -22,6 +22,10 @@ #include "e-mail-tab-picker.h" +#define E_MAIL_TAB_PICKER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_TAB_PICKER, EMailTabPickerPrivate)) + static void mx_droppable_iface_init (MxDroppableIface *iface); static gint e_mail_tab_picker_find_tab_cb (gconstpointer a, gconstpointer b); @@ -277,8 +281,9 @@ e_mail_tab_picker_paint (ClutterActor *actor) { GList *t; gfloat width, height, offset; + EMailTabPickerPrivate *priv; - EMailTabPickerPrivate *priv = E_MAIL_TAB_PICKER (actor)->priv; + priv = E_MAIL_TAB_PICKER_GET_PRIVATE (actor); CLUTTER_ACTOR_CLASS (e_mail_tab_picker_parent_class)->paint (actor); @@ -346,7 +351,9 @@ static void e_mail_tab_picker_pick (ClutterActor *actor, const ClutterColor *color) { - EMailTabPickerPrivate *priv = E_MAIL_TAB_PICKER (actor)->priv; + EMailTabPickerPrivate *priv; + + priv = E_MAIL_TAB_PICKER_GET_PRIVATE (actor); /* Chain up to paint background */ CLUTTER_ACTOR_CLASS (e_mail_tab_picker_parent_class)->pick (actor, color); @@ -363,8 +370,9 @@ e_mail_tab_picker_get_preferred_width (ClutterActor *actor, { GList *t; MxPadding padding; + EMailTabPickerPrivate *priv; - EMailTabPickerPrivate *priv = E_MAIL_TAB_PICKER (actor)->priv; + priv = E_MAIL_TAB_PICKER_GET_PRIVATE (actor); clutter_actor_get_preferred_width ( CLUTTER_ACTOR (priv->chooser_button), @@ -740,7 +748,9 @@ static void e_mail_tab_picker_map (ClutterActor *actor) { GList *t; - EMailTabPickerPrivate *priv = E_MAIL_TAB_PICKER (actor)->priv; + EMailTabPickerPrivate *priv; + + priv = E_MAIL_TAB_PICKER_GET_PRIVATE (actor); CLUTTER_ACTOR_CLASS (e_mail_tab_picker_parent_class)->map (actor); @@ -758,7 +768,9 @@ static void e_mail_tab_picker_unmap (ClutterActor *actor) { GList *t; - EMailTabPickerPrivate *priv = E_MAIL_TAB_PICKER (actor)->priv; + EMailTabPickerPrivate *priv; + + priv = E_MAIL_TAB_PICKER_GET_PRIVATE (actor); CLUTTER_ACTOR_CLASS (e_mail_tab_picker_parent_class)->unmap (actor); @@ -817,7 +829,7 @@ e_mail_tab_picker_class_init (EMailTabPickerClass *class) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - E_MAIL_TYPE_TAB); + E_TYPE_MAIL_TAB); signals[CHOOSER_CLICKED] = g_signal_new ( "chooser-clicked", @@ -831,9 +843,9 @@ e_mail_tab_picker_class_init (EMailTabPickerClass *class) static void e_mail_tab_picker_chooser_clicked_cb (ClutterActor *button, - EMailTabPicker *self) + EMailTabPicker *picker) { - g_signal_emit (self, signals[CHOOSER_CLICKED], 0); + g_signal_emit (picker, signals[CHOOSER_CLICKED], 0); } static gboolean @@ -841,8 +853,8 @@ e_mail_tab_picker_scroll_event_cb (ClutterActor *actor, ClutterScrollEvent *event, gpointer user_data) { - EMailTabPicker *self = E_MAIL_TAB_PICKER (actor); - EMailTabPickerPrivate *priv = self->priv; + EMailTabPicker *picker = E_MAIL_TAB_PICKER (actor); + EMailTabPickerPrivate *priv = picker->priv; priv->keep_current_visible = FALSE; @@ -850,13 +862,13 @@ e_mail_tab_picker_scroll_event_cb (ClutterActor *actor, case CLUTTER_SCROLL_UP : case CLUTTER_SCROLL_LEFT : e_mail_tab_picker_scroll_to ( - self, priv->scroll_end - 200, 150); + picker, priv->scroll_end - 200, 150); break; case CLUTTER_SCROLL_DOWN : case CLUTTER_SCROLL_RIGHT : e_mail_tab_picker_scroll_to ( - self, priv->scroll_end + 200, 150); + picker, priv->scroll_end + 200, 150); break; } @@ -879,45 +891,48 @@ e_mail_tab_picker_scroll_value_cb (MxAdjustment *adjustment, } static void -e_mail_tab_picker_init (EMailTabPicker *self) +e_mail_tab_picker_init (EMailTabPicker *picker) { - EMailTabPickerPrivate *priv; - - priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - self, E_MAIL_TYPE_TAB_PICKER, EMailTabPickerPrivate); + picker->priv = E_MAIL_TAB_PICKER_GET_PRIVATE (picker); - clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); + clutter_actor_set_reactive (CLUTTER_ACTOR (picker), TRUE); - priv->chooser_button = mx_button_new (); + picker->priv->chooser_button = mx_button_new (); clutter_actor_set_name ( - CLUTTER_ACTOR (priv->chooser_button), "chooser-button"); + CLUTTER_ACTOR (picker->priv->chooser_button), + "chooser-button"); clutter_actor_set_parent ( - CLUTTER_ACTOR (priv->chooser_button), CLUTTER_ACTOR (self)); + CLUTTER_ACTOR (picker->priv->chooser_button), + CLUTTER_ACTOR (picker)); - priv->close_button = mx_button_new (); + picker->priv->close_button = mx_button_new (); clutter_actor_set_name ( - CLUTTER_ACTOR (priv->close_button), "chooser-close-button"); + CLUTTER_ACTOR (picker->priv->close_button), + "chooser-close-button"); clutter_actor_set_parent ( - CLUTTER_ACTOR (priv->close_button), CLUTTER_ACTOR (self)); - clutter_actor_hide (CLUTTER_ACTOR (priv->close_button)); + CLUTTER_ACTOR (picker->priv->close_button), + CLUTTER_ACTOR (picker)); + clutter_actor_hide (CLUTTER_ACTOR (picker->priv->close_button)); - priv->scroll_adjustment = + picker->priv->scroll_adjustment = mx_adjustment_new_with_values (0, 0, 0, 100, 200, 200); - priv->scroll_bar = - mx_scroll_bar_new_with_adjustment (priv->scroll_adjustment); - g_object_unref (priv->scroll_adjustment); + picker->priv->scroll_bar = + mx_scroll_bar_new_with_adjustment ( + picker->priv->scroll_adjustment); + g_object_unref (picker->priv->scroll_adjustment); clutter_actor_set_parent ( - CLUTTER_ACTOR (priv->scroll_bar), CLUTTER_ACTOR (self)); - clutter_actor_hide (CLUTTER_ACTOR (priv->scroll_bar)); + CLUTTER_ACTOR (picker->priv->scroll_bar), + CLUTTER_ACTOR (picker)); + clutter_actor_hide (CLUTTER_ACTOR (picker->priv->scroll_bar)); g_signal_connect ( - priv->chooser_button, "clicked", - G_CALLBACK (e_mail_tab_picker_chooser_clicked_cb), self); + picker->priv->chooser_button, "clicked", + G_CALLBACK (e_mail_tab_picker_chooser_clicked_cb), picker); g_signal_connect ( - priv->close_button, "clicked", - G_CALLBACK (e_mail_tab_picker_chooser_clicked_cb), self); + picker->priv->close_button, "clicked", + G_CALLBACK (e_mail_tab_picker_chooser_clicked_cb), picker); g_signal_connect ( - self, "scroll-event", + picker, "scroll-event", G_CALLBACK (e_mail_tab_picker_scroll_event_cb), NULL); } @@ -933,9 +948,9 @@ e_mail_tab_picker_find_tab_cb (gconstpointer a, static void e_mail_tab_picker_tab_clicked_cb (EMailTab *tab, - EMailTabPicker *self) + EMailTabPicker *picker) { - EMailTabPickerPrivate *priv = self->priv; + EMailTabPickerPrivate *priv = picker->priv; EMailTab *old_tab; GList *new_tab_link; @@ -953,7 +968,7 @@ e_mail_tab_picker_tab_clicked_cb (EMailTab *tab, if (tab == old_tab) { e_mail_tab_set_active (tab, TRUE); if (priv->preview_mode) - g_signal_emit (self, signals[TAB_ACTIVATED], 0, tab); + g_signal_emit (picker, signals[TAB_ACTIVATED], 0, tab); return; } @@ -962,13 +977,13 @@ e_mail_tab_picker_tab_clicked_cb (EMailTab *tab, /* Set new tab */ priv->current_tab = g_list_position (priv->tabs, new_tab_link); - g_signal_emit (self, signals[TAB_ACTIVATED], 0, tab); + g_signal_emit (picker, signals[TAB_ACTIVATED], 0, tab); } ClutterActor * e_mail_tab_picker_new (void) { - return g_object_new (E_MAIL_TYPE_TAB_PICKER, NULL); + return g_object_new (E_TYPE_MAIL_TAB_PICKER, NULL); } static void diff --git a/mail/e-mail-tab-picker.h b/mail/e-mail-tab-picker.h index 5d6ae61182..56a9b4ac43 100644 --- a/mail/e-mail-tab-picker.h +++ b/mail/e-mail-tab-picker.h @@ -16,95 +16,90 @@ * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef _E_MAIL_TAB_PICKER_H -#define _E_MAIL_TAB_PICKER_H +#ifndef E_MAIL_TAB_PICKER_H +#define E_MAIL_TAB_PICKER_H #include <clutter/clutter.h> #include <mx/mx.h> #include "e-mail-tab.h" -G_BEGIN_DECLS - -#define E_MAIL_TYPE_TAB_PICKER e_mail_tab_picker_get_type() - +/* Standard GObject macros */ +#define E_TYPE_MAIL_TAB_PICKER \ + (e_mail_tab_picker_get_type ()) #define E_MAIL_TAB_PICKER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - E_MAIL_TYPE_TAB_PICKER, EMailTabPicker)) - -#define E_MAIL_TAB_PICKER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - E_MAIL_TYPE_TAB_PICKER, EMailTabPickerClass)) - + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_TAB_PICKER, EMailTabPicker)) +#define E_MAIL_TAB_PICKER_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_TAB_PICKER, EMailTabPickerClass)) #define E_MAIL_IS_TAB_PICKER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - E_MAIL_TYPE_TAB_PICKER)) - -#define E_MAIL_IS_TAB_PICKER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - E_MAIL_TYPE_TAB_PICKER)) - + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_TAB_PICKER)) +#define E_MAIL_IS_TAB_PICKER_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MAIL_TAB_PICKER)) #define E_MAIL_TAB_PICKER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - E_MAIL_TYPE_TAB_PICKER, EMailTabPickerClass)) - -typedef struct _EMailTabPickerPrivate EMailTabPickerPrivate; - -typedef struct { - MxWidget parent; - - EMailTabPickerPrivate *priv; -} EMailTabPicker; - -typedef struct { - MxWidgetClass parent_class; - - void (* tab_activated) (EMailTabPicker *picker, EMailTab *tab); - void (* chooser_clicked) (EMailTabPicker *picker); -} EMailTabPickerClass; - -GType e_mail_tab_picker_get_type (void); - -ClutterActor *e_mail_tab_picker_new (void); + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MAIL_TAB_PICKER, EMailTabPickerClass)) -void e_mail_tab_picker_add_tab (EMailTabPicker *picker, EMailTab *tab, gint position); - -void e_mail_tab_picker_remove_tab (EMailTabPicker *picker, EMailTab *tab); - -GList *e_mail_tab_picker_get_tabs (EMailTabPicker *picker); - -gint e_mail_tab_picker_get_n_tabs (EMailTabPicker *picker); - -EMailTab *e_mail_tab_picker_get_tab (EMailTabPicker *picker, gint tab); - -gint e_mail_tab_picker_get_tab_no (EMailTabPicker *picker, EMailTab *tab); - -gint e_mail_tab_picker_get_current_tab (EMailTabPicker *picker); - -void e_mail_tab_picker_set_current_tab (EMailTabPicker *picker, gint tab); - -void e_mail_tab_picker_reorder (EMailTabPicker *picker, - gint old_position, - gint new_position); - -void e_mail_tab_picker_set_tab_width (EMailTabPicker *picker, - gint width); - -gint e_mail_tab_picker_get_tab_width (EMailTabPicker *picker); - -void -e_mail_tab_picker_get_preferred_height (EMailTabPicker *tab_picker, - gfloat for_width, - gfloat *min_height_p, - gfloat *natural_height_p, - gboolean with_previews); - -void e_mail_tab_picker_set_preview_mode (EMailTabPicker *picker, gboolean preview); +G_BEGIN_DECLS -gboolean e_mail_tab_picker_get_preview_mode (EMailTabPicker *picker); +typedef struct _EMailTabPicker EMailTabPicker; +typedef struct _EMailTabPickerClass EMailTabPickerClass; +typedef struct _EMailTabPickerPrivate EMailTabPickerPrivate; -void e_mail_tab_picker_enable_drop (EMailTabPicker *picker, gboolean enable); +struct _EMailTabPicker { + MxWidget parent; + EMailTabPickerPrivate *priv; +}; + +struct _EMailTabPickerClass { + MxWidgetClass parent_class; + + void (*tab_activated) (EMailTabPicker *picker, + EMailTab *tab); + void (*chooser_clicked) (EMailTabPicker *picker); +}; + +GType e_mail_tab_picker_get_type (void) G_GNUC_CONST; +ClutterActor * e_mail_tab_picker_new (void); +void e_mail_tab_picker_add_tab (EMailTabPicker *picker, + EMailTab *tab, + gint position); +void e_mail_tab_picker_remove_tab (EMailTabPicker *picker, + EMailTab *tab); +GList * e_mail_tab_picker_get_tabs (EMailTabPicker *picker); +gint e_mail_tab_picker_get_n_tabs (EMailTabPicker *picker); +EMailTab * e_mail_tab_picker_get_tab (EMailTabPicker *picker, + gint tab); +gint e_mail_tab_picker_get_tab_no (EMailTabPicker *picker, + EMailTab *tab); +gint e_mail_tab_picker_get_current_tab + (EMailTabPicker *picker); +void e_mail_tab_picker_set_current_tab + (EMailTabPicker *picker, + gint tab); +void e_mail_tab_picker_reorder (EMailTabPicker *picker, + gint old_position, + gint new_position); +void e_mail_tab_picker_set_tab_width (EMailTabPicker *picker, + gint width); +gint e_mail_tab_picker_get_tab_width (EMailTabPicker *picker); +void e_mail_tab_picker_get_preferred_height + (EMailTabPicker *tab_picker, + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p, + gboolean with_previews); +void e_mail_tab_picker_set_preview_mode + (EMailTabPicker *picker, + gboolean preview); +gboolean e_mail_tab_picker_get_preview_mode + (EMailTabPicker *picker); +void e_mail_tab_picker_enable_drop (EMailTabPicker *picker, + gboolean enable); G_END_DECLS -#endif /* _E_MAIL_TAB_PICKER_H */ +#endif /* E_MAIL_TAB_PICKER_H */ diff --git a/mail/e-mail-tab.c b/mail/e-mail-tab.c index cb461c28f3..b50b14fe2b 100644 --- a/mail/e-mail-tab.c +++ b/mail/e-mail-tab.c @@ -25,6 +25,10 @@ #include <gtk/gtk.h> #include "e-mail-tab.h" +#define E_MAIL_TAB_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_TAB, EMailTabPrivate)) + #define E_MAIL_PIXBOUND(u) ((gfloat)((gint)(u))) static void mx_draggable_iface_init (MxDraggableIface *iface); @@ -115,13 +119,13 @@ e_mail_tab_drag_begin (MxDraggable *draggable, gint event_button, ClutterModifierType modifiers) { - gfloat x, y; - - EMailTabPrivate *priv = E_MAIL_TAB (draggable)->priv; + EMailTabPrivate *priv; ClutterActor *self = CLUTTER_ACTOR (draggable); ClutterActor *actor = mx_draggable_get_drag_actor (draggable); ClutterActor *stage = clutter_actor_get_stage (self); + gfloat x, y; + priv = E_MAIL_TAB_GET_PRIVATE (draggable); priv->in_drag = TRUE; clutter_actor_get_transformed_position (self, &x, &y); @@ -489,8 +493,10 @@ e_mail_tab_get_preferred_width (ClutterActor *actor, gfloat *min_width_p, gfloat *natural_width_p) { + EMailTabPrivate *priv; MxPadding padding; - EMailTabPrivate *priv = E_MAIL_TAB (actor)->priv; + + priv = E_MAIL_TAB_GET_PRIVATE (actor); /* Get padding */ mx_widget_get_padding (MX_WIDGET (actor), &padding); @@ -658,6 +664,7 @@ e_mail_tab_allocate (ClutterActor *actor, const ClutterActorBox *box, ClutterAllocationFlags flags) { + EMailTabPrivate *priv; MxPadding padding; ClutterActorBox child_box; gfloat icon_width, icon_height; @@ -665,7 +672,7 @@ e_mail_tab_allocate (ClutterActor *actor, gfloat close_width, close_height; gfloat preview_width, preview_height; - EMailTabPrivate *priv = E_MAIL_TAB (actor)->priv; + priv = E_MAIL_TAB_GET_PRIVATE (actor); /* Chain up to store box */ CLUTTER_ACTOR_CLASS (e_mail_tab_parent_class)->allocate (actor, box, flags); @@ -815,7 +822,9 @@ e_mail_tab_allocate (ClutterActor *actor, static void e_mail_tab_paint (ClutterActor *actor) { - EMailTabPrivate *priv = E_MAIL_TAB (actor)->priv; + EMailTabPrivate *priv; + + priv = E_MAIL_TAB_GET_PRIVATE (actor); /* Chain up to paint background */ CLUTTER_ACTOR_CLASS (e_mail_tab_parent_class)->paint (actor); @@ -848,7 +857,9 @@ e_mail_tab_pick (ClutterActor *actor, static void e_mail_tab_map (ClutterActor *actor) { - EMailTabPrivate *priv = E_MAIL_TAB (actor)->priv; + EMailTabPrivate *priv; + + priv = E_MAIL_TAB_GET_PRIVATE (actor); CLUTTER_ACTOR_CLASS (e_mail_tab_parent_class)->map (actor); @@ -866,7 +877,9 @@ e_mail_tab_map (ClutterActor *actor) static void e_mail_tab_unmap (ClutterActor *actor) { - EMailTabPrivate *priv = E_MAIL_TAB (actor)->priv; + EMailTabPrivate *priv; + + priv = E_MAIL_TAB_GET_PRIVATE (actor); CLUTTER_ACTOR_CLASS (e_mail_tab_parent_class)->unmap (actor); @@ -885,7 +898,9 @@ static gboolean e_mail_tab_button_press_event (ClutterActor *actor, ClutterButtonEvent *event) { - EMailTabPrivate *priv = E_MAIL_TAB (actor)->priv; + EMailTabPrivate *priv; + + priv = E_MAIL_TAB_GET_PRIVATE (actor); if (event->button == 1) { mx_stylable_set_style_pseudo_class ( @@ -956,7 +971,9 @@ static gboolean e_mail_tab_enter_event (ClutterActor *actor, ClutterCrossingEvent *event) { - EMailTabPrivate *priv = E_MAIL_TAB (actor)->priv; + EMailTabPrivate *priv; + + priv = E_MAIL_TAB_GET_PRIVATE (actor); if (event->source != actor) return FALSE; @@ -977,7 +994,9 @@ static gboolean e_mail_tab_leave_event (ClutterActor *actor, ClutterCrossingEvent *event) { - EMailTabPrivate *priv = E_MAIL_TAB (actor)->priv; + EMailTabPrivate *priv; + + priv = E_MAIL_TAB_GET_PRIVATE (actor); if ((event->source != actor) || (event->related == (ClutterActor *) priv->close_button)) @@ -1216,7 +1235,9 @@ e_mail_tab_anim_completed_cb (ClutterAnimation *animation, static void e_mail_tab_style_changed_cb (MxWidget *widget) { - EMailTabPrivate *priv = E_MAIL_TAB (widget)->priv; + EMailTabPrivate *priv; + + priv = E_MAIL_TAB_GET_PRIVATE (widget); /* Don't transition on hover */ if (g_strcmp0 (mx_stylable_get_style_pseudo_class ( @@ -1284,61 +1305,59 @@ e_mail_tab_dnd_notify_cb (GObject *settings, } static void -e_mail_tab_init (EMailTab *self) +e_mail_tab_init (EMailTab *tab) { ClutterActor *text; GtkSettings *settings; - EMailTabPrivate *priv; - priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - self, E_MAIL_TYPE_TAB, EMailTabPrivate); + tab->priv = E_MAIL_TAB_GET_PRIVATE (tab); - priv->width = -1; - priv->anim_length = 200; - priv->spacing = 6.0; - priv->can_close = TRUE; + tab->priv->width = -1; + tab->priv->anim_length = 200; + tab->priv->spacing = 6.0; + tab->priv->can_close = TRUE; - priv->label = mx_label_new (); - g_object_set (priv->label, "clip-to-allocation", TRUE, NULL); - text = mx_label_get_clutter_text (MX_LABEL (priv->label)); + tab->priv->label = mx_label_new (); + g_object_set (tab->priv->label, "clip-to-allocation", TRUE, NULL); + text = mx_label_get_clutter_text (MX_LABEL (tab->priv->label)); clutter_text_set_ellipsize (CLUTTER_TEXT (text), PANGO_ELLIPSIZE_END); clutter_actor_set_parent ( - CLUTTER_ACTOR (priv->label), CLUTTER_ACTOR (self)); + CLUTTER_ACTOR (tab->priv->label), CLUTTER_ACTOR (tab)); - priv->close_button = mx_button_new (); + tab->priv->close_button = mx_button_new (); clutter_actor_set_name ( - CLUTTER_ACTOR (priv->close_button), "tab-close-button"); + CLUTTER_ACTOR (tab->priv->close_button), "tab-close-button"); clutter_actor_set_parent ( - CLUTTER_ACTOR (priv->close_button), CLUTTER_ACTOR (self)); + CLUTTER_ACTOR (tab->priv->close_button), CLUTTER_ACTOR (tab)); g_signal_connect ( - priv->close_button, "clicked", - G_CALLBACK (e_mail_tab_close_clicked_cb), self); + tab->priv->close_button, "clicked", + G_CALLBACK (e_mail_tab_close_clicked_cb), tab); /* Connect up styling signals */ g_signal_connect ( - self, "style-changed", + tab, "style-changed", G_CALLBACK (e_mail_tab_style_changed_cb), NULL); g_signal_connect ( - self, "stylable-changed", + tab, "stylable-changed", G_CALLBACK (e_mail_tab_stylable_changed_cb), NULL); - clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); + clutter_actor_set_reactive (CLUTTER_ACTOR (tab), TRUE); settings = gtk_settings_get_default (); - priv->drag_threshold_handler = g_signal_connect ( + tab->priv->drag_threshold_handler = g_signal_connect ( settings, "notify::gtk-dnd-drag-threshold", - G_CALLBACK (e_mail_tab_dnd_notify_cb), self); + G_CALLBACK (e_mail_tab_dnd_notify_cb), tab); g_object_get ( G_OBJECT (settings), - "gtk-dnd-drag-threshold", &priv->drag_threshold, + "gtk-dnd-drag-threshold", &tab->priv->drag_threshold, NULL); } ClutterActor * e_mail_tab_new (void) { - return g_object_new (E_MAIL_TYPE_TAB, NULL); + return g_object_new (E_TYPE_MAIL_TAB, NULL); } ClutterActor * @@ -1347,7 +1366,7 @@ e_mail_tab_new_full (const gchar *text, gint width) { return g_object_new ( - E_MAIL_TYPE_TAB, + E_TYPE_MAIL_TAB, "text", text, "icon", icon, "tab-width", width, diff --git a/mail/e-mail-tab.h b/mail/e-mail-tab.h index b8f9abf18e..5f3f8666b8 100644 --- a/mail/e-mail-tab.h +++ b/mail/e-mail-tab.h @@ -16,92 +16,100 @@ * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef _E_MAIL_TAB_H -#define _E_MAIL_TAB_H +#ifndef E_MAIL_TAB_H +#define E_MAIL_TAB_H #include <clutter/clutter.h> #include <mx/mx.h> -G_BEGIN_DECLS - -#define E_MAIL_TYPE_TAB e_mail_tab_get_type() - +/* Standard GObject macros */ +#define E_TYPE_MAIL_TAB \ + (e_mail_tab_get_type ()) #define E_MAIL_TAB(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - E_MAIL_TYPE_TAB, EMailTab)) - -#define E_MAIL_TAB_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - E_MAIL_TYPE_TAB, EMailTabClass)) - + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_TAB, EMailTab)) +#define E_MAIL_TAB_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_TAB, EMailTabClass)) #define E_MAIL_IS_TAB(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - E_MAIL_TYPE_TAB)) - -#define E_MAIL_IS_TAB_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - E_MAIL_TYPE_TAB)) - + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_TAB)) +#define E_MAIL_IS_TAB_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MAIL_TAB)) #define E_MAIL_TAB_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - E_MAIL_TYPE_TAB, EMailTabClass)) - -typedef struct _EMailTabPrivate EMailTabPrivate; + (G_TYPE_INSTANCE_GET_CLASS ( \ + (obj), E_TYPE_MAIL_TAB, EMailTabClass)) -typedef struct { - MxWidget parent; - - EMailTabPrivate *priv; -} EMailTab; - -typedef struct { - MxWidgetClass parent_class; - - void (* clicked) (EMailTab *tab); - void (* closed) (EMailTab *tab); - void (* transition_complete) (EMailTab *tab); -} EMailTabClass; - -GType e_mail_tab_get_type (void); - -ClutterActor *e_mail_tab_new (void); -ClutterActor *e_mail_tab_new_full (const gchar *text, - ClutterActor *icon, - gint width); - -void e_mail_tab_set_text (EMailTab *tab, const gchar *text); -void e_mail_tab_set_default_icon (EMailTab *tab, ClutterActor *icon); -void e_mail_tab_set_icon (EMailTab *tab, ClutterActor *icon); -void e_mail_tab_set_can_close (EMailTab *tab, gboolean can_close); -void e_mail_tab_set_width (EMailTab *tab, gint width); -void e_mail_tab_set_docking (EMailTab *tab, gboolean docking); -void e_mail_tab_set_preview_actor (EMailTab *tab, ClutterActor *actor); -void e_mail_tab_set_preview_mode (EMailTab *tab, gboolean preview); -void e_mail_tab_set_preview_duration (EMailTab *tab, guint duration); -void e_mail_tab_set_spacing (EMailTab *tab, gfloat spacing); -void e_mail_tab_set_private (EMailTab *tab, gboolean private); -void e_mail_tab_set_active (EMailTab *tab, gboolean active); +G_BEGIN_DECLS -const gchar *e_mail_tab_get_text (EMailTab *tab); -ClutterActor *e_mail_tab_get_icon (EMailTab *tab); -gboolean e_mail_tab_get_can_close (EMailTab *tab); -gint e_mail_tab_get_width (EMailTab *tab); -gboolean e_mail_tab_get_docking (EMailTab *tab); -ClutterActor *e_mail_tab_get_preview_actor (EMailTab *tab); -gboolean e_mail_tab_get_preview_mode (EMailTab *tab); -void e_mail_tab_get_height_no_preview (EMailTab *tab, - gfloat for_width, - gfloat *min_height_p, - gfloat *natural_height_p); -guint e_mail_tab_get_preview_duration (EMailTab *tab); -gfloat e_mail_tab_get_spacing (EMailTab *tab); -gboolean e_mail_tab_get_private (EMailTab *tab); -gboolean e_mail_tab_get_active (EMailTab *tab); +typedef struct _EMailTab EMailTab; +typedef struct _EMailTabClass EMailTabClass; +typedef struct _EMailTabPrivate EMailTabPrivate; -void e_mail_tab_alert (EMailTab *tab); -void e_mail_tab_enable_drag (EMailTab *tab, gboolean enable); +struct _EMailTab { + MxWidget parent; + EMailTabPrivate *priv; +}; + +struct _EMailTabClass { + MxWidgetClass parent_class; + + void (*clicked) (EMailTab *tab); + void (*closed) (EMailTab *tab); + void (*transition_complete) (EMailTab *tab); +}; + +GType e_mail_tab_get_type (void) G_GNUC_CONST; +ClutterActor * e_mail_tab_new (void); +ClutterActor * e_mail_tab_new_full (const gchar *text, + ClutterActor *icon, + gint width); +void e_mail_tab_set_text (EMailTab *tab, + const gchar *text); +void e_mail_tab_set_default_icon (EMailTab *tab, + ClutterActor *icon); +void e_mail_tab_set_icon (EMailTab *tab, + ClutterActor *icon); +void e_mail_tab_set_can_close (EMailTab *tab, + gboolean can_close); +void e_mail_tab_set_width (EMailTab *tab, + gint width); +void e_mail_tab_set_docking (EMailTab *tab, + gboolean docking); +void e_mail_tab_set_preview_actor (EMailTab *tab, + ClutterActor *actor); +void e_mail_tab_set_preview_mode (EMailTab *tab, + gboolean preview); +void e_mail_tab_set_preview_duration (EMailTab *tab, + guint duration); +void e_mail_tab_set_spacing (EMailTab *tab, + gfloat spacing); +void e_mail_tab_set_private (EMailTab *tab, + gboolean private_); +void e_mail_tab_set_active (EMailTab *tab, + gboolean active); +const gchar * e_mail_tab_get_text (EMailTab *tab); +ClutterActor * e_mail_tab_get_icon (EMailTab *tab); +gboolean e_mail_tab_get_can_close (EMailTab *tab); +gint e_mail_tab_get_width (EMailTab *tab); +gboolean e_mail_tab_get_docking (EMailTab *tab); +ClutterActor * e_mail_tab_get_preview_actor (EMailTab *tab); +gboolean e_mail_tab_get_preview_mode (EMailTab *tab); +void e_mail_tab_get_height_no_preview + (EMailTab *tab, + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p); +guint e_mail_tab_get_preview_duration (EMailTab *tab); +gfloat e_mail_tab_get_spacing (EMailTab *tab); +gboolean e_mail_tab_get_private (EMailTab *tab); +gboolean e_mail_tab_get_active (EMailTab *tab); +void e_mail_tab_alert (EMailTab *tab); +void e_mail_tab_enable_drag (EMailTab *tab, + gboolean enable); G_END_DECLS -#endif /* _E_MAIL_TAB_H */ +#endif /* E_MAIL_TAB_H */ diff --git a/mail/e-mail-tag-editor.c b/mail/e-mail-tag-editor.c index d1ef428bc3..57db55a5db 100644 --- a/mail/e-mail-tag-editor.c +++ b/mail/e-mail-tag-editor.c @@ -33,6 +33,10 @@ #include "e-util/e-util.h" #include "widgets/misc/e-dateedit.h" +#define E_MAIL_TAG_EDITOR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_TAG_EDITOR, EMailTagEditorPrivate)) + #define DEFAULT_FLAG 2 /* "Follow-Up" */ struct _EMailTagEditorPrivate { @@ -60,7 +64,7 @@ enum { COLUMN_SUBJECT }; -static gpointer parent_class; +G_DEFINE_TYPE (EMailTagEditor, e_mail_tag_editor, GTK_TYPE_DIALOG) static void mail_tag_editor_clear_clicked_cb (EMailTagEditor *editor) @@ -138,7 +142,7 @@ mail_tag_editor_realize (GtkWidget *widget) GtkWidget *content_area; /* Chain up to parent's realize() method. */ - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (e_mail_tag_editor_parent_class)->realize (widget); /* XXX Override GTK's brain-dead border width defaults. */ @@ -219,12 +223,11 @@ mail_tag_editor_set_tag_list (EMailTagEditor *editor, } static void -mail_tag_editor_class_init (EMailTagEditorClass *class) +e_mail_tag_editor_class_init (EMailTagEditorClass *class) { GObjectClass *object_class; GtkWidgetClass *widget_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailTagEditorPrivate)); object_class = G_OBJECT_CLASS (class); @@ -271,7 +274,7 @@ mail_tag_editor_class_init (EMailTagEditorClass *class) } static void -mail_tag_editor_init (EMailTagEditor *editor) +e_mail_tag_editor_init (EMailTagEditor *editor) { GtkBuilder *builder; GtkDialog *dialog; @@ -281,8 +284,7 @@ mail_tag_editor_init (EMailTagEditor *editor) GtkCellRenderer *renderer; GtkListStore *store; - editor->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - editor, E_TYPE_MAIL_TAG_EDITOR, EMailTagEditorPrivate); + editor->priv = E_MAIL_TAG_EDITOR_GET_PRIVATE (editor); dialog = GTK_DIALOG (editor); window = GTK_WINDOW (editor); @@ -360,32 +362,6 @@ mail_tag_editor_init (EMailTagEditor *editor) g_object_unref (builder); } -GType -e_mail_tag_editor_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailTagEditorClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_tag_editor_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailTagEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_tag_editor_init, - NULL /* valute_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_DIALOG, "EMailTagEditor", &type_info, 0); - } - - return type; -} - GtkWidget * e_mail_tag_editor_new (void) { diff --git a/mail/e-mail-view.c b/mail/e-mail-view.c index 90c74d7299..72884dcc4b 100644 --- a/mail/e-mail-view.c +++ b/mail/e-mail-view.c @@ -28,6 +28,10 @@ #include <glib/gi18n-lib.h> +#define E_MAIL_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_VIEW, EMailViewPrivate)) + struct _EMailViewPrivate { EShellView *shell_view; GtkOrientation orientation; @@ -154,7 +158,7 @@ mail_view_dispose (GObject *object) { EMailViewPrivate *priv; - priv = E_MAIL_VIEW (object)->priv; + priv = E_MAIL_VIEW_GET_PRIVATE (object); if (priv->shell_view != NULL) { g_object_unref (priv->shell_view); @@ -319,8 +323,7 @@ e_mail_view_class_init (EMailViewClass *class) static void e_mail_view_init (EMailView *view) { - view->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - view, E_TYPE_MAIL_VIEW, EMailViewPrivate); + view->priv = E_MAIL_VIEW_GET_PRIVATE (view); } EShellView * diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index 64aa851d6c..45dd41fd9a 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -75,6 +75,10 @@ #include "smime/gui/e-cert-selector.h" #endif +#define EM_ACCOUNT_EDITOR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_ACCOUNT_EDITOR, EMAccountEditorPrivate)) + /* Option widgets whose sensitivity depends on another widget, such * as a checkbox being active, are indented to the right slightly for * better visual clarity. This specifies how far to the right. */ @@ -262,7 +266,7 @@ enum { static void em_account_editor_construct (EMAccountEditor *emae, EMAccountEditorType type, const gchar *id); static void emae_account_folder_changed (EMFolderSelectionButton *folder, EMAccountEditor *emae); -static gpointer parent_class; +G_DEFINE_TYPE (EMAccountEditor, em_account_editor, G_TYPE_OBJECT) static void emae_config_target_changed_cb (EMAccountEditor *emae) @@ -843,7 +847,7 @@ emae_dispose (GObject *object) { EMAccountEditorPrivate *priv; - priv = EM_ACCOUNT_EDITOR (object)->priv; + priv = EM_ACCOUNT_EDITOR_GET_PRIVATE (object); if (priv->backend != NULL) { g_object_unref (priv->backend); @@ -880,7 +884,7 @@ emae_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (em_account_editor_parent_class)->dispose (object); } static void @@ -901,15 +905,14 @@ emae_finalize (GObject *object) g_list_free (priv->providers); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (em_account_editor_parent_class)->finalize (object); } static void -emae_class_init (GObjectClass *class) +em_account_editor_class_init (EMAccountEditorClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMAccountEditorPrivate)); object_class = G_OBJECT_CLASS (class); @@ -1141,10 +1144,9 @@ emae_class_init (GObjectClass *class) } static void -emae_init (EMAccountEditor *emae) +em_account_editor_init (EMAccountEditor *emae) { - emae->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - emae, EM_TYPE_ACCOUNT_EDITOR, EMAccountEditorPrivate); + emae->priv = EM_ACCOUNT_EDITOR_GET_PRIVATE (emae); emae->priv->selected_server = NULL; emae->priv->source.emae = emae; @@ -1159,32 +1161,6 @@ emae_init (EMAccountEditor *emae) emae->priv->is_yahoo = FALSE; } -GType -em_account_editor_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMAccountEditorClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) emae_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMAccountEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) emae_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - G_TYPE_OBJECT, "EMAccountEditor", &type_info, 0); - } - - return type; -} - /** * em_account_editor_new: * @account: diff --git a/mail/em-config.c b/mail/em-config.c index e9c1105c85..6a133f1c56 100644 --- a/mail/em-config.c +++ b/mail/em-config.c @@ -138,7 +138,7 @@ em_config_new (gint type, { EMConfig *emp; - emp = g_object_new (em_config_get_type (), NULL); + emp = g_object_new (EM_TYPE_CONFIG, NULL); e_config_construct (&emp->config, type, menuid); return emp; diff --git a/mail/em-config.h b/mail/em-config.h index 24a75fb511..a90ecf3262 100644 --- a/mail/em-config.h +++ b/mail/em-config.h @@ -29,6 +29,25 @@ #include "e-util/e-config.h" +/* Standard GObject macros */ +#define EM_TYPE_CONFIG \ + (em_config_get_type ()) +#define EM_CONFIG(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), EM_TYPE_CONFIG, EMConfig)) +#define EM_CONFIG_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), EM_TYPE_CONFIG, EMConfigClass)) +#define EM_IS_CONFIG(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), EM_TYPE_CONFIG)) +#define EM_IS_CONFIG_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), EM_TYPE_CONFIG, EMConfigClass)) +#define EM_CONFIG_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), EM_TYPE_CONFIG, EMConfigClass)) + G_BEGIN_DECLS typedef struct _EMConfig EMConfig; diff --git a/mail/em-event.c b/mail/em-event.c index 7a99618727..a89069f360 100644 --- a/mail/em-event.c +++ b/mail/em-event.c @@ -98,7 +98,7 @@ EMEvent * em_event_peek (void) { if (em_event == NULL) { - em_event = g_object_new (em_event_get_type (), NULL); + em_event = g_object_new (EM_TYPE_EVENT, NULL); e_event_construct ( &em_event->popup, "org.gnome.evolution.mail.events"); diff --git a/mail/em-event.h b/mail/em-event.h index 3fc5ac0fc3..d48341a0b8 100644 --- a/mail/em-event.h +++ b/mail/em-event.h @@ -27,6 +27,25 @@ #include "e-util/e-event.h" #include "composer/e-msg-composer.h" +/* Standard GObject macros */ +#define EM_TYPE_EVENT \ + (em_event_get_type ()) +#define EM_EVENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), EM_TYPE_EVENT, EMEvent)) +#define EM_EVENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), EM_TYPE_EVENT, EMEventClass)) +#define EM_IS_EVENT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), EM_TYPE_EVENT)) +#define EM_IS_EVENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), EM_TYPE_EVENT)) +#define EM_EVENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), EM_TYPE_EVENT, EMEventClass)) + G_BEGIN_DECLS typedef struct _EMEvent EMEvent; diff --git a/mail/em-filter-context.c b/mail/em-filter-context.c index 2885a4c20a..085c32dbd0 100644 --- a/mail/em-filter-context.c +++ b/mail/em-filter-context.c @@ -36,6 +36,10 @@ /* For poking into filter-folder guts */ #include "em-filter-folder-element.h" +#define EM_FILTER_CONTEXT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_FILTER_CONTEXT, EMFilterContextPrivate)) + struct _EMFilterContextPrivate { EMailBackend *backend; GList *actions; @@ -101,7 +105,7 @@ filter_context_dispose (GObject *object) { EMFilterContextPrivate *priv; - priv = EM_FILTER_CONTEXT (object)->priv; + priv = EM_FILTER_CONTEXT_GET_PRIVATE (object); if (priv->backend != NULL) { g_object_unref (priv->backend); @@ -229,7 +233,7 @@ filter_context_new_element (ERuleContext *context, { EMFilterContextPrivate *priv; - priv = EM_FILTER_CONTEXT (context)->priv; + priv = EM_FILTER_CONTEXT_GET_PRIVATE (context); if (strcmp (type, "folder") == 0) return em_filter_folder_element_new (priv->backend); @@ -280,8 +284,7 @@ em_filter_context_class_init (EMFilterContextClass *class) static void em_filter_context_init (EMFilterContext *context) { - context->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - context, EM_TYPE_FILTER_CONTEXT, EMFilterContextPrivate); + context->priv = EM_FILTER_CONTEXT_GET_PRIVATE (context); e_rule_context_add_part_set ( E_RULE_CONTEXT (context), diff --git a/mail/em-filter-editor.c b/mail/em-filter-editor.c index b92e202b96..06bb8d33c9 100644 --- a/mail/em-filter-editor.c +++ b/mail/em-filter-editor.c @@ -35,7 +35,7 @@ #include "em-filter-editor.h" #include "em-filter-rule.h" -static gpointer parent_class; +G_DEFINE_TYPE (EMFilterEditor, em_filter_editor, E_TYPE_RULE_EDITOR) static EFilterRule * filter_editor_create_rule (ERuleEditor *rule_editor) @@ -56,18 +56,16 @@ filter_editor_create_rule (ERuleEditor *rule_editor) } static void -filter_editor_class_init (EMFilterEditorClass *class) +em_filter_editor_class_init (EMFilterEditorClass *class) { ERuleEditorClass *rule_editor_class; - parent_class = g_type_class_peek_parent (class); - rule_editor_class = E_RULE_EDITOR_CLASS (class); rule_editor_class->create_rule = filter_editor_create_rule; } static void -filter_editor_init (EMFilterEditor *filter_editor) +em_filter_editor_init (EMFilterEditor *filter_editor) { GConfBridge *bridge; const gchar *key_prefix; @@ -79,32 +77,6 @@ filter_editor_init (EMFilterEditor *filter_editor) bridge, key_prefix, GTK_WINDOW (filter_editor)); } -GType -em_filter_editor_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMFilterEditorClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_editor_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMFilterEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_editor_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_RULE_EDITOR, "EMFilterEditor", &type_info, 0); - } - - return type; -} - /** * em_filter_editor_new: * diff --git a/mail/em-filter-rule.c b/mail/em-filter-rule.c index 6cd287b0ea..90e82e5744 100644 --- a/mail/em-filter-rule.c +++ b/mail/em-filter-rule.c @@ -40,83 +40,42 @@ static gint filter_eq (EFilterRule *fr, EFilterRule *cm); static xmlNodePtr xml_encode (EFilterRule *fr); static gint xml_decode (EFilterRule *fr, xmlNodePtr, ERuleContext *rc); static void rule_copy (EFilterRule *dest, EFilterRule *src); -/*static void build_code(EFilterRule *, GString *out);*/ static GtkWidget *get_widget (EFilterRule *fr, ERuleContext *rc); -static void em_filter_rule_class_init (EMFilterRuleClass *klass); -static void em_filter_rule_init (EMFilterRule *ff); -static void em_filter_rule_finalize (GObject *obj); +G_DEFINE_TYPE (EMFilterRule, em_filter_rule, E_TYPE_FILTER_RULE) -static EFilterRuleClass *parent_class = NULL; - -GType -em_filter_rule_get_type (void) +static void +em_filter_rule_finalize (GObject *object) { - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EMFilterRuleClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) em_filter_rule_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EMFilterRule), - 0, /* n_preallocs */ - (GInstanceInitFunc) em_filter_rule_init, - }; - - type = g_type_register_static(E_TYPE_FILTER_RULE, "EMFilterRule", &info, 0); - } + EMFilterRule *ff =(EMFilterRule *) object; - return type; + g_list_free_full (ff->actions, (GDestroyNotify) g_object_unref); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (em_filter_rule_parent_class)->finalize (object); } static void -em_filter_rule_class_init (EMFilterRuleClass *klass) +em_filter_rule_class_init (EMFilterRuleClass *class) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - EFilterRuleClass *fr_class =(EFilterRuleClass *) klass; - - parent_class = g_type_class_ref (E_TYPE_FILTER_RULE); + GObjectClass *object_class; + EFilterRuleClass *filter_rule_class; + object_class = G_OBJECT_CLASS (class); object_class->finalize = em_filter_rule_finalize; - /* override methods */ - fr_class->validate = validate; - fr_class->eq = filter_eq; - fr_class->xml_encode = xml_encode; - fr_class->xml_decode = xml_decode; - /*fr_class->build_code = build_code;*/ - fr_class->copy = rule_copy; - fr_class->get_widget = get_widget; + filter_rule_class = E_FILTER_RULE_CLASS (class); + filter_rule_class->validate = validate; + filter_rule_class->eq = filter_eq; + filter_rule_class->xml_encode = xml_encode; + filter_rule_class->xml_decode = xml_decode; + filter_rule_class->copy = rule_copy; + filter_rule_class->get_widget = get_widget; } static void em_filter_rule_init (EMFilterRule *ff) { - ; -} - -static void -unref_list (GList *l) -{ - while (l) { - g_object_unref (l->data); - l = l->next; - } -} - -static void -em_filter_rule_finalize (GObject *obj) -{ - EMFilterRule *ff =(EMFilterRule *) obj; - - unref_list (ff->actions); - g_list_free (ff->actions); - - G_OBJECT_CLASS (parent_class)->finalize (obj); } /** @@ -184,7 +143,8 @@ validate (EFilterRule *fr, GList *parts; gint valid; - valid = E_FILTER_RULE_CLASS (parent_class)->validate (fr, alert); + valid = E_FILTER_RULE_CLASS (em_filter_rule_parent_class)-> + validate (fr, alert); /* validate rule actions */ parts = ff->actions; @@ -217,8 +177,10 @@ static gint filter_eq (EFilterRule *fr, EFilterRule *cm) { - return E_FILTER_RULE_CLASS (parent_class)->eq (fr, cm) - && list_eq (((EMFilterRule *) fr)->actions,((EMFilterRule *) cm)->actions); + return E_FILTER_RULE_CLASS (em_filter_rule_parent_class)->eq (fr, cm) + && list_eq ( + ((EMFilterRule *) fr)->actions, + ((EMFilterRule *) cm)->actions); } static xmlNodePtr @@ -228,7 +190,8 @@ xml_encode (EFilterRule *fr) xmlNodePtr node, set, work; GList *l; - node = E_FILTER_RULE_CLASS (parent_class)->xml_encode (fr); + node = E_FILTER_RULE_CLASS (em_filter_rule_parent_class)-> + xml_encode (fr); g_return_val_if_fail (node != NULL, NULL); set = xmlNewNode(NULL, (const guchar *)"actionset"); xmlAddChild (node, set); @@ -281,7 +244,8 @@ xml_decode (EFilterRule *fr, xmlNodePtr work; gint result; - result = E_FILTER_RULE_CLASS (parent_class)->xml_decode (fr, node, rc); + result = E_FILTER_RULE_CLASS (em_filter_rule_parent_class)-> + xml_decode (fr, node, rc); if (result != 0) return result; @@ -321,14 +285,9 @@ rule_copy (EFilterRule *dest, node = node->next; } - E_FILTER_RULE_CLASS (parent_class)->copy (dest, src); + E_FILTER_RULE_CLASS (em_filter_rule_parent_class)->copy (dest, src); } -/*static void build_code(EFilterRule *fr, GString *out) -{ - return FILTER_RULE_CLASS (parent_class)->build_code (fr, out); -}*/ - struct _part_data { EFilterRule *fr; EMFilterContext *f; @@ -555,7 +514,8 @@ get_widget (EFilterRule *fr, gint rows, i = 0; gchar *msg; - widget = E_FILTER_RULE_CLASS (parent_class)->get_widget (fr, rc); + widget = E_FILTER_RULE_CLASS (em_filter_rule_parent_class)-> + get_widget (fr, rc); /* and now for the action area */ msg = g_strdup_printf("<b>%s</b>", _("Then")); diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c index 9aa198fa8e..1b8ef6cd71 100644 --- a/mail/em-folder-selection-button.c +++ b/mail/em-folder-selection-button.c @@ -262,7 +262,7 @@ folder_selection_button_clicked (GtkButton *button) GtkTreeSelection *selection; gpointer parent; - priv = EM_FOLDER_SELECTION_BUTTON (button)->priv; + priv = EM_FOLDER_SELECTION_BUTTON_GET_PRIVATE (button); parent = gtk_widget_get_toplevel (GTK_WIDGET (button)); parent = gtk_widget_is_toplevel (parent) ? parent : NULL; diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 79e9a04288..59f936d9d8 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -437,7 +437,7 @@ folder_tree_select_func (GtkTreeSelection *selection, tree_view = gtk_tree_selection_get_tree_view (selection); - priv = EM_FOLDER_TREE (tree_view)->priv; + priv = EM_FOLDER_TREE_GET_PRIVATE (tree_view); if (selected) return TRUE; diff --git a/mail/em-format-hook.c b/mail/em-format-hook.c index 51608ca07d..7777914577 100644 --- a/mail/em-format-hook.c +++ b/mail/em-format-hook.c @@ -31,7 +31,7 @@ #include <glib/gi18n.h> -/* class name -> klass map for EMFormat and subclasses */ +/* class name -> class map for EMFormat and subclasses */ static GHashTable *emfh_types; /* ********************************************************************** */ @@ -48,7 +48,6 @@ static GHashTable *emfh_types; * </hook> */ -static gpointer emfh_parent_class; #define emfh ((EMFormatHook *)eph) #define d(x) @@ -59,6 +58,8 @@ static const EPluginHookTargetKey emfh_flag_map[] = { { NULL } }; +G_DEFINE_TYPE (EMFormatHook, em_format_hook, E_TYPE_PLUGIN_HOOK) + static void emfh_format_format (EMFormat *md, CamelStream *stream, @@ -171,7 +172,7 @@ emfh_construct (EPluginHook *eph, d(printf("loading format hook\n")); - if (((EPluginHookClass *) emfh_parent_class)->construct (eph, ep, root) == -1) + if (((EPluginHookClass *) em_format_hook_parent_class)->construct (eph, ep, root) == -1) return -1; node = root->children; @@ -181,10 +182,10 @@ emfh_construct (EPluginHook *eph, group = emfh_construct_group (eph, node); if (group) { - EMFormatClass *klass; + EMFormatClass *class; if (emfh_types - && (klass = g_hash_table_lookup (emfh_types, group->id))) { + && (class = g_hash_table_lookup (emfh_types, group->id))) { GSList *l = group->items; for (; l; l = g_slist_next (l)) { @@ -194,7 +195,7 @@ emfh_construct (EPluginHook *eph, * if we leave as is, then we can enable the * plugin after startup and it will start * working automagically */ - em_format_class_add_handler (klass, &item->handler); + em_format_class_add_handler (class, &item->handler); } } /* We don't actually need to keep this @@ -217,7 +218,7 @@ emfh_enable (EPluginHook *eph, gint state) { GSList *g, *l; - EMFormatClass *klass; + EMFormatClass *class; g = emfh->groups; if (emfh_types == NULL) @@ -226,75 +227,60 @@ emfh_enable (EPluginHook *eph, for (; g; g = g_slist_next (g)) { struct _EMFormatHookGroup *group = g->data; - klass = g_hash_table_lookup (emfh_types, group->id); + class = g_hash_table_lookup (emfh_types, group->id); for (l = group->items; l; l = g_slist_next (l)) { EMFormatHookItem *item = l->data; if (state) - em_format_class_add_handler (klass, &item->handler); + em_format_class_add_handler (class, &item->handler); else - em_format_class_remove_handler (klass, &item->handler); + em_format_class_remove_handler (class, &item->handler); } } } static void -emfh_finalize (GObject *o) +format_hook_finalize (GObject *object) { - EPluginHook *eph = (EPluginHook *) o; + EPluginHook *eph = (EPluginHook *) object; g_slist_foreach (emfh->groups, (GFunc) emfh_free_group, NULL); g_slist_free (emfh->groups); - ((GObjectClass *) emfh_parent_class)->finalize (o); + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (em_format_hook_parent_class)->finalize (object); } static void -emfh_class_init (EPluginHookClass *klass) +em_format_hook_class_init (EMFormatHookClass *class) { - ((GObjectClass *) klass)->finalize = emfh_finalize; - klass->construct = emfh_construct; - klass->enable = emfh_enable; - klass->id = "org.gnome.evolution.mail.format:1.0"; -} + GObjectClass *object_class; + EPluginHookClass *hook_class; -GType -em_format_hook_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EMFormatHookClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) emfh_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMFormatHook), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - NULL /* value_table */ - }; + object_class = G_OBJECT_CLASS (class); + object_class->finalize = format_hook_finalize; - emfh_parent_class = g_type_class_ref (E_TYPE_PLUGIN_HOOK); - type = g_type_register_static ( - E_TYPE_PLUGIN_HOOK, "EMFormatHook", &info, 0); - } + hook_class = E_PLUGIN_HOOK_CLASS (class); + hook_class->construct = emfh_construct; + hook_class->enable = emfh_enable; + hook_class->id = "org.gnome.evolution.mail.format:1.0"; +} - return type; +static void +em_format_hook_init (EMFormatHook *hook) +{ } void em_format_hook_register_type (GType type) { - EMFormatClass *klass; + EMFormatClass *class; if (emfh_types == NULL) emfh_types = g_hash_table_new (g_str_hash, g_str_equal); d(printf("registering formatter type '%s'\n", g_type_name(type))); - klass = g_type_class_ref (type); - g_hash_table_insert (emfh_types, (gpointer) g_type_name (type), klass); + class = g_type_class_ref (type); + g_hash_table_insert (emfh_types, (gpointer) g_type_name (type), class); } diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 158b647641..48b62b7960 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -66,6 +66,10 @@ #include "widgets/misc/e-attachment-button.h" #include "widgets/misc/e-attachment-view.h" +#define EM_FORMAT_HTML_DISPLAY_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_FORMAT_HTML_DISPLAY, EMFormatHTMLDisplayPrivate)) + #define d(x) struct _EMFormatHTMLDisplayPrivate { @@ -156,7 +160,10 @@ static void efhd_message_prefix (EMFormat *emf, static void efhd_builtin_init (EMFormatHTMLDisplayClass *efhc); -static gpointer parent_class; +G_DEFINE_TYPE ( + EMFormatHTMLDisplay, + em_format_html_display, + EM_TYPE_FORMAT_HTML) static void efhd_xpkcs7mime_free (EMFormatHTMLPObject *o) @@ -439,7 +446,7 @@ efhd_format_clone (EMFormat *emf, EM_FORMAT_HTML (emf)->header_wrap_flags = 0; /* Chain up to parent's format_clone() method. */ - EM_FORMAT_CLASS (parent_class)-> + EM_FORMAT_CLASS (em_format_html_display_parent_class)-> format_clone (emf, folder, uid, msg, src, cancellable); } @@ -835,17 +842,17 @@ efhd_finalize (GObject *object) } /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (em_format_html_display_parent_class)-> + finalize (object); } static void -efhd_class_init (EMFormatHTMLDisplayClass *class) +em_format_html_display_class_init (EMFormatHTMLDisplayClass *class) { GObjectClass *object_class; EMFormatClass *format_class; EMFormatHTMLClass *format_html_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMFormatHTMLDisplayPrivate)); object_class = G_OBJECT_CLASS (class); @@ -864,7 +871,7 @@ efhd_class_init (EMFormatHTMLDisplayClass *class) } static void -efhd_init (EMFormatHTMLDisplay *efhd) +em_format_html_display_init (EMFormatHTMLDisplay *efhd) { EWebView *web_view; GtkActionGroup *image_actions; @@ -873,9 +880,9 @@ efhd_init (EMFormatHTMLDisplay *efhd) web_view = em_format_html_get_web_view (EM_FORMAT_HTML (efhd)); - efhd->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - efhd, EM_TYPE_FORMAT_HTML_DISPLAY, EMFormatHTMLDisplayPrivate); - efhd->priv->attachment_views = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + efhd->priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efhd); + efhd->priv->attachment_views = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, NULL); efhd->priv->attachment_expanded = FALSE; e_mail_display_set_formatter ( @@ -906,33 +913,6 @@ efhd_init (EMFormatHTMLDisplay *efhd) G_CALLBACK (efhd_web_view_update_actions_cb), efhd); } -GType -em_format_html_display_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMFormatHTMLDisplayClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) efhd_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMFormatHTMLDisplay), - 0, /* n_preallocs */ - (GInstanceInitFunc) efhd_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - EM_TYPE_FORMAT_HTML, "EMFormatHTMLDisplay", - &type_info, 0); - } - - return type; -} - EMFormatHTMLDisplay * em_format_html_display_new (void) { @@ -1253,7 +1233,7 @@ efhd_bar_resize (EMFormatHTML *efh, GtkWidget *widget; gint width; - priv = EM_FORMAT_HTML_DISPLAY (efh)->priv; + priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efh); web_view = em_format_html_get_web_view (efh); @@ -1281,7 +1261,7 @@ efhd_add_bar (EMFormatHTML *efh, g_return_val_if_fail (pobject != NULL && pobject->classid != NULL, FALSE); g_return_val_if_fail (g_str_has_prefix (pobject->classid, "attachment-bar:"), FALSE); - priv = EM_FORMAT_HTML_DISPLAY (efh)->priv; + priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efh); widget = e_mail_attachment_bar_new (); gtk_container_add (GTK_CONTAINER (eb), widget); diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c index dbfe011759..fd47275e30 100644 --- a/mail/em-format-html-print.c +++ b/mail/em-format-html-print.c @@ -35,7 +35,10 @@ #include "em-format-html-print.h" #include <e-util/e-print.h> -static gpointer parent_class = NULL; +G_DEFINE_TYPE ( + EMFormatHTMLPrint, + em_format_html_print, + EM_TYPE_FORMAT_HTML) static void efhp_finalize (GObject *object) @@ -47,7 +50,7 @@ efhp_finalize (GObject *object) g_object_unref (efhp->source); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (em_format_html_print_parent_class)->finalize (object); } static gboolean @@ -61,13 +64,11 @@ efhp_is_inline (EMFormat *emf, } static void -efhp_class_init (EMFormatHTMLPrintClass *class) +em_format_html_print_class_init (EMFormatHTMLPrintClass *class) { GObjectClass *object_class; EMFormatClass *format_class; - parent_class = g_type_class_peek_parent (class); - object_class = G_OBJECT_CLASS (class); object_class->finalize = efhp_finalize; @@ -76,9 +77,8 @@ efhp_class_init (EMFormatHTMLPrintClass *class) } static void -efhp_init (GObject *o) +em_format_html_print_init (EMFormatHTMLPrint *efhp) { - EMFormatHTMLPrint *efhp = (EMFormatHTMLPrint *) o; EWebView *web_view; web_view = em_format_html_get_web_view (EM_FORMAT_HTML (efhp)); @@ -92,32 +92,6 @@ efhp_init (GObject *o) ((EMFormat *) efhp)->print = TRUE; } -GType -em_format_html_print_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMFormatHTMLPrintClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) efhp_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMFormatHTMLPrint), - 0, /* n_preallocs */ - (GInstanceInitFunc) efhp_init - }; - - type = g_type_register_static ( - EM_TYPE_FORMAT_HTML, "EMFormatHTMLPrint", - &type_info, 0); - } - - return type; -} - EMFormatHTMLPrint * em_format_html_print_new (EMFormatHTML *source, GtkPrintOperationAction action) diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 9a7c87f105..960cdc1267 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -64,6 +64,10 @@ #include "mail-config.h" #include "mail-mt.h" +#define EM_FORMAT_HTML_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_FORMAT_HTML, EMFormatHTMLPrivate)) + #define d(x) #define EFM_MESSAGE_START_ANAME "evolution#message#start" @@ -811,7 +815,7 @@ efh_busy (EMFormat *emf) { EMFormatHTMLPrivate *priv; - priv = EM_FORMAT_HTML (emf)->priv; + priv = EM_FORMAT_HTML_GET_PRIVATE (emf); return (priv->format_id != -1); } @@ -1009,8 +1013,7 @@ efh_init (EMFormatHTML *efh, EWebView *web_view; GdkColor *color; - efh->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - efh, EM_TYPE_FORMAT_HTML, EMFormatHTMLPrivate); + efh->priv = EM_FORMAT_HTML_GET_PRIVATE (efh); g_queue_init (&efh->pending_object_list); g_queue_init (&efh->priv->pending_jobs); diff --git a/mail/em-search-context.c b/mail/em-search-context.c index f4b817b6b6..2a900752aa 100644 --- a/mail/em-search-context.c +++ b/mail/em-search-context.c @@ -33,7 +33,7 @@ #include "filter/e-filter-option.h" #include "filter/e-filter-int.h" -static gpointer parent_class; +G_DEFINE_TYPE (EMSearchContext, em_search_context, E_TYPE_RULE_CONTEXT) static EFilterElement * search_context_new_element (ERuleContext *context, @@ -46,53 +46,29 @@ search_context_new_element (ERuleContext *context, return (EFilterElement *) e_filter_int_new_type ("score", -3, 3); /* Chain up to parent's new_element() method. */ - return E_RULE_CONTEXT_CLASS (parent_class)->new_element (context, type); + return E_RULE_CONTEXT_CLASS (em_search_context_parent_class)-> + new_element (context, type); } static void -search_context_class_init (EMSearchContextClass *class) +em_search_context_class_init (EMSearchContextClass *class) { ERuleContextClass *rule_context_class; - parent_class = g_type_class_peek_parent (class); - rule_context_class = E_RULE_CONTEXT_CLASS (class); rule_context_class->new_element = search_context_new_element; } static void -search_context_init (EMSearchContext *vc) +em_search_context_init (EMSearchContext *vc) { ERuleContext *rule_context; rule_context = E_RULE_CONTEXT (vc); - rule_context->flags = E_RULE_CONTEXT_THREADING | E_RULE_CONTEXT_GROUPING; -} - -GType -em_search_context_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMSearchContextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) search_context_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMSearchContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) search_context_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_RULE_CONTEXT, "EMSearchContext", &type_info, 0); - } - return type; + rule_context->flags = + E_RULE_CONTEXT_THREADING | + E_RULE_CONTEXT_GROUPING; } ERuleContext * diff --git a/mail/em-vfolder-context.c b/mail/em-vfolder-context.c index 371914c886..6ac2cb62f2 100644 --- a/mail/em-vfolder-context.c +++ b/mail/em-vfolder-context.c @@ -35,6 +35,10 @@ #include "em-filter-folder-element.h" +#define EM_VFOLDER_CONTEXT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_VFOLDER_CONTEXT, EMVFolderContextPrivate)) + struct _EMVFolderContextPrivate { EMailBackend *backend; }; @@ -99,7 +103,7 @@ vfolder_context_dispose (GObject *object) { EMVFolderContextPrivate *priv; - priv = EM_VFOLDER_CONTEXT (object)->priv; + priv = EM_VFOLDER_CONTEXT_GET_PRIVATE (object); if (priv->backend != NULL) { g_object_unref (priv->backend); @@ -116,7 +120,7 @@ vfolder_context_new_element (ERuleContext *context, { EMVFolderContextPrivate *priv; - priv = EM_VFOLDER_CONTEXT (context)->priv; + priv = EM_VFOLDER_CONTEXT_GET_PRIVATE (context); if (strcmp (type, "system-flag") == 0) return e_filter_option_new (); @@ -166,8 +170,7 @@ em_vfolder_context_class_init (EMVFolderContextClass *class) static void em_vfolder_context_init (EMVFolderContext *context) { - context->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - context, EM_TYPE_VFOLDER_CONTEXT, EMVFolderContextPrivate); + context->priv = EM_VFOLDER_CONTEXT_GET_PRIVATE (context); e_rule_context_add_part_set ( E_RULE_CONTEXT (context), "partset", E_TYPE_FILTER_PART, diff --git a/mail/em-vfolder-rule.c b/mail/em-vfolder-rule.c index 04c009bc00..831059910c 100644 --- a/mail/em-vfolder-rule.c +++ b/mail/em-vfolder-rule.c @@ -43,6 +43,10 @@ #include "e-util/e-alert.h" #include "e-util/e-util-private.h" +#define EM_VFOLDER_RULE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate)) + struct _EMVFolderRulePrivate { EMailBackend *backend; }; @@ -131,7 +135,7 @@ vfolder_rule_dispose (GObject *object) { EMVFolderRulePrivate *priv; - priv = EM_VFOLDER_RULE (object)->priv; + priv = EM_VFOLDER_RULE_GET_PRIVATE (object); if (priv->backend != NULL) { g_object_unref (priv->backend); @@ -192,9 +196,7 @@ em_vfolder_rule_class_init (EMVFolderRuleClass *class) static void em_vfolder_rule_init (EMVFolderRule *rule) { - rule->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - rule, EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate); - + rule->priv = EM_VFOLDER_RULE_GET_PRIVATE (rule); rule->with = EM_VFOLDER_RULE_WITH_SPECIFIC; rule->rule.source = g_strdup ("incoming"); } diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 5dd215a156..dbb8ef8bfc 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -56,6 +56,10 @@ #define w(x) #define d(x) +#define MAIL_FOLDER_CACHE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), MAIL_TYPE_FOLDER_CACHE, MailFolderCachePrivate)) + /* This code is a mess, there is no reason it should be so complicated. */ struct _MailFolderCachePrivate { @@ -141,51 +145,51 @@ free_update (struct _folder_update *up) } static gboolean -flush_updates_idle_cb (MailFolderCache *self) +flush_updates_idle_cb (MailFolderCache *cache) { struct _folder_update *up; - g_mutex_lock (self->priv->stores_mutex); - while ((up = g_queue_pop_head (&self->priv->updates)) != NULL) { - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_lock (cache->priv->stores_mutex); + while ((up = g_queue_pop_head (&cache->priv->updates)) != NULL) { + g_mutex_unlock (cache->priv->stores_mutex); if (up->remove) { if (up->delete) { g_signal_emit ( - self, signals[FOLDER_DELETED], 0, + cache, signals[FOLDER_DELETED], 0, up->store, up->full_name); } else g_signal_emit ( - self, signals[FOLDER_UNAVAILABLE], 0, + cache, signals[FOLDER_UNAVAILABLE], 0, up->store, up->full_name); } else { if (up->oldfull && up->add) { g_signal_emit ( - self, signals[FOLDER_RENAMED], 0, + cache, signals[FOLDER_RENAMED], 0, up->store, up->oldfull, up->full_name); } if (!up->oldfull && up->add) g_signal_emit ( - self, signals[FOLDER_AVAILABLE], 0, + cache, signals[FOLDER_AVAILABLE], 0, up->store, up->full_name); } /* update unread counts */ - g_signal_emit (self, signals[FOLDER_UNREAD_UPDATED], 0, + g_signal_emit (cache, signals[FOLDER_UNREAD_UPDATED], 0, up->store, up->full_name, up->unread); /* indicate that the folder has changed (new mail received, etc) */ if (up->store != NULL && up->full_name != NULL) { g_signal_emit ( - self, signals[FOLDER_CHANGED], 0, up->store, + cache, signals[FOLDER_CHANGED], 0, up->store, up->full_name, up->new, up->msg_uid, up->msg_sender, up->msg_subject); } if (CAMEL_IS_VEE_STORE (up->store) && !up->remove) { /* Normally the vfolder store takes care of the - * folder_opened event itself, but we add folder to + * folder_opened event itcache, but we add folder to * the noting system later, thus we do not know about * search folders to update them in a tree, thus * ensure their changes will be tracked correctly. */ @@ -196,32 +200,32 @@ flush_updates_idle_cb (MailFolderCache *self) up->store, up->full_name, 0, NULL, NULL); if (folder) { - mail_folder_cache_note_folder (self, folder); + mail_folder_cache_note_folder (cache, folder); g_object_unref (folder); } } free_update (up); - g_mutex_lock (self->priv->stores_mutex); + g_mutex_lock (cache->priv->stores_mutex); } - self->priv->update_id = 0; - g_mutex_unlock (self->priv->stores_mutex); + cache->priv->update_id = 0; + g_mutex_unlock (cache->priv->stores_mutex); return FALSE; } static void -flush_updates (MailFolderCache *self) +flush_updates (MailFolderCache *cache) { - if (self->priv->update_id > 0) + if (cache->priv->update_id > 0) return; - if (g_queue_is_empty (&self->priv->updates)) + if (g_queue_is_empty (&cache->priv->updates)) return; - self->priv->update_id = g_idle_add ( - (GSourceFunc) flush_updates_idle_cb, self); + cache->priv->update_id = g_idle_add ( + (GSourceFunc) flush_updates_idle_cb, cache); } /* This is how unread counts work (and don't work): @@ -247,7 +251,7 @@ flush_updates (MailFolderCache *self) * it's correct. */ static void -update_1folder (MailFolderCache *self, +update_1folder (MailFolderCache *cache, struct _folder_info *mfi, gint new, const gchar *msg_uid, @@ -274,8 +278,8 @@ update_1folder (MailFolderCache *self, folder_is_vtrash = CAMEL_IS_VTRASH_FOLDER (folder); special_case = - (self->priv->count_trash && folder_is_vtrash) || - (self->priv->count_sent && folder_is_sent) || + (cache->priv->count_trash && folder_is_vtrash) || + (cache->priv->count_sent && folder_is_sent) || folder_is_drafts || folder_is_outbox; if (special_case) { @@ -313,14 +317,14 @@ update_1folder (MailFolderCache *self, up->msg_uid = g_strdup (msg_uid); up->msg_sender = g_strdup (msg_sender); up->msg_subject = g_strdup (msg_subject); - g_queue_push_tail (&self->priv->updates, up); - flush_updates (self); + g_queue_push_tail (&cache->priv->updates, up); + flush_updates (cache); } static void folder_changed_cb (CamelFolder *folder, CamelFolderChangeInfo *changes, - MailFolderCache *self) + MailFolderCache *cache) { static GHashTable *last_newmail_per_folder = NULL; time_t latest_received, new_latest_received; @@ -395,14 +399,14 @@ folder_changed_cb (CamelFolder *folder, last_newmail_per_folder, folder, GINT_TO_POINTER (new_latest_received)); - g_mutex_lock (self->priv->stores_mutex); - if (self->priv->stores != NULL - && (si = g_hash_table_lookup (self->priv->stores, parent_store)) != NULL + g_mutex_lock (cache->priv->stores_mutex); + if (cache->priv->stores != NULL + && (si = g_hash_table_lookup (cache->priv->stores, parent_store)) != NULL && (mfi = g_hash_table_lookup (si->folders, full_name)) != NULL && mfi->folder == folder) { - update_1folder (self, mfi, new, uid, sender, subject, NULL); + update_1folder (cache, mfi, new, uid, sender, subject, NULL); } - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); g_free (uid); g_free (sender); @@ -410,7 +414,7 @@ folder_changed_cb (CamelFolder *folder, } static void -unset_folder_info (MailFolderCache *self, +unset_folder_info (MailFolderCache *cache, struct _folder_info *mfi, gint delete, gint unsub) @@ -423,7 +427,7 @@ unset_folder_info (MailFolderCache *self, CamelFolder *folder = mfi->folder; g_signal_handlers_disconnect_by_func ( - folder, folder_changed_cb, self); + folder, folder_changed_cb, cache); g_object_remove_weak_pointer ( G_OBJECT (mfi->folder), &mfi->folder); @@ -438,8 +442,8 @@ unset_folder_info (MailFolderCache *self, up->store = g_object_ref (mfi->store_info->store); up->full_name = g_strdup (mfi->full_name); - g_queue_push_tail (&self->priv->updates, up); - flush_updates (self); + g_queue_push_tail (&cache->priv->updates, up); + flush_updates (cache); } } @@ -451,7 +455,7 @@ free_folder_info (struct _folder_info *mfi) } static void -setup_folder (MailFolderCache *self, +setup_folder (MailFolderCache *cache, CamelFolderInfo *fi, struct _store_info *si) { @@ -460,7 +464,7 @@ setup_folder (MailFolderCache *self, mfi = g_hash_table_lookup (si->folders, fi->full_name); if (mfi) { - update_1folder (self, mfi, 0, NULL, NULL, NULL, fi); + update_1folder (cache, mfi, 0, NULL, NULL, NULL, fi); } else { mfi = g_malloc0 (sizeof (*mfi)); mfi->full_name = g_strdup (fi->full_name); @@ -478,21 +482,21 @@ setup_folder (MailFolderCache *self, if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0) up->add = TRUE; - g_queue_push_tail (&self->priv->updates, up); - flush_updates (self); + g_queue_push_tail (&cache->priv->updates, up); + flush_updates (cache); } } static void -create_folders (MailFolderCache *self, +create_folders (MailFolderCache *cache, CamelFolderInfo *fi, struct _store_info *si) { while (fi) { - setup_folder (self, fi, si); + setup_folder (cache, fi, si); if (fi->child) - create_folders (self, fi->child, si); + create_folders (cache, fi->child, si); fi = fi->next; } @@ -501,15 +505,15 @@ create_folders (MailFolderCache *self, static void store_folder_subscribed_cb (CamelStore *store, CamelFolderInfo *info, - MailFolderCache *self) + MailFolderCache *cache) { struct _store_info *si; - g_mutex_lock (self->priv->stores_mutex); - si = g_hash_table_lookup (self->priv->stores, store); + g_mutex_lock (cache->priv->stores_mutex); + si = g_hash_table_lookup (cache->priv->stores, store); if (si) - setup_folder (self, info, si); - g_mutex_unlock (self->priv->stores_mutex); + setup_folder (cache, info, si); + g_mutex_unlock (cache->priv->stores_mutex); } static void @@ -526,45 +530,45 @@ store_folder_created_cb (CamelStore *store, static void store_folder_opened_cb (CamelStore *store, CamelFolder *folder, - MailFolderCache *self) + MailFolderCache *cache) { - mail_folder_cache_note_folder (self, folder); + mail_folder_cache_note_folder (cache, folder); } static void store_folder_unsubscribed_cb (CamelStore *store, CamelFolderInfo *info, - MailFolderCache *self) + MailFolderCache *cache) { struct _store_info *si; struct _folder_info *mfi; - g_mutex_lock (self->priv->stores_mutex); - si = g_hash_table_lookup (self->priv->stores, store); + g_mutex_lock (cache->priv->stores_mutex); + si = g_hash_table_lookup (cache->priv->stores, store); if (si) { mfi = g_hash_table_lookup (si->folders, info->full_name); if (mfi) { g_hash_table_remove (si->folders, mfi->full_name); - unset_folder_info (self, mfi, TRUE, TRUE); + unset_folder_info (cache, mfi, TRUE, TRUE); free_folder_info (mfi); } } - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); } static void store_folder_deleted_cb (CamelStore *store, CamelFolderInfo *info, - MailFolderCache *self) + MailFolderCache *cache) { /* We only want deleted events to do more work * if we dont support subscriptions. */ if (!CAMEL_IS_SUBSCRIBABLE (store)) - store_folder_unsubscribed_cb (store, info, self); + store_folder_unsubscribed_cb (store, info, cache); } static void -rename_folders (MailFolderCache *self, +rename_folders (MailFolderCache *cache, struct _store_info *si, const gchar *oldbase, const gchar *newbase, @@ -610,13 +614,13 @@ rename_folders (MailFolderCache *self, if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0) up->add = TRUE; - g_queue_push_tail (&self->priv->updates, up); - flush_updates (self); + g_queue_push_tail (&cache->priv->updates, up); + flush_updates (cache); #if 0 if (fi->sibling) - rename_folders (self, si, oldbase, newbase, fi->sibling, folders); + rename_folders (cache, si, oldbase, newbase, fi->sibling, folders); if (fi->child) - rename_folders (self, si, oldbase, newbase, fi->child, folders); + rename_folders (cache, si, oldbase, newbase, fi->child, folders); #endif /* rename the meta-data we maintain ourselves */ @@ -669,12 +673,12 @@ static void store_folder_renamed_cb (CamelStore *store, const gchar *old_name, CamelFolderInfo *info, - MailFolderCache *self) + MailFolderCache *cache) { struct _store_info *si; - g_mutex_lock (self->priv->stores_mutex); - si = g_hash_table_lookup (self->priv->stores, store); + g_mutex_lock (cache->priv->stores_mutex); + si = g_hash_table_lookup (cache->priv->stores, store); if (si) { GPtrArray *folders = g_ptr_array_new (); CamelFolderInfo *top; @@ -687,13 +691,13 @@ store_folder_renamed_cb (CamelStore *store, top = folders->pdata[0]; for (i = 0; i < folders->len; i++) { - rename_folders (self, si, old_name, top->full_name, folders->pdata[i]); + rename_folders (cache, si, old_name, top->full_name, folders->pdata[i]); } g_ptr_array_free (folders, TRUE); } - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); } struct _update_data { @@ -708,8 +712,8 @@ unset_folder_info_hash (gchar *path, struct _folder_info *mfi, gpointer data) { - MailFolderCache *self = (MailFolderCache *) data; - unset_folder_info (self, mfi, FALSE, FALSE); + MailFolderCache *cache = (MailFolderCache *) data; + unset_folder_info (cache, mfi, FALSE, FALSE); } static void @@ -842,13 +846,13 @@ ping_store (CamelStore *store) } static gboolean -ping_cb (MailFolderCache *self) +ping_cb (MailFolderCache *cache) { - g_mutex_lock (self->priv->stores_mutex); + g_mutex_lock (cache->priv->stores_mutex); - g_hash_table_foreach (self->priv->stores, (GHFunc) ping_store, NULL); + g_hash_table_foreach (cache->priv->stores, (GHFunc) ping_store, NULL); - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); return TRUE; } @@ -1064,26 +1068,25 @@ mail_folder_cache_class_init (MailFolderCacheClass *class) } static void -mail_folder_cache_init (MailFolderCache *self) +mail_folder_cache_init (MailFolderCache *cache) { const gchar *buf; guint timeout; - self->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - self, MAIL_TYPE_FOLDER_CACHE, MailFolderCachePrivate); + cache->priv = MAIL_FOLDER_CACHE_GET_PRIVATE (cache); /* initialize values */ - self->priv->stores = g_hash_table_new (NULL, NULL); - self->priv->stores_mutex = g_mutex_new (); + cache->priv->stores = g_hash_table_new (NULL, NULL); + cache->priv->stores_mutex = g_mutex_new (); - g_queue_init (&self->priv->updates); - self->priv->count_sent = getenv("EVOLUTION_COUNT_SENT") != NULL; - self->priv->count_trash = getenv("EVOLUTION_COUNT_TRASH") != NULL; + g_queue_init (&cache->priv->updates); + cache->priv->count_sent = getenv("EVOLUTION_COUNT_SENT") != NULL; + cache->priv->count_trash = getenv("EVOLUTION_COUNT_TRASH") != NULL; buf = getenv ("EVOLUTION_PING_TIMEOUT"); timeout = buf ? strtoul (buf, NULL, 10) : 600; - self->priv->ping_id = g_timeout_add_seconds ( - timeout, (GSourceFunc) ping_cb, self); + cache->priv->ping_id = g_timeout_add_seconds ( + timeout, (GSourceFunc) ping_cb, cache); } MailFolderCache * @@ -1100,7 +1103,7 @@ mail_folder_cache_new (void) * @done function returns if we can free folder info. */ void -mail_folder_cache_note_store (MailFolderCache *self, +mail_folder_cache_note_store (MailFolderCache *cache, CamelSession *session, CamelStore *store, GCancellable *cancellable, @@ -1114,14 +1117,14 @@ mail_folder_cache_note_store (MailFolderCache *self, g_return_if_fail (CAMEL_IS_STORE (store)); g_return_if_fail (mail_in_main_thread ()); - g_mutex_lock (self->priv->stores_mutex); + g_mutex_lock (cache->priv->stores_mutex); - si = g_hash_table_lookup (self->priv->stores, store); + si = g_hash_table_lookup (cache->priv->stores, store); if (si == NULL) { si = g_malloc0 (sizeof (*si)); si->folders = g_hash_table_new (g_str_hash, g_str_equal); si->store = g_object_ref (store); - g_hash_table_insert (self->priv->stores, store, si); + g_hash_table_insert (cache->priv->stores, store, si); g_queue_init (&si->folderinfo_updates); hook = TRUE; } @@ -1129,7 +1132,7 @@ mail_folder_cache_note_store (MailFolderCache *self, ud = g_malloc0 (sizeof (*ud)); ud->done = done; ud->data = data; - ud->cache = self; + ud->cache = cache; if (G_IS_CANCELLABLE (cancellable)) ud->cancellable = g_object_ref (cancellable); @@ -1170,32 +1173,32 @@ mail_folder_cache_note_store (MailFolderCache *self, g_queue_push_tail (&si->folderinfo_updates, ud); - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); /* there is potential for race here, but it is safe as we check * for the store anyway */ if (hook) { g_signal_connect ( store, "folder-opened", - G_CALLBACK (store_folder_opened_cb), self); + G_CALLBACK (store_folder_opened_cb), cache); g_signal_connect ( store, "folder-created", - G_CALLBACK (store_folder_created_cb), self); + G_CALLBACK (store_folder_created_cb), cache); g_signal_connect ( store, "folder-deleted", - G_CALLBACK (store_folder_deleted_cb), self); + G_CALLBACK (store_folder_deleted_cb), cache); g_signal_connect ( store, "folder-renamed", - G_CALLBACK (store_folder_renamed_cb), self); + G_CALLBACK (store_folder_renamed_cb), cache); } if (hook && CAMEL_IS_SUBSCRIBABLE (store)) { g_signal_connect ( store, "folder-subscribed", - G_CALLBACK (store_folder_subscribed_cb), self); + G_CALLBACK (store_folder_subscribed_cb), cache); g_signal_connect ( store, "folder-unsubscribed", - G_CALLBACK (store_folder_unsubscribed_cb), self); + G_CALLBACK (store_folder_unsubscribed_cb), cache); } } @@ -1205,31 +1208,31 @@ mail_folder_cache_note_store (MailFolderCache *self, * Notify the cache that the specified @store can be removed from the cache */ void -mail_folder_cache_note_store_remove (MailFolderCache *self, +mail_folder_cache_note_store_remove (MailFolderCache *cache, CamelStore *store) { struct _store_info *si; g_return_if_fail (CAMEL_IS_STORE (store)); - if (self->priv->stores == NULL) + if (cache->priv->stores == NULL) return; d(printf("store removed!!\n")); - g_mutex_lock (self->priv->stores_mutex); - si = g_hash_table_lookup (self->priv->stores, store); + g_mutex_lock (cache->priv->stores_mutex); + si = g_hash_table_lookup (cache->priv->stores, store); if (si) { GList *link; - g_hash_table_remove (self->priv->stores, store); + g_hash_table_remove (cache->priv->stores, store); g_signal_handlers_disconnect_matched ( store, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, self); + 0, 0, NULL, NULL, cache); g_hash_table_foreach ( si->folders, (GHFunc) - unset_folder_info_hash, self); + unset_folder_info_hash, cache); link = g_queue_peek_head_link (&si->folderinfo_updates); @@ -1245,7 +1248,7 @@ mail_folder_cache_note_store_remove (MailFolderCache *self, g_free (si); } - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); } /** @@ -1256,7 +1259,7 @@ mail_folder_cache_note_store_remove (MailFolderCache *self, * folder can be opened */ void -mail_folder_cache_note_folder (MailFolderCache *self, +mail_folder_cache_note_folder (MailFolderCache *cache, CamelFolder *folder) { CamelStore *parent_store; @@ -1267,18 +1270,18 @@ mail_folder_cache_note_folder (MailFolderCache *self, full_name = camel_folder_get_full_name (folder); parent_store = camel_folder_get_parent_store (folder); - g_mutex_lock (self->priv->stores_mutex); - if (self->priv->stores == NULL - || (si = g_hash_table_lookup (self->priv->stores, parent_store)) == NULL + g_mutex_lock (cache->priv->stores_mutex); + if (cache->priv->stores == NULL + || (si = g_hash_table_lookup (cache->priv->stores, parent_store)) == NULL || (mfi = g_hash_table_lookup (si->folders, full_name)) == NULL) { w(g_warning("Noting folder before store initialised")); - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); return; } /* dont do anything if we already have this */ if (mfi->folder == folder) { - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); return; } @@ -1286,13 +1289,13 @@ mail_folder_cache_note_folder (MailFolderCache *self, g_object_add_weak_pointer (G_OBJECT (folder), &mfi->folder); - update_1folder (self, mfi, 0, NULL, NULL, NULL, NULL); + update_1folder (cache, mfi, 0, NULL, NULL, NULL, NULL); - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); g_signal_connect ( folder, "changed", - G_CALLBACK (folder_changed_cb), self); + G_CALLBACK (folder_changed_cb), cache); } /** @@ -1304,18 +1307,18 @@ mail_folder_cache_note_folder (MailFolderCache *self, * folder if the folder has also already been opened */ gboolean -mail_folder_cache_get_folder_from_uri (MailFolderCache *self, +mail_folder_cache_get_folder_from_uri (MailFolderCache *cache, const gchar *uri, CamelFolder **folderp) { struct _find_info fi = { uri, NULL }; - if (self->priv->stores == NULL) + if (cache->priv->stores == NULL) return FALSE; - g_mutex_lock (self->priv->stores_mutex); + g_mutex_lock (cache->priv->stores_mutex); g_hash_table_foreach ( - self->priv->stores, (GHFunc) + cache->priv->stores, (GHFunc) storeinfo_find_folder_info, &fi); if (folderp) { if (fi.fi && fi.fi->folder) @@ -1323,28 +1326,28 @@ mail_folder_cache_get_folder_from_uri (MailFolderCache *self, else *folderp = NULL; } - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); return fi.fi != NULL; } gboolean -mail_folder_cache_get_folder_info_flags (MailFolderCache *self, +mail_folder_cache_get_folder_info_flags (MailFolderCache *cache, CamelFolder *folder, CamelFolderInfoFlags *flags) { struct _find_info fi = { NULL, NULL }; gchar *folder_uri; - if (self->priv->stores == NULL) + if (cache->priv->stores == NULL) return FALSE; folder_uri = e_mail_folder_uri_from_folder (folder); fi.folder_uri = folder_uri; - g_mutex_lock (self->priv->stores_mutex); + g_mutex_lock (cache->priv->stores_mutex); g_hash_table_foreach ( - self->priv->stores, (GHFunc) + cache->priv->stores, (GHFunc) storeinfo_find_folder_info, &fi); if (flags) { if (fi.fi) @@ -1352,7 +1355,7 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *self, else *flags = 0; } - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); g_free (folder_uri); @@ -1362,29 +1365,29 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *self, /* Returns whether folder 'folder' has children based on folder_info->child property. * If not found returns FALSE and sets 'found' to FALSE, if not NULL. */ gboolean -mail_folder_cache_get_folder_has_children (MailFolderCache *self, +mail_folder_cache_get_folder_has_children (MailFolderCache *cache, CamelFolder *folder, gboolean *found) { struct _find_info fi = { NULL, NULL }; gchar *folder_uri; - g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (cache != NULL, FALSE); g_return_val_if_fail (folder != NULL, FALSE); - if (self->priv->stores == NULL) + if (cache->priv->stores == NULL) return FALSE; folder_uri = e_mail_folder_uri_from_folder (folder); fi.folder_uri = folder_uri; - g_mutex_lock (self->priv->stores_mutex); + g_mutex_lock (cache->priv->stores_mutex); g_hash_table_foreach ( - self->priv->stores, (GHFunc) + cache->priv->stores, (GHFunc) storeinfo_find_folder_info, &fi); if (found) *found = fi.fi != NULL; - g_mutex_unlock (self->priv->stores_mutex); + g_mutex_unlock (cache->priv->stores_mutex); g_free (folder_uri); diff --git a/mail/message-list.c b/mail/message-list.c index e01f42fca2..a405959de3 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -97,6 +97,10 @@ #define d(x) #define t(x) +#define MESSAGE_LIST_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), MESSAGE_LIST_TYPE, MessageListPrivate)) + struct _MLSelection { GPtrArray *uids; CamelFolder *folder; @@ -135,7 +139,17 @@ enum { PROP_PASTE_TARGET_LIST }; -static gpointer parent_class; +/* Forward Declarations */ +static void message_list_selectable_init + (ESelectableInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( + MessageList, + message_list, + E_TYPE_TREE, + G_IMPLEMENT_INTERFACE ( + E_TYPE_SELECTABLE, + message_list_selectable_init)) static struct { const gchar *target; @@ -2547,8 +2561,7 @@ message_list_init (MessageList *message_list) GtkTargetList *target_list; GdkAtom matom; - message_list->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - message_list, MESSAGE_LIST_TYPE, MessageListPrivate); + message_list->priv = MESSAGE_LIST_GET_PRIVATE (message_list); #if HAVE_CLUTTER message_list->priv->timeline = NULL; @@ -2706,7 +2719,7 @@ message_list_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (message_list_parent_class)->dispose (object); } static void @@ -2735,7 +2748,7 @@ message_list_finalize (GObject *object) clear_selection (message_list, &priv->clipboard); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (message_list_parent_class)->finalize (object); } static void @@ -2768,7 +2781,6 @@ message_list_class_init (MessageListClass *class) for (i = 0; i < G_N_ELEMENTS (ml_drag_info); i++) ml_drag_info[i].atom = gdk_atom_intern (ml_drag_info[i].target, FALSE); - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (MessageListPrivate)); object_class = G_OBJECT_CLASS (class); @@ -2957,41 +2969,6 @@ message_list_construct (MessageList *message_list) G_CALLBACK (ml_tree_sorting_changed), message_list); } -GType -message_list_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (MessageListClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) message_list_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (MessageList), - 0, /* n_preallocs */ - (GInstanceInitFunc) message_list_init, - NULL /* value_table */ - }; - - static const GInterfaceInfo selectable_info = { - (GInterfaceInitFunc) message_list_selectable_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - - type = g_type_register_static ( - E_TYPE_TREE, "MessageList", &type_info, 0); - - g_type_add_interface_static ( - type, E_TYPE_SELECTABLE, &selectable_info); - } - - return type; -} - /** * message_list_new: * |