Updated Macedonian Translation <arangela@cvs.gnome.org>
[rhythmbox.git] / lib / rb-glade-helpers.c
blob2a3c4f496df59451b659c4676be2c471e1f2c541
1 /*
2 * arch-tag: Implementation of Rhythmbox Glade XML utility functions
4 * Copyright (C) 2002 Jorn Baayen
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <gmodule.h>
23 #include <gtk/gtk.h>
24 #include <string.h>
26 #include "rb-glade-helpers.h"
27 #include "rb-file-helpers.h"
29 static void glade_signal_connect_func (const gchar *cb_name, GObject *obj,
30 const gchar *signal_name, const gchar *signal_data,
31 GObject *conn_obj, gboolean conn_after,
32 gpointer user_data);
34 GladeXML *
35 rb_glade_xml_new (const char *file,
36 const char *root,
37 gpointer user_data)
39 GladeXML *xml;
41 xml = glade_xml_new (rb_file (file), root, NULL);
43 glade_xml_signal_autoconnect_full (xml,
44 (GladeXMLConnectFunc) glade_signal_connect_func,
45 user_data);
47 return xml;
50 static void
51 glade_signal_connect_func (const gchar *cb_name, GObject *obj,
52 const gchar *signal_name, const gchar *signal_data,
53 GObject *conn_obj, gboolean conn_after,
54 gpointer user_data)
56 /** Module with all the symbols of the program */
57 static GModule *mod_self = NULL;
58 gpointer handler_func;
60 /* initialize gmodule */
61 if (mod_self == NULL)
63 mod_self = g_module_open (NULL, 0);
64 g_assert (mod_self != NULL);
67 if (g_module_symbol (mod_self, cb_name, &handler_func))
69 /* found callback */
70 if (conn_obj)
72 if (conn_after)
74 g_signal_connect_object
75 (obj, signal_name,
76 handler_func, conn_obj,
77 G_CONNECT_AFTER);
79 else
81 g_signal_connect_object
82 (obj, signal_name,
83 handler_func, conn_obj,
84 G_CONNECT_SWAPPED);
87 else
89 /* no conn_obj; use standard connect */
90 gpointer data = NULL;
92 data = user_data;
94 if (conn_after)
96 g_signal_connect_after
97 (obj, signal_name,
98 handler_func, data);
100 else
102 g_signal_connect
103 (obj, signal_name,
104 handler_func, data);
108 else
110 g_warning("callback function not found: %s", cb_name);
114 void
115 rb_glade_boldify_label (GladeXML *xml, const char *name)
117 GtkWidget *widget;
119 widget = glade_xml_get_widget (xml, name);
121 if (widget == NULL) {
122 g_warning ("widget '%s' not found", name);
123 return;
126 /* this way is probably better, but for some reason doesn't work with
127 * labels with mnemonics.
129 static PangoAttrList *pattrlist = NULL;
131 if (pattrlist == NULL) {
132 PangoAttribute *attr;
134 pattrlist = pango_attr_list_new ();
135 attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
136 attr->start_index = 0;
137 attr->end_index = G_MAXINT;
138 pango_attr_list_insert (pattrlist, attr);
140 gtk_label_set_attributes (GTK_LABEL (widget), pattrlist);*/
142 gchar *str_final;
143 str_final = g_strdup_printf ("<b>%s</b>", gtk_label_get_label (GTK_LABEL (widget)));
144 gtk_label_set_markup_with_mnemonic (GTK_LABEL (widget), str_final);
145 g_free (str_final);
148 gboolean
149 rb_combo_box_hyphen_separator_func (GtkTreeModel *model,
150 GtkTreeIter *iter,
151 gpointer data)
153 const char *s;
155 gtk_tree_model_get (model, iter, 0, &s, -1);
157 if (s == NULL)
158 return FALSE;
160 return (strcmp (s, "-") == 0);