Modification log added
[mediadatabase.git] / gtk / glade.c
blob72ca571e34c70c200ad48a7e4c83af2bbf60f61e
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * $Id: glade.c,v 1.6 2005/02/19 13:37:47 nedko Exp $
6 * DESCRIPTION:
7 * libglade helpers
9 *****************************************************************************/
11 #include <stdlib.h>
12 #include <gtk/gtk.h>
13 #include <glade/glade.h>
15 #include "glade.h"
16 #include "path.h"
18 static void
19 glade_signal_connect_func(
20 const gchar *cb_name, GObject *obj,
21 const gchar *signal_name, const gchar *signal_data,
22 GObject *conn_obj, gboolean conn_after,
23 gpointer user_data)
25 /** Module with all the symbols of the program */
26 static GModule *mod_self = NULL;
27 gpointer handler_func;
29 /* initialize gmodule */
30 if (mod_self == NULL)
32 mod_self = g_module_open(NULL, 0);
33 g_assert(mod_self != NULL);
36 /* g_print("glade_signal_connect_func:" */
37 /* " cb_name = '%s', signal_name = '%s', " */
38 /* "signal_data = '%s', obj = 0x%08X, conn_after = %s\n", */
39 /* cb_name, signal_name, */
40 /* signal_data, (unsigned int)obj, conn_after?"true":"false"); */
42 if (g_module_symbol(mod_self, cb_name, &handler_func))
44 /* found callback */
45 if (conn_obj)
47 if (conn_after)
49 g_signal_connect_object(
50 obj,
51 signal_name,
52 handler_func,
53 conn_obj,
54 G_CONNECT_AFTER);
56 else
58 g_signal_connect_object(
59 obj,
60 signal_name,
61 handler_func,
62 conn_obj,
63 G_CONNECT_SWAPPED);
66 else
68 /* no conn_obj; use standard connect */
69 gpointer data = NULL;
71 data = user_data;
73 if (conn_after)
75 g_signal_connect_after(
76 obj,
77 signal_name,
78 handler_func,
79 data);
81 else
83 g_signal_connect(
84 obj,
85 signal_name,
86 handler_func,
87 data);
91 else
93 g_warning("callback function not found: %s", cb_name);
97 GtkWidget *
98 construct_glade_widget(
99 const gchar * id)
101 gchar * glade_filename;
102 GtkWidget * widget;
103 GladeXML * xml;
105 glade_filename = path_get_data_filename("mediadatabase.glade");
106 if (glade_filename == NULL)
108 g_warning("Cannot find glade UI description file.");
109 exit(1);
112 /* load the interface */
113 xml = glade_xml_new(glade_filename, id, NULL);
115 g_free(glade_filename);
117 widget = glade_xml_get_widget(xml, id);
119 /* connect the signals in the interface */
120 glade_xml_signal_autoconnect_full(
121 xml,
122 (GladeXMLConnectFunc)glade_signal_connect_func,
123 widget);
125 return widget;
128 GtkWidget *
129 get_glade_widget_child(
130 GtkWidget * root,
131 const gchar * id)
133 GladeXML * xml;
134 GtkWidget * widget;
136 xml = glade_get_widget_tree(root);
138 widget = glade_xml_get_widget(xml, id);
140 return widget;
143 void
144 setup_text_combo(
145 GtkWidget * combo)
147 GtkCellRenderer * cell;
148 GtkListStore * store;
150 store = gtk_list_store_new(1, G_TYPE_STRING);
151 gtk_combo_box_set_model(GTK_COMBO_BOX(combo), GTK_TREE_MODEL(store));
152 g_object_unref(store);
154 cell = gtk_cell_renderer_text_new();
155 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
157 gtk_cell_layout_set_attributes(
158 GTK_CELL_LAYOUT(combo), cell,
159 "text", 0,
160 NULL);
163 /*****************************************************************************
165 * Modifications log:
167 * !!! WARNING !!! Following lines are automatically updated by the CVS system.
169 * $Log: glade.c,v $
170 * Revision 1.6 2005/02/19 13:37:47 nedko
171 * gtk_combo_box_new_text for glade
173 * Revision 1.5 2005/02/18 22:41:26 nedko
174 * Improve connect dump
176 * Revision 1.4 2005/02/18 22:18:07 nedko
177 * Cleanup things and make them better way.
179 * Revision 1.3 2005/02/18 21:38:28 nedko
180 * NOTSURE: Load more than one window.
182 * Revision 1.2 2005/02/18 02:14:22 nedko
183 * Set source file description
185 * Revision 1.1 2005/02/18 02:13:35 nedko
186 * libglade helpers.
188 *****************************************************************************/