![]() |
![]() |
![]() |
Gnome Scan Reference Manual | ![]() |
---|---|---|---|---|
#include <gnome-scan.h> #define GS_DEFINE_PARAM (prefix, Prefix, param_name, ParamName, VALUE_TYPE) #define GS_PARAM_GROUP_SCANNER_FRONT #define GS_PARAM_GROUP_FORMAT #define GS_PARAM_GROUP_SINK_FRONT #define GS_PARAM_GROUP_PREVIEW #define GS_PARAM_GROUP_HIDDEN GQuark gs_param_spec_get_group (GParamSpec *spec); const gchar* gs_param_spec_get_group_string (GParamSpec *spec); void gs_param_spec_set_group (GParamSpec *spec, GQuark group); void gs_param_spec_set_group_from_string (GParamSpec *spec, const gchar *group); void gs_param_spec_set_domain (GParamSpec *spec, const gchar *domain); const gchar* gs_param_spec_get_domain (GParamSpec *spec); void gs_param_spec_set_unit (GParamSpec *spec, GnomeScanUnit unit); GnomeScanUnit gs_param_spec_get_unit (GParamSpec *spec); void gs_param_spec_set_index (GParamSpec *spec, guint index); guint gs_param_spec_get_index (GParamSpec *spec); void gs_param_spec_set_widget_type (GParamSpec *spec, GType type); GParamSpec* gs_param_spec_boolean (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, gboolean default_value, GParamFlags flags); GParamSpec* gs_param_spec_int (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, gint minimum, gint maximum, gint default_value, GParamFlags flags); GParamSpec* gs_param_spec_double (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, gdouble minimum, gdouble maximum, gdouble default_value, GParamFlags flags); GParamSpec* gs_param_spec_string (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, const gchar *default_value, GParamFlags flags); GParamSpec* gs_param_spec_pointer (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, GType widget, GParamFlags flags); GParamSpec* gs_param_spec_range (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, GValue *minimum, GValue *maximum, GValue *step, GValue *default_value, GParamFlags flags); GParamSpec* gs_param_spec_enum (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, GValueArray *values, GValue *default_value, GParamFlags flags); GParamSpec* gs_param_spec_paper_size (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, GtkPaperSize *default_ps, GSList *enumeration, GParamFlags flags); GParamSpec* gs_param_spec_page_orientation (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, guint default_value, GParamFlags flags);
Instead of using a all-in-one option object (like in Gnome Scan
0.4), Gnome Scan now use regular GParamSpecs. Gnome Scan
GParamSpecs (referred as GSParamSpecs) have been designed in order
to build generic widget for plugins parameters (like Gegl and other
projects does). A common attribute added to each GSParamSpec is
the group
quark. The group
quark is computed from the translated
group title.
Also, GSParamSpecs are much more high-level than it's parent GParamSpec in order to build complex param widgets (range, area, paper-size, …).
Current implementation makes a heavy use of
g_param_spec_set_qdata()
, because GParamSpec is a shallow
type. Future implementation might break thing for either creating
its own GSParamSpec fundamental type or simply using a common
struct right after the parent_instance
field.
#define GS_DEFINE_PARAM(prefix, Prefix, param_name, ParamName, VALUE_TYPE)
Convenient function that avoid duplicated bug writing GLib boiler plate for GType registration for a custom GParamSpec.
For example:
GS_DEFINE_PARAM (foo, Foo,bar, Bar, G_TYPE_INT);
expands to:
GType foo_param_bar_get_type () { static GType type = 0; if (!type) { const GParamSpecTypeInfo info = { sizeof (FooParamBarSpec), 0, NULL, G_TYPE_INT, NULL, NULL, NULL, NULL }; type = g_param_type_register_static ("FooParamBarSpec", &info); } return type; }
You'll then have to declare a FooParamSpecBar structure as
well as declaring foo_param_bar_get_type()
and writing some macros.
|
|
|
|
|
param prefix |
|
Capitalized param name |
|
The macro returning the value GType |
#define GS_PARAM_GROUP_SCANNER_FRONT (gs_scanner_front_quark ())
Scanner option group for not every user
#define GS_PARAM_GROUP_PREVIEW (gs_preview_quark())
Scanner option group for preview page. Option that's needs instant view of the effect of selecting them
#define GS_PARAM_GROUP_HIDDEN (gs_hidden_quark())
Scanner option group not shown to user
GQuark gs_param_spec_get_group (GParamSpec *spec);
Retrieve the spec
group. Since the group
is not store in a
struct, but using qdata, just cast spec
to GParamSpec.
|
The GSParamSpec |
Returns : |
spec group's quark
|
const gchar* gs_param_spec_get_group_string (GParamSpec *spec);
Retrieve the spec
group string. Since the group
is not store in a
struct, but using qdata, just cast spec
to GParamSpec. The string
is not translated.
See: gs_param_spec_get_group()
|
The GSParamSpec |
Returns : |
spec group's quark
|
void gs_param_spec_set_group (GParamSpec *spec, GQuark group);
|
a GSParamSpec |
|
new spec group's GQuark.
|
void gs_param_spec_set_group_from_string (GParamSpec *spec, const gchar *group);
|
a GSParamSpec |
|
new spec group name
|
void gs_param_spec_set_domain (GParamSpec *spec, const gchar *domain);
|
a GSParamSpec |
|
domain for translating spec nick and blurb
|
const gchar* gs_param_spec_get_domain (GParamSpec *spec);
|
a GSParamSpec |
Returns : |
void gs_param_spec_set_unit (GParamSpec *spec, GnomeScanUnit unit);
Parameter unit is specified for UI, but can also be need for e.g. length of scan ROI where unit translation might occur.
|
a GSParamSpec |
|
GnomeScanUnit fo spec
|
GnomeScanUnit gs_param_spec_get_unit (GParamSpec *spec);
|
a GSParamSpec |
Returns : |
a GnomeScanUnit |
void gs_param_spec_set_index (GParamSpec *spec, guint index);
|
a GSParamSpec |
|
new spec 'index
|
guint gs_param_spec_get_index (GParamSpec *spec);
|
a GSParamSpec |
Returns : |
an integer. |
void gs_param_spec_set_widget_type (GParamSpec *spec, GType type);
This part is the only bound from backend to frontend. It might be removed later. The idea is to have widget per param, not per type.
|
a GSParamSpec |
|
a widget GType |
GParamSpec* gs_param_spec_boolean (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, gboolean default_value, GParamFlags flags);
Create a new GSParamSpec of for boolean value. name
is for use
internally (e.g. gconf key) while nick and blurb
should be marked
for translation.
|
param name |
|
param nickname |
|
description of the parameter |
|
param group quark |
|
default value |
|
Flags |
Returns : |
a new GSParamSpec |
GParamSpec* gs_param_spec_int (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, gint minimum, gint maximum, gint default_value, GParamFlags flags);
Create a new GSParamSpec of for integer value. name
is for use
internally (e.g. gconf key) while nick and blurb
should be marked
for translation.
|
param name |
|
param nickname |
|
description of the parameter |
|
param group quark |
|
minimum value |
|
maximum value |
|
default value |
|
Flags |
Returns : |
a new GSParamSpec |
GParamSpec* gs_param_spec_double (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, gdouble minimum, gdouble maximum, gdouble default_value, GParamFlags flags);
Create a new GSParamSpec of for double value. name
is for use
internally (e.g. gconf key) while nick and blurb
should be marked
for translation.
|
param name |
|
param nickname |
|
description of the parameter |
|
param group quark |
|
minimum value |
|
maximum value |
|
default value |
|
Flags |
Returns : |
a new GSParamSpec |
GParamSpec* gs_param_spec_string (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, const gchar *default_value, GParamFlags flags);
Create a new GSParamSpec of for string value. name
is for use
internally (e.g. gconf key) while nick and blurb
should be marked
for translation.
|
param name |
|
param nickname |
|
description of the parameter |
|
param group quark |
|
default value |
|
Flags |
Returns : |
a new GSParamSpec |
GParamSpec* gs_param_spec_pointer (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, GType widget, GParamFlags flags);
Create a new GSParamSpec of for boolean value. name
is for use
internally (e.g. gconf key) while nick and blurb
should be marked
for translation.
Other GSParamSpec have predefined widget type. Pointer spec allow to store alsmost everything and thus needs specific widget type.
|
param name |
|
param nickname |
|
description of the parameter |
|
param group quark |
|
widget type |
|
Flags |
Returns : |
a new GSParamSpec |
GParamSpec* gs_param_spec_range (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, GValue *minimum, GValue *maximum, GValue *step, GValue *default_value, GParamFlags flags);
Create a new GSParamSpecRange. This spec has been designed to store both integer and float value. Ensure all GValue have the same type.
|
spec name |
|
spec nick |
|
spec blurb |
|
The quark of the group the param belong to |
|
value of the lowest allowed value |
|
value of the highed allowed value |
|
lenght between two values |
|
|
|
Param flags. |
Returns : |
the new GSParamSpecRange |
GParamSpec* gs_param_spec_enum (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, GValueArray *values, GValue *default_value, GParamFlags flags);
Create a new GSParamSpecEnum . This parameter spec has been designed to handle integer, float and string value.
|
spec name |
|
spec nick |
|
spec blurb |
|
The quark of the group the param belong to |
|
Allowed values |
|
default value; |
|
Param flags. |
Returns : |
the new GSParamSpecEnum |
GParamSpec* gs_param_spec_paper_size (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, GtkPaperSize *default_ps, GSList *enumeration, GParamFlags flags);
Create a new GSParamSpec of for GtkPaperSize value. name
is for use
internally (e.g. gconf key) while nick and blurb
should be marked
for translation.
|
param name |
|
param nickname |
|
description of the parameter |
|
param group quark |
|
default paper size |
|
available paper size |
|
Flags |
Returns : |
a new GSParamSpec |
GParamSpec* gs_param_spec_page_orientation (const gchar *name, const gchar *nick, const gchar *blurb, GQuark group, guint default_value, GParamFlags flags);
Create a new GSParamSpec of for GtkPageOrientation value. name
is for use
internally (e.g. gconf key) while nick and blurb
should be marked
for translation.
|
param name |
|
param nickname |
|
description of the parameter |
|
param group quark |
|
default value |
|
Flags |
Returns : |
a new GSParamSpec |