]> git.street.me.uk Git - andy/viking.git/blobdiff - src/background.c
Add the storage and retrieval of any kind of track or waypoint selected item (either...
[andy/viking.git] / src / background.c
index d1d0c9b5ff461fc5b02897a58908e38670c896db..2cc3a178531b0c4aab75a02e07cf9b788a2ea3ff 100644 (file)
@@ -78,7 +78,8 @@ static void thread_die ( gpointer args[6] )
 {
   vik_thr_free_func userdata_free_func = args[3];
 
-  userdata_free_func ( args[2] );
+  if ( userdata_free_func != NULL )
+    userdata_free_func ( args[2] );
 
   if ( GPOINTER_TO_INT(args[6]) )
   {
@@ -104,7 +105,8 @@ int a_background_testcancel ( gpointer callbackdata )
   }
   return 0;
 }
-void thread_helper ( gpointer args[6], gpointer user_data )
+
+static void thread_helper ( gpointer args[6], gpointer user_data )
 {
   /* unpack args */
   vik_thr_func func = args[1];
@@ -122,6 +124,18 @@ void thread_helper ( gpointer args[6], gpointer user_data )
   thread_die ( args );
 }
 
+/**
+ * a_background_thread:
+ * @parent:
+ * @message:
+ * @func: worker function
+ * @userdata:
+ * @userdata_free_func: free function for userdata
+ * @userdata_cancel_cleanup_func:
+ * @number_items:
+ *
+ * Function to enlist new background function.
+ */
 void a_background_thread ( GtkWindow *parent, const gchar *message, vik_thr_func func, gpointer userdata, vik_thr_free_func userdata_free_func, vik_thr_free_func userdata_cancel_cleanup_func, gint number_items )
 {
   GtkTreeIter *piter = g_malloc ( sizeof ( GtkTreeIter ) );
@@ -150,6 +164,11 @@ void a_background_thread ( GtkWindow *parent, const gchar *message, vik_thr_func
   g_thread_pool_push( thread_pool, args, NULL );
 }
 
+/**
+ * a_background_show_window:
+ *
+ * Display the background window.
+ */
 void a_background_show_window ()
 {
   gtk_widget_show_all ( bgwindow );
@@ -159,7 +178,7 @@ static void cancel_job_with_iter ( GtkTreeIter *piter )
 {
     gpointer *args;
 
-  g_debug(__FUNCTION__);
+    g_debug(__FUNCTION__);
 
     gtk_tree_model_get( GTK_TREE_MODEL(bgstore), piter, DATA_COLUMN, &args, -1 );
 
@@ -199,6 +218,11 @@ static void bgwindow_response (GtkDialog *dialog, gint arg1 )
     gtk_widget_hide ( bgwindow );
 }
 
+/**
+ * a_background_init:
+ *
+ * Initialize background feature.
+ */
 void a_background_init()
 {
   /* initialize thread pool */
@@ -234,9 +258,16 @@ void a_background_init()
   gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
 
   bgwindow = gtk_dialog_new_with_buttons ( "", NULL, 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_DELETE, 1, GTK_STOCK_CLEAR, 2, NULL );
+  gtk_dialog_set_default_response ( GTK_DIALOG(bgwindow), GTK_RESPONSE_ACCEPT );
+  GtkWidget *response_w = NULL;
+#if GTK_CHECK_VERSION (2, 20, 0)
+  response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(bgwindow), GTK_RESPONSE_ACCEPT );
+#endif
   gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(bgwindow)->vbox), scrolled_window, TRUE, TRUE, 0 );
   gtk_window_set_default_size ( GTK_WINDOW(bgwindow), 400, 400 );
   gtk_window_set_title ( GTK_WINDOW(bgwindow), _("Viking Background Jobs") );
+  if ( response_w )
+    gtk_widget_grab_focus ( response_w );
   /* don't destroy win */
   g_signal_connect ( G_OBJECT(bgwindow), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL );
 
@@ -244,6 +275,11 @@ void a_background_init()
 
 }
 
+/**
+ * a_background_uninit:
+ *
+ * Uninitialize background feature.
+ */
 void a_background_uninit()
 {
   /* wait until all running threads stop */