|
Freya
0.0.1
A Gtk3 MPD Client
|
00001 /*********************************************************** 00002 * This file is part of Freya 00003 * - A free MPD Gtk3 MPD Client - 00004 * 00005 * Authors: Christopher Pahl, Christoph Piechula, 00006 * Eduard Schneider 00007 * 00008 * Copyright (C) [2011-2012] 00009 * Hosted at: https://github.com/studentkittens/Freya 00010 * 00011 * __..--''``---....___ _..._ __ 00012 * /// //_.-' .-/"; ` ``<._ ``.''_ `. / // / 00013 * ///_.-' _..--.'_ `( ) ) // // 00014 * / (_..-' // (< _ ;_..__ ; `' / /// 00015 * / // // // `-._,_)' // / ``--...____..-' /// / // 00016 * Ascii-Art by Felix Lee <flee@cse.psu.edu> 00017 * 00018 * Freya is free software: you can redistribute it and/or modify 00019 * it under the terms of the GNU General Public License as published by 00020 * the Free Software Foundation, either version 3 of the License, or 00021 * (at your option) any later version. 00022 * 00023 * Freya is distributed in the hope that it will be useful, 00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00026 * GNU General Public License for more details. 00027 * 00028 * You should have received a copy of the GNU General Public License 00029 * along with Freya. If not, see <http://www.gnu.org/licenses/>. 00030 **************************************************************/ 00031 #ifndef FREYA_UTILS_GUARD 00032 #define FREYA_UTILS_GUARD 00033 00034 #include <glibmm/ustring.h> 00035 #include <gtkmm/builder.h> 00036 #include <gdkmm/pixbuf.h> 00037 00038 /* For Error() */ 00039 #include "../Log/Writer.hh" 00040 00041 /* Gtk::Builder macros */ 00042 #define BUILDER_GET(builder_refp, widget_name, widget_ptr) \ 00043 BUILDER_GET_NO_MANAGE(builder_refp, widget_name, widget_ptr) \ 00044 Gtk::manage(widget_ptr); 00045 00046 #define BUILDER_GET_DERIVED(builder_refp, widget_name, derived_class) \ 00047 derived_class = NULL; \ 00048 builder_refp->get_widget_derived(widget_name,derived_class); \ 00049 g_assert(derived_class); \ 00050 Gtk::manage(derived_class); \ 00051 00052 #define BUILDER_GET_NO_MANAGE(builder_refp, widget_name, widget_ptr) \ 00053 widget_ptr = NULL; \ 00054 builder_refp->get_widget(widget_name,widget_ptr); \ 00055 g_assert(widget_ptr); \ 00056 00057 #define BUILDER_ADD(builder_ref, filename) \ 00058 g_assert(filename); \ 00059 Utils::builder_internal_fetch(builder_ref,filename); \ 00060 00061 namespace Utils 00062 { 00063 00071 Glib::ustring seconds_to_duration(unsigned long); 00072 00073 00081 Glib::ustring seconds_to_timestamp(const long); 00082 00083 00091 std::string int_to_string(int num); 00092 00099 void builder_internal_fetch(Glib::RefPtr<Gtk::Builder>& ref, const char * file); 00100 00101 Glib::RefPtr<Gdk::Pixbuf> create_pixbuf_from_data(const guchar * data, gsize len, int width = 150, int height = 150, bool aspect = false); 00102 Glib::RefPtr<Gdk::Pixbuf> pixbuf_internal_fetch(const char * file, int width = 150, int height = 150, bool aspect = false); 00103 } 00104 #endif
1.8.0