mirror of
https://github.com/elementary/gala.git
synced 2024-12-25 02:02:11 +03:00
Replace dbus-glib dependent sources
This commit is contained in:
parent
e31834592c
commit
88b2718c75
@ -44,7 +44,6 @@ libgala_notify_la_VALASOURCES = \
|
|||||||
nodist_libgala_notify_la_SOURCES = \
|
nodist_libgala_notify_la_SOURCES = \
|
||||||
$(BUILT_SOURCES) \
|
$(BUILT_SOURCES) \
|
||||||
$(libgala_notify_la_VALASOURCES:.vala=.c) \
|
$(libgala_notify_la_VALASOURCES:.vala=.c) \
|
||||||
pixbuf-dbus-util.c \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libgala_notify_la_vala.stamp: $(libgala_notify_la_VALASOURCES)
|
libgala_notify_la_vala.stamp: $(libgala_notify_la_VALASOURCES)
|
||||||
|
@ -19,9 +19,6 @@ using Meta;
|
|||||||
|
|
||||||
namespace Gala.Plugins.Notify
|
namespace Gala.Plugins.Notify
|
||||||
{
|
{
|
||||||
[CCode (cname = "get_pixbuf_from_dbus_variant")]
|
|
||||||
public extern Gdk.Pixbuf get_pixbuf_from_dbus_variant (Variant variant);
|
|
||||||
|
|
||||||
public enum NotificationUrgency {
|
public enum NotificationUrgency {
|
||||||
LOW = 0,
|
LOW = 0,
|
||||||
NORMAL = 1,
|
NORMAL = 1,
|
||||||
@ -179,12 +176,9 @@ namespace Gala.Plugins.Notify
|
|||||||
|
|
||||||
if (hints.contains ("image_data") || hints.contains ("image-data")) {
|
if (hints.contains ("image_data") || hints.contains ("image-data")) {
|
||||||
|
|
||||||
var image = hints.contains ("image_data") ?
|
var data = hints.contains ("image_data") ?
|
||||||
hints.lookup ("image_data") : hints.lookup ("image-data");
|
hints.lookup ("image_data") : hints.lookup ("image-data");
|
||||||
|
pixbuf = load_from_variant_at_size (data, size);
|
||||||
pixbuf = get_pixbuf_from_dbus_variant (image);
|
|
||||||
|
|
||||||
pixbuf = pixbuf.scale_simple (size, size, Gdk.InterpType.HYPER);
|
|
||||||
|
|
||||||
} else if (hints.contains ("image-path") || hints.contains ("image_path")) {
|
} else if (hints.contains ("image-path") || hints.contains ("image_path")) {
|
||||||
|
|
||||||
@ -210,7 +204,10 @@ namespace Gala.Plugins.Notify
|
|||||||
} catch (Error e) { warning (e.message); }
|
} catch (Error e) { warning (e.message); }
|
||||||
|
|
||||||
} else if (hints.contains ("icon_data")) {
|
} else if (hints.contains ("icon_data")) {
|
||||||
warning ("icon data is not supported");
|
|
||||||
|
var data = hints.lookup ("icon_data");
|
||||||
|
pixbuf = load_from_variant_at_size (data, size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixbuf == null) {
|
if (pixbuf == null) {
|
||||||
@ -227,6 +224,26 @@ namespace Gala.Plugins.Notify
|
|||||||
|
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Gdk.Pixbuf? load_from_variant_at_size (Variant variant, int size)
|
||||||
|
{
|
||||||
|
if (!variant.is_of_type (new VariantType ("(iiibiiay)"))) {
|
||||||
|
critical ("notify icon/image-data format invalid");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width, height, rowstride, bits_per_sample, n_channels;
|
||||||
|
bool has_alpha;
|
||||||
|
|
||||||
|
variant.get ("(iiibiiay)", out width, out height, out rowstride,
|
||||||
|
out has_alpha, out bits_per_sample, out n_channels, null);
|
||||||
|
|
||||||
|
var data = variant.get_child_value (6);
|
||||||
|
unowned uint8[] pixel_data = (uint8[]) data.get_data ();
|
||||||
|
|
||||||
|
var pixbuf = new Gdk.Pixbuf.with_unowned_data (pixel_data, Gdk.Colorspace.RGB, has_alpha, bits_per_sample, width, height, rowstride, null);
|
||||||
|
return pixbuf.scale_simple (size, size, Gdk.InterpType.BILINEAR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
#include <glib-object.h>
|
|
||||||
#include <glib-object.h>
|
|
||||||
#include <gdk/gdk.h>
|
|
||||||
|
|
||||||
// copied from notify-osd /src/stack.c with some minor changes
|
|
||||||
|
|
||||||
GdkPixbuf *
|
|
||||||
get_pixbuf_from_dbus_variant (GVariant *variant)
|
|
||||||
{
|
|
||||||
GValue data = G_VALUE_INIT;
|
|
||||||
GType dbus_icon_t;
|
|
||||||
GArray *pixels;
|
|
||||||
int width, height, rowstride, bits_per_sample, n_channels, size;
|
|
||||||
gboolean has_alpha;
|
|
||||||
guchar *copy;
|
|
||||||
GdkPixbuf *pixbuf = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (variant != NULL, NULL);
|
|
||||||
|
|
||||||
dbus_icon_t = dbus_g_type_get_struct ("GValueArray",
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_BOOLEAN,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_INT,
|
|
||||||
dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR),
|
|
||||||
G_TYPE_INVALID);
|
|
||||||
|
|
||||||
dbus_g_value_parse_g_variant (variant, &data);
|
|
||||||
|
|
||||||
if (G_VALUE_HOLDS (&data, dbus_icon_t)) {
|
|
||||||
dbus_g_type_struct_get (&data,
|
|
||||||
0, &width,
|
|
||||||
1, &height,
|
|
||||||
2, &rowstride,
|
|
||||||
3, &has_alpha,
|
|
||||||
4, &bits_per_sample,
|
|
||||||
5, &n_channels,
|
|
||||||
6, &pixels,
|
|
||||||
G_MAXUINT);
|
|
||||||
|
|
||||||
size = (height - 1) * rowstride + width *
|
|
||||||
((n_channels * bits_per_sample + 7) / 8);
|
|
||||||
copy = (guchar *) g_memdup (pixels->data, size);
|
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_data(copy, GDK_COLORSPACE_RGB,
|
|
||||||
has_alpha,
|
|
||||||
bits_per_sample,
|
|
||||||
width, height,
|
|
||||||
rowstride,
|
|
||||||
(GdkPixbufDestroyNotify)g_free,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pixbuf;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user