pnmixer
Volume mixer for the system tray
support-ui.c
Go to the documentation of this file.
1 /* support-ui.c
2  * PNmixer is written by Nick Lanham, a fork of OBmixer
3  * which was programmed by Lee Ferrett, derived
4  * from the program "AbsVolume" by Paul Sherman
5  * This program is free software; you can redistribute
6  * it and/or modify it under the terms of the GNU General
7  * Public License v3. source code is available at
8  * <http://github.com/nicklan/pnmixer>
9  */
10 
17 #include <glib.h>
18 #include <gtk/gtk.h>
19 
20 #include "support-log.h"
21 #include "support-intl.h"
22 
23 #ifndef WITH_GTK3
24 GtkBuilder *
25 gtk_builder_new_from_file (const gchar *filename)
26 {
27  GError *error = NULL;
28  GtkBuilder *builder;
29 
30  builder = gtk_builder_new();
31  if (!gtk_builder_add_from_file(builder, filename, &error))
32  g_error("failed to add UI: %s", error->message);
33 
34  return builder;
35 }
36 
37 void
38 gtk_combo_box_text_remove_all(GtkComboBoxText *combo_box)
39 {
40  GtkListStore *store;
41 
42  g_return_if_fail(GTK_IS_COMBO_BOX_TEXT(combo_box));
43 
44  store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box)));
45  gtk_list_store_clear(store);
46 }
47 #endif
48 
57 gchar *
58 get_ui_file(const char *filename)
59 {
60  gchar *path;
61 
62  path = g_build_filename(".", "data", "ui", filename, NULL);
63  if (g_file_test(path, G_FILE_TEST_EXISTS))
64  return path;
65  g_free(path);
66 
67  path = g_build_filename(PACKAGE_DATA_DIR, PACKAGE, "ui", filename, NULL);
68  if (g_file_test(path, G_FILE_TEST_EXISTS))
69  return path;
70  g_free(path);
71 
72  WARN("Could not find ui file '%s'", filename);
73  return NULL;
74 }
75 
84 gchar *
85 get_pixmap_file(const gchar *filename)
86 {
87  gchar *path;
88 
89  path = g_build_filename(".", "data", "pixmaps", filename, NULL);
90  if (g_file_test(path, G_FILE_TEST_EXISTS))
91  return path;
92  g_free(path);
93 
94  path = g_build_filename(PACKAGE_DATA_DIR, PACKAGE, "pixmaps", filename, NULL);
95  if (g_file_test(path, G_FILE_TEST_EXISTS))
96  return path;
97  g_free(path);
98 
99  WARN("Could not find pixmap file '%s'", filename);
100  return NULL;
101 }
GtkBuilder * gtk_builder_new_from_file(const gchar *filename)
Definition: support-ui.c:25
Internationalization support.
Logging support.
void gtk_combo_box_text_remove_all(GtkComboBoxText *combo_box)
Definition: support-ui.c:38
gchar * get_ui_file(const char *filename)
Definition: support-ui.c:58
gchar * get_pixmap_file(const gchar *filename)
Definition: support-ui.c:85
#define WARN(...)
Definition: support-log.h:37