Merge branch 'master' of file:///srv/git/moonshot-ui into debian
[moonshot-ui.git] / src / moonshot-utils.c
1 /* moonshot-utils.c generated by valac 0.10.4, the Vala compiler
2  * generated from moonshot-utils.vala, do not modify */
3
4
5 #include <glib.h>
6 #include <glib-object.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <gtk/gtk.h>
10 #include <gdk-pixbuf/gdk-pixdata.h>
11 #include <stdio.h>
12
13 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
14 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
15
16
17
18 GdkPixbuf* find_icon_sized (const char* name, GtkIconSize icon_size);
19 GdkPixbuf* find_icon (const char* name, gint size);
20
21
22
23 GdkPixbuf* find_icon_sized (const char* name, GtkIconSize icon_size) {
24         GdkPixbuf* result = NULL;
25         gint width = 0;
26         gint height = 0;
27         g_return_val_if_fail (name != NULL, NULL);
28         gtk_icon_size_lookup (icon_size, &width, &height);
29         result = find_icon (name, width);
30         return result;
31 }
32
33
34 static gpointer _g_object_ref0 (gpointer self) {
35         return self ? g_object_ref (self) : NULL;
36 }
37
38
39 GdkPixbuf* find_icon (const char* name, gint size) {
40         GdkPixbuf* result = NULL;
41         GError * _inner_error_ = NULL;
42         g_return_val_if_fail (name != NULL, NULL);
43         {
44                 GtkIconTheme* icon_theme;
45                 GdkPixbuf* _tmp0_;
46                 icon_theme = _g_object_ref0 (gtk_icon_theme_get_default ());
47                 _tmp0_ = gtk_icon_theme_load_icon (icon_theme, name, size, GTK_ICON_LOOKUP_FORCE_SIZE, &_inner_error_);
48                 if (_inner_error_ != NULL) {
49                         _g_object_unref0 (icon_theme);
50                         goto __catch7_g_error;
51                 }
52                 result = _tmp0_;
53                 _g_object_unref0 (icon_theme);
54                 return result;
55         }
56         goto __finally7;
57         __catch7_g_error:
58         {
59                 GError * e;
60                 e = _inner_error_;
61                 _inner_error_ = NULL;
62                 {
63                         fprintf (stdout, "Error loading icon '%s': %s\n", name, e->message);
64                         result = NULL;
65                         _g_error_free0 (e);
66                         return result;
67                 }
68         }
69         __finally7:
70         {
71                 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
72                 g_clear_error (&_inner_error_);
73                 return NULL;
74         }
75 }
76
77
78
79