summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbalping <[email protected]>2021-09-02 23:16:53 +0100
committerraveit65 <[email protected]>2021-11-09 22:37:23 +0100
commitcc64eec85368a1e60f3e2646b353fecc43a5b9e6 (patch)
tree2a7b5aaa463c05e220c027954a8e990cbc9abcb8
parent8bbb321aba5791b07fca5455f18cc61c0c13b464 (diff)
downloadmate-applets-cc64eec85368a1e60f3e2646b353fecc43a5b9e6.tar.bz2
mate-applets-cc64eec85368a1e60f3e2646b353fecc43a5b9e6.tar.xz
Charpick-applet: use GtkInvisible widget
Fixed #372 by applying following patches by Alberts Muktupāvels: * https://gitlab.gnome.org/GNOME/gnome-applets/-/commit/36f313d880aef4df2925a1fce585fa820429d4fd * https://gitlab.gnome.org/GNOME/gnome-applets/-/commit/19c7ccdc26094988c979fa2ee9ace315acfa9f5e
-rw-r--r--charpick/charpick.c52
-rw-r--r--charpick/charpick.h2
2 files changed, 47 insertions, 7 deletions
diff --git a/charpick/charpick.c b/charpick/charpick.c
index 6f03e6b6..acc4a408 100644
--- a/charpick/charpick.c
+++ b/charpick/charpick.c
@@ -169,10 +169,10 @@ toggle_button_toggled_cb (GtkToggleButton *button,
unichar = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "unichar"));
curr_data->selected_unichar = unichar;
/* set this? widget as the selection owner */
- gtk_selection_owner_set (curr_data->applet,
+ gtk_selection_owner_set (curr_data->invisible,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
- gtk_selection_owner_set (curr_data->applet,
+ gtk_selection_owner_set (curr_data->invisible,
GDK_SELECTION_CLIPBOARD,
GDK_CURRENT_TIME);
curr_data->last_index = button_index;
@@ -547,6 +547,31 @@ build_table (charpick_data *p_curr_data)
p_curr_data->last_toggle_button = NULL;
}
+static gboolean
+rebuild_cb (gpointer user_data)
+{
+ charpick_data *curr_data;
+
+ curr_data = user_data;
+ curr_data->rebuild_id = 0;
+
+ build_table (curr_data);
+
+ return G_SOURCE_REMOVE;
+}
+
+static void
+queue_rebuild (charpick_data *curr_data)
+{
+ if (curr_data->rebuild_id != 0)
+ return;
+
+ curr_data->rebuild_id = g_idle_add (rebuild_cb, curr_data);
+ g_source_set_name_by_id (curr_data->rebuild_id, "[charpick] rebuild_cb");
+}
+
+
+
static void
applet_size_allocate (MatePanelApplet *applet,
GtkAllocation *allocation,
@@ -563,7 +588,7 @@ applet_size_allocate (MatePanelApplet *applet,
curr_data->panel_size = allocation->height;
}
- build_table (curr_data);
+ queue_rebuild (curr_data);
return;
}
@@ -647,6 +672,12 @@ applet_destroy (GtkWidget *widget,
g_return_if_fail (curr_data);
+ if (curr_data->rebuild_id != 0)
+ {
+ g_source_remove (curr_data->rebuild_id);
+ curr_data->rebuild_id = 0;
+ }
+
if (curr_data->about_dialog)
gtk_widget_destroy (curr_data->about_dialog);
if (curr_data->propwindow)
@@ -655,6 +686,8 @@ applet_destroy (GtkWidget *widget,
gtk_widget_destroy (curr_data->box);
if (curr_data->menu)
gtk_widget_destroy (curr_data->menu);
+ if (curr_data->invisible)
+ gtk_widget_destroy (curr_data->invisible);
g_free (curr_data->charlist);
g_free (curr_data);
}
@@ -729,6 +762,7 @@ charpicker_applet_fill (MatePanelApplet *applet)
{
MatePanelAppletOrient orientation;
charpick_data *curr_data;
+ GdkScreen *screen;
GdkAtom utf8_atom;
gchar *string;
GtkActionGroup *action_group;
@@ -746,6 +780,7 @@ charpicker_applet_fill (MatePanelApplet *applet)
curr_data->add_edit_dialog = NULL;
curr_data->settings = mate_panel_applet_settings_new (applet,
"org.mate.panel.applet.charpick");
+ curr_data->rebuild_id = 0;
get_chartable (curr_data);
@@ -769,19 +804,22 @@ charpicker_applet_fill (MatePanelApplet *applet)
utf8_atom = gdk_atom_intern ("UTF8_STRING", FALSE);
- gtk_selection_add_target (curr_data->applet,
+ screen = gtk_widget_get_screen (GTK_WIDGET (applet));
+ curr_data->invisible = gtk_invisible_new_for_screen (screen);
+
+ gtk_selection_add_target (curr_data->invisible,
GDK_SELECTION_PRIMARY,
utf8_atom, 0);
- gtk_selection_add_target (curr_data->applet,
+ gtk_selection_add_target (curr_data->invisible,
GDK_SELECTION_CLIPBOARD,
utf8_atom, 0);
- g_signal_connect (curr_data->applet, "selection_get",
+ g_signal_connect (curr_data->invisible, "selection_get",
G_CALLBACK (charpick_selection_handler),
curr_data);
- g_signal_connect (curr_data->applet, "selection_clear_event",
+ g_signal_connect (curr_data->invisible, "selection_clear_event",
G_CALLBACK (selection_clear_cb),
curr_data);
diff --git a/charpick/charpick.h b/charpick/charpick.h
index 7a70ef5b..713685c2 100644
--- a/charpick/charpick.h
+++ b/charpick/charpick.h
@@ -22,6 +22,7 @@ struct _charpick_data {
GtkWidget *box;
GtkWidget *frame;
GtkWidget *applet;
+ GtkWidget *invisible;
GtkToggleButton *last_toggle_button;
gint panel_size;
gboolean panel_vertical;
@@ -32,6 +33,7 @@ struct _charpick_data {
GtkWidget *add_edit_dialog;
GtkWidget *add_edit_entry;
GSettings *settings;
+ guint rebuild_id;
};
typedef struct _charpick_button_cb_data charpick_button_cb_data;