[gnome-panel/wip/muktupavels/run-applet] action-button: turn run object into applet
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/run-applet] action-button: turn run object into applet
- Date: Fri, 17 Apr 2020 22:22:13 +0000 (UTC)
commit 340efb60afe6144a49a3ed707c3a5ea4ab3626df
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Apr 18 01:21:25 2020 +0300
action-button: turn run object into applet
gnome-panel/Makefile.am | 4 -
gnome-panel/applet.c | 20 +-
gnome-panel/applet.h | 9 +-
gnome-panel/button-widget.c | 647 ------------------------
gnome-panel/button-widget.h | 39 --
gnome-panel/panel-action-button.c | 436 ----------------
gnome-panel/panel-action-button.h | 84 ---
gnome-panel/panel-addto-dialog.c | 92 +---
gnome-panel/panel-applet-frame.c | 12 +-
gnome-panel/panel-enums.h | 11 -
gnome-panel/panel-layout.c | 45 +-
gnome-panel/panel-layout.h | 12 +-
gnome-panel/panel-object-loader.c | 161 +-----
gnome-panel/panel-object-loader.h | 11 -
gnome-panel/panel-util.c | 90 ----
gnome-panel/panel-util.h | 10 -
gnome-panel/panel-widget.c | 3 +-
gnome-panel/panel-widget.h | 5 -
gnome-panel/panel.c | 62 +--
modules/action-button/Makefile.am | 2 +
modules/action-button/gp-action-button-module.c | 13 +
modules/action-button/gp-run-applet.c | 141 ++++++
modules/action-button/gp-run-applet.h | 34 ++
po/POTFILES.in | 3 +-
24 files changed, 242 insertions(+), 1704 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index c5f8ff868..ed699b279 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -27,7 +27,6 @@ panel_sources = \
gp-theme.c \
gp-theme.h \
panel-widget.c \
- button-widget.c \
panel.c \
applet.c \
panel-util.c \
@@ -35,7 +34,6 @@ panel_sources = \
panel-context-menu.c \
panel-applet-frame.c \
panel-applets-manager.c \
- panel-action-button.c \
panel-action-protocol.c \
panel-toplevel.c \
panel-struts.c \
@@ -52,7 +50,6 @@ panel_sources = \
panel_headers = \
panel-types.h \
panel-widget.h \
- button-widget.h \
panel.h \
applet.h \
panel-util.h \
@@ -60,7 +57,6 @@ panel_headers = \
panel-context-menu.h \
panel-applet-frame.h \
panel-applets-manager.h \
- panel-action-button.h \
panel-action-protocol.h \
panel-toplevel.h \
panel-struts.h \
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index a14781a88..6c30930de 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -17,7 +17,6 @@
#include <libpanel-util/panel-glib.h>
#include <libpanel-util/panel-show.h>
-#include "button-widget.h"
#include "panel.h"
#include "panel-bindings.h"
#include "panel-applet-frame.h"
@@ -66,10 +65,6 @@ panel_applet_destroy (GtkWidget *widget,
queued_position_saves =
g_slist_remove (queued_position_saves, info);
- if (info->data_destroy)
- info->data_destroy (info->data);
- info->data = NULL;
-
if (info->settings)
g_object_unref (info->settings);
info->settings = NULL;
@@ -182,8 +177,6 @@ panel_applet_activate_main_menu (guint32 activate_time)
GtkWidget *applet;
info = l->data;
- if (info->type != PANEL_OBJECT_APPLET)
- continue;
applet = gtk_bin_get_child (GTK_BIN (info->widget));
if (applet == NULL)
@@ -202,11 +195,8 @@ panel_applet_activate_main_menu (guint32 activate_time)
AppletInfo *
panel_applet_register (GtkWidget *applet,
PanelWidget *panel,
- PanelObjectType type,
const char *id,
- GSettings *settings,
- gpointer data,
- GDestroyNotify data_destroy)
+ GSettings *settings)
{
AppletInfo *info;
PanelObjectPackType pack_type;
@@ -221,11 +211,8 @@ panel_applet_register (GtkWidget *applet,
GDK_POINTER_MOTION_HINT_MASK));
info = g_new0 (AppletInfo, 1);
- info->type = type;
info->widget = applet;
info->settings = g_object_ref (settings);
- info->data = data;
- info->data_destroy = data_destroy;
info->id = g_strdup (id);
g_object_set_data (G_OBJECT (applet), "applet_info", info);
@@ -247,10 +234,7 @@ panel_applet_register (GtkWidget *applet,
orientation_change (info, panel);
- if (type != PANEL_OBJECT_APPLET)
- gtk_widget_grab_focus (applet);
- else
- gtk_widget_child_focus (applet, GTK_DIR_TAB_FORWARD);
+ gtk_widget_child_focus (applet, GTK_DIR_TAB_FORWARD);
return info;
}
diff --git a/gnome-panel/applet.h b/gnome-panel/applet.h
index 970770481..3237cbb4b 100644
--- a/gnome-panel/applet.h
+++ b/gnome-panel/applet.h
@@ -14,23 +14,16 @@ G_BEGIN_DECLS
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK)
typedef struct {
- PanelObjectType type;
GtkWidget *widget;
GSettings *settings;
- gpointer data;
- GDestroyNotify data_destroy;
-
char *id;
} AppletInfo;
AppletInfo *panel_applet_register (GtkWidget *applet,
PanelWidget *panel,
- PanelObjectType type,
const char *id,
- GSettings *settings,
- gpointer data,
- GDestroyNotify data_destroy);
+ GSettings *settings);
const char *panel_applet_get_id (AppletInfo *info);
diff --git a/gnome-panel/panel-addto-dialog.c b/gnome-panel/panel-addto-dialog.c
index c57adf902..ad6ef2a58 100644
--- a/gnome-panel/panel-addto-dialog.c
+++ b/gnome-panel/panel-addto-dialog.c
@@ -31,13 +31,11 @@
#include "panel.h"
#include "panel-applets-manager.h"
#include "panel-applet-frame.h"
-#include "panel-action-button.h"
#include "panel-toplevel.h"
#include "panel-layout.h"
#include "panel-lockdown.h"
#include "panel-util.h"
#include "panel-addto-dialog.h"
-#include "panel-icon-names.h"
struct _PanelAddtoDialog
{
@@ -66,17 +64,10 @@ G_DEFINE_TYPE (PanelAddtoDialog, panel_addto_dialog, GTK_TYPE_WINDOW)
static GQuark panel_addto_dialog_quark = 0;
-typedef enum {
- PANEL_ADDTO_APPLET,
- PANEL_ADDTO_ACTION
-} PanelAddtoItemType;
-
typedef struct {
- PanelAddtoItemType type;
char *name;
char *description;
GIcon *icon;
- PanelActionButtonType action_type;
char *iid;
} PanelAddtoItemInfo;
@@ -104,32 +95,6 @@ panel_addto_applet_info_sort_func (PanelAddtoItemInfo *a,
return g_utf8_collate (a->name, b->name);
}
-static GSList *
-panel_addto_prepend_internal_applets (GSList *list)
-{
- int i;
-
- for (i = 1; i < PANEL_ACTION_LAST; i++) {
- PanelAddtoItemInfo *info;
-
- if (panel_action_get_is_disabled (i))
- continue;
-
- info = g_new0 (PanelAddtoItemInfo, 1);
- info->type = PANEL_ADDTO_ACTION;
- info->action_type = i;
- info->name = g_strdup (panel_action_get_text (i));
- info->description = g_strdup (panel_action_get_tooltip (i));
- if (panel_action_get_icon_name (i) != NULL)
- info->icon = g_themed_icon_new (panel_action_get_icon_name (i));
- info->iid = g_strdup (panel_action_get_drag_id (i));
-
- list = g_slist_prepend (list, info);
- }
-
- return list;
-}
-
static char *
panel_addto_make_text (const char *name,
const char *desc)
@@ -232,17 +197,6 @@ panel_addto_setup_applet_drag (GtkTreeView *tree_view,
panel_addto_setup_drag (tree_view, target, iid);
}
-static void
-panel_addto_setup_internal_applet_drag (GtkTreeView *tree_view,
- const char *applet_type)
-{
- static const GtkTargetEntry target[] = {
- { (gchar *) "application/x-panel-applet-internal", 0, 0 }
- };
-
- panel_addto_setup_drag (tree_view, target, applet_type);
-}
-
static GSList *
panel_addto_query_applets (GSList *list)
{
@@ -267,7 +221,6 @@ panel_addto_query_applets (GSList *list)
}
applet = g_new0 (PanelAddtoItemInfo, 1);
- applet->type = PANEL_ADDTO_APPLET;
applet->name = g_strdup (name);
applet->description = g_strdup (description);
if (icon)
@@ -326,7 +279,6 @@ panel_addto_make_applet_model (PanelAddtoDialog *dialog)
if (panel_layout_is_writable ()) {
dialog->applet_list = panel_addto_query_applets (dialog->applet_list);
- dialog->applet_list = panel_addto_prepend_internal_applets (dialog->applet_list);
}
dialog->applet_list = g_slist_sort (dialog->applet_list,
@@ -424,28 +376,19 @@ panel_addto_add_item (PanelAddtoDialog *dialog,
pack_index = panel_widget_get_new_pack_index (dialog->panel_widget,
dialog->insert_pack_type);
- switch (item_info->type) {
- case PANEL_ADDTO_APPLET:
- data = initial_setup_data_new (dialog, item_info->iid);
-
- if (!panel_applets_manager_open_initial_setup_dialog (item_info->iid,
- NULL,
- GTK_WINDOW (dialog),
- initial_setup_dialog_cb,
- data, initial_setup_data_free)) {
- panel_applet_frame_create (dialog->panel_widget->toplevel,
- dialog->insert_pack_type, pack_index,
- item_info->iid, NULL);
- }
- break;
- case PANEL_ADDTO_ACTION:
- panel_action_button_create (dialog->panel_widget->toplevel,
- dialog->insert_pack_type,
- pack_index,
- item_info->action_type);
- break;
- default:
- break;
+ data = initial_setup_data_new (dialog, item_info->iid);
+
+ if (!panel_applets_manager_open_initial_setup_dialog (item_info->iid,
+ NULL,
+ GTK_WINDOW (dialog),
+ initial_setup_dialog_cb,
+ data,
+ initial_setup_data_free)) {
+ panel_applet_frame_create (dialog->panel_widget->toplevel,
+ dialog->insert_pack_type,
+ pack_index,
+ item_info->iid,
+ NULL);
}
}
@@ -660,13 +603,8 @@ panel_addto_selection_changed (PanelAddtoDialog *dialog,
/* only allow dragging applets if we can add applets */
if (panel_layout_is_writable ()) {
- if (data->type == PANEL_ADDTO_APPLET) {
- panel_addto_setup_applet_drag (GTK_TREE_VIEW (dialog->tree_view),
- data->iid);
- } else if (data->type == PANEL_ADDTO_ACTION) {
- panel_addto_setup_internal_applet_drag (GTK_TREE_VIEW (dialog->tree_view),
- data->iid);
- }
+ panel_addto_setup_applet_drag (GTK_TREE_VIEW (dialog->tree_view),
+ data->iid);
}
}
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index 19e10e936..b288c8cd4 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -786,16 +786,15 @@ _panel_applet_frame_activated (PanelAppletFrame *frame,
frame->priv->panel = frame_act->panel;
gtk_widget_show (GTK_WIDGET (frame));
- info = panel_applet_register (GTK_WIDGET (frame), frame->priv->panel,
- PANEL_OBJECT_APPLET, frame_act->id,
- frame_act->settings,
- GTK_WIDGET (frame), NULL);
+ info = panel_applet_register (GTK_WIDGET (frame),
+ frame->priv->panel,
+ frame_act->id,
+ frame_act->settings);
frame->priv->applet_info = info;
panel_widget_set_applet_size_constrained (frame->priv->panel,
GTK_WIDGET (frame), TRUE);
-
panel_lockdown_on_notify (panel_lockdown_get (),
NULL,
G_OBJECT (frame),
@@ -1019,8 +1018,7 @@ panel_applet_frame_create (PanelToplevel *toplevel,
{
g_return_if_fail (iid != NULL);
- panel_layout_object_create (PANEL_OBJECT_APPLET,
- iid,
+ panel_layout_object_create (iid,
panel_toplevel_get_id (toplevel),
pack_type, pack_index,
initial_settings);
diff --git a/gnome-panel/panel-enums.h b/gnome-panel/panel-enums.h
index ba82ead3b..1b686069a 100644
--- a/gnome-panel/panel-enums.h
+++ b/gnome-panel/panel-enums.h
@@ -31,17 +31,6 @@ G_BEGIN_DECLS
#define PANEL_HORIZONTAL_MASK (PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)
#define PANEL_VERTICAL_MASK (PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)
-typedef enum {
- PANEL_OBJECT_APPLET,
- PANEL_OBJECT_ACTION
-} PanelObjectType;
-
-typedef enum {
- PANEL_ACTION_NONE = 0,
- PANEL_ACTION_RUN,
- PANEL_ACTION_LAST
-} PanelActionButtonType;
-
G_END_DECLS
#endif /* __PANEL_ENUMS_H__ */
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index a94d4d26d..21d62299a 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -640,8 +640,7 @@ panel_layout_toplevel_create (GdkScreen *screen)
}
void
-panel_layout_object_create (PanelObjectType type,
- const char *type_detail,
+panel_layout_object_create (const char *iid,
const char *toplevel_id,
PanelObjectPackType pack_type,
int pack_index,
@@ -649,9 +648,9 @@ panel_layout_object_create (PanelObjectType type,
{
char *id;
- id = panel_layout_object_create_start (type, type_detail,
+ id = panel_layout_object_create_start (iid,
toplevel_id, pack_type, pack_index,
- initial_settings, NULL);
+ initial_settings);
if (!id)
return;
@@ -661,27 +660,6 @@ panel_layout_object_create (PanelObjectType type,
g_free (id);
}
-GSettings *
-panel_layout_get_instance_settings (GSettings *settings_object,
- const char *schema)
-{
- char *path;
- char *path_instance;
- GSettings *settings_instance;
-
- g_return_val_if_fail (G_IS_SETTINGS (settings_object), NULL);
-
- g_object_get (settings_object, "path", &path, NULL);
- path_instance = g_strdup_printf ("%s%s", path,
- PANEL_LAYOUT_OBJECT_CONFIG_SUFFIX);
- g_free (path);
-
- settings_instance = g_settings_new_with_path (schema, path_instance);
- g_free (path_instance);
-
- return settings_instance;
-}
-
static char *
panel_layout_object_generate_id (const char *iid)
{
@@ -713,24 +691,17 @@ panel_layout_object_generate_id (const char *iid)
}
char *
-panel_layout_object_create_start (PanelObjectType type,
- const char *type_detail,
+panel_layout_object_create_start (const char *iid,
const char *toplevel_id,
PanelObjectPackType pack_type,
int pack_index,
- GVariant *initial_settings,
- GSettings **settings)
+ GVariant *initial_settings)
{
char *unique_id;
char *path;
GSettings *settings_object;
- char *iid;
char *try_id;
- if (settings)
- *settings = NULL;
-
- iid = panel_object_type_to_iid (type, type_detail);
if (!iid)
return NULL;
@@ -769,12 +740,8 @@ panel_layout_object_create_start (PanelObjectType type,
}
g_free (try_id);
- g_free (iid);
- if (settings)
- *settings = settings_object;
- else
- g_object_unref (settings_object);
+ g_object_unref (settings_object);
return unique_id;
}
diff --git a/gnome-panel/panel-layout.h b/gnome-panel/panel-layout.h
index 8f9b0abcb..f751c6677 100644
--- a/gnome-panel/panel-layout.h
+++ b/gnome-panel/panel-layout.h
@@ -35,23 +35,17 @@ gboolean panel_layout_load (void);
gboolean panel_layout_is_writable (void);
void panel_layout_toplevel_create (GdkScreen *screen);
-void panel_layout_object_create (PanelObjectType type,
- const char *type_detail,
+void panel_layout_object_create (const char *iid,
const char *toplevel_id,
PanelObjectPackType pack_type,
int pack_index,
GVariant *initial_settings);
-GSettings *panel_layout_get_instance_settings (GSettings *settings_object,
- const char *schema);
-
-char *panel_layout_object_create_start (PanelObjectType type,
- const char *type_detail,
+char *panel_layout_object_create_start (const char *iid,
const char *toplevel_id,
PanelObjectPackType pack_type,
int pack_index,
- GVariant *initial_settings,
- GSettings **settings);
+ GVariant *initial_settings);
void panel_layout_object_create_finish (const char *object_id);
void panel_layout_delete_toplevel (const char *toplevel_id);
diff --git a/gnome-panel/panel-object-loader.c b/gnome-panel/panel-object-loader.c
index 5cabdd633..a7421df46 100644
--- a/gnome-panel/panel-object-loader.c
+++ b/gnome-panel/panel-object-loader.c
@@ -36,7 +36,6 @@
#include "panel-toplevel.h"
/* Includes for objects we can load */
-#include "panel-action-button.h"
#include "panel-applet-frame.h"
#include "panel-object-loader.h"
@@ -134,6 +133,18 @@ panel_object_loader_stop_loading (const char *id)
panel_object_loader_queue_initial_unhide_toplevels (NULL);
}
+static gboolean
+is_valid_iid (const char *iid)
+{
+ const char *instance_id;
+
+ instance_id = g_strrstr (iid, "::");
+ if (!instance_id)
+ return FALSE;
+
+ return TRUE;
+}
+
static gboolean
panel_object_loader_idle_handler (gpointer dummy)
{
@@ -142,9 +153,6 @@ panel_object_loader_idle_handler (gpointer dummy)
PanelWidget *panel_widget;
GSList *l;
char *iid = NULL;
- PanelObjectType object_type;
- char *object_type_detail = NULL;
- gboolean ret;
if (!panel_objects_to_load) {
panel_object_loader_have_idle = FALSE;
@@ -181,9 +189,8 @@ panel_object_loader_idle_handler (gpointer dummy)
panel_widget = panel_toplevel_get_panel_widget (toplevel);
iid = g_settings_get_string (object->settings, PANEL_OBJECT_IID_KEY);
- ret = panel_object_iid_to_type (iid, &object_type, &object_type_detail);
- if (!ret) {
+ if (!is_valid_iid (iid)) {
g_printerr ("Object '%s' has an invalid iid ('%s')\n",
object->id, iid);
panel_object_loader_stop_loading (object->id);
@@ -193,27 +200,7 @@ panel_object_loader_idle_handler (gpointer dummy)
g_free (iid);
- switch (object_type) {
- case PANEL_OBJECT_APPLET:
- panel_applet_frame_load (panel_widget,
- object->id,
- object->settings);
- break;
- case PANEL_OBJECT_ACTION:
- panel_action_button_load (panel_widget,
- object->id,
- object->settings,
- object_type_detail);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- /* We load applets asynchronously, so we specifically don't call
- * panel_object_loader_stop_loading() for this type. */
- if (object_type != PANEL_OBJECT_APPLET)
- panel_object_loader_stop_loading (object->id);
+ panel_applet_frame_load (panel_widget, object->id, object->settings);
return TRUE;
}
@@ -326,123 +313,3 @@ panel_object_loader_is_queued (const char *id)
}
return FALSE;
}
-
-
-/*******************************\
- * iid <=> object type mapping *
-\*******************************/
-
-#define PANEL_INTERNAL_FACTORY "PanelInternalFactory"
-
-static struct {
- PanelObjectType type;
- const char *id;
- gboolean has_detail;
-} panel_object_iid_map[] = {
- { PANEL_OBJECT_ACTION, "ActionButton", TRUE }
-};
-
-char *
-panel_object_type_to_iid (PanelObjectType type,
- const char *detail)
-{
- guint i;
-
- if (type == PANEL_OBJECT_APPLET)
- return g_strdup (detail);
-
- for (i = 0; i < G_N_ELEMENTS (panel_object_iid_map); i++) {
- if (panel_object_iid_map[i].type != type)
- continue;
-
- if (panel_object_iid_map[i].has_detail &&
- PANEL_GLIB_STR_EMPTY (detail))
- return NULL;
-
- if (panel_object_iid_map[i].has_detail)
- return g_strdup_printf ("%s::%s:%s",
- PANEL_INTERNAL_FACTORY,
- panel_object_iid_map[i].id,
- detail);
- else
- return g_strdup_printf ("%s::%s",
- PANEL_INTERNAL_FACTORY,
- panel_object_iid_map[i].id);
- }
-
- return NULL;
-}
-
-gboolean
-panel_object_iid_to_type (const char *iid,
- PanelObjectType *type,
- char **detail)
-{
- const char *instance_id;
- char *factory_id;
- gboolean is_applet;
- guint i;
-
- if (detail)
- *detail = NULL;
-
- instance_id = g_strrstr (iid, "::");
- if (!instance_id)
- return FALSE;
-
- factory_id = g_strndup (iid, strlen (iid) - strlen (instance_id));
- is_applet = (g_strcmp0 (factory_id, PANEL_INTERNAL_FACTORY) != 0);
- g_free (factory_id);
-
- if (is_applet) {
- *type = PANEL_OBJECT_APPLET;
- return TRUE;
- }
-
- instance_id += 2;
-
- for (i = 0; i < G_N_ELEMENTS (panel_object_iid_map); i++) {
- if (!panel_object_iid_map[i].has_detail &&
- g_strcmp0 (panel_object_iid_map[i].id,
- instance_id) == 0) {
- *type = panel_object_iid_map[i].type;
- return TRUE;
- }
-
- if (panel_object_iid_map[i].has_detail) {
- const char *d;
-
- if (!g_str_has_prefix (instance_id,
- panel_object_iid_map[i].id))
- continue;
-
- d = instance_id + strlen (panel_object_iid_map[i].id);
- if (d[0] != ':')
- return FALSE;
-
- d += 1;
- if (d[0] == '\0')
- 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;
- return TRUE;
- }
-
- *type = panel_object_iid_map[i].type;
- if (detail)
- *detail = g_strdup (d);
-
- return TRUE;
- }
- }
-
- /* We don't know this id; it could be provided by an applet now (for
- * features that moved from being internal to the panel to applets, and
- * that provide compatibility with the same id). So let's try it. */
- *type = PANEL_OBJECT_APPLET;
- return TRUE;
-}
diff --git a/gnome-panel/panel-object-loader.h b/gnome-panel/panel-object-loader.h
index 3da1e1255..9603077e0 100644
--- a/gnome-panel/panel-object-loader.h
+++ b/gnome-panel/panel-object-loader.h
@@ -35,17 +35,6 @@ void panel_object_loader_do_load (gboolean initial_load);
gboolean panel_object_loader_is_queued (const char *id);
void panel_object_loader_stop_loading (const char *id);
-/*******************************\
- * iid <=> object type mapping *
-\*******************************/
-
-char *panel_object_type_to_iid (PanelObjectType type,
- const char *detail);
-
-gboolean panel_object_iid_to_type (const char *iid,
- PanelObjectType *type,
- char **detail);
-
G_END_DECLS
#endif /* __PANEL_OBJECT_LOADER_H__ */
diff --git a/gnome-panel/panel-util.c b/gnome-panel/panel-util.c
index ebd6b6183..b9fc1eaca 100644
--- a/gnome-panel/panel-util.c
+++ b/gnome-panel/panel-util.c
@@ -179,45 +179,6 @@ panel_find_icon (GtkIconTheme *icon_theme,
return retval;
}
-GdkPixbuf *
-panel_load_icon (GtkIconTheme *icon_theme,
- const char *icon_name,
- int size,
- int desired_width,
- int desired_height,
- char **error_msg)
-{
- GdkPixbuf *retval;
- char *file;
- GError *error;
-
- g_return_val_if_fail (error_msg == NULL || *error_msg == NULL, NULL);
-
- file = panel_find_icon (icon_theme, icon_name, size);
- if (!file) {
- if (error_msg)
- *error_msg = g_strdup_printf (_("Icon '%s' not found"),
- icon_name);
-
- return NULL;
- }
-
- error = NULL;
- retval = gdk_pixbuf_new_from_file_at_size (file,
- desired_width,
- desired_height,
- &error);
- if (error) {
- if (error_msg)
- *error_msg = g_strdup (error->message);
- g_error_free (error);
- }
-
- g_free (file);
-
- return retval;
-}
-
static char *
panel_util_get_from_personal_path (const char *file)
{
@@ -802,57 +763,6 @@ panel_util_get_icon_for_uri (const char *text_uri)
return retval;
}
-static gboolean
-panel_util_query_tooltip_cb (GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_tip,
- GtkTooltip *tooltip,
- const char *text)
-{
- GSettings *gsettings;
- gboolean enable_tooltips;
-
- gsettings = g_settings_new (PANEL_GENERAL_SCHEMA);
- enable_tooltips = g_settings_get_boolean (gsettings,
- PANEL_GENERAL_ENABLE_TOOLTIPS_KEY);
- g_object_unref (gsettings);
-
- if (!enable_tooltips)
- return FALSE;
-
- gtk_tooltip_set_text (tooltip, text);
- return TRUE;
-}
-
-static void
-free_tooltip (gchar *tooltip,
- GClosure *closure)
-{
- g_free (tooltip);
-}
-
-void
-panel_util_set_tooltip_text (GtkWidget *widget,
- const char *text)
-{
- g_signal_handlers_disconnect_matched (widget,
- G_SIGNAL_MATCH_FUNC,
- 0, 0, NULL,
- panel_util_query_tooltip_cb,
- NULL);
-
- if (PANEL_GLIB_STR_EMPTY (text)) {
- g_object_set (widget, "has-tooltip", FALSE, NULL);
- return;
- }
-
- g_object_set (widget, "has-tooltip", TRUE, NULL);
- g_signal_connect_data (widget, "query-tooltip",
- G_CALLBACK (panel_util_query_tooltip_cb),
- g_strdup (text), (GClosureNotify) free_tooltip, 0);
-}
-
/* This is similar to what g_file_new_for_commandline_arg() does, but
* we end up with something relative to $HOME instead of the current working
* directory */
diff --git a/gnome-panel/panel-util.h b/gnome-panel/panel-util.h
index 910a23885..3bdf0add1 100644
--- a/gnome-panel/panel-util.h
+++ b/gnome-panel/panel-util.h
@@ -11,13 +11,6 @@ G_BEGIN_DECLS
void panel_push_window_busy (GtkWidget *window);
void panel_pop_window_busy (GtkWidget *window);
-GdkPixbuf * panel_load_icon (GtkIconTheme *icon_theme,
- const char *icon_name,
- int size,
- int desired_width,
- int desired_height,
- char **error_msg);
-
char *panel_launcher_get_filename (const char *location);
char *panel_make_full_path (const char *dir,
@@ -32,9 +25,6 @@ char *guess_icon_from_exec (GtkIconTheme *icon_theme,
char *panel_util_get_label_for_uri (const char *text_uri);
char *panel_util_get_icon_for_uri (const char *text_uri);
-void panel_util_set_tooltip_text (GtkWidget *widget,
- const char *text);
-
GFile *panel_util_get_file_optional_homedir (const char *location);
void panel_util_key_event_is_popup (GdkEventKey *event,
diff --git a/gnome-panel/panel-widget.c b/gnome-panel/panel-widget.c
index 59bde4960..d507d097a 100644
--- a/gnome-panel/panel-widget.c
+++ b/gnome-panel/panel-widget.c
@@ -15,7 +15,6 @@
#include "applet.h"
#include "panel-widget.h"
-#include "button-widget.h"
#include "panel.h"
#include "panel-bindings.h"
#include "panel-util.h"
@@ -2403,7 +2402,7 @@ panel_widget_reparent (PanelWidget *old_panel,
gtk_container_add (GTK_CONTAINER (new_panel), applet);
g_object_unref (applet);
- if (info && info->type == PANEL_OBJECT_APPLET)
+ if (info != NULL)
panel_applet_frame_set_panel (PANEL_APPLET_FRAME (ad->applet), new_panel);
if (gtk_widget_get_can_focus (GTK_WIDGET (new_panel)))
diff --git a/gnome-panel/panel-widget.h b/gnome-panel/panel-widget.h
index 2ac978a98..ef30c1f91 100644
--- a/gnome-panel/panel-widget.h
+++ b/gnome-panel/panel-widget.h
@@ -12,7 +12,6 @@
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include "button-widget.h"
#include "panel-types.h"
#include "panel-toplevel.h"
@@ -161,10 +160,6 @@ void panel_widget_set_size (PanelWidget *panel_widget,
/*draw EVERYTHING (meaning icons)*/
void panel_widget_draw_all (PanelWidget *panel,
GdkRectangle *area);
-/*draw just one icon (applet has to be an icon of course)*/
-void panel_widget_draw_icon (PanelWidget *panel,
- ButtonWidget *applet);
-
/*get pos of the cursor location in panel coordinates*/
int panel_widget_get_cursorloc (PanelWidget *panel);
diff --git a/gnome-panel/panel.c b/gnome-panel/panel.c
index 17f4b39d5..161ab570f 100644
--- a/gnome-panel/panel.c
+++ b/gnome-panel/panel.c
@@ -25,13 +25,11 @@
#include "panel.h"
#include "applet.h"
-#include "button-widget.h"
#include "panel-applets-manager.h"
#include "panel-bindings.h"
#include "panel-context-menu.h"
#include "panel-util.h"
#include "panel-applet-frame.h"
-#include "panel-action-button.h"
#include "panel-multiscreen.h"
#include "panel-toplevel.h"
#include "panel-lockdown.h"
@@ -52,7 +50,6 @@ enum {
TARGET_DIRECTORY,
TARGET_COLOR,
TARGET_APPLET,
- TARGET_APPLET_INTERNAL,
TARGET_BGIMAGE,
TARGET_BACKGROUND_RESET
};
@@ -68,17 +65,8 @@ orientation_change (AppletInfo *info,
orientation = panel_widget_get_applet_orientation (panel);
- switch (info->type) {
- case PANEL_OBJECT_APPLET:
- panel_applet_frame_change_orientation (
- PANEL_APPLET_FRAME (info->widget), orientation);
- break;
- case PANEL_OBJECT_ACTION:
- button_widget_set_orientation (BUTTON_WIDGET (info->widget), orientation);
- break;
- default:
- break;
- }
+ panel_applet_frame_change_orientation (PANEL_APPLET_FRAME (info->widget),
+ orientation);
}
static void
@@ -898,33 +886,6 @@ drop_urilist (PanelWidget *panel,
return success;
}
-static gboolean
-drop_internal_applet (PanelWidget *panel,
- PanelObjectPackType pack_type,
- int pack_index,
- const char *applet_type,
- int action)
-{
- gboolean success = FALSE;
-
- if (applet_type == NULL)
- return FALSE;
-
- if (!strncmp (applet_type, "ACTION:", strlen ("ACTION:"))) {
- if (panel_layout_is_writable ()) {
- panel_action_button_load_from_drag (panel->toplevel,
- pack_type,
- pack_index,
- applet_type);
- success = TRUE;
- } else {
- success = FALSE;
- }
- }
-
- return success;
-}
-
static GtkTargetList *
get_target_list (void)
{
@@ -935,7 +896,6 @@ get_target_list (void)
{ (gchar *) "_NETSCAPE_URL", 0, TARGET_NETSCAPE_URL },
{ (gchar *) "application/x-panel-directory", 0, TARGET_DIRECTORY },
{ (gchar *) "application/x-panel-applet-iid", 0, TARGET_APPLET },
- { (gchar *) "application/x-panel-applet-internal", 0, TARGET_APPLET_INTERNAL },
{ (gchar *) "application/x-color", 0, TARGET_COLOR },
{ (gchar *) "property/bgimage", 0, TARGET_BGIMAGE },
{ (gchar *) "x-special/gnome-reset-background", 0, TARGET_BACKGROUND_RESET },
@@ -961,8 +921,7 @@ panel_check_dnd_target_data (GtkWidget *widget,
g_return_val_if_fail (widget, FALSE);
- if (!PANEL_IS_TOPLEVEL (widget) &&
- !BUTTON_IS_WIDGET (widget))
+ if (!PANEL_IS_TOPLEVEL (widget))
return FALSE;
if (!(gdk_drag_context_get_actions (context) & (GDK_ACTION_COPY|GDK_ACTION_MOVE)))
@@ -1025,15 +984,7 @@ panel_check_drop_forbidden (PanelWidget *panel,
if (panel_lockdown_get_panels_locked_down_s ())
return FALSE;
- if (info == TARGET_APPLET_INTERNAL) {
- if (gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE)
- gdk_drag_status (context, GDK_ACTION_MOVE, time_);
- else
- gdk_drag_status (context,
- gdk_drag_context_get_suggested_action (context),
- time_);
-
- } else if (gdk_drag_context_get_actions (context) & GDK_ACTION_COPY)
+ if (gdk_drag_context_get_actions (context) & GDK_ACTION_COPY)
gdk_drag_status (context, GDK_ACTION_COPY, time_);
else
gdk_drag_status (context,
@@ -1171,11 +1122,6 @@ panel_receive_dnd_data (PanelWidget *panel,
success = FALSE;
}
break;
- case TARGET_APPLET_INTERNAL:
- success = drop_internal_applet (panel, pack_type, pack_index,
- (char *)data,
- gdk_drag_context_get_selected_action (context));
- break;
default:
gtk_drag_finish (context, FALSE, FALSE, time_);
return;
diff --git a/modules/action-button/Makefile.am b/modules/action-button/Makefile.am
index 0515c2859..00685a464 100644
--- a/modules/action-button/Makefile.am
+++ b/modules/action-button/Makefile.am
@@ -30,6 +30,8 @@ org_gnome_gnome_panel_action_button_la_SOURCES = \
gp-lock-screen-applet.h \
gp-logout-applet.c \
gp-logout-applet.h \
+ gp-run-applet.c \
+ gp-run-applet.h \
gp-shutdown-applet.c \
gp-shutdown-applet.h \
panel-force-quit.c \
diff --git a/modules/action-button/gp-action-button-module.c b/modules/action-button/gp-action-button-module.c
index cd89c14fa..ab5a64a11 100644
--- a/modules/action-button/gp-action-button-module.c
+++ b/modules/action-button/gp-action-button-module.c
@@ -23,6 +23,7 @@
#include "gp-lock-screen-applet.h"
#include "gp-force-quit-applet.h"
#include "gp-logout-applet.h"
+#include "gp-run-applet.h"
#include "gp-shutdown-applet.h"
static GpAppletInfo *
@@ -64,6 +65,15 @@ action_button_get_applet_info (const char *id)
is_disabled_func = gp_logout_applet_is_disabled;
}
+ else if (g_strcmp0 (id, "run") == 0)
+ {
+ type_func = gp_run_applet_get_type;
+ name = _("Run Application...");
+ description = _("Run an application by typing a command or choosing from a list");
+ icon = "system-run";
+
+ is_disabled_func = gp_run_applet_is_disabled;
+ }
else if (g_strcmp0 (id, "shutdown") == 0)
{
type_func = gp_shutdown_applet_get_type;
@@ -96,6 +106,8 @@ action_button_get_applet_id_from_iid (const char *iid)
return "lock-screen";
else if (g_strcmp0 (iid, "PanelInternalFactory::ActionButton:logout") == 0)
return "logout";
+ else if (g_strcmp0 (iid, "PanelInternalFactory::ActionButton:run") == 0)
+ return "run";
else if (g_strcmp0 (iid, "PanelInternalFactory::ActionButton:shutdown") == 0)
return "shutdown";
@@ -118,6 +130,7 @@ gp_module_load (GpModule *module)
"force-quit",
"lock-screen",
"logout",
+ "run",
"shutdown",
NULL);
diff --git a/modules/action-button/gp-run-applet.c b/modules/action-button/gp-run-applet.c
new file mode 100644
index 000000000..771e350a4
--- /dev/null
+++ b/modules/action-button/gp-run-applet.c
@@ -0,0 +1,141 @@
+/*
+ * 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-run-applet.h"
+
+#include <glib/gi18n-lib.h>
+
+struct _GpRunApplet
+{
+ GpActionButtonApplet parent;
+};
+
+G_DEFINE_TYPE (GpRunApplet, gp_run_applet, GP_TYPE_ACTION_BUTTON_APPLET)
+
+static void
+lockdown_changed (GpRunApplet *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_COMMAND_LINE) == GP_LOCKDOWN_FLAGS_COMMAND_LINE)
+ applet_sensitive = FALSE;
+
+ gtk_widget_set_sensitive (GTK_WIDGET (self), applet_sensitive);
+}
+
+static void
+lockdowns_cb (GpApplet *applet,
+ GParamSpec *pspec,
+ GpRunApplet *self)
+{
+ lockdown_changed (self);
+}
+
+static void
+setup_applet (GpRunApplet *self)
+{
+ const char *text;
+ AtkObject *atk;
+
+ gp_action_button_applet_set_icon_name (GP_ACTION_BUTTON_APPLET (self),
+ "system-run");
+
+ text = _("Run an application by typing a command or choosing from a list");
+
+ 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_run_applet_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (gp_run_applet_parent_class)->constructed (object);
+ setup_applet (GP_RUN_APPLET (object));
+}
+
+static void
+gp_run_applet_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (gp_run_applet_parent_class)->dispose (object);
+}
+
+extern void panel_run_dialog_present (GdkScreen *screen,
+ guint32 activate_time);
+
+static void
+gp_run_applet_clicked (GpActionButtonApplet *applet)
+{
+ panel_run_dialog_present (gtk_widget_get_screen (GTK_WIDGET (applet)),
+ gtk_get_current_event_time ());
+}
+
+static void
+gp_run_applet_class_init (GpRunAppletClass *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_run_applet_constructed;
+ object_class->dispose = gp_run_applet_dispose;
+
+ action_button_applet_class->clicked = gp_run_applet_clicked;
+}
+
+static void
+gp_run_applet_init (GpRunApplet *self)
+{
+ g_signal_connect (self,
+ "notify::lockdowns",
+ G_CALLBACK (lockdowns_cb),
+ self);
+}
+
+gboolean
+gp_run_applet_is_disabled (GpLockdownFlags flags,
+ char **reason)
+{
+ if ((flags & GP_LOCKDOWN_FLAGS_COMMAND_LINE) != GP_LOCKDOWN_FLAGS_COMMAND_LINE)
+ return FALSE;
+
+ if (reason != NULL)
+ *reason = g_strdup (_("Disabled because “disable-command-line” setting in "
+ "“org.gnome.desktop.lockdown” GSettings schema is "
+ "set to true."));
+
+ return TRUE;
+}
diff --git a/modules/action-button/gp-run-applet.h b/modules/action-button/gp-run-applet.h
new file mode 100644
index 000000000..c2d2656d5
--- /dev/null
+++ b/modules/action-button/gp-run-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_RUN_APPLET_H
+#define GP_RUN_APPLET_H
+
+#include "gp-action-button-applet.h"
+
+G_BEGIN_DECLS
+
+#define GP_TYPE_RUN_APPLET (gp_run_applet_get_type ())
+G_DECLARE_FINAL_TYPE (GpRunApplet, gp_run_applet,
+ GP, RUN_APPLET, GpActionButtonApplet)
+
+gboolean gp_run_applet_is_disabled (GpLockdownFlags flags,
+ char **reason);
+
+G_END_DECLS
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6cfe210d7..ef2f3590a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,7 +7,6 @@ data/org.gnome.gnome-panel.applet.workspace-switcher.gschema.xml
data/org.gnome.gnome-panel.gschema.xml
data/org.gnome.gnome-panel.object.gschema.xml
data/org.gnome.gnome-panel.toplevel.gschema.xml
-gnome-panel/button-widget.c
gnome-panel/gnome-panel.desktop.in
gnome-panel/gp-add-applet-window.c
gnome-panel/gp-arrow-button.c
@@ -16,7 +15,6 @@ gnome-panel/gp-properties-dialog.c
gnome-panel/gp-properties-dialog.ui
gnome-panel/libpanel-util/panel-error.c
gnome-panel/libpanel-util/panel-show.c
-gnome-panel/panel-action-button.c
gnome-panel/panel-addto-dialog.c
gnome-panel/panel-addto-dialog.ui
gnome-panel/panel-applet-frame.c
@@ -35,6 +33,7 @@ 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-run-applet.c
modules/action-button/gp-shutdown-applet.c
modules/action-button/panel-force-quit.c
modules/clock/calendar-client.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]