GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dialog-object-references.c
1 /********************************************************************\
2  * dialog-object-references.c -- dialog for displaying a list of *
3  * objects which refer to another *
4  * specific object *
5  * *
6  * Copyright (C) 2010 Phil Longstaff ([email protected]) *
7  * *
8  * This program is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU General Public License as *
10  * published by the Free Software Foundation; either version 2 of *
11  * the License, or (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License*
19  * along with this program; if not, contact: *
20  * *
21  * Free Software Foundation Voice: +1-617-542-5942 *
22  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
23  * Boston, MA 02110-1301, USA [email protected] *
24 \********************************************************************/
25 
26 #include "config.h"
27 
28 #include <gtk/gtk.h>
29 #include <glib/gi18n.h>
30 
31 #include "gnc-ui.h"
32 #include "dialog-utils.h"
34 
35 static QofLogModule log_module = GNC_MOD_GUI;
36 
37 void
38 gnc_ui_object_references_show( const gchar* explanation_text, GList* objlist )
39 {
40  GtkWidget* dialog;
41  GtkBuilder* builder;
42  GtkWidget* box;
43  GList* node;
44  GtkLabel* explanation;
45  GtkListStore* store;
46  GtkWidget* listview;
47  GtkTreeViewColumn* column;
48  GtkCellRenderer* renderer;
49 
50  ENTER("");
51 
52  /* Open the dialog */
53  builder = gtk_builder_new();
54  gnc_builder_add_from_file (builder, "dialog-object-references.glade", "Object references" );
55  dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Object references" ));
56 
57  explanation = GTK_LABEL(gtk_builder_get_object (builder, "lbl_explanation" ));
58  gtk_label_set_text( explanation, explanation_text );
59 
60  /* Set up the list store */
61  store = gtk_list_store_new( 1, G_TYPE_STRING );
62  for ( node = objlist; node != NULL; node = node->next )
63  {
64  QofInstance* inst = node->data;
65  GtkTreeIter iter;
66 
67  gtk_list_store_append( store, &iter );
68  gtk_list_store_set( store, &iter, 0, qof_instance_get_display_name( inst ), -1 );
69  }
70 
71  /* Set up the list view */
72  listview = gtk_tree_view_new_with_model( GTK_TREE_MODEL(store) );
73  renderer = gtk_cell_renderer_text_new();
74  column = gtk_tree_view_column_new_with_attributes( "Object", renderer, "text", 0, NULL );
75  gtk_tree_view_append_column( GTK_TREE_VIEW(listview), column );
76 
77  box = GTK_WIDGET(gtk_builder_get_object (builder, "hbox_list" ));
78  gtk_container_add( GTK_CONTAINER(box), listview );
79 
80  /* Autoconnect signals */
81  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, dialog);
82 
83  /* Run the dialog */
84  gtk_widget_show_all( dialog );
85  gtk_dialog_run( GTK_DIALOG(dialog) );
86  g_object_unref(G_OBJECT(builder));
87  gtk_widget_destroy( dialog );
88 
89  LEAVE("");
90 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
const gchar * QofLogModule
Definition: qofid.h:89
gchar * qof_instance_get_display_name(const QofInstance *inst)