Commit b01985c7 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels
Browse files

libstatus-notifier: add code from old library

parent 97fb3f4b
......@@ -3,6 +3,18 @@ NULL =
noinst_LTLIBRARIES = libstatus-notifier.la
libstatus_notifier_la_SOURCES = \
sn-item.c \
sn-item.h \
sn-dbus-item.c \
sn-dbus-item.h \
sn-dbus-item-server.c \
sn-dbus-item-server.h \
sn-dbus-item-server-v0.c \
sn-dbus-item-server-v0.h \
sn-dbus-menu-server.c \
sn-dbus-menu-server.h \
sn-item-private.h \
sn-watcher-private.h \
$(BUILT_SOURCES) \
$(NULL)
......@@ -28,6 +40,18 @@ libstatus_notifier_la_LIBADD = \
$(LIBSTATUS_NOTIFIER_LIBS) \
$(NULL)
ENUM_TYPES = \
$(srcdir)/sn-item.h \
$(NULL)
sn-enum-types.c: sn-enum-types.c.in sn-enum-types.h $(ENUM_TYPES)
$(AM_V_GEN) $(GLIB_MKENUMS) --template $(srcdir)/sn-enum-types.c.in $(ENUM_TYPES) > \
sn-enum-types.c.tmp && mv sn-enum-types.c.tmp sn-enum-types.c
sn-enum-types.h: sn-enum-types.h.in $(ENUM_TYPES)
$(AM_V_GEN) $(GLIB_MKENUMS) --template $(srcdir)/sn-enum-types.h.in $(ENUM_TYPES) > \
sn-enum-types.h.tmp && mv sn-enum-types.h.tmp sn-enum-types.h
sn-dbus-menu-gen.h:
sn-dbus-menu-gen.c: com.canonical.dbusmenu.xml
$(AM_V_GEN) $(GDBUS_CODEGEN) --c-namespace Sn \
......@@ -53,12 +77,16 @@ BUILT_SOURCES = \
sn-item-v0-gen.h \
sn-watcher-v0-gen.c \
sn-watcher-v0-gen.h \
sn-enum-types.c \
sn-enum-types.h \
$(NULL)
EXTRA_DIST = \
com.canonical.dbusmenu.xml \
org.kde.StatusNotifierItem.xml \
org.kde.StatusNotifierWatcher.xml \
sn-enum-types.c.in \
sn-enum-types.h.in \
$(NULL)
-include $(top_srcdir)/git.mk
This diff is collapsed.
/*
* Copyright (C) 2016 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SN_DBUS_ITEM_SERVER_V0_H
#define SN_DBUS_ITEM_SERVER_V0_H
#include "sn-dbus-item-server.h"
G_BEGIN_DECLS
#define SN_TYPE_DBUS_ITEM_SERVER_V0 sn_dbus_item_server_v0_get_type ()
G_DECLARE_FINAL_TYPE (SnDBusItemServerV0, sn_dbus_item_server_v0,
SN, DBUS_ITEM_SERVER_V0, SnDBusItemServer)
G_END_DECLS
#endif
/*
* Copyright (C) 2016 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "sn-dbus-item-server.h"
#include "sn-enum-types.h"
typedef struct
{
gboolean well_known;
} SnDBusItemServerPrivate;
enum
{
PROP_0,
PROP_WELL_KNOWN,
LAST_PROP
};
static GParamSpec *properties[LAST_PROP] = { NULL };
enum
{
CONTEXT_MENU,
ACTIVATE,
SECONDARY_ACTIVATE,
SCROLL,
HOSTS_CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SnDBusItemServer, sn_dbus_item_server,
SN_TYPE_DBUS_ITEM)
static void
sn_dbus_item_server_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
SnDBusItemServer *server;
SnDBusItemServerPrivate *priv;
server = SN_DBUS_ITEM_SERVER (object);
priv = sn_dbus_item_server_get_instance_private (server);
switch (property_id)
{
case PROP_WELL_KNOWN:
priv->well_known = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
sn_dbus_item_server_context_menu (SnDBusItemServer *server,
gint x,
gint y)
{
if (!g_signal_has_handler_pending (server, signals[CONTEXT_MENU], 0, TRUE))
g_assert_not_reached ();
}
static void
sn_dbus_item_server_activate (SnDBusItemServer *server,
gint x,
gint y)
{
if (!g_signal_has_handler_pending (server, signals[ACTIVATE], 0, TRUE))
g_assert_not_reached ();
}
static void
sn_dbus_item_server_secondary_activate (SnDBusItemServer *server,
gint x,
gint y)
{
if (!g_signal_has_handler_pending (server, signals[SECONDARY_ACTIVATE],
0, TRUE))
{
g_assert_not_reached ();
}
}
static void
sn_dbus_item_server_scroll (SnDBusItemServer *server,
gint delta,
SnItemOrientation orientation)
{
if (!g_signal_has_handler_pending (server, signals[SCROLL], 0, TRUE))
g_assert_not_reached ();
}
static void
sn_dbus_item_server_hosts_changed (SnDBusItemServer *server,
gboolean registered)
{
if (!g_signal_has_handler_pending (server, signals[HOSTS_CHANGED], 0, TRUE))
g_assert_not_reached ();
}
static void
sn_dbus_item_server_class_init (SnDBusItemServerClass *server_class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (server_class);
object_class->set_property = sn_dbus_item_server_set_property;
server_class->context_menu = sn_dbus_item_server_context_menu;
server_class->activate = sn_dbus_item_server_activate;
server_class->secondary_activate = sn_dbus_item_server_secondary_activate;
server_class->scroll = sn_dbus_item_server_scroll;
server_class->hosts_changed = sn_dbus_item_server_hosts_changed;
properties[PROP_WELL_KNOWN] =
g_param_spec_boolean ("well-known", "well-known", "well-known", FALSE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, properties);
signals[CONTEXT_MENU] =
g_signal_new ("context-menu", SN_TYPE_DBUS_ITEM_SERVER,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_INT);
signals[ACTIVATE] =
g_signal_new ("activate", SN_TYPE_DBUS_ITEM_SERVER,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_INT);
signals[SECONDARY_ACTIVATE] =
g_signal_new ("secondary-activate", SN_TYPE_DBUS_ITEM_SERVER,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_INT);
signals[SCROLL] =
g_signal_new ("scroll", SN_TYPE_DBUS_ITEM_SERVER,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE,
2, G_TYPE_INT, SN_TYPE_ITEM_ORIENTATION);
signals[HOSTS_CHANGED] =
g_signal_new ("hosts-changed", SN_TYPE_DBUS_ITEM_SERVER,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE,
1, G_TYPE_BOOLEAN);
}
static void
sn_dbus_item_server_init (SnDBusItemServer *server)
{
}
gboolean
sn_dbus_item_server_get_well_known (SnDBusItemServer *server)
{
SnDBusItemServerPrivate *priv;
priv = sn_dbus_item_server_get_instance_private (server);
return priv->well_known;
}
void
sn_dbus_item_server_emit_context_menu (SnDBusItemServer *server,
gint x,
gint y)
{
g_signal_emit (server, signals[CONTEXT_MENU], 0, x, y);
}
void
sn_dbus_item_server_emit_activate (SnDBusItemServer *server,
gint x,
gint y)
{
g_signal_emit (server, signals[ACTIVATE], 0, x, y);
}
void
sn_dbus_item_server_emit_secondary_activate (SnDBusItemServer *server,
gint x,
gint y)
{
g_signal_emit (server, signals[SECONDARY_ACTIVATE], 0, x, y);
}
void
sn_dbus_item_server_emit_scroll (SnDBusItemServer *server,
gint delta,
SnItemOrientation orientation)
{
g_signal_emit (server, signals[SCROLL], 0, delta, orientation);
}
void
sn_dbus_item_server_emit_hosts_changed (SnDBusItemServer *server,
gboolean registered)
{
g_signal_emit (server, signals[HOSTS_CHANGED], 0, registered);
}
/*
* Copyright (C) 2016 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SN_DBUS_ITEM_SERVER_H
#define SN_DBUS_ITEM_SERVER_H
#include "sn-dbus-item.h"
G_BEGIN_DECLS
#define SN_TYPE_DBUS_ITEM_SERVER sn_dbus_item_server_get_type ()
G_DECLARE_DERIVABLE_TYPE (SnDBusItemServer, sn_dbus_item_server,
SN, DBUS_ITEM_SERVER, SnDBusItem)
struct _SnDBusItemServerClass
{
SnDBusItemClass parent_class;
void (* context_menu) (SnDBusItemServer *server,
gint x,
gint y);
void (* activate) (SnDBusItemServer *server,
gint x,
gint y);
void (* secondary_activate) (SnDBusItemServer *server,
gint x,
gint y);
void (* scroll) (SnDBusItemServer *server,
gint delta,
SnItemOrientation orientation);
void (* hosts_changed) (SnDBusItemServer *server,
gboolean registered);
};
gboolean sn_dbus_item_server_get_well_known (SnDBusItemServer *server);
void sn_dbus_item_server_emit_context_menu (SnDBusItemServer *server,
gint x,
gint y);
void sn_dbus_item_server_emit_activate (SnDBusItemServer *server,
gint x,
gint y);
void sn_dbus_item_server_emit_secondary_activate (SnDBusItemServer *server,
gint x,
gint y);
void sn_dbus_item_server_emit_scroll (SnDBusItemServer *server,
gint delta,
SnItemOrientation orientation);
void sn_dbus_item_server_emit_hosts_changed (SnDBusItemServer *server,
gboolean registered);
G_END_DECLS
#endif
/*
* Copyright (C) 2016 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "sn-dbus-item-server-v0.h"
#include "sn-dbus-item.h"
typedef struct _SnDBusItemPrivate
{
gchar *bus_name;
gchar *object_path;
} SnDBusItemPrivate;
enum
{
PROP_0,
PROP_BUS_NAME,
PROP_OBJECT_PATH,
LAST_PROP
};
static GParamSpec *properties[LAST_PROP] = { NULL };
enum
{
ERROR,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SnDBusItem, sn_dbus_item, G_TYPE_OBJECT)
static void
sn_dbus_item_finalize (GObject *object)
{
SnDBusItem *impl;
SnDBusItemPrivate *priv;
impl = SN_DBUS_ITEM (object);
priv = sn_dbus_item_get_instance_private (impl);
g_free (priv->bus_name);
g_free (priv->object_path);
G_OBJECT_CLASS (sn_dbus_item_parent_class)->finalize (object);
}
static void
sn_dbus_item_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
SnDBusItem *impl;
SnDBusItemPrivate *priv;
impl = SN_DBUS_ITEM (object);
priv = sn_dbus_item_get_instance_private (impl);
switch (property_id)
{
case PROP_BUS_NAME:
g_value_set_string (value, priv->bus_name);
break;
case PROP_OBJECT_PATH:
g_value_set_string (value, priv->object_path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
sn_dbus_item_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
SnDBusItem *impl;
SnDBusItemPrivate *priv;
impl = SN_DBUS_ITEM (object);
priv = sn_dbus_item_get_instance_private (impl);
switch (property_id)
{
case PROP_BUS_NAME:
g_assert (priv->bus_name == NULL);
priv->bus_name = g_value_dup_string (value);
break;
case PROP_OBJECT_PATH:
g_assert (priv->object_path == NULL);
priv->object_path = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
sn_dbus_item_error (SnDBusItem *item,
const GError *error)
{
if (!g_signal_has_handler_pending (item, signals[ERROR], 0, TRUE))
g_assert_not_reached ();
}
static void
sn_dbus_item_class_init (SnDBusItemClass *impl_class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (impl_class);
object_class->finalize = sn_dbus_item_finalize;
object_class->get_property = sn_dbus_item_get_property;
object_class->set_property = sn_dbus_item_set_property;
impl_class->error = sn_dbus_item_error;
properties[PROP_BUS_NAME] =
g_param_spec_string ("bus-name", "bus-name", "bus-name", NULL,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
properties[PROP_OBJECT_PATH] =
g_param_spec_string ("object-path", "object-path", "object-path", NULL,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, properties);
signals[ERROR] =
g_signal_new ("error", SN_TYPE_DBUS_ITEM, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (SnDBusItemClass, error),
NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_ERROR);
}
static void
sn_dbus_item_init (SnDBusItem *impl)
{
}
const gchar *
sn_dbus_item_get_attention_icon_name (SnDBusItem *impl)
{
return SN_DBUS_ITEM_GET_CLASS (impl)->get_attention_icon_name (impl);
}
void
sn_dbus_item_set_attention_icon_name (SnDBusItem *impl,
const gchar *attention_icon_name)
{
SN_DBUS_ITEM_GET_CLASS (impl)->set_attention_icon_name (impl,
attention_icon_name);
}
GVariant *
sn_dbus_item_get_attention_icon_pixmap (SnDBusItem *impl)
{
return SN_DBUS_ITEM_GET_CLASS (impl)->get_attention_icon_pixmap (impl);
}
void
sn_dbus_item_set_attention_icon_pixmap (SnDBusItem *impl,
GVariant *attention_icon_pixmap)
{
SN_DBUS_ITEM_GET_CLASS (impl)->set_attention_icon_pixmap (impl,
attention_icon_pixmap);
}
const gchar *
sn_dbus_item_get_attention_movie_name (SnDBusItem *impl)
{
return SN_DBUS_ITEM_GET_CLASS (impl)->get_attention_movie_name (impl);
}
void
sn_dbus_item_set_attention_movie_name (SnDBusItem *impl,
const gchar *attention_movie_name)
{
SN_DBUS_ITEM_GET_CLASS (impl)->set_attention_movie_name (impl,
attention_movie_name);
}
SnItemCategory
sn_dbus_item_get_category (SnDBusItem *impl)
{
return SN_DBUS_ITEM_GET_CLASS (impl)->get_category (impl);
}
void
sn_dbus_item_set_category (SnDBusItem *impl,
SnItemCategory category)
{
SN_DBUS_ITEM_GET_CLASS (impl)->set_category (impl, category);
}
const gchar *
sn_dbus_item_get_id (SnDBusItem *impl)
{
return SN_DBUS_ITEM_GET_CLASS (impl)->get_id (impl);
}