1 /* 2 * libaudgui-gtk.h 3 * Copyright 2010-2012 John Lindgren 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions, and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions, and the following disclaimer in the documentation 13 * provided with the distribution. 14 * 15 * This software is provided "as is" and without any warranty, express or 16 * implied. In no event shall the authors be liable for any damages arising from 17 * the use of this software. 18 */ 19 20 #ifndef LIBAUDGUI_GTK_H 21 #define LIBAUDGUI_GTK_H 22 23 #include <stdint.h> 24 #include <gtk/gtk.h> 25 26 #include <libaudcore/objects.h> 27 28 #define audgui_create_widgets(b, w) audgui_create_widgets_with_domain (b, w, PACKAGE) 29 30 enum class AudMenuID; 31 struct PreferencesWidget; 32 33 typedef void (* AudguiCallback) (void * data); 34 35 class AudguiPixbuf : public SmartPtr<GdkPixbuf, aud::typed_func<GdkPixbuf, g_object_unref>> 36 { 37 public: AudguiPixbuf()38 AudguiPixbuf () : SmartPtr () {} AudguiPixbuf(GdkPixbuf * ptr)39 explicit AudguiPixbuf (GdkPixbuf * ptr) : SmartPtr (ptr) {} 40 width()41 int width () 42 { return gdk_pixbuf_get_width (get ()); } height()43 int height () 44 { return gdk_pixbuf_get_height (get ()); } 45 ref()46 AudguiPixbuf ref () 47 { return AudguiPixbuf (get () ? (GdkPixbuf *) g_object_ref (get ()) : nullptr); } 48 }; 49 50 /* pixbufs.c */ 51 AudguiPixbuf audgui_pixbuf_from_data (const void * data, int64_t size); 52 AudguiPixbuf audgui_pixbuf_fallback (); 53 void audgui_pixbuf_scale_within (AudguiPixbuf & pixbuf, int size); 54 AudguiPixbuf audgui_pixbuf_request (const char * filename, bool * queued = nullptr); 55 AudguiPixbuf audgui_pixbuf_request_current (bool * queued = nullptr); 56 57 /* plugin-menu.c */ 58 GtkWidget * audgui_get_plugin_menu (AudMenuID id); 59 60 /* prefs-widget.c */ 61 void audgui_create_widgets_with_domain (GtkWidget * box, 62 ArrayRef<PreferencesWidget> widgets, const char * domain); 63 64 /* scaled-image.c -- okay to use without audgui_init() */ 65 GtkWidget * audgui_scaled_image_new (GdkPixbuf * pixbuf); 66 void audgui_scaled_image_set (GtkWidget * widget, GdkPixbuf * pixbuf); 67 68 /* util.c -- okay to use without audgui_init() */ 69 int audgui_get_dpi (); 70 int audgui_to_native_dpi (int size); 71 int audgui_to_portable_dpi (int size); 72 int audgui_get_digit_width (GtkWidget * widget); 73 void audgui_get_mouse_coords (GtkWidget * widget, int * x, int * y); 74 void audgui_get_mouse_coords (GdkScreen * screen, int * x, int * y); 75 void audgui_get_monitor_geometry (GdkScreen * screen, int x, int y, GdkRectangle * geom); 76 void audgui_destroy_on_escape (GtkWidget * widget); 77 void audgui_simple_message (GtkWidget * * widget, GtkMessageType type, 78 const char * title, const char * text); 79 80 GtkWidget * audgui_button_new (const char * text, const char * icon, 81 AudguiCallback callback, void * data); 82 83 GtkWidget * audgui_file_entry_new (GtkFileChooserAction action, const char * title); 84 String audgui_file_entry_get_uri (GtkWidget * entry); 85 void audgui_file_entry_set_uri (GtkWidget * entry, const char * uri); 86 87 GtkWidget * audgui_dialog_new (GtkMessageType type, const char * title, 88 const char * text, GtkWidget * button1, GtkWidget * button2); 89 void audgui_dialog_add_widget (GtkWidget * dialog, GtkWidget * widget); 90 91 cairo_pattern_t * audgui_dark_bg_gradient (const GdkColor & base, int height); 92 void audgui_vis_bar_color (const GdkColor & hue, int bar, int n_bars, 93 float & r, float & g, float & b); 94 95 #endif 96