1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
/*****************************************************************
* gmerlin - a general purpose multimedia framework and applications
*
* Copyright (c) 2001 - 2024 Members of the Gmerlin project
* http://github.com/bplaum
*
* 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 2 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/>.
* *****************************************************************/
#include <config.h>
#include <locale.h>
#include <gtk/gtk.h>
#include <gmerlin/mdb.h>
#include <gmerlin/cfg_registry.h>
#include <gmerlin/parameter.h>
#include <gmerlin/cfgctx.h>
#include <gmerlin/utils.h>
#include <gmerlin/cmdline.h>
#include <gmerlin/translation.h>
#include <gmerlin/iconfont.h>
#include <gmerlin/application.h>
#include <gui_gtk/mdb.h>
static int do_create = 0;
static int do_monitor = 0;
char * path = NULL;
bg_mdb_t * mdb = NULL;
bg_controllable_t * mdb_ctrl;
bg_control_t ctrl;
static void opt_create(void * data, int * argc, char *** _argv, int arg)
{
do_create = 1;
}
static void opt_monitor(void * data, int * argc, char *** _argv, int arg)
{
do_monitor = 1;
}
static void opt_db(void * data, int * argc, char *** _argv, int arg)
{
if(arg >= *argc)
{
fprintf(stderr, "Option -db requires an argument\n");
exit(-1);
}
path = gavl_strdup((*_argv)[arg]);
bg_cmdline_remove_arg(argc, _argv, arg);
}
static bg_cmdline_arg_t global_options[] =
{
{
.arg = "-create",
.help_string = "Create DB if it doesn't exist",
.callback = opt_create,
},
{
.arg = "-monitor",
.help_string = "Monitor the db until Ctrl+C is pressed",
.callback = opt_monitor,
},
{
.arg = "-db",
.help_arg = "<path>",
.help_string = "DB path",
.callback = opt_db,
},
{
/* End */
}
};
const bg_cmdline_app_data_t app_data =
{
.package = PACKAGE,
.version = VERSION,
.synopsis = TRS("[options]\n"),
.help_before = TRS("gmerlin GUI db editor\n"),
.args = (bg_cmdline_arg_array_t[]) { { TRS("Options"), global_options },
{ } },
};
static gboolean destroy_callback(GtkWidget * w, GdkEventAny * event,
gpointer data)
{
fprintf(stderr, "destroy callback\n");
gtk_main_quit();
return FALSE;
}
int main(int argc, char ** argv)
{
bg_mdb_t * mdb;
GtkWidget * window;
bg_gtk_mdb_tree_t * tree;
bg_iconfont_init();
bg_app_init("mdb-tree", TRS("GUI tree editor"), NULL);
/* Create registries */
bg_cmdline_init(&app_data);
bg_cmdline_parse(global_options, &argc, &argv, NULL);
bg_plugins_init();
if(!(mdb = bg_mdb_create(path, do_create, NULL)))
return EXIT_FAILURE;
gtk_init(&argc, &argv);
/* No, we don't like commas as decimal separators */
setlocale(LC_NUMERIC, "C");
tree = bg_gtk_mdb_tree_create(bg_mdb_get_controllable(mdb));
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(destroy_callback),
NULL);
gtk_container_add(GTK_CONTAINER(window),
bg_gtk_mdb_tree_get_widget(tree));
gtk_window_set_default_size(GTK_WINDOW(window),
600, 400);
gtk_widget_show(window);
gtk_main();
fprintf(stderr, "gtk_main finished\n");
bg_mdb_destroy(mdb);
return EXIT_SUCCESS;
}
|