summaryrefslogtreecommitdiff
path: root/pango-view
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-03-16 16:57:58 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-03-16 16:57:58 -0400
commit69e1f7921525c2849d937b5a822475007a4f9a2f (patch)
tree13d5c49b60d70c742020e64d8a0744158567e2b8 /pango-view
parent56ff9ed93d1cc9fd091da609304bd153d706d818 (diff)
downloadpango-69e1f7921525c2849d937b5a822475007a4f9a2f.tar.gz
Bug 502804 – pango-view or pangocairo-view option to annotate
Added --annotate. Also fixes: Bug 502801 – per-backend pango-view options
Diffstat (limited to 'pango-view')
-rw-r--r--pango-view/viewer-cairo.c5
-rw-r--r--pango-view/viewer-cairo.h2
-rw-r--r--pango-view/viewer-pangocairo.c33
-rw-r--r--pango-view/viewer-render.c15
-rw-r--r--pango-view/viewer.h1
5 files changed, 51 insertions, 5 deletions
diff --git a/pango-view/viewer-cairo.c b/pango-view/viewer-cairo.c
index 1da05b8a..72aae5d5 100644
--- a/pango-view/viewer-cairo.c
+++ b/pango-view/viewer-cairo.c
@@ -358,3 +358,8 @@ cairo_viewer_iface_create (const CairoViewerIface **iface)
*iface = &cairo_image_viewer_iface;
return (*iface)->backend_class->create ((*iface)->backend_class);
}
+
+void
+cairo_viewer_add_options (GOptionGroup *group G_GNUC_UNUSED)
+{
+}
diff --git a/pango-view/viewer-cairo.h b/pango-view/viewer-cairo.h
index 81d2eeee..e843664f 100644
--- a/pango-view/viewer-cairo.h
+++ b/pango-view/viewer-cairo.h
@@ -42,4 +42,6 @@ struct _CairoViewerIface
gpointer cairo_viewer_iface_create (const CairoViewerIface **iface_out);
+void cairo_viewer_add_options (GOptionGroup *group);
+
#endif /* VIEWER_CAIRO_H */
diff --git a/pango-view/viewer-pangocairo.c b/pango-view/viewer-pangocairo.c
index e834540d..3d19668e 100644
--- a/pango-view/viewer-pangocairo.c
+++ b/pango-view/viewer-pangocairo.c
@@ -26,6 +26,8 @@
#include <pango/pangocairo.h>
+static int opt_annotate = 0;
+
typedef struct
{
const CairoViewerIface *iface;
@@ -136,7 +138,7 @@ render_callback (PangoLayout *layout,
gpointer state)
{
cairo_t *cr = (cairo_t *) context;
- int annotate = GPOINTER_TO_INT (state) % 3;
+ int annotate = (GPOINTER_TO_INT (state) + opt_annotate) % 3;
cairo_save (cr);
cairo_translate (cr, x, y);
@@ -406,6 +408,30 @@ pangocairo_view_display (gpointer instance,
state);
}
+static GOptionGroup *
+pangocairo_view_get_option_group (const PangoViewer *klass G_GNUC_UNUSED)
+{
+ GOptionEntry entries[] =
+ {
+ {"annotate", 0, 0, G_OPTION_ARG_INT, &opt_annotate,
+ "Annotate the output", "1 or 2"},
+ {NULL}
+ };
+ GOptionGroup *group;
+
+ group = g_option_group_new ("cairo",
+ "Cairo backend options:",
+ "Options understood by the cairo backend",
+ NULL,
+ NULL);
+
+ g_option_group_add_entries (group, entries);
+
+ cairo_viewer_add_options (group);
+
+ return group;
+}
+
const PangoViewer pangocairo_viewer = {
"PangoCairo",
"cairo",
@@ -427,5 +453,8 @@ const PangoViewer pangocairo_viewer = {
#endif
pangocairo_view_create_window,
pangocairo_view_destroy_window,
- pangocairo_view_display
+ pangocairo_view_display,
+ NULL,
+ NULL,
+ pangocairo_view_get_option_group
};
diff --git a/pango-view/viewer-render.c b/pango-view/viewer-render.c
index e078dd16..b3ee52b5 100644
--- a/pango-view/viewer-render.c
+++ b/pango-view/viewer-render.c
@@ -466,7 +466,6 @@ parse_rgba_color (PangoColor *color,
gpointer data G_GNUC_UNUSED,
GError **error)
{
- char *possible_values = NULL;
gboolean ret;
char buf[32];
int len;
@@ -653,7 +652,7 @@ parse_options (int argc, char *argv[])
{"backend", 0, backend_flag, G_OPTION_ARG_CALLBACK, &parse_backend,
backend_desc, backend_options},
{"background", 0, 0, G_OPTION_ARG_CALLBACK, &parse_background,
- "Set the background color", "red/#rrggbb/#rrggbbaa/transparent/etc"},
+ "Set the background color", "red/#rrggbb/#rrggbbaa/transparent"},
{"no-display", 'q', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &opt_display,
"Do not display (just write to file or whatever)", NULL},
{"dpi", 0, 0, G_OPTION_ARG_INT, &opt_dpi,
@@ -665,7 +664,7 @@ parse_options (int argc, char *argv[])
{"font", 0, 0, G_OPTION_ARG_STRING, &opt_font,
"Set the font description", "description"},
{"foreground", 0, 0, G_OPTION_ARG_CALLBACK, &parse_foreground,
- "Set the text color", "red/#rrggbb/#rrggbbaa/etc"},
+ "Set the text color", "red/#rrggbb/#rrggbbaa"},
{"gravity", 0, 0, G_OPTION_ARG_CALLBACK, &parse_gravity,
"Base gravity: glyph rotation", "south/east/north/west/auto"},
{"gravity-hint", 0, 0, G_OPTION_ARG_CALLBACK, &parse_gravity_hint,
@@ -714,10 +713,20 @@ parse_options (int argc, char *argv[])
GError *parse_error = NULL;
GOptionContext *context;
size_t len;
+ const PangoViewer **viewer;
prog_name = g_path_get_basename (argv[0]);
context = g_option_context_new ("- FILE");
g_option_context_add_main_entries (context, entries, NULL);
+
+ for (viewer = viewers; *viewer; viewer++)
+ if ((*viewer)->get_option_group)
+ {
+ GOptionGroup *group = (*viewer)->get_option_group (*viewer);
+ if (group)
+ g_option_context_add_group (context, group);
+ }
+
if (!g_option_context_parse (context, &argc, &argv, &parse_error))
{
if (parse_error != NULL)
diff --git a/pango-view/viewer.h b/pango-view/viewer.h
index 055ca58f..a4937693 100644
--- a/pango-view/viewer.h
+++ b/pango-view/viewer.h
@@ -91,6 +91,7 @@ struct _PangoViewer {
int height,
int stride);
+ GOptionGroup * (*get_option_group) (const PangoViewer *klass);
};
extern const PangoViewer *viewers[];