|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * dialog-object-references.c -- dialog for displaying a list of * 00003 * objects which refer to another * 00004 * specific object * 00005 * * 00006 * Copyright (C) 2010 Phil Longstaff (plongstaff@rogers.com) * 00007 * * 00008 * This program is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU General Public License as * 00010 * published by the Free Software Foundation; either version 2 of * 00011 * the License, or (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License* 00019 * along with this program; if not, contact: * 00020 * * 00021 * Free Software Foundation Voice: +1-617-542-5942 * 00022 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00023 * Boston, MA 02110-1301, USA gnu@gnu.org * 00024 \********************************************************************/ 00025 00026 #include "config.h" 00027 00028 #include <gtk/gtk.h> 00029 #include <glib/gi18n.h> 00030 00031 #include "gnc-ui.h" 00032 #include "dialog-utils.h" 00033 #include "dialog-object-references.h" 00034 00035 static QofLogModule log_module = GNC_MOD_GUI; 00036 00037 void 00038 gnc_ui_object_references_show( const gchar* explanation_text, GList* objlist ) 00039 { 00040 GtkWidget* dialog; 00041 GtkBuilder* builder; 00042 GtkWidget* box; 00043 GList* ds_node; 00044 GtkButton* op; 00045 GList* node; 00046 GtkLabel* explanation; 00047 GtkListStore* store; 00048 GtkWidget* listview; 00049 GtkTreeViewColumn* column; 00050 GtkCellRenderer* renderer; 00051 gint response; 00052 00053 ENTER(""); 00054 00055 /* Open the dialog */ 00056 builder = gtk_builder_new(); 00057 gnc_builder_add_from_file (builder, "dialog-object-references.glade", "Object references" ); 00058 dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Object references" )); 00059 00060 explanation = GTK_LABEL(gtk_builder_get_object (builder, "lbl_explanation" )); 00061 gtk_label_set_text( explanation, explanation_text ); 00062 00063 /* Set up the list store */ 00064 store = gtk_list_store_new( 1, G_TYPE_STRING ); 00065 for ( node = objlist; node != NULL; node = node->next ) 00066 { 00067 QofInstance* inst = node->data; 00068 GtkTreeIter iter; 00069 00070 gtk_list_store_append( store, &iter ); 00071 gtk_list_store_set( store, &iter, 0, qof_instance_get_display_name( inst ), -1 ); 00072 } 00073 00074 /* Set up the list view */ 00075 listview = gtk_tree_view_new_with_model( GTK_TREE_MODEL(store) ); 00076 renderer = gtk_cell_renderer_text_new(); 00077 column = gtk_tree_view_column_new_with_attributes( "Object", renderer, "text", 0, NULL ); 00078 gtk_tree_view_append_column( GTK_TREE_VIEW(listview), column ); 00079 00080 box = GTK_WIDGET(gtk_builder_get_object (builder, "hbox_list" )); 00081 gtk_container_add( GTK_CONTAINER(box), listview ); 00082 00083 /* Autoconnect signals */ 00084 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, dialog); 00085 00086 /* Run the dialog */ 00087 gtk_widget_show_all( dialog ); 00088 response = gtk_dialog_run( GTK_DIALOG(dialog) ); 00089 g_object_unref(G_OBJECT(builder)); 00090 gtk_widget_destroy( dialog ); 00091 00092 LEAVE(""); 00093 }
1.7.4