1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Naba Kumar <naba@gnome.org>
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 of the License, or
9 * (at your option) 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * @title: Program resources
24 * @short_description: Application resource management
26 * @stability: Unstable
27 * @include: libanjuta/resources.h
37 #include <libanjuta/resources.h>
40 anjuta_res_lookup_widget (GtkWidget
* widget
, const gchar
* widget_name
)
42 GtkWidget
*parent
, *found_widget
;
46 if (GTK_IS_MENU (widget
))
48 gtk_menu_get_attach_widget (GTK_MENU
51 parent
= widget
->parent
;
57 found_widget
= (GtkWidget
*) g_object_get_data (G_OBJECT (widget
),
60 g_warning (_("Widget not found: %s"), widget_name
);
65 anjuta_res_get_image (const gchar
* pixfile
)
70 if (!pixfile
|| !pixfile
[0])
71 return gtk_image_new ();
73 pathname
= anjuta_res_get_pixmap_file (pixfile
);
76 g_warning (_("Could not find application pixmap file: %s"),
78 return gtk_image_new ();
80 pixmap
= gtk_image_new_from_file (pathname
);
86 anjuta_res_get_image_sized (const gchar
* pixfile
, gint width
, gint height
)
92 if (!pixfile
|| !pixfile
[0])
93 return gtk_image_new ();
95 pathname
= anjuta_res_get_pixmap_file (pixfile
);
98 g_warning (_("Could not find application pixmap file: %s"),
100 return gtk_image_new ();
102 pixbuf
= gdk_pixbuf_new_from_file_at_size (pathname
, width
, height
, NULL
);
103 pixmap
= gtk_image_new_from_pixbuf (pixbuf
);
104 gdk_pixbuf_unref (pixbuf
);
109 /* All the return strings MUST be freed */
111 anjuta_res_get_pixmap_dir ()
114 path
= g_strdup (PACKAGE_PIXMAPS_DIR
);
115 if (g_file_test (path
, G_FILE_TEST_IS_DIR
))
122 anjuta_res_get_data_dir ()
125 path
= g_strdup (PACKAGE_DATA_DIR
);
126 if (g_file_test (path
, G_FILE_TEST_IS_DIR
))
133 anjuta_res_get_help_dir ()
136 path
= g_strdup (PACKAGE_HELP_DIR
);
137 if (g_file_test (path
, G_FILE_TEST_IS_DIR
))
144 anjuta_res_get_help_dir_locale (const gchar
* locale
)
148 path
= g_strconcat (PACKAGE_HELP_DIR
, "/", locale
, NULL
);
150 path
= g_strdup (PACKAGE_HELP_DIR
);
151 if (g_file_test (path
, G_FILE_TEST_IS_DIR
))
158 anjuta_res_get_doc_dir ()
161 path
= g_strdup (PACKAGE_DOC_DIR
);
162 if (g_file_test (path
, G_FILE_TEST_IS_DIR
))
168 /* All the return strings MUST be freed */
170 anjuta_res_get_pixmap_file (const gchar
* pixfile
)
173 g_return_val_if_fail (pixfile
!= NULL
, NULL
);
174 path
= g_strconcat (PACKAGE_PIXMAPS_DIR
, "/", pixfile
, NULL
);
175 if (g_file_test (path
, G_FILE_TEST_IS_REGULAR
))
177 g_warning ("Pixmap file not found: %s", path
);
183 anjuta_res_get_data_file (const gchar
* datafile
)
186 g_return_val_if_fail (datafile
!= NULL
, NULL
);
187 path
= g_strconcat (PACKAGE_DATA_DIR
, "/", datafile
, NULL
);
188 if (g_file_test (path
, G_FILE_TEST_IS_REGULAR
))
195 anjuta_res_get_help_file (const gchar
* helpfile
)
198 g_return_val_if_fail (helpfile
!= NULL
, NULL
);
199 path
= g_strconcat (PACKAGE_HELP_DIR
, "/", helpfile
, NULL
);
200 if (g_file_test (path
, G_FILE_TEST_IS_REGULAR
))
207 anjuta_res_get_help_file_locale (const gchar
* helpfile
, const gchar
* locale
)
210 g_return_val_if_fail (helpfile
!= NULL
, NULL
);
212 path
= g_strconcat (PACKAGE_HELP_DIR
, "/", locale
, "/",
215 path
= g_strconcat (PACKAGE_HELP_DIR
, "/", helpfile
, NULL
);
216 if (g_file_test (path
, G_FILE_TEST_IS_REGULAR
))
223 anjuta_res_get_doc_file (const gchar
* docfile
)
226 g_return_val_if_fail (docfile
!= NULL
, NULL
);
227 path
= g_strconcat (PACKAGE_DOC_DIR
, "/", docfile
, NULL
);
228 if (g_file_test (path
, G_FILE_TEST_IS_REGULAR
))
235 /* File type icons 16x16 */
237 anjuta_res_get_icon_for_file (PropsID props
, const gchar
*filename
)
243 g_return_val_if_fail (filename
!= NULL
, NULL
);
244 file
= g_path_get_basename (filename
);
245 value
= prop_get_new_expand (props
, "icon.", file
);
247 value
= g_strdup ("file_text.png");
248 pixbuf
= anjuta_res_get_pixbuf (value
);
256 anjuta_res_help_search (const gchar
* word
)
260 fprintf(stderr
, "Word is %s\n", word
);
263 execlp("devhelp", "devhelp", "-s", word
, NULL
);
264 g_warning (_("Cannot execute command: \"%s\""), "devhelp");
272 execlp("devhelp", "devhelp", NULL
);
273 g_warning (_("Cannot execute command: \"%s\""), "devhelp");
279 void anjuta_res_url_show (const char *url
)
281 GError
*error
= NULL
;
282 gnome_url_show (url
, &error
);