[gnome-panel/wip/muktupavels/force-quit-applet] action-button: turn force quit object into applet
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/force-quit-applet] action-button: turn force quit object into applet
- Date: Fri, 17 Apr 2020 20:56:53 +0000 (UTC)
commit 79dff80d5b07b364834b040676135e9d0e6543a1
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Apr 17 23:51:42 2020 +0300
action-button: turn force quit object into applet
And remove unused _GNOME_PANEL_ACTION_KILL_DIALOG.
https://bugzilla.gnome.org/show_bug.cgi?id=442625
https://bugzilla.gnome.org/show_bug.cgi?id=131617
gnome-panel/Makefile.am | 2 -
gnome-panel/panel-action-button.c | 20 ---
gnome-panel/panel-action-protocol.c | 15 ---
gnome-panel/panel-enums.h | 1 -
gnome-panel/panel-icon-names.h | 1 -
gnome-panel/panel-object-loader.c | 1 +
modules/action-button/Makefile.am | 4 +
modules/action-button/gp-action-button-module.c | 17 ++-
modules/action-button/gp-force-quit-applet.c | 140 +++++++++++++++++++++
modules/action-button/gp-force-quit-applet.h | 34 +++++
.../action-button}/panel-force-quit.c | 13 +-
.../action-button}/panel-force-quit.h | 0
po/POTFILES.in | 3 +-
13 files changed, 203 insertions(+), 48 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 339781195..c5f8ff868 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -43,7 +43,6 @@ panel_sources = \
panel-multiscreen.c \
panel-a11y.c \
panel-bindings.c \
- panel-force-quit.c \
panel-lockdown.c \
panel-addto-dialog.c \
panel-layout.c \
@@ -71,7 +70,6 @@ panel_headers = \
panel-bindings.h \
panel-enums.h \
panel-enums-gsettings.h \
- panel-force-quit.h \
panel-lockdown.h \
panel-addto-dialog.h \
panel-icon-names.h \
diff --git a/gnome-panel/panel-action-button.c b/gnome-panel/panel-action-button.c
index eb128820c..407d4c3a7 100644
--- a/gnome-panel/panel-action-button.c
+++ b/gnome-panel/panel-action-button.c
@@ -36,7 +36,6 @@
#include "applet.h"
#include "panel-typebuiltins.h"
-#include "panel-force-quit.h"
#include "panel-util.h"
#include "panel-run-dialog.h"
#include "panel-a11y.h"
@@ -64,7 +63,6 @@ typedef struct {
static PanelEnumStringPair panel_action_type_map [] = {
{ PANEL_ACTION_NONE, "none" },
{ PANEL_ACTION_RUN, "run" },
- { PANEL_ACTION_FORCE_QUIT, "force-quit" },
{ 0, NULL },
};
@@ -106,15 +104,6 @@ panel_action_run_program (GtkWidget *widget)
gtk_get_current_event_time ());
}
-/* Force Quit
- */
-static void
-panel_action_force_quit (GtkWidget *widget)
-{
- panel_force_quit (gtk_widget_get_screen (widget),
- gtk_get_current_event_time ());
-}
-
typedef struct {
PanelActionButtonType type;
const gchar *icon_name;
@@ -141,15 +130,6 @@ static PanelAction actions [] = {
"ACTION:run:NEW",
panel_action_run_program,
panel_lockdown_get_disable_command_line_s
- },
- {
- PANEL_ACTION_FORCE_QUIT,
- PANEL_ICON_FORCE_QUIT,
- N_("Force Quit"),
- N_("Force a misbehaving application to quit"),
- "ACTION:force-quit:NEW",
- panel_action_force_quit,
- panel_lockdown_get_disable_force_quit_s
}
};
diff --git a/gnome-panel/panel-action-protocol.c b/gnome-panel/panel-action-protocol.c
index ea7e1ba86..97f63850a 100644
--- a/gnome-panel/panel-action-protocol.c
+++ b/gnome-panel/panel-action-protocol.c
@@ -32,13 +32,11 @@
#include "applet.h"
#include "panel-toplevel.h"
#include "panel-util.h"
-#include "panel-force-quit.h"
#include "panel-run-dialog.h"
static Atom atom_gnome_panel_action = None;
static Atom atom_gnome_panel_action_main_menu = None;
static Atom atom_gnome_panel_action_run_dialog = None;
-static Atom atom_gnome_panel_action_kill_dialog = None;
static void
menu_destroy_cb (GtkWidget *widget,
@@ -104,13 +102,6 @@ panel_action_protocol_run_dialog (GdkScreen *screen,
panel_run_dialog_present (screen, activate_time);
}
-static void
-panel_action_protocol_kill_dialog (GdkScreen *screen,
- guint32 activate_time)
-{
- panel_force_quit (screen, activate_time);
-}
-
static GdkFilterReturn
panel_action_protocol_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
@@ -143,8 +134,6 @@ panel_action_protocol_filter (GdkXEvent *gdk_xevent,
panel_action_protocol_main_menu (screen, xevent->xclient.data.l [1]);
else if (atom == atom_gnome_panel_action_run_dialog)
panel_action_protocol_run_dialog (screen, xevent->xclient.data.l [1]);
- else if (atom == atom_gnome_panel_action_kill_dialog)
- panel_action_protocol_kill_dialog (screen, xevent->xclient.data.l [1]);
else
return GDK_FILTER_CONTINUE;
@@ -170,10 +159,6 @@ panel_action_protocol_init (void)
XInternAtom (GDK_DISPLAY_XDISPLAY (display),
"_GNOME_PANEL_ACTION_RUN_DIALOG",
FALSE);
- atom_gnome_panel_action_kill_dialog =
- XInternAtom (GDK_DISPLAY_XDISPLAY (display),
- "_GNOME_PANEL_ACTION_KILL_DIALOG",
- FALSE);
/* We'll filter event sent on non-root windows later */
gdk_window_add_filter (NULL, panel_action_protocol_filter, NULL);
diff --git a/gnome-panel/panel-enums.h b/gnome-panel/panel-enums.h
index 412ec221f..ba82ead3b 100644
--- a/gnome-panel/panel-enums.h
+++ b/gnome-panel/panel-enums.h
@@ -39,7 +39,6 @@ typedef enum {
typedef enum {
PANEL_ACTION_NONE = 0,
PANEL_ACTION_RUN,
- PANEL_ACTION_FORCE_QUIT,
PANEL_ACTION_LAST
} PanelActionButtonType;
diff --git a/gnome-panel/panel-icon-names.h b/gnome-panel/panel-icon-names.h
index 7481598b9..aa16a10af 100644
--- a/gnome-panel/panel-icon-names.h
+++ b/gnome-panel/panel-icon-names.h
@@ -13,7 +13,6 @@
#define PANEL_ICON_FOLDER_PUBLIC_SHARE "folder-publicshare"
#define PANEL_ICON_FOLDER_TEMPLATES "folder-templates"
#define PANEL_ICON_FOLDER_VIDEOS "folder-videos"
-#define PANEL_ICON_FORCE_QUIT "gnome-panel-force-quit"
#define PANEL_ICON_HOME "user-home"
#define PANEL_ICON_LAUNCHER "gnome-panel-launcher"
#define PANEL_ICON_NETWORK "network-workgroup"
diff --git a/gnome-panel/panel-object-loader.c b/gnome-panel/panel-object-loader.c
index cfb82bd1b..5cabdd633 100644
--- a/gnome-panel/panel-object-loader.c
+++ b/gnome-panel/panel-object-loader.c
@@ -425,6 +425,7 @@ panel_object_iid_to_type (const char *iid,
return FALSE;
if (g_strcmp0 (d, "lock") == 0 ||
+ g_strcmp0 (d, "force-quit") == 0 ||
g_strcmp0 (d, "shutdown") == 0 ||
g_strcmp0 (d, "logout") == 0) {
*type = PANEL_OBJECT_APPLET;
diff --git a/modules/action-button/Makefile.am b/modules/action-button/Makefile.am
index 308481706..0515c2859 100644
--- a/modules/action-button/Makefile.am
+++ b/modules/action-button/Makefile.am
@@ -24,12 +24,16 @@ org_gnome_gnome_panel_action_button_la_SOURCES = \
gp-action-button.c \
gp-action-button.h \
gp-action-button-module.c \
+ gp-force-quit-applet.c \
+ gp-force-quit-applet.h \
gp-lock-screen-applet.c \
gp-lock-screen-applet.h \
gp-logout-applet.c \
gp-logout-applet.h \
gp-shutdown-applet.c \
gp-shutdown-applet.h \
+ panel-force-quit.c \
+ panel-force-quit.h \
$(BUILT_SOURCES) \
$(NULL)
diff --git a/modules/action-button/gp-action-button-module.c b/modules/action-button/gp-action-button-module.c
index 6fd47277c..cd89c14fa 100644
--- a/modules/action-button/gp-action-button-module.c
+++ b/modules/action-button/gp-action-button-module.c
@@ -21,6 +21,7 @@
#include <libgnome-panel/gp-module.h>
#include "gp-lock-screen-applet.h"
+#include "gp-force-quit-applet.h"
#include "gp-logout-applet.h"
#include "gp-shutdown-applet.h"
@@ -36,7 +37,16 @@ action_button_get_applet_info (const char *id)
is_disabled_func = NULL;
- if (g_strcmp0 (id, "lock-screen") == 0)
+ if (g_strcmp0 (id, "force-quit") == 0)
+ {
+ type_func = gp_force_quit_applet_get_type;
+ name = _("Force Quit");
+ description = _("Force a misbehaving application to quit");
+ icon = "gnome-panel-force-quit";
+
+ is_disabled_func = gp_force_quit_applet_is_disabled;
+ }
+ else if (g_strcmp0 (id, "lock-screen") == 0)
{
type_func = gp_lock_screen_applet_get_type;
name = _("Lock Screen");
@@ -80,7 +90,9 @@ action_button_get_applet_info (const char *id)
static const char *
action_button_get_applet_id_from_iid (const char *iid)
{
- if (g_strcmp0 (iid, "PanelInternalFactory::ActionButton:lock") == 0)
+ if (g_strcmp0 (iid, "PanelInternalFactory::ActionButton:force-quit") == 0)
+ return "force-quit";
+ else if (g_strcmp0 (iid, "PanelInternalFactory::ActionButton:lock") == 0)
return "lock-screen";
else if (g_strcmp0 (iid, "PanelInternalFactory::ActionButton:logout") == 0)
return "logout";
@@ -103,6 +115,7 @@ gp_module_load (GpModule *module)
gp_module_set_version (module, PACKAGE_VERSION);
gp_module_set_applet_ids (module,
+ "force-quit",
"lock-screen",
"logout",
"shutdown",
diff --git a/modules/action-button/gp-force-quit-applet.c b/modules/action-button/gp-force-quit-applet.c
new file mode 100644
index 000000000..7b7c58beb
--- /dev/null
+++ b/modules/action-button/gp-force-quit-applet.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2020 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 2 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 "gp-force-quit-applet.h"
+
+#include <glib/gi18n-lib.h>
+
+#include "panel-force-quit.h"
+
+struct _GpForceQuitApplet
+{
+ GpActionButtonApplet parent;
+};
+
+G_DEFINE_TYPE (GpForceQuitApplet, gp_force_quit_applet, GP_TYPE_ACTION_BUTTON_APPLET)
+
+static void
+lockdown_changed (GpForceQuitApplet *self)
+{
+ GpLockdownFlags lockdowns;
+ gboolean applet_sensitive;
+
+ lockdowns = gp_applet_get_lockdowns (GP_APPLET (self));
+
+ applet_sensitive = TRUE;
+
+ if ((lockdowns & GP_LOCKDOWN_FLAGS_APPLET) == GP_LOCKDOWN_FLAGS_APPLET ||
+ (lockdowns & GP_LOCKDOWN_FLAGS_FORCE_QUIT) == GP_LOCKDOWN_FLAGS_FORCE_QUIT)
+ applet_sensitive = FALSE;
+
+ gtk_widget_set_sensitive (GTK_WIDGET (self), applet_sensitive);
+}
+
+static void
+lockdowns_cb (GpApplet *applet,
+ GParamSpec *pspec,
+ GpForceQuitApplet *self)
+{
+ lockdown_changed (self);
+}
+
+static void
+setup_applet (GpForceQuitApplet *self)
+{
+ const char *text;
+ AtkObject *atk;
+
+ gp_action_button_applet_set_icon_name (GP_ACTION_BUTTON_APPLET (self),
+ "gnome-panel-force-quit");
+
+ text = _("Force a misbehaving application to quit");
+
+ atk = gtk_widget_get_accessible (GTK_WIDGET (self));
+ atk_object_set_name (atk, text);
+ atk_object_set_description (atk, text);
+
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), text);
+
+ g_object_bind_property (self,
+ "enable-tooltips",
+ self,
+ "has-tooltip",
+ G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+
+ lockdown_changed (self);
+}
+
+static void
+gp_force_quit_applet_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (gp_force_quit_applet_parent_class)->constructed (object);
+ setup_applet (GP_FORCE_QUIT_APPLET (object));
+}
+
+static void
+gp_force_quit_applet_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (gp_force_quit_applet_parent_class)->dispose (object);
+}
+
+static void
+gp_force_quit_applet_clicked (GpActionButtonApplet *applet)
+{
+ panel_force_quit (gtk_widget_get_screen (GTK_WIDGET (applet)),
+ gtk_get_current_event_time ());
+}
+
+static void
+gp_force_quit_applet_class_init (GpForceQuitAppletClass *self_class)
+{
+ GObjectClass *object_class;
+ GpActionButtonAppletClass *action_button_applet_class;
+
+ object_class = G_OBJECT_CLASS (self_class);
+ action_button_applet_class = GP_ACTION_BUTTON_APPLET_CLASS (self_class);
+
+ object_class->constructed = gp_force_quit_applet_constructed;
+ object_class->dispose = gp_force_quit_applet_dispose;
+
+ action_button_applet_class->clicked = gp_force_quit_applet_clicked;
+}
+
+static void
+gp_force_quit_applet_init (GpForceQuitApplet *self)
+{
+ g_signal_connect (self,
+ "notify::lockdowns",
+ G_CALLBACK (lockdowns_cb),
+ self);
+}
+
+gboolean
+gp_force_quit_applet_is_disabled (GpLockdownFlags flags,
+ char **reason)
+{
+ if ((flags & GP_LOCKDOWN_FLAGS_FORCE_QUIT) != GP_LOCKDOWN_FLAGS_FORCE_QUIT)
+ return FALSE;
+
+ if (reason != NULL)
+ *reason = g_strdup (_("Disabled because “disable-force-quit” setting in "
+ "“org.gnome.gnome-panel.lockdown” GSettings schema "
+ "is set to true."));
+
+ return TRUE;
+}
diff --git a/modules/action-button/gp-force-quit-applet.h b/modules/action-button/gp-force-quit-applet.h
new file mode 100644
index 000000000..4fe21b4b2
--- /dev/null
+++ b/modules/action-button/gp-force-quit-applet.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2020 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 2 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 GP_FORCE_QUIT_APPLET_H
+#define GP_FORCE_QUIT_APPLET_H
+
+#include "gp-action-button-applet.h"
+
+G_BEGIN_DECLS
+
+#define GP_TYPE_FORCE_QUIT_APPLET (gp_force_quit_applet_get_type ())
+G_DECLARE_FINAL_TYPE (GpForceQuitApplet, gp_force_quit_applet,
+ GP, FORCE_QUIT_APPLET, GpActionButtonApplet)
+
+gboolean gp_force_quit_applet_is_disabled (GpLockdownFlags flags,
+ char **reason);
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-panel/panel-force-quit.c b/modules/action-button/panel-force-quit.c
similarity index 97%
rename from gnome-panel/panel-force-quit.c
rename to modules/action-button/panel-force-quit.c
index b6969a7c9..ccb7f320a 100644
--- a/gnome-panel/panel-force-quit.c
+++ b/modules/action-button/panel-force-quit.c
@@ -20,11 +20,10 @@
* Mark McLoughlin <mark skynet ie>
*/
-#include <config.h>
-
+#include "config.h"
#include "panel-force-quit.h"
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
@@ -32,8 +31,6 @@
#include <X11/extensions/XInput2.h>
-#include "panel-icon-names.h"
-
static GdkFilterReturn popup_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
GtkWidget *popup);
@@ -66,7 +63,7 @@ display_popup_window (GdkScreen *screen)
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
- image = gtk_image_new_from_icon_name (PANEL_ICON_FORCE_QUIT,
+ image = gtk_image_new_from_icon_name ("gnome-panel-force-quit",
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (vbox), image, TRUE, TRUE, 4);
gtk_widget_show (image);
@@ -316,6 +313,7 @@ panel_force_quit (GdkScreen *screen,
GdkCursor *cross;
GtkWidget *popup;
GdkWindow *root;
+ GdkEventMask event_mask;
GdkDisplay *display;
GdkSeat *seat;
@@ -323,6 +321,9 @@ panel_force_quit (GdkScreen *screen,
root = gdk_screen_get_root_window (screen);
+ event_mask = gdk_window_get_events (root);
+ gdk_window_set_events (root, event_mask | GDK_KEY_PRESS_MASK);
+
gdk_window_add_filter (root, (GdkFilterFunc) popup_filter, popup);
cross = gdk_cursor_new_for_display (gdk_display_get_default (),
diff --git a/gnome-panel/panel-force-quit.h b/modules/action-button/panel-force-quit.h
similarity index 100%
rename from gnome-panel/panel-force-quit.h
rename to modules/action-button/panel-force-quit.h
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 36e3b0525..6cfe210d7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -23,7 +23,6 @@ gnome-panel/panel-applet-frame.c
gnome-panel/panel-bindings.c
gnome-panel/panel.c
gnome-panel/panel-context-menu.c
-gnome-panel/panel-force-quit.c
gnome-panel/panel-layout.c
gnome-panel/panel-run-dialog.c
gnome-panel/panel-run-dialog.ui
@@ -32,10 +31,12 @@ gnome-panel/panel-util.c
libgnome-panel/gp-initial-setup-dialog.c
libgnome-panel/gp-module.c
modules/action-button/gp-action-button-module.c
+modules/action-button/gp-force-quit-applet.c
modules/action-button/gp-lock-screen-applet.c
modules/action-button/gp-lock-screen-menu.ui
modules/action-button/gp-logout-applet.c
modules/action-button/gp-shutdown-applet.c
+modules/action-button/panel-force-quit.c
modules/clock/calendar-client.c
modules/clock/calendar-window.c
modules/clock/clock-applet.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]