grim/guifications3

moved gflib-gtk to the new cmake module
cmake
2010-12-15, Gary Kramlich
b6418db658c1
moved gflib-gtk to the new cmake module
/*
* Guifications - The end-all, be-all notification framework
* Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gf_lib.h>
enum {
OPT_VARIABLE
};
static gint verbosity = 0;
static gboolean
verbosity_cb(const gchar *n, const gchar *v, gpointer d, GError **e) {
verbosity++;
return TRUE;
}
static GOptionEntry entries[] = {
{
"verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
verbosity_cb,
"Increase verbosity.",
NULL,
}, {
"version", 'V', 0, G_OPTION_ARG_NONE, NULL,
"Disable the version and exit.",
NULL,
}, {
NULL
}
};
static void
print_plugin(GfPlugin *plugin) {
GfPluginInfo *info = gf_plugin_get_info(plugin);
printf("%s\n", info->name);
if(verbosity > 0) {
printf(" version: %s\n", info->version);
printf(" summary: %s\n", info->summary);
printf(" description: %s\n", info->description);
printf(" author: %s\n", info->author);
printf(" website: %s\n", info->website);
if(verbosity > 1) {
printf(" filename: %s\n", gf_plugin_get_filename(plugin));
printf(" ABI version: %d\n", info->abi_version);
}
printf("\n");
}
}
static void
list_cb(GfPlugin *plugin, gpointer data) {
print_plugin(plugin);
}
gint
main(gint argc, gchar **argv, gchar **envp) {
GError *error = NULL;
GOptionContext *ctx = NULL;
gint i = 0;
gf_lib_init(&argc, &argv);
ctx = g_option_context_new("PLUGIN");
g_option_context_add_main_entries(ctx, entries, GETTEXT_PACKAGE);
g_option_context_add_group(ctx, gf_get_option_group());
g_option_context_parse(ctx, &argc, &argv, &error);
if(error) {
gint ret = error->code;
gf_log_critical("gflib-queryplugins", "%s\n", error->message);
g_error_free(error);
return ret;
}
/* check if the user gave us a plugin to look for */
if(argc > 1) {
gboolean found = FALSE;
for(i = 1; i < argc; i++) {
GfPlugin *plugin = NULL;
if(!argv[i])
continue;
plugin = gf_plugin_manager_find_plugin_by_name(argv[i]);
if(plugin) {
found = TRUE;
print_plugin(plugin);
} else {
printf("%s (not found)\n", argv[i]);
}
}
if(!found)
return EXIT_FAILURE;
} else {
/* if not, just output all of them */
gf_plugin_manager_foreach(list_cb, NULL);
}
return EXIT_SUCCESS;
}