のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

get_option_group

749  for (viewer = viewers; *viewer; viewer++)
750      if ((*viewer)->get_option_group)
751      {
752          GOptionGroup *group = (*viewer)->get_option_group (*viewer);
753	         if (group)
754	             g_option_context_add_group (context, group);
755      }
413 static GOptionGroup *
414 pangocairo_view_get_option_group (const PangoViewer *klass G_GNUC_UNUSED)
415 {
416     GOptionEntry entries[] =
417     {
418         {"annotate",	0, 0, G_OPTION_ARG_INT, &opt_annotate,
419         "Annotate the output",				"1 or 2"},
420         {NULL}
421      };
422     GOptionGroup *group;
423
424     group = g_option_group_new ("cairo",
425			      "Cairo backend options:",
426			      "Options understood by the cairo backend",
427			      NULL,
428			      NULL);
429
430     g_option_group_add_entries (group, entries);
431
432     cairo_viewer_add_options (group);
433
434     return group;
435 }
436

struct GOptionEntry
struct GOptionEntry {
const gchar *long_name;
gchar short_name;
gint flags;

GOptionArg arg;
gpointer arg_data;

const gchar *description;
const gchar *arg_description;
};
A GOptionEntry struct defines a single option. To have an effect, they must be added to a GOptionGroup with g_option_context_add_main_entries() or g_option_group_add_entries().

GOptionEntry

typedef struct {
const gchar *long_name;
gchar short_name;
gint flags;

GOptionArg arg;
gpointer arg_data;

const gchar *description;
const gchar *arg_description;
} GOptionEntry;
GOptionEntry 構造体は単一のオプションを定義します。このオプションを利用する時は、g_option_context_add_main_entries() または g_option_group_add_entries() 関数を使って GOptionGroup を追加する必要があります。