]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/gnome2-console/callbacks.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / gnome2-console / callbacks.c
index fc03aba7342bd1c791327037c9a98c7d4adc717e..f6fbfb930ea29c6480bad492aa1a269c06ab7d13 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  *    Version $Id$
  */
 
 #define KEY_Left  65361
 #define KEY_Right 65363
 
+void terminate_console(int sig);
+
+extern "C" gint compare_func(const void *data1, const void *data2);
+
 gboolean
 on_console_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
 {
    gtk_main_quit();
-   return FALSE;
+   terminate_console(0);
+   return TRUE;
 }
 
 void
@@ -100,8 +105,8 @@ on_connect_button_clicked(GtkButton *button, gpointer user_data)
    }
 }
 
-/* Define max length of history and how many to delete when it gets there.  
- * If you make HIST_DEL > HIST_MAX, you shoot yourself in the foot. 
+/* Define max length of history and how many to delete when it gets there.
+ * If you make HIST_DEL > HIST_MAX, you shoot yourself in the foot.
  */
 #define HIST_MAX 2500
 #define HIST_DEL  500
@@ -128,7 +133,7 @@ static void add_to_history(gchar *ecmd)
       }
       hist_len -= HIST_DEL;
    }
-   hc = NULL;            
+   hc = NULL;
 }
 
 /*
@@ -148,21 +153,33 @@ on_entry1_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer user_d
       gtk_entry_set_text((GtkEntry *)entry1, "");
    } else if (event->keyval == KEY_Up) {
       if (!hc) {
+        if (!hist) {
+           return FALSE;
+        }
         hc = g_list_last(hist);
       } else {
         hc = g_list_previous(hc);
       }
       if (!hc) {
+        if (!hist) {
+           return FALSE;
+        }
         hc = g_list_first(hist);
       }
       gtk_entry_set_text((GtkEntry *)entry1, (gchar *)hc->data);
    } else if (event->keyval == KEY_Down) {
       if (!hc) {
+        if (!hist) {
+           return FALSE;
+        }
         hc = g_list_first(hist);
       } else {
         hc = g_list_next(hc);
       }
       if (!hc) {
+        if (!hist) {
+           return FALSE;
+        }
         hc = g_list_last(hist);
       }
       gtk_entry_set_text((GtkEntry *)entry1, (gchar *)hc->data);
@@ -222,7 +239,8 @@ on_select_director_cancel_clicked(GtkButton *button, gpointer user_data)
 /*
  * Compare list string items
  */
-static gint compare_func(const void *data1, const void *data2)
+extern "C"
+gint compare_func(const void *data1, const void *data2)
 {
    return strcmp((const char *)data1, (const char *)data2);
 }
@@ -280,12 +298,12 @@ static void set_run_defaults()
       }
       *def++ = 0;
       if (strcmp(UA_sock->msg, "job") == 0 ||
-          strcmp(UA_sock->msg, "when") == 0) {
+         strcmp(UA_sock->msg, "when") == 0) {
         continue;
       }
       /* Where is an entry box */
       if (strcmp(UA_sock->msg, "where") == 0) {
-         entry = lookup_widget(run_dialog, "entry_where");
+        entry = lookup_widget(run_dialog, "entry_where");
         gtk_entry_set_text(GTK_ENTRY(entry), def);
         continue;
       }
@@ -329,7 +347,7 @@ on_run_button_clicked(GtkButton *button, gpointer user_data)
 }
 
 
-static char *get_combo_text(GtkWidget *dialog, char *combo_name)
+static char *get_combo_text(GtkWidget *dialog, const char *combo_name)
 {
    GtkWidget *combo;
    combo = lookup_widget(dialog, combo_name);
@@ -339,7 +357,7 @@ static char *get_combo_text(GtkWidget *dialog, char *combo_name)
    return (char *)gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
 }
 
-static char *get_entry_text(GtkWidget *dialog, char *entry_name)
+static char *get_entry_text(GtkWidget *dialog, const char *entry_name)
 {
    GtkWidget *entry;
    entry = lookup_widget(dialog, entry_name);
@@ -349,7 +367,7 @@ static char *get_entry_text(GtkWidget *dialog, char *entry_name)
    return (char *)gtk_entry_get_text(GTK_ENTRY(entry));
 }
 
-static char *get_spin_text(GtkWidget *dialog, char *spin_name)
+static char *get_spin_text(GtkWidget *dialog, const char *spin_name)
 {
    GtkSpinButton *spin;
    spin = (GtkSpinButton *)lookup_widget(dialog, spin_name);
@@ -385,12 +403,13 @@ on_run_ok_clicked(GtkButton *button, gpointer user_data)
       set_status_ready();
       return;
    }
-      
-   bsnprintf(cmd, sizeof(cmd), 
-             "run job=\"%s\" fileset=\"%s\" level=%s client=\"%s\" pool=\"%s\" "
-             "when=\"%s\" where=\"%s\" storage=\"%s\"", 
+
+   bsnprintf(cmd, sizeof(cmd),
+            "run job=\"%s\" fileset=\"%s\" level=%s client=\"%s\" pool=\"%s\" "
+            "when=\"%s\" where=\"%s\" storage=\"%s\"",
             job, fileset, level, client, pool, when, where, storage);
    write_director(cmd);
+   set_text(cmd, strlen(cmd));
    write_director("yes");
    return;
 }
@@ -458,11 +477,12 @@ on_label_ok_clicked(GtkButton *button, gpointer user_data)
       set_status_ready();
       return;
    }
-      
-   bsnprintf(cmd, sizeof(cmd), 
-             "label name=\"%s\" pool=\"%s\" storage=\"%s\" slot=%s", 
+
+   bsnprintf(cmd, sizeof(cmd),
+            "label name=\"%s\" pool=\"%s\" storage=\"%s\" slot=%s",
             volume, pool, storage, slot);
    write_director(cmd);
+   set_text(cmd, strlen(cmd));
 }
 
 
@@ -494,11 +514,12 @@ on_select_files_button_clicked(GtkButton *button, gpointer user_data)
       set_status_ready();
       return;
    }
-      
-   bsnprintf(cmd, sizeof(cmd), 
-             "restore select current fileset=\"%s\" client=\"%s\" pool=\"%s\" "
-             "storage=\"%s\"", fileset, client, pool, storage);
+
+   bsnprintf(cmd, sizeof(cmd),
+            "restore select current fileset=\"%s\" client=\"%s\" pool=\"%s\" "
+            "storage=\"%s\"", fileset, client, pool, storage);
    write_director(cmd);
+   set_text(cmd, strlen(cmd));
    gtk_widget_show(restore_file_selection);
    select_restore_files();           /* put up select files dialog */
 }
@@ -651,11 +672,11 @@ void set_restore_dialog_defaults()
       }
       *def++ = 0;
       if (strcmp(UA_sock->msg, "job") == 0 ||
-          strcmp(UA_sock->msg, "when") == 0 ||
-          strcmp(UA_sock->msg, "where") == 0 ||
-          strcmp(UA_sock->msg, "messages") == 0 ||
-          strcmp(UA_sock->msg, "level") == 0 ||
-          strcmp(UA_sock->msg, "type") == 0) {
+         strcmp(UA_sock->msg, "when") == 0 ||
+         strcmp(UA_sock->msg, "where") == 0 ||
+         strcmp(UA_sock->msg, "messages") == 0 ||
+         strcmp(UA_sock->msg, "level") == 0 ||
+         strcmp(UA_sock->msg, "type") == 0) {
         continue;
       }