summaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-05-19 14:10:54 +0300
committermonsta <[email protected]>2016-05-19 14:10:54 +0300
commite9a16f9dd6e56080643557470dea5778400ba306 (patch)
tree972b77f511e337c44952baa888d8080ed9dd0e65 /src/daemon
parentddc3c12d06e80f64eb8b8248920aa7bca2d52753 (diff)
downloadmate-notification-daemon-e9a16f9dd6e56080643557470dea5778400ba306.tar.bz2
mate-notification-daemon-e9a16f9dd6e56080643557470dea5778400ba306.tar.xz
require GTK+ >= 3.14, drop GTK+2 code and --with-gtk build option
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/daemon.c150
-rw-r--r--src/daemon/stack.c8
2 files changed, 0 insertions, 158 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 8d941f2..ca357cb 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -106,12 +106,7 @@ struct _NotifyDaemonPrivate {
gboolean url_clicked_lock;
NotifyStackLocation stack_location;
-#if GTK_CHECK_VERSION (3, 8, 0)
NotifyScreen* screen;
-#else
- NotifyScreen** screens;
- int n_screens;
-#endif
};
typedef struct {
@@ -183,12 +178,7 @@ static void remove_exit_timeout(NotifyDaemon* daemon)
static void create_stack_for_monitor(NotifyDaemon* daemon, GdkScreen* screen, int monitor_num)
{
-#if GTK_CHECK_VERSION (3, 8, 0)
NotifyScreen* nscreen = daemon->priv->screen;
-#else
- int screen_num = gdk_screen_get_number(screen);
- NotifyScreen* nscreen = daemon->priv->screens[screen_num];
-#endif
nscreen->stacks[monitor_num] = notify_stack_new(daemon, screen, monitor_num, daemon->priv->stack_location);
}
@@ -196,18 +186,10 @@ static void create_stack_for_monitor(NotifyDaemon* daemon, GdkScreen* screen, in
static void on_screen_monitors_changed(GdkScreen* screen, NotifyDaemon* daemon)
{
NotifyScreen* nscreen;
-#if !GTK_CHECK_VERSION (3, 8, 0)
- int screen_num;
-#endif
int n_monitors;
int i;
-#if GTK_CHECK_VERSION (3, 8, 0)
nscreen = daemon->priv->screen;
-#else
- screen_num = gdk_screen_get_number(screen);
- nscreen = daemon->priv->screens[screen_num];
-#endif
n_monitors = gdk_screen_get_n_monitors(screen);
@@ -259,17 +241,9 @@ static void on_screen_monitors_changed(GdkScreen* screen, NotifyDaemon* daemon)
static void create_stacks_for_screen(NotifyDaemon* daemon, GdkScreen *screen)
{
NotifyScreen* nscreen;
-#if !GTK_CHECK_VERSION (3, 8, 0)
- int screen_num;
-#endif
int i;
-#if GTK_CHECK_VERSION (3, 8, 0)
nscreen = daemon->priv->screen;
-#else
- screen_num = gdk_screen_get_number(screen);
- nscreen = daemon->priv->screens[screen_num];
-#endif
nscreen->n_stacks = gdk_screen_get_n_monitors(screen);
@@ -298,7 +272,6 @@ static GdkFilterReturn screen_xevent_filter(GdkXEvent* xevent, GdkEvent* event,
return GDK_FILTER_CONTINUE;
}
-#if GTK_CHECK_VERSION (3, 8, 0)
static void create_screen(NotifyDaemon* daemon)
{
GdkDisplay *display;
@@ -322,39 +295,6 @@ static void create_screen(NotifyDaemon* daemon)
create_stacks_for_screen(daemon, screen);
}
-#else
-static void create_screens(NotifyDaemon* daemon)
-{
- GdkDisplay* display;
- int i;
-
- g_assert(daemon->priv->screens == NULL);
-
- display = gdk_display_get_default();
- daemon->priv->n_screens = gdk_display_get_n_screens(display);
-
- daemon->priv->screens = g_new0(NotifyScreen *, daemon->priv->n_screens);
-
- for (i = 0; i < daemon->priv->n_screens; i++)
- {
- GdkScreen* screen;
- GdkWindow* gdkwindow;
-
- screen = gdk_display_get_screen(display, i);
- g_signal_connect(screen, "monitors-changed", G_CALLBACK(on_screen_monitors_changed), daemon);
-
- daemon->priv->screens[i] = g_new0(NotifyScreen, 1);
-
- daemon->priv->screens[i]->workarea_atom = XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_WORKAREA", True);
-
- gdkwindow = gdk_screen_get_root_window(screen);
- gdk_window_add_filter(gdkwindow, (GdkFilterFunc) screen_xevent_filter, daemon->priv->screens[i]);
- gdk_window_set_events(gdkwindow, gdk_window_get_events(gdkwindow) | GDK_PROPERTY_CHANGE_MASK);
-
- create_stacks_for_screen(daemon, gdk_display_get_screen(display, i));
- }
-}
-#endif
static void on_popup_location_changed(GSettings *settings, gchar *key, NotifyDaemon* daemon)
{
@@ -378,7 +318,6 @@ static void on_popup_location_changed(GSettings *settings, gchar *key, NotifyDae
daemon->priv->stack_location = stack_location;
g_free(slocation);
-#if GTK_CHECK_VERSION (3, 8, 0)
NotifyScreen *nscreen;
nscreen = daemon->priv->screen;
@@ -388,19 +327,6 @@ static void on_popup_location_changed(GSettings *settings, gchar *key, NotifyDae
stack = nscreen->stacks[i];
notify_stack_set_location(stack, stack_location);
}
-#else
- for (i = 0; i < daemon->priv->n_screens; i++)
- {
- int j;
-
- for (j = 0; j < daemon->priv->screens[i]->n_stacks; j++)
- {
- NotifyStack* stack;
- stack = daemon->priv->screens[i]->stacks[j];
- notify_stack_set_location(stack, stack_location);
- }
- }
-#endif
}
static void notify_daemon_init(NotifyDaemon* daemon)
@@ -422,23 +348,15 @@ static void notify_daemon_init(NotifyDaemon* daemon)
daemon->priv->stack_location = get_stack_location_from_string(location);
g_free(location);
-#if GTK_CHECK_VERSION (3, 8, 0)
daemon->priv->screen = NULL;
create_screen(daemon);
-#else
- daemon->priv->n_screens = 0;
- daemon->priv->screens = NULL;
-
- create_screens(daemon);
-#endif
daemon->priv->idle_reposition_notify_ids = g_hash_table_new(NULL, NULL);
daemon->priv->monitored_window_hash = g_hash_table_new(NULL, NULL);
daemon->priv->notification_hash = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, (GDestroyNotify) _notify_timeout_destroy);
}
-#if GTK_CHECK_VERSION (3, 8, 0)
static void destroy_screen(NotifyDaemon* daemon)
{
GdkDisplay *display;
@@ -465,39 +383,6 @@ static void destroy_screen(NotifyDaemon* daemon)
g_free(daemon->priv->screen);
daemon->priv->screen = NULL;
}
-#else
-static void destroy_screens(NotifyDaemon* daemon)
-{
- GdkDisplay* display;
- int i;
- int j;
-
- display = gdk_display_get_default();
-
- for (i = 0; i < daemon->priv->n_screens; i++)
- {
- GdkScreen* screen;
- GdkWindow* gdkwindow;
-
- screen = gdk_display_get_screen(display, i);
- g_signal_handlers_disconnect_by_func(screen, G_CALLBACK(on_screen_monitors_changed), daemon);
-
- gdkwindow = gdk_screen_get_root_window(screen);
- gdk_window_remove_filter(gdkwindow, (GdkFilterFunc) screen_xevent_filter, daemon->priv->screens[i]);
-
- for (j = 0; j < daemon->priv->screens[i]->n_stacks; j++)
- {
- notify_stack_destroy(daemon->priv->screens[i]->stacks[j]);
- daemon->priv->screens[i]->stacks[j] = NULL;
- }
-
- g_free(daemon->priv->screens[i]->stacks);
- }
-
- g_free(daemon->priv->screens);
- daemon->priv->screens = NULL;
-}
-#endif
static void notify_daemon_finalize(GObject* object)
{
@@ -516,11 +401,7 @@ static void notify_daemon_finalize(GObject* object)
g_hash_table_destroy(daemon->priv->idle_reposition_notify_ids);
g_hash_table_destroy(daemon->priv->notification_hash);
-#if GTK_CHECK_VERSION (3, 8, 0)
destroy_screen(daemon);
-#else
- destroy_screens(daemon);
-#endif
g_free(daemon->priv);
@@ -1101,11 +982,7 @@ static GdkPixbuf* _notify_daemon_pixbuf_from_path(const char* path)
pixbuf = gtk_icon_theme_load_icon (theme, path, icon_size, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
-#if GTK_CHECK_VERSION (3, 8, 0)
g_object_unref (icon_info);
-#else
- gtk_icon_info_free (icon_info);
-#endif
}
if (pixbuf == NULL)
@@ -1592,14 +1469,9 @@ gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const char* app_name
else
{
int monitor_num;
-#if !GTK_CHECK_VERSION (3, 8, 0)
- int screen_num;
-#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display;
GdkDeviceManager *device_manager;
GdkDevice *pointer;
-#endif
GdkScreen* screen;
gint x, y;
@@ -1610,49 +1482,27 @@ gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const char* app_name
* number the user has set in gsettings. */
if (g_settings_get_boolean(daemon->gsettings, GSETTINGS_KEY_USE_ACTIVE))
{
-#if GTK_CHECK_VERSION (3, 0, 0)
display = gdk_display_get_default ();
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
gdk_device_get_position (pointer, &screen, &x, &y);
-#else
- gdk_display_get_pointer (gdk_display_get_default (), &screen, &x, &y, NULL);
-#endif
-#if !GTK_CHECK_VERSION (3, 8, 0)
- screen_num = gdk_screen_get_number (screen);
-#endif
monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
}
else
{
screen = gdk_display_get_default_screen(gdk_display_get_default());
-#if !GTK_CHECK_VERSION (3, 8, 0)
- screen_num = gdk_screen_get_number(screen);
-#endif
monitor_num = g_settings_get_int(daemon->gsettings, GSETTINGS_KEY_MONITOR_NUMBER);
}
-#if GTK_CHECK_VERSION (3, 8, 0)
if (monitor_num >= priv->screen->n_stacks)
-#else
- if (monitor_num >= priv->screens[screen_num]->n_stacks)
-#endif
{
/* screw it - dump it on the last one we'll get
a monitors-changed signal soon enough*/
-#if GTK_CHECK_VERSION (3, 8, 0)
monitor_num = priv->screen->n_stacks - 1;
-#else
- monitor_num = priv->screens[screen_num]->n_stacks - 1;
-#endif
}
-#if GTK_CHECK_VERSION (3, 8, 0)
notify_stack_add_window (priv->screen->stacks[monitor_num], nw, new_notification);
-#else
- notify_stack_add_window (priv->screens[screen_num]->stacks[monitor_num], nw, new_notification);
-#endif
}
if (id == 0)
diff --git a/src/daemon/stack.c b/src/daemon/stack.c
index a60f2b2..0fd8775 100644
--- a/src/daemon/stack.c
+++ b/src/daemon/stack.c
@@ -301,11 +301,7 @@ notify_stack_shift_notifications (NotifyStack *stack,
GtkRequisition req;
if (nw == NULL || nw2 != nw) {
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_get_preferred_size (GTK_WIDGET (nw2), NULL, &req);
-#else
- gtk_widget_size_request (GTK_WIDGET (nw2), &req);
-#endif
translate_coordinates (stack->location,
&workarea,
@@ -366,11 +362,7 @@ void notify_stack_add_window(NotifyStack* stack, GtkWindow* nw, gboolean new_not
GtkRequisition req;
gint x, y;
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_get_preferred_size(GTK_WIDGET(nw), NULL, &req);
-#else
- gtk_widget_size_request(GTK_WIDGET(nw), &req);
-#endif
notify_stack_shift_notifications(stack, nw, NULL, req.width, req.height + NOTIFY_STACK_SPACING, &x, &y);
theme_move_notification(nw, x, y);