aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2020-08-10 11:52:51 +0200
committerRobert Tari <robert@tari.in>2020-08-10 11:52:51 +0200
commitd9fced125c2a6e1cf44171370753df00c8d554ba (patch)
tree634824490604bb5f5ebc39d6da4be1dd0ee09643 /src
parentac5d6867a8ce34b8a77bf5545bbb4b36f8bafb15 (diff)
downloadayatana-indicator-notifications-d9fced125c2a6e1cf44171370753df00c8d554ba.tar.gz
ayatana-indicator-notifications-d9fced125c2a6e1cf44171370753df00c8d554ba.tar.bz2
ayatana-indicator-notifications-d9fced125c2a6e1cf44171370753df00c8d554ba.zip
Fix deprecations (fixes #4)
Diffstat (limited to 'src')
-rw-r--r--src/dbus-spy.c23
-rw-r--r--src/dbus-spy.h3
-rw-r--r--src/indicator-notifications.c27
-rw-r--r--src/notification-menuitem.c17
-rw-r--r--src/notification-menuitem.h3
-rw-r--r--src/notification.c11
-rw-r--r--src/notification.h3
7 files changed, 33 insertions, 54 deletions
diff --git a/src/dbus-spy.c b/src/dbus-spy.c
index 3e97ada..506def2 100644
--- a/src/dbus-spy.c
+++ b/src/dbus-spy.c
@@ -26,22 +26,19 @@ static void add_filter(DBusSpy *self);
static void bus_get_cb(GObject *source_object, GAsyncResult *res, gpointer user_data);
-static GDBusMessage *message_filter(GDBusConnection *connection, GDBusMessage *message,
+static GDBusMessage *message_filter(GDBusConnection *connection, GDBusMessage *message,
gboolean incoming, gpointer user_data);
static gboolean idle_message_emit(gpointer user_data);
#define MATCH_STRING "eavesdrop=true,type='method_call',interface='org.freedesktop.Notifications',member='Notify'"
-G_DEFINE_TYPE (DBusSpy, dbus_spy, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_PRIVATE(DBusSpy, dbus_spy, G_TYPE_OBJECT);
static void
dbus_spy_class_init(DBusSpyClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
- g_type_class_add_private(klass, sizeof(DBusSpyPrivate));
-
object_class->dispose = dbus_spy_dispose;
signals[MESSAGE_RECEIVED] =
@@ -94,11 +91,11 @@ add_filter(DBusSpy *self)
body = g_variant_new_parsed("(%s,)", MATCH_STRING);
g_dbus_message_set_body(message, body);
-
- g_dbus_connection_send_message(self->priv->connection,
- message,
- G_DBUS_SEND_MESSAGE_FLAGS_NONE,
- NULL,
+
+ g_dbus_connection_send_message(self->priv->connection,
+ message,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE,
+ NULL,
&error);
if(error != NULL) {
g_warning("Failed to send AddMatch message: %s\n", error->message);
@@ -109,7 +106,7 @@ add_filter(DBusSpy *self)
g_dbus_connection_add_filter(self->priv->connection, message_filter, self, NULL);
}
-static GDBusMessage*
+static GDBusMessage*
message_filter(GDBusConnection *connection, GDBusMessage *message, gboolean incoming, gpointer user_data)
{
if(!incoming) return message;
@@ -150,7 +147,7 @@ idle_message_emit(gpointer user_data)
static void
dbus_spy_init(DBusSpy *self)
{
- self->priv = DBUS_SPY_GET_PRIVATE(self);
+ self->priv = dbus_spy_get_instance_private(self);
self->priv->connection = NULL;
self->priv->connection_cancel = g_cancellable_new();
@@ -181,7 +178,7 @@ dbus_spy_dispose(GObject *object)
G_OBJECT_CLASS(dbus_spy_parent_class)->dispose(object);
}
-DBusSpy*
+DBusSpy*
dbus_spy_new(void)
{
return DBUS_SPY(g_object_new(DBUS_SPY_TYPE, NULL));
diff --git a/src/dbus-spy.h b/src/dbus-spy.h
index efa4732..6415de6 100644
--- a/src/dbus-spy.h
+++ b/src/dbus-spy.h
@@ -42,9 +42,6 @@ struct _DBusSpyPrivate {
GCancellable *connection_cancel;
};
-#define DBUS_SPY_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUS_SPY_TYPE, DBusSpyPrivate))
-
#define DBUS_SPY_SIGNAL_MESSAGE_RECEIVED "message-received"
GType dbus_spy_get_type(void);
diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c
index 7850546..07ccd26 100644
--- a/src/indicator-notifications.c
+++ b/src/indicator-notifications.c
@@ -4,16 +4,16 @@ An indicator to display recent notifications.
Adapted from: indicator-datetime/src/indicator-datetime.c by
Ted Gould <ted@canonical.com>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -80,9 +80,6 @@ struct _IndicatorNotificationsPrivate {
GSettings *settings;
};
-#define INDICATOR_NOTIFICATIONS_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_NOTIFICATIONS_TYPE, IndicatorNotificationsPrivate))
-
#include "settings.h"
#define INDICATOR_ICON_SIZE 22
@@ -101,7 +98,7 @@ static void indicator_notifications_finalize(GObject *object);
static GtkImage *get_image(IndicatorObject *io);
static GtkMenu *get_menu(IndicatorObject *io);
static const gchar *get_accessible_desc(IndicatorObject *io);
-static void indicator_notifications_middle_click(IndicatorObject *io,
+static void indicator_notifications_middle_click(IndicatorObject *io,
IndicatorObjectEntry *entry,
guint time,
gpointer user_data);
@@ -127,7 +124,7 @@ static void settings_item_activated_cb(GtkMenuItem *menuitem, gpointer user_data
INDICATOR_SET_VERSION
INDICATOR_SET_TYPE(INDICATOR_NOTIFICATIONS_TYPE)
-G_DEFINE_TYPE(IndicatorNotifications, indicator_notifications, INDICATOR_OBJECT_TYPE);
+G_DEFINE_TYPE_WITH_PRIVATE(IndicatorNotifications, indicator_notifications, INDICATOR_OBJECT_TYPE);
static void
indicator_notifications_class_init(IndicatorNotificationsClass *klass)
@@ -138,8 +135,6 @@ indicator_notifications_class_init(IndicatorNotificationsClass *klass)
bindtextdomain( GETTEXT_PACKAGE, LOCALEDIR );
textdomain( GETTEXT_PACKAGE );
- g_type_class_add_private(klass, sizeof(IndicatorNotificationsPrivate));
-
object_class->dispose = indicator_notifications_dispose;
object_class->finalize = indicator_notifications_finalize;
@@ -156,7 +151,7 @@ indicator_notifications_class_init(IndicatorNotificationsClass *klass)
static void
indicator_notifications_init(IndicatorNotifications *self)
{
- self->priv = INDICATOR_NOTIFICATIONS_GET_PRIVATE(self);
+ self->priv = indicator_notifications_get_instance_private(self);
self->priv->menu = NULL;
@@ -358,7 +353,7 @@ insert_menuitem(IndicatorNotifications *self, GtkWidget *item)
/* Move items that overflow to the hidden list */
while(g_list_length(self->priv->visible_items) > self->priv->max_items) {
- last_item = g_list_last(self->priv->visible_items);
+ last_item = g_list_last(self->priv->visible_items);
last_widget = GTK_WIDGET(last_item->data);
/* Steal the ref from the visible list */
self->priv->visible_items = g_list_delete_link(self->priv->visible_items, last_item);
@@ -496,7 +491,7 @@ static void
update_indicator_visibility(IndicatorNotifications *self)
{
g_return_if_fail(IS_INDICATOR_NOTIFICATIONS(self));
-
+
if(self->priv->image != NULL) {
if(self->priv->hide_indicator)
gtk_widget_hide(GTK_WIDGET(self->priv->image));
diff --git a/src/notification-menuitem.c b/src/notification-menuitem.c
index 3a3236f..392d9d3 100644
--- a/src/notification-menuitem.c
+++ b/src/notification-menuitem.c
@@ -37,7 +37,7 @@ static gboolean widget_contains_event(GtkWidget *widget, GdkEventButton *event);
static guint notification_menuitem_signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (NotificationMenuItem, notification_menuitem, GTK_TYPE_MENU_ITEM);
+G_DEFINE_TYPE_WITH_PRIVATE(NotificationMenuItem, notification_menuitem, GTK_TYPE_MENU_ITEM);
static void
notification_menuitem_class_init(NotificationMenuItemClass *klass)
@@ -50,8 +50,6 @@ notification_menuitem_class_init(NotificationMenuItemClass *klass)
widget_class->button_press_event = notification_menuitem_button_press;
widget_class->button_release_event = notification_menuitem_button_release;
- g_type_class_add_private(klass, sizeof(NotificationMenuItemPrivate));
-
menu_item_class->hide_on_activate = FALSE;
menu_item_class->activate = notification_menuitem_activate;
menu_item_class->select = notification_menuitem_select;
@@ -73,14 +71,15 @@ notification_menuitem_class_init(NotificationMenuItemClass *klass)
static void
notification_menuitem_init(NotificationMenuItem *self)
{
- self->priv = NOTIFICATION_MENUITEM_GET_PRIVATE(self);
+ self->priv = notification_menuitem_get_instance_private(self);
self->priv->pressed_close_image = FALSE;
self->priv->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
self->priv->label = gtk_label_new(NULL);
- gtk_misc_set_alignment(GTK_MISC(self->priv->label), 0, 0);
+ gtk_widget_set_halign(self->priv->label, GTK_ALIGN_START);
+ gtk_widget_set_valign(self->priv->label, GTK_ALIGN_START);
gtk_label_set_use_markup(GTK_LABEL(self->priv->label), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(self->priv->label), TRUE);
gtk_label_set_line_wrap_mode(GTK_LABEL(self->priv->label), PANGO_WRAP_WORD_CHAR);
@@ -100,7 +99,7 @@ notification_menuitem_init(NotificationMenuItem *self)
gtk_widget_show(self->priv->hbox);
}
-GtkWidget *
+GtkWidget *
notification_menuitem_new(void)
{
return g_object_new(NOTIFICATION_MENUITEM_TYPE, NULL);
@@ -320,8 +319,8 @@ notification_menuitem_activate_link_cb(GtkLabel *label, gchar *uri, gpointer use
/* Show the link */
GError *error = NULL;
- if (!gtk_show_uri(gtk_widget_get_screen(GTK_WIDGET(label)),
- uri, gtk_get_current_event_time(), &error)) {
+ if (!gtk_show_uri_on_window(NULL, uri, gtk_get_current_event_time(), &error))
+ {
g_warning("Unable to show '%s': %s", uri, error->message);
g_error_free(error);
}
@@ -400,7 +399,7 @@ widget_contains_event(GtkWidget *widget, GdkEventButton *event)
int xmin = allocation.x;
int xmax = allocation.x + allocation.width;
int ymin = allocation.y;
- int ymax = allocation.y + allocation.height;
+ int ymax = allocation.y + allocation.height;
int x = event->x_root - xwin;
int y = event->y_root - ywin;
diff --git a/src/notification-menuitem.h b/src/notification-menuitem.h
index 2aa051e..afb2b98 100644
--- a/src/notification-menuitem.h
+++ b/src/notification-menuitem.h
@@ -41,9 +41,6 @@ struct _NotificationMenuItemPrivate {
gboolean pressed_close_image;
};
-#define NOTIFICATION_MENUITEM_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), NOTIFICATION_MENUITEM_TYPE, NotificationMenuItemPrivate))
-
#define NOTIFICATION_MENUITEM_SIGNAL_CLICKED "clicked"
GType notification_menuitem_get_type(void);
diff --git a/src/notification.c b/src/notification.c
index a4868a3..19d42fc 100644
--- a/src/notification.c
+++ b/src/notification.c
@@ -22,22 +22,19 @@ static void notification_class_init(NotificationClass *klass);
static void notification_init(Notification *self);
static void notification_dispose(GObject *object);
-G_DEFINE_TYPE (Notification, notification, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_PRIVATE(Notification, notification, G_TYPE_OBJECT);
static void
notification_class_init(NotificationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
- g_type_class_add_private(klass, sizeof(NotificationPrivate));
-
object_class->dispose = notification_dispose;
}
static void
notification_init(Notification *self)
{
- self->priv = NOTIFICATION_GET_PRIVATE(self);
+ self->priv = notification_get_instance_private(self);
self->priv->app_name = NULL;
self->priv->replaces_id = 0;
@@ -82,7 +79,7 @@ notification_dispose(GObject *object)
G_OBJECT_CLASS(notification_parent_class)->dispose(object);
}
-Notification*
+Notification*
notification_new(void)
{
return NOTIFICATION(g_object_new(NOTIFICATION_TYPE, NULL));
@@ -104,7 +101,7 @@ notification_new_from_dbus_message(GDBusMessage *message)
/* app_name */
child = g_variant_get_child_value(body, COLUMN_APP_NAME);
g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_STRING));
- self->priv->app_name = g_variant_dup_string(child,
+ self->priv->app_name = g_variant_dup_string(child,
&(self->priv->app_name_length));
g_variant_unref(child);
diff --git a/src/notification.h b/src/notification.h
index 3009998..b6fec9d 100644
--- a/src/notification.h
+++ b/src/notification.h
@@ -49,9 +49,6 @@ struct _NotificationPrivate {
gboolean is_private;
};
-#define NOTIFICATION_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), NOTIFICATION_TYPE, NotificationPrivate))
-
GType notification_get_type(void);
Notification *notification_new(void);
Notification *notification_new_from_dbus_message(GDBusMessage *);