*/
/*
- Copyright (C) 2002 Kern Sibbald and John Walker
+ Copyright (C) 2002-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
/* Imported functions */
int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
+void select_restore_setup();
/* Exported variables */
-GtkWidget *app1; /* application window */
+GtkWidget *console; /* application window */
GtkWidget *text1; /* text window */
GtkWidget *entry1; /* entry box */
GtkWidget *status1; /* status bar */
GtkWidget *run_dialog; /* run dialog */
GtkWidget *dir_dialog; /* director selection dialog */
GtkWidget *restore_dialog; /* restore dialog */
-GtkWidget *restore_files; /* restore files dialog */
+GtkWidget *restore_file_selection;
GtkWidget *dir_select;
GtkWidget *about1; /* about box */
GtkWidget *label_dialog;
GList *type_list, *level_list;
/* Forward referenced functions */
-static void terminate_console(int sig);
-static gint message_handler(gpointer data);
-static int initial_connect_to_director(gpointer data);
+void terminate_console(int sig);
+
+extern "C" {
+ static gint message_handler(gpointer data);
+ static int initial_connect_to_director(gpointer data);
+}
+
static void set_scroll_bar_to_end(void);
/* Static variables */
static char *configfile = NULL;
static DIRRES *dir;
static int ndir;
-static int director_reader_running = FALSE;
+static bool director_reader_running = false;
static bool at_prompt = false;
static bool ready = false;
static bool quit = false;
static void usage()
{
fprintf(stderr, _(
+"Copyright (C) 2002-2004 Kern Sibbald and John Walker\n"
"\nVersion: " VERSION " (" BDATE ") %s %s %s\n\n"
"Usage: gnome-console [-s] [-c config_file] [-d debug_level] [config_file]\n"
" -c <file> set configuration file to file\n"
int no_signals = TRUE;
int test_config = FALSE;
int gargc = 1;
- char *gargv[2] = {"gnome-console", NULL};
+ const char *gargv[2] = {"gnome-console", NULL};
CONFONTRES *con_font;
init_stack_dump();
- app1 = create_app1();
- gtk_window_set_default_size(GTK_WINDOW(app1), 800, 700);
+ console = create_console();
+ gtk_window_set_default_size(GTK_WINDOW(console), 800, 700);
run_dialog = create_RunDialog();
label_dialog = create_label_dialog();
- restore_dialog = create_restore_dialog();
- restore_files = create_restore_files();
+ restore_dialog = create_RestoreDialog();
about1 = create_about1();
- gtk_widget_show(app1);
+ text1 = lookup_widget(console, "text1");
+ entry1 = lookup_widget(console, "entry1");
+ status1 = lookup_widget(console, "status1");
+ scroll1 = lookup_widget(console, "scroll1");
- text1 = lookup_widget(app1, "text1");
- entry1 = lookup_widget(app1, "entry1");
- status1 = lookup_widget(app1, "status1");
- scroll1 = lookup_widget(app1, "scroll1");
+ select_restore_setup();
+
+ gtk_widget_show(console);
/*
* Thanks to Phil Stracchino for providing the font configuration code.
text_font = gdk_font_load("-misc-fixed-medium-r-normal-*-*-130-*-*-c-*-iso8859-1");
}
font_desc = pango_font_description_from_string("LucidaTypewriter 9");
- gtk_widget_modify_font (app1, font_desc);
- gtk_widget_modify_font (text1, font_desc);
- gtk_widget_modify_font (entry1, font_desc);
- gtk_widget_modify_font (status1, font_desc);
- pango_font_description_free (font_desc);
+ gtk_widget_modify_font(console, font_desc);
+ gtk_widget_modify_font(text1, font_desc);
+ gtk_widget_modify_font(entry1, font_desc);
+ gtk_widget_modify_font(status1, font_desc);
+ pango_font_description_free(font_desc);
if (test_config) {
terminate_console(0);
}
-static GList *get_and_fill_combo(GtkWidget *dialog, char *combo_name, char *cmd)
+static GList *get_and_fill_combo(GtkWidget *dialog, const char *combo_name, const char *cm)
{
GtkWidget *combo;
GList *options;
return options;
}
-static void fill_combo(GtkWidget *dialog, char *combo_name, GList *options)
+static void fill_combo(GtkWidget *dialog, const char *combo_name, GList *options)
{
GtkWidget *combo;
combo = lookup_widget(dialog, combo_name);
- if (combo) {
+ if (combo && options) {
gtk_combo_set_popdown_strings(GTK_COMBO(combo), options);
}
return;
{
GList *dirs = NULL;
GtkWidget *combo;
- char buf[1000];
JCR jcr;
if (ndir > 1) {
LockRes();
foreach_res(dir, R_DIRECTOR) {
- sprintf(buf, "%s at %s:%d", dir->hdr.name, dir->address,
- dir->DIRport);
- printf("%s\n", buf);
dirs = g_list_append(dirs, dir->hdr.name);
}
UnlockRes();
dir_dialog = create_SelectDirectorDialog();
combo = lookup_widget(dir_dialog, "combo1");
dir_select = lookup_widget(dir_dialog, "dirselect");
- gtk_combo_set_popdown_strings(GTK_COMBO(combo), dirs);
- printf("dialog run\n");
+ if (dirs) {
+ gtk_combo_set_popdown_strings(GTK_COMBO(combo), dirs);
+ }
gtk_widget_show(dir_dialog);
gtk_main();
}
if (!dir) {
- printf("dir is NULL\n");
return 0;
}
type_list = get_and_fill_combo(run_dialog, "combo_type", ".types");
level_list = get_and_fill_combo(run_dialog, "combo_level", ".levels");
+ /* Fill the label dialog combo boxes */
fill_combo(label_dialog, "label_combo_storage", storage_list);
fill_combo(label_dialog, "label_combo_pool", pool_list);
+
+ /* Fill the restore_dialog combo boxes */
+ fill_combo(restore_dialog, "combo_restore_job", job_list);
+ fill_combo(restore_dialog, "combo_restore_client", client_list);
+ fill_combo(restore_dialog, "combo_restore_fileset", fileset_list);
+ fill_combo(restore_dialog, "combo_restore_pool", pool_list);
+ fill_combo(restore_dialog, "combo_restore_storage", storage_list);
+
set_status(" Connected");
return 1;
}
-void write_director(gchar *msg)
+void write_director(const gchar *msg)
{
if (UA_sock) {
at_prompt = false;
}
}
+extern "C"
void read_director(gpointer data, gint fd, GdkInputCondition condition)
{
int stat;
if (director_reader_running || !UA_sock) {
return;
}
- director_reader_running = TRUE;
-
tag = gdk_input_add(UA_sock->fd, GDK_INPUT_READ, read_director, NULL);
+ director_reader_running = true;
}
void stop_director_reader(gpointer data)
return;
}
gdk_input_remove(tag);
- director_reader_running = FALSE;
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ gdk_input_remove(tag);
+ director_reader_running = false;
}
/* Cleanup and then exit */
-static void terminate_console(int sig)
+void terminate_console(int sig)
{
static int already_here = FALSE;
gtk_text_iter_set_offset(&iter, len);
}
-void set_textf(char *fmt, ...)
+void set_textf(const char *fmt, ...)
{
va_list arg_ptr;
char buf[1000];
set_text(buf, len);
}
-void set_text(char *buf, int len)
+void set_text(const char *buf, int len)
{
GtkTextBuffer *textbuf;
GtkTextIter iter;
set_scroll_bar_to_end();
}
-void set_statusf(char *fmt, ...)
+void set_statusf(const char *fmt, ...)
{
va_list arg_ptr;
char buf[1000];
// set_scroll_bar_to_end();
}
-void set_status(char *buf)
+void set_status(const char *buf)
{
gtk_label_set_text(GTK_LABEL(status1), buf);
// set_scroll_bar_to_end();