glade.c (3217B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2010, 2024 GNUnet e.V. 4 5 GNUnet is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with GNUnet; see the file COPYING. If not, write to the 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 21 /** 22 * @file src/lib/glade.c 23 * @brief code for integration with glade 24 * @author Christian Grothoff 25 */ 26 #include "anastasis_gtk_config.h" 27 #include "anastasis_gtk_util.h" 28 29 30 void 31 ANASTASIS_GTK_set_icon_search_path (const struct GNUNET_OS_ProjectData *pd) 32 { 33 char *buf; 34 35 buf = GNUNET_OS_installation_get_path (pd, 36 GNUNET_OS_IPK_ICONDIR); 37 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), 38 buf); 39 GNUNET_free (buf); 40 } 41 42 43 const char * 44 ANASTASIS_GTK_get_data_dir (const struct GNUNET_OS_ProjectData *pd) 45 { 46 static char *dd; 47 48 if (NULL == dd) 49 dd = GNUNET_OS_installation_get_path (pd, 50 GNUNET_OS_IPK_DATADIR); 51 return dd; 52 } 53 54 55 GtkBuilder * 56 ANASTASIS_GTK_get_new_builder2 (const struct GNUNET_OS_ProjectData *pd, 57 const char *filename, 58 void *user_data, 59 GtkBuilderConnectFunc cb) 60 { 61 char *glade_path; 62 GtkBuilder *ret; 63 GError *error; 64 65 ret = gtk_builder_new (); 66 GNUNET_asprintf (&glade_path, 67 "%s%s", 68 ANASTASIS_GTK_get_data_dir (pd), 69 filename); 70 error = NULL; 71 if (0 == gtk_builder_add_from_file (ret, 72 glade_path, 73 &error)) 74 { 75 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 76 _ ("Failed to load `%s': %s\n"), 77 glade_path, 78 error->message); 79 g_error_free (error); 80 GNUNET_free (glade_path); 81 return NULL; 82 } 83 if (NULL == user_data) 84 user_data = ret; 85 if (NULL != cb) 86 gtk_builder_connect_signals_full (ret, 87 cb, user_data); 88 else 89 gtk_builder_connect_signals (ret, 90 user_data); 91 GNUNET_free (glade_path); 92 return ret; 93 } 94 95 96 void 97 GNUNET_FS_GTK_remove_treestore_subtree (GtkTreeStore *ts, 98 GtkTreeIter *root) 99 { 100 GtkTreeIter child; 101 102 while (gtk_tree_model_iter_children (GTK_TREE_MODEL (ts), 103 &child, 104 root)) 105 GNUNET_FS_GTK_remove_treestore_subtree (ts, 106 &child); 107 gtk_tree_store_remove (ts, 108 root); 109 } 110 111 112 /* end of glade.c */