diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-02-18 18:00:42 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-02-18 18:00:42 -0500 |
commit | de0039546ba6258cd1c3af1624ecc02553b5ac7e (patch) | |
tree | 7bae124055ed8664ee13dab258dbb2b9b46c9942 /modules | |
parent | 7272610a02a144ff30106e647fa67736bf1642d8 (diff) | |
download | gtk+-de0039546ba6258cd1c3af1624ecc02553b5ac7e.tar.gz |
Convert print backends to use a GIOExtensionPoint
Use GIOModule and GIOExtensionPoint. This is the preferred
way to define extensions these days, instead of manually
implementing type modules.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/printbackends/cloudprint/gtkprintbackendcloudprint.c | 58 | ||||
-rw-r--r-- | modules/printbackends/cups/gtkprintbackendcups.c | 66 | ||||
-rw-r--r-- | modules/printbackends/file/gtkprintbackendfile.c | 63 | ||||
-rw-r--r-- | modules/printbackends/lpr/gtkprintbackendlpr.c | 64 |
4 files changed, 105 insertions, 146 deletions
diff --git a/modules/printbackends/cloudprint/gtkprintbackendcloudprint.c b/modules/printbackends/cloudprint/gtkprintbackendcloudprint.c index c3d28cb347..8fc3352b3c 100644 --- a/modules/printbackends/cloudprint/gtkprintbackendcloudprint.c +++ b/modules/printbackends/cloudprint/gtkprintbackendcloudprint.c @@ -103,48 +103,37 @@ static void cloudprint_printer_request_details (GtkPri TGOAAccount * t_goa_account_copy (TGOAAccount *account); void t_goa_account_free (gpointer data); +GG_DEFINE_DYNAMIC_TYPE(GtkPrintBackendCloudprint, gtk_print_backend_cloudprint, GTK_TYPE_PRINT_BACKEND) - -static void -gtk_print_backend_cloudprint_register_type (GTypeModule *module) +void +g_io_module_load (GIOModule *module) { - const GTypeInfo print_backend_cloudprint_info = - { - sizeof (GtkPrintBackendCloudprintClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_print_backend_cloudprint_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkPrintBackendCloudprint), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_print_backend_cloudprint_init, - }; + g_type_module_use (G_TYPE_MODULE (module)); - print_backend_cloudprint_type = g_type_module_register_type (module, - GTK_TYPE_PRINT_BACKEND, - "GtkPrintBackendCloudprint", - &print_backend_cloudprint_info, 0); -} + gtk_print_backend_cloudprint_register_type (G_TYPE_MODULE (module)); + gtk_cloudprint_account_register_type (G_TYPE_MODULE (module)); + gtk_printer_cloudprint_register_type (G_TYPE_MODULE (module)); -G_MODULE_EXPORT void -pb_module_init (GTypeModule *module) -{ - gtk_print_backend_cloudprint_register_type (module); - gtk_cloudprint_account_register_type (module); - gtk_printer_cloudprint_register_type (module); + g_io_extension_point_implement (GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + GTK_TYPE_PRINT_BACKEND_CLOUDPRINT, + "cloudprint", + 10); } -G_MODULE_EXPORT void -pb_module_exit (void) +void +g_io_module_unload (GIOModule *module) { - } -G_MODULE_EXPORT GtkPrintBackend * -pb_module_create (void) +char ** +g_io_module_query (void) { - return gtk_print_backend_cloudprint_new (); + char *eps[] = { + GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + NULL + }; + + return g_strdupv (eps); } /* @@ -191,6 +180,11 @@ gtk_print_backend_cloudprint_class_init (GtkPrintBackendCloudprintClass *klass) } static void +gtk_print_backend_cloudprint_class_finalize (GtkPrintBackendCloudprintClass *class) +{ +} + +static void gtk_print_backend_cloudprint_init (GtkPrintBackendCloudprint *backend) { backend->cancellable = g_cancellable_new (); diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c index da6ce27a48..454bc86a7e 100644 --- a/modules/printbackends/cups/gtkprintbackendcups.c +++ b/modules/printbackends/cups/gtkprintbackendcups.c @@ -236,49 +236,38 @@ static void secrets_service_vanished_cb (GDBusConnec const gchar *name, gpointer user_data); -static void -gtk_print_backend_cups_register_type (GTypeModule *module) +G_DEFINE_DYNAMIC_TYPE(GtkPrintBackendCups, gtk_print_backend_cups, GTK_TYPE_PRINT_BACKEND) + +void +g_io_module_load (GIOModule *module) { - const GTypeInfo print_backend_cups_info = - { - sizeof (GtkPrintBackendCupsClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_print_backend_cups_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkPrintBackendCups), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_print_backend_cups_init - }; + g_type_module_use (G_TYPE_MODULE (module)); + + gtk_print_backend_cups_register_type (G_TYPE_MODULE (module)); + gtk_printer_cups_register_type (G_TYPE_MODULE (module)); - print_backend_cups_type = g_type_module_register_type (module, - GTK_TYPE_PRINT_BACKEND, - "GtkPrintBackendCups", - &print_backend_cups_info, 0); + g_io_extension_point_implement (GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + GTK_TYPE_PRINT_BACKEND_CUPS, + "cups", + 10); } -G_MODULE_EXPORT void -pb_module_init (GTypeModule *module) +void +g_io_module_unload (GIOModule *module) { - GTK_NOTE (PRINTING, - g_print ("CUPS Backend: Initializing the CUPS print backend module\n")); - - gtk_print_backend_cups_register_type (module); - gtk_printer_cups_register_type (module); } -G_MODULE_EXPORT void -pb_module_exit (void) +char ** +g_io_module_query (void) { + char *eps[] = { + GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + NULL + }; + return g_strdupv (eps); } -G_MODULE_EXPORT GtkPrintBackend * -pb_module_create (void) -{ - return gtk_print_backend_cups_new (); -} /* CUPS 1.6 Getter/Setter Functions CUPS 1.6 makes private most of the * IPP structures and enforces access via new getter functions, which * are unfortunately not available in earlier versions. We define @@ -287,7 +276,7 @@ pb_module_create (void) */ #ifndef HAVE_CUPS_API_1_6 #define ippGetOperation(ipp_request) ipp_request->request.op.operation_id -#define ippGetInteger(attr, index) attr->values[index].integer +#define ippGet:Integer(attr, index) attr->values[index].integer #define ippGetBoolean(attr, index) attr->values[index].boolean #define ippGetString(attr, index, foo) attr->values[index].string.text #define ippGetValueTag(attr) attr->value_tag @@ -323,14 +312,10 @@ ippNextAttribute (ipp_t *ipp) return (ipp->current = ipp->current->next); } #endif + /* * GtkPrintBackendCups */ -GType -gtk_print_backend_cups_get_type (void) -{ - return print_backend_cups_type; -} /** * gtk_print_backend_cups_new: @@ -376,6 +361,11 @@ gtk_print_backend_cups_class_init (GtkPrintBackendCupsClass *class) backend_class->set_password = gtk_print_backend_cups_set_password; } +static void +gtk_print_backend_cups_class_finalize (GtkPrintBackendCupsClass *class) +{ +} + static gboolean option_is_ipp_option (GtkPrinterOption *option) { diff --git a/modules/printbackends/file/gtkprintbackendfile.c b/modules/printbackends/file/gtkprintbackendfile.c index 775af6647c..385154a352 100644 --- a/modules/printbackends/file/gtkprintbackendfile.c +++ b/modules/printbackends/file/gtkprintbackendfile.c @@ -104,53 +104,35 @@ static cairo_surface_t * file_printer_create_cairo_surface (GtkPrinter static GList * file_printer_list_papers (GtkPrinter *printer); static GtkPageSetup * file_printer_get_default_page_size (GtkPrinter *printer); -static void -gtk_print_backend_file_register_type (GTypeModule *module) -{ - const GTypeInfo print_backend_file_info = - { - sizeof (GtkPrintBackendFileClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_print_backend_file_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkPrintBackendFile), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_print_backend_file_init, - }; - - print_backend_file_type = g_type_module_register_type (module, - GTK_TYPE_PRINT_BACKEND, - "GtkPrintBackendFile", - &print_backend_file_info, 0); -} +G_DEFINE_DYNAMIC_TYPE(GtkPrintBackendFile, gtk_print_backend_file, GTK_TYPE_PRINT_BACKEND) -G_MODULE_EXPORT void -pb_module_init (GTypeModule *module) +void +g_io_module_load (GIOModule *module) { - gtk_print_backend_file_register_type (module); -} + g_type_module_use (G_TYPE_MODULE (module)); -G_MODULE_EXPORT void -pb_module_exit (void) -{ + gtk_print_backend_file_register_type (G_TYPE_MODULE (module)); + g_io_extension_point_implement (GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + GTK_TYPE_PRINT_BACKEND_FILE, + "file", + 10); } - -G_MODULE_EXPORT GtkPrintBackend * -pb_module_create (void) + +void +g_io_module_unload (GIOModule *module) { - return gtk_print_backend_file_new (); } -/* - * GtkPrintBackendFile - */ -GType -gtk_print_backend_file_get_type (void) +char ** +g_io_module_query (void) { - return print_backend_file_type; + char *eps[] = { + GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + NULL + }; + + return g_strdupv (eps); } /** @@ -184,6 +166,11 @@ gtk_print_backend_file_class_init (GtkPrintBackendFileClass *class) backend_class->printer_get_default_page_size = file_printer_get_default_page_size; } +static void +gtk_print_backend_file_class_finalize (GtkPrintBackendFileClass *class) +{ +} + /* return N_FORMATS if no explicit format in the settings */ static OutputFormat format_from_settings (GtkPrintSettings *settings) diff --git a/modules/printbackends/lpr/gtkprintbackendlpr.c b/modules/printbackends/lpr/gtkprintbackendlpr.c index 4257771dbf..d79592c7bc 100644 --- a/modules/printbackends/lpr/gtkprintbackendlpr.c +++ b/modules/printbackends/lpr/gtkprintbackendlpr.c @@ -83,53 +83,36 @@ static void gtk_print_backend_lpr_print_stream (GtkPrintBacke gpointer user_data, GDestroyNotify dnotify); -static void -gtk_print_backend_lpr_register_type (GTypeModule *module) -{ - const GTypeInfo print_backend_lpr_info = - { - sizeof (GtkPrintBackendLprClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_print_backend_lpr_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkPrintBackendLpr), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_print_backend_lpr_init, - }; - - print_backend_lpr_type = g_type_module_register_type (module, - GTK_TYPE_PRINT_BACKEND, - "GtkPrintBackendLpr", - &print_backend_lpr_info, 0); -} +G_DEFINE_DYNAMIC_TYPE(GtkPrintBackendLpr, gtk_print_backend_lpr, GTK_TYPE_PRINT_BACKEND -G_MODULE_EXPORT void -pb_module_init (GTypeModule *module) +void +g_io_module_load (GIOModule *module) { - gtk_print_backend_lpr_register_type (module); -} + g_type_module_use (G_TYPE_MODULE (module)); -G_MODULE_EXPORT void -pb_module_exit (void) -{ + gtk_print_backend_lpr_register_type (G_TYPE_MODULE (module)); + gtk_printer_lpr_register_type (G_TYPE_MODULE (module)); + g_io_extension_point_implement (GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + GTK_TYPE_PRINT_BACKEND_CUPS, + "lpr", + 10); } - -G_MODULE_EXPORT GtkPrintBackend * -pb_module_create (void) + +void +g_io_module_unload (GIOModule *module) { - return gtk_print_backend_lpr_new (); } -/* - * GtkPrintBackendLpr - */ -GType -gtk_print_backend_lpr_get_type (void) +char ** +g_io_module_query (void) { - return print_backend_lpr_type; + char *eps[] = { + GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + NULL + }; + + return g_strdupv (eps); } /** @@ -161,6 +144,11 @@ gtk_print_backend_lpr_class_init (GtkPrintBackendLprClass *class) backend_class->printer_prepare_for_print = lpr_printer_prepare_for_print; } +static void +gtk_print_backend_lpr_class_finalize (GtkPrintBackendLprClass *class) +{ +} + static cairo_status_t _cairo_write (void *closure, const unsigned char *data, |