summaryrefslogtreecommitdiff
path: root/trashapplet/src
diff options
context:
space:
mode:
Diffstat (limited to 'trashapplet/src')
-rw-r--r--trashapplet/src/Makefile.am56
-rw-r--r--trashapplet/src/trash-empty.c47
-rw-r--r--trashapplet/src/trashapplet.c66
-rw-r--r--trashapplet/src/xstuff.c180
-rw-r--r--trashapplet/src/xstuff.h10
5 files changed, 96 insertions, 263 deletions
diff --git a/trashapplet/src/Makefile.am b/trashapplet/src/Makefile.am
index 194e44ad..8e5eec2e 100644
--- a/trashapplet/src/Makefile.am
+++ b/trashapplet/src/Makefile.am
@@ -4,32 +4,44 @@ AM_CPPFLAGS = -I$(top_srcdir) \
-DGRESOURCE=\""/org/mate/mate-applets/trash/\"" \
${WARN_CFLAGS}
-libexec_PROGRAMS = trashapplet
-
-BUILT_SOURCES = \
- trashapplet-resources.c \
- trashapplet-resources.h
+BUILT_SOURCES = \
+ trashapplet-resources.c \
+ trashapplet-resources.h \
+ $(NULL)
+APPLET_SOURCES = \
+ trashapplet.c \
+ trash-empty.h \
+ trash-empty.c \
+ $(NULL)
+
+APPLET_LIBS = \
+ $(MATE_APPLETS4_LIBS) \
+ $(GIO_LIBS) \
+ -lX11
+if ENABLE_IN_PROCESS
+pkglib_LTLIBRARIES = libmate-trash-applet.la
+nodist_libmate_trash_applet_la_SOURCES = $(BUILT_SOURCES)
+libmate_trash_applet_la_SOURCES = $(APPLET_SOURCES)
+libmate_trash_applet_la_CFLAGS = $(AM_CFLAGS)
+libmate_trash_applet_la_LDFLAGS = -module -avoid-version
+libmate_trash_applet_la_LIBADD = $(APPLET_LIBS)
+else !ENABLE_IN_PROCESS
+libexec_PROGRAMS = trashapplet
nodist_trashapplet_SOURCES = $(BUILT_SOURCES)
-trashapplet_SOURCES = \
- trashapplet.c \
- trash-empty.h \
- trash-empty.c \
- xstuff.c \
- xstuff.h
-
-trashapplet_LDADD = \
- $(MATE_APPLETS4_LIBS) \
- $(GIO_LIBS) \
- -lX11
+trashapplet_SOURCES = $(APPLET_SOURCES)
+trashapplet_CFLAGS = $(AM_CFLAGS)
+trashapplet_LDADD = $(APPLET_LIBS)
+endif !ENABLE_IN_PROCESS
-trashapplet-resources.c: ../trashapplet-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/../ --generate-dependencies $(srcdir)/../trashapplet-resources.gresource.xml)
- $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/../ --generate --c-name trashapplet $<
+trashapplet-resources.c: ../data/trashapplet-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/../data/ --generate-dependencies $(srcdir)/../data/trashapplet-resources.gresource.xml)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/../data/ --generate --c-name trashapplet $<
-trashapplet-resources.h: ../trashapplet-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/../ --generate-dependencies $(srcdir)/../trashapplet-resources.gresource.xml)
- $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/../ --generate --c-name trashapplet $<
+trashapplet-resources.h: ../data/trashapplet-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/../data/ --generate-dependencies $(srcdir)/../data/trashapplet-resources.gresource.xml)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/../data/ --generate --c-name trashapplet $<
-CLEANFILES = \
- $(BUILT_SOURCES)
+CLEANFILES = \
+ $(BUILT_SOURCES) \
+ $(NULL)
-include $(top_srcdir)/git.mk
diff --git a/trashapplet/src/trash-empty.c b/trashapplet/src/trash-empty.c
index 9ad61e5a..3a3bb6fa 100644
--- a/trashapplet/src/trash-empty.c
+++ b/trashapplet/src/trash-empty.c
@@ -114,20 +114,19 @@ trash_empty_update_dialog (gpointer user_data)
return FALSE;
}
-static gboolean
-trash_empty_done (gpointer user_data)
+static void
+trash_empty_done (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
gtk_widget_destroy (GTK_WIDGET (trash_empty_dialog));
g_assert (trash_empty_dialog == NULL);
-
- return FALSE;
}
/* =============== worker thread code begins here =============== */
static void
-trash_empty_maybe_schedule_update (GIOSchedulerJob *job,
- GFile *file,
+trash_empty_maybe_schedule_update (GFile *file,
gsize deleted)
{
if (!trash_empty_update_pending)
@@ -138,15 +137,12 @@ trash_empty_maybe_schedule_update (GIOSchedulerJob *job,
trash_empty_deleted_files = deleted;
trash_empty_update_pending = TRUE;
- g_io_scheduler_job_send_to_mainloop_async (job,
- trash_empty_update_dialog,
- NULL, NULL);
+ g_main_context_invoke (NULL, trash_empty_update_dialog, NULL);
}
}
static void
-trash_empty_delete_contents (GIOSchedulerJob *job,
- GCancellable *cancellable,
+trash_empty_delete_contents (GCancellable *cancellable,
GFile *file,
gboolean actually_delete,
gsize *deleted)
@@ -171,12 +167,12 @@ trash_empty_delete_contents (GIOSchedulerJob *job,
child = g_file_get_child (file, g_file_info_get_name (info));
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
- trash_empty_delete_contents (job, cancellable, child,
+ trash_empty_delete_contents (cancellable, child,
actually_delete, deleted);
if (actually_delete)
{
- trash_empty_maybe_schedule_update (job, child, *deleted);
+ trash_empty_maybe_schedule_update (child, *deleted);
g_file_delete (child, cancellable, NULL);
}
@@ -193,10 +189,11 @@ trash_empty_delete_contents (GIOSchedulerJob *job,
}
}
-static gboolean
-trash_empty_job (GIOSchedulerJob *job,
- GCancellable *cancellable,
- gpointer user_data)
+static void
+trash_empty_job (GTask *task,
+ gpointer source_object,
+ gpointer user_data,
+ GCancellable *cancellable)
{
gsize deleted;
GFile *trash;
@@ -205,20 +202,16 @@ trash_empty_job (GIOSchedulerJob *job,
/* first do a dry run to count the number of files */
deleted = 0;
- trash_empty_delete_contents (job, cancellable, trash, FALSE, &deleted);
+ trash_empty_delete_contents (cancellable, trash, FALSE, &deleted);
trash_empty_total_files = deleted;
/* now do the real thing */
deleted = 0;
- trash_empty_delete_contents (job, cancellable, trash, TRUE, &deleted);
+ trash_empty_delete_contents (cancellable, trash, TRUE, &deleted);
/* done */
g_object_unref (trash);
- g_io_scheduler_job_send_to_mainloop_async (job,
- trash_empty_done,
- NULL, NULL);
-
- return FALSE;
+ g_task_return_boolean (task, TRUE);
}
/* ================ worker thread code ends here ================ */
@@ -234,6 +227,7 @@ trash_empty_start (GtkWidget *parent)
};
GCancellable *cancellable;
GtkBuilder *builder;
+ GTask *task;
gint i;
builder = gtk_builder_new_from_resource (GRESOURCE "trashapplet-empty-progress.ui");
@@ -264,7 +258,10 @@ trash_empty_start (GtkWidget *parent)
g_signal_connect_object (trash_empty_dialog, "response",
G_CALLBACK (g_cancellable_cancel),
cancellable, G_CONNECT_SWAPPED);
- g_io_scheduler_push_job (trash_empty_job, NULL, NULL, 0, cancellable);
+
+ task = g_task_new (parent, cancellable, trash_empty_done, NULL);
+ g_task_run_in_thread (task, trash_empty_job);
+ g_object_unref (task);
g_object_unref (cancellable);
gtk_window_set_screen (GTK_WINDOW (trash_empty_dialog),
diff --git a/trashapplet/src/trashapplet.c b/trashapplet/src/trashapplet.c
index f50d136f..e4f2966b 100644
--- a/trashapplet/src/trashapplet.c
+++ b/trashapplet/src/trashapplet.c
@@ -28,13 +28,13 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gio/gio.h>
#include <mate-panel-applet.h>
#include "trash-empty.h"
-#include "xstuff.h"
#define TRASH_TYPE_APPLET (trash_applet_get_type ())
@@ -85,6 +85,7 @@ trash_applet_monitor_changed (TrashApplet *applet)
GError *error = NULL;
GFileInfo *info;
GIcon *icon;
+ AtkObject *atk_obj;
gint items;
info = g_file_query_info (applet->trash,
@@ -92,6 +93,8 @@ trash_applet_monitor_changed (TrashApplet *applet)
G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT,
0, NULL, &error);
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet));
+
if (!info)
{
g_critical ("could not query trash:/: '%s'", error->message);
@@ -120,19 +123,20 @@ trash_applet_monitor_changed (TrashApplet *applet)
if (items != applet->items)
{
+ char *text;
+
if (items)
{
- char *text;
-
text = g_strdup_printf (ngettext ("%d Item in Trash",
"%d Items in Trash",
items), items);
- gtk_widget_set_tooltip_text (GTK_WIDGET (applet), text);
- g_free (text);
}
else
- gtk_widget_set_tooltip_text (GTK_WIDGET (applet),
- _("No Items in Trash"));
+ text = g_strdup (_("No Items in Trash"));
+
+ gtk_widget_set_tooltip_text (GTK_WIDGET (applet), text);
+ atk_object_set_description (atk_obj, text);
+ g_free (text);
applet->items = items;
}
@@ -251,21 +255,18 @@ trash_applet_button_release (GtkWidget *widget,
if (settings == NULL)
settings = g_settings_new (PANEL_SCHEMA);
- if (event->button == 1)
- {
- if (g_settings_get_boolean (settings, PANEL_ENABLE_ANIMATIONS))
- xstuff_zoom_animate (widget, NULL);
+ if (event->button == 2)
+ return FALSE;
+ if ((event->button == 1) &&
+ (event->type != GDK_2BUTTON_PRESS) &&
+ (event->type != GDK_3BUTTON_PRESS))
+ {
trash_applet_open_folder (NULL, applet);
-
return TRUE;
}
- if (GTK_WIDGET_CLASS (trash_applet_parent_class)->button_release_event)
- return GTK_WIDGET_CLASS (trash_applet_parent_class)
- ->button_release_event (widget, event);
- else
- return FALSE;
+ return GTK_WIDGET_CLASS (trash_applet_parent_class)->button_press_event (widget, event);
}
static gboolean
trash_applet_key_press (GtkWidget *widget,
@@ -339,7 +340,7 @@ error_dialog (TrashApplet *applet, const gchar *error, ...)
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
"%s", error_string);
- g_signal_connect (G_OBJECT (dialog), "response",
+ g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
NULL);
@@ -398,7 +399,6 @@ trash_applet_show_help (GtkAction *action,
}
}
-
static void
trash_applet_show_about (GtkAction *action,
TrashApplet *applet)
@@ -429,7 +429,7 @@ trash_applet_show_about (GtkAction *action,
"version", VERSION,
"copyright", _("Copyright \xc2\xa9 2004 Michiel Sikkes\n"
"Copyright \xc2\xa9 2008 Ryan Lortie\n"
- "Copyright \xc2\xa9 2012-2020 MATE developers"),
+ "Copyright \xc2\xa9 2012-2021 MATE developers"),
"comments", _("A MATE trash bin that lives in your panel. "
"You can use it to view the trash or drag "
"and drop items into the trash."),
@@ -600,7 +600,12 @@ trash_applet_class_init (TrashAppletClass *class)
gobject_class->dispose = trash_applet_dispose;
widget_class->size_allocate = trash_applet_size_allocate;
- widget_class->button_release_event = trash_applet_button_release;
+#ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ widget_class->button_release_event = trash_applet_button_release;
+ else /* for Wayland we need to watch button press rather than release */
+#endif
+ widget_class->button_press_event = trash_applet_button_release;
widget_class->key_press_event = trash_applet_key_press;
widget_class->drag_motion = trash_applet_drag_motion;
widget_class->drag_data_received = trash_applet_drag_data_received;
@@ -615,9 +620,12 @@ trash_applet_factory (MatePanelApplet *applet,
if (!strcmp (iid, "TrashApplet"))
{
+ AtkObject *atk_obj;
GtkActionGroup *action_group;
+#ifndef ENABLE_IN_PROCESS
g_set_application_name (_("Trash Applet"));
+#endif
gtk_window_set_default_icon_name ("user-trash");
@@ -633,6 +641,12 @@ trash_applet_factory (MatePanelApplet *applet,
action_group);
g_object_unref (action_group);
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet));
+
+ if (GTK_IS_ACCESSIBLE (atk_obj)) {
+ atk_object_set_name (atk_obj, _("Trash Applet"));
+ }
+
gtk_widget_show (GTK_WIDGET (applet));
retval = TRUE;
@@ -641,8 +655,8 @@ trash_applet_factory (MatePanelApplet *applet,
return retval;
}
-MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("TrashAppletFactory",
- TRASH_TYPE_APPLET,
- "TrashApplet",
- trash_applet_factory,
- NULL)
+PANEL_APPLET_FACTORY ("TrashAppletFactory",
+ TRASH_TYPE_APPLET,
+ "TrashApplet",
+ trash_applet_factory,
+ NULL)
diff --git a/trashapplet/src/xstuff.c b/trashapplet/src/xstuff.c
deleted file mode 100644
index 91c8c8fe..00000000
--- a/trashapplet/src/xstuff.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * MATE panel x stuff
- *
- * Copyright (C) 2000, 2001 Eazel, Inc.
- * 2002 Sun Microsystems Inc.
- *
- * Authors: George Lebl <[email protected]>
- * Mark McLoughlin <[email protected]>
- *
- * Contains code from the Window Maker window manager
- *
- * Copyright (c) 1997-2002 Alfredo K. Kojima
-
- */
-#include <config.h>
-#include <unistd.h>
-
-#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
-
-#include <X11/Xlib.h>
-
-#include "xstuff.h"
-
-
-/* Zoom animation */
-#define MINIATURIZE_ANIMATION_FRAMES_Z 1
-#define MINIATURIZE_ANIMATION_STEPS_Z 6
-/* the delay per draw */
-#define MINIATURIZE_ANIMATION_DELAY_Z 10
-
-static void
-draw_zoom_animation (GdkScreen *gscreen,
- int x, int y, int w, int h,
- int fx, int fy, int fw, int fh,
- int steps)
-{
-#define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
- float cx[FRAMES], cy[FRAMES], cw[FRAMES], ch[FRAMES];
- int cxi[FRAMES], cyi[FRAMES], cwi[FRAMES], chi[FRAMES];
- float xstep, ystep, wstep, hstep;
- int i, j;
- GC frame_gc;
- XGCValues gcv;
- GdkColor color = { 0, 65535, 65535, 65535 };
- Display *dpy;
- Window root_win;
- int screen;
- int depth;
-
- dpy = gdk_x11_display_get_xdisplay (gdk_screen_get_display (gscreen));
- root_win = GDK_WINDOW_XID (gdk_screen_get_root_window (gscreen));
- screen = gdk_x11_screen_get_screen_number (gscreen);
- depth = DefaultDepth(dpy,screen);
-
- /* frame GC */
- gcv.function = GXxor;
- /* this will raise the probability of the XORed color being different
- * of the original color in PseudoColor when not all color cells are
- * initialized */
- if (DefaultVisual(dpy, screen)->class==PseudoColor)
- gcv.plane_mask = (1<<(depth-1))|1;
- else
- gcv.plane_mask = AllPlanes;
- gcv.foreground = color.pixel;
- if (gcv.foreground == 0)
- gcv.foreground = 1;
- gcv.line_width = 1;
- gcv.subwindow_mode = IncludeInferiors;
- gcv.graphics_exposures = False;
-
- frame_gc = XCreateGC(dpy, root_win, GCForeground|GCGraphicsExposures
- |GCFunction|GCSubwindowMode|GCLineWidth
- |GCPlaneMask, &gcv);
-
- xstep = (float)(fx-x)/steps;
- ystep = (float)(fy-y)/steps;
- wstep = (float)(fw-w)/steps;
- hstep = (float)(fh-h)/steps;
-
- for (j=0; j<FRAMES; j++) {
- cx[j] = (float)x;
- cy[j] = (float)y;
- cw[j] = (float)w;
- ch[j] = (float)h;
- cxi[j] = (int)cx[j];
- cyi[j] = (int)cy[j];
- cwi[j] = (int)cw[j];
- chi[j] = (int)ch[j];
- }
- XGrabServer(dpy);
- for (i=0; i<steps; i++) {
- for (j=0; j<FRAMES; j++) {
- XDrawRectangle(dpy, root_win, frame_gc, cxi[j], cyi[j], cwi[j], chi[j]);
- }
- XFlush(dpy);
-#if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
- usleep(MINIATURIZE_ANIMATION_DELAY_Z);
-#else
- usleep(10);
-#endif
- for (j=0; j<FRAMES; j++) {
- XDrawRectangle(dpy, root_win, frame_gc,
- cxi[j], cyi[j], cwi[j], chi[j]);
- if (j<FRAMES-1) {
- cx[j]=cx[j+1];
- cy[j]=cy[j+1];
- cw[j]=cw[j+1];
- ch[j]=ch[j+1];
-
- cxi[j]=cxi[j+1];
- cyi[j]=cyi[j+1];
- cwi[j]=cwi[j+1];
- chi[j]=chi[j+1];
-
- } else {
- cx[j]+=xstep;
- cy[j]+=ystep;
- cw[j]+=wstep;
- ch[j]+=hstep;
-
- cxi[j] = (int)cx[j];
- cyi[j] = (int)cy[j];
- cwi[j] = (int)cw[j];
- chi[j] = (int)ch[j];
- }
- }
- }
-
- for (j=0; j<FRAMES; j++) {
- XDrawRectangle(dpy, root_win, frame_gc,
- cxi[j], cyi[j], cwi[j], chi[j]);
- }
- XFlush(dpy);
-#if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
- usleep(MINIATURIZE_ANIMATION_DELAY_Z);
-#else
- usleep(10);
-#endif
- for (j=0; j<FRAMES; j++) {
- XDrawRectangle(dpy, root_win, frame_gc,
- cxi[j], cyi[j], cwi[j], chi[j]);
- }
-
- XUngrabServer(dpy);
- XFreeGC (dpy, frame_gc);
-}
-#undef FRAMES
-
-void
-xstuff_zoom_animate (GtkWidget *widget, GdkRectangle *opt_rect)
-{
- GdkScreen *gscreen;
- GdkRectangle rect, dest;
- GtkAllocation allocation;
- GdkMonitor *monitor;
-
- if (opt_rect)
- rect = *opt_rect;
- else {
- gdk_window_get_origin (gtk_widget_get_window (widget), &rect.x, &rect.y);
- gtk_widget_get_allocation (widget, &allocation);
- if (!gtk_widget_get_has_window (widget)) {
- rect.x += allocation.x;
- rect.y += allocation.y;
- }
- rect.height = allocation.height;
- rect.width = allocation.width;
- }
-
- gscreen = gtk_widget_get_screen (widget);
- monitor = gdk_display_get_monitor_at_window (gdk_screen_get_display (gscreen),
- gtk_widget_get_window (widget));
- gdk_monitor_get_geometry (monitor, &dest);
-
- draw_zoom_animation (gscreen,
- rect.x, rect.y, rect.width, rect.height,
- dest.x, dest.y, dest.width, dest.height,
- MINIATURIZE_ANIMATION_STEPS_Z);
-}
diff --git a/trashapplet/src/xstuff.h b/trashapplet/src/xstuff.h
deleted file mode 100644
index 0431ce79..00000000
--- a/trashapplet/src/xstuff.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __XSTUFF_H__
-#define __XSTUFF_H__
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-void xstuff_zoom_animate (GtkWidget *widget,
- GdkRectangle *opt_src_rect);
-
-#endif /* __XSTUFF_H__ */