@@ -100,6 +100,11 @@ static void _workspace_select_db(GtkWidget *button, dt_workspace_t *session)
100100 dt_conf_set_string ("database" , "library.db" );
101101 dt_conf_set_string ("workspace/label" , "" );
102102 }
103+ else if (strcmp (label , _ ("memory" )) == 0 )
104+ {
105+ dt_conf_set_string ("database" , ":memory:" );
106+ dt_conf_set_string ("workspace/label" , "memory" );
107+ }
103108 else
104109 {
105110 char * dbname = g_strdup_printf ("library-%s.db" , label );
@@ -123,6 +128,18 @@ static void _workspace_new_db(GtkWidget *button, dt_workspace_t *session)
123128 _workspace_screen_destroy (session );
124129}
125130
131+ static GtkBox * _insert_button (dt_workspace_t * session , const char * label )
132+ {
133+ GtkBox * box = GTK_BOX (dt_gui_hbox ());
134+ GtkWidget * b = gtk_button_new_with_label (label );
135+ gtk_widget_set_hexpand (GTK_WIDGET (b ), TRUE);
136+ dt_gui_box_add (box , b );
137+ g_signal_connect (G_OBJECT (b ), "clicked" ,
138+ G_CALLBACK (_workspace_select_db ), session );
139+ dt_gui_dialog_add (session -> db_screen , box );
140+ return box ;
141+ }
142+
126143void dt_workspace_create (const char * datadir )
127144{
128145 if (dt_check_gimpmode ("file" )
@@ -166,10 +183,11 @@ void dt_workspace_create(const char *datadir)
166183 char * name = (char * )l -> data ;
167184 GtkWidget * b = NULL ;
168185 const gboolean is_default = strcmp (name , "library.db" ) == 0 ;
186+ GtkBox * box = NULL ;
169187
170188 if (is_default )
171189 {
172- b = gtk_button_new_with_label ( _ ("default" ));
190+ box = _insert_button ( session , _ ("default" ));
173191 }
174192 else if (g_str_has_prefix (name , "library-" ))
175193 {
@@ -180,31 +198,27 @@ void dt_workspace_create(const char *datadir)
180198 while (* e != '.' ) e ++ ;
181199 * e = '\0' ;
182200
183- b = gtk_button_new_with_label ( f );
201+ box = _insert_button ( session , f );
184202 }
185203
186- gtk_widget_set_hexpand (GTK_WIDGET (b ), TRUE);
187-
188204 if (strcmp (name , current_db ) == 0 )
189205 current_db_found = TRUE;
190206
191- g_signal_connect (G_OBJECT (b ), "clicked" ,
192- G_CALLBACK (_workspace_select_db ), session );
193-
194- GtkBox * box = GTK_BOX (dt_gui_hbox ());
195- dt_gui_box_add (box , b );
196-
197- if (!is_default )
207+ if (is_default )
208+ {
209+ // add a memory workspace just after default one
210+ box = _insert_button (session , _ ("memory" ));
211+ }
212+ else if (!is_default )
198213 {
199214 GtkWidget * del = dtgtk_button_new (dtgtk_cairo_paint_remove , 0 , NULL );
200215 g_signal_connect (G_OBJECT (del ), "clicked" ,
201216 G_CALLBACK (_workspace_delete_db ), session );
202217 g_object_set_data (G_OBJECT (del ), "db" , b );
203218 dt_gui_box_add (box , del );
204219 }
205-
206- dt_gui_dialog_add (session -> db_screen , box );
207220 }
221+
208222 g_list_free_full (dbs , g_free );
209223
210224 // if the current registerred db is not found reset to
0 commit comments