Commit ce19f5a2 authored by Matthias Clasen's avatar Matthias Clasen

color editor: Avoid popup-menu use

parent b0505729
......@@ -188,16 +188,18 @@ dismiss_current_popup (GtkColorEditor *editor)
}
}
static void
popup_edit (GtkWidget *widget,
GtkColorEditor *editor)
void
gtk_color_editor_popup_menu (GtkWidget *widget)
{
GtkColorEditor *editor;
GtkWidget *popup = NULL;
GtkRoot *root;
GtkWidget *focus;
gint position;
gint s, e;
editor = GTK_COLOR_EDITOR (gtk_widget_get_ancestor (widget, GTK_TYPE_COLOR_EDITOR));
if (widget == editor->priv->sv_plane)
{
popup = editor->priv->sv_popup;
......@@ -546,7 +548,6 @@ gtk_color_editor_class_init (GtkColorEditorClass *class)
gtk_widget_class_bind_template_callback (widget_class, entry_text_changed);
gtk_widget_class_bind_template_callback (widget_class, entry_apply);
gtk_widget_class_bind_template_callback (widget_class, entry_focus_changed);
gtk_widget_class_bind_template_callback (widget_class, popup_edit);
gtk_widget_class_bind_template_callback (widget_class, pick_color);
}
......
......@@ -56,6 +56,8 @@ struct _GtkColorEditorClass
GType gtk_color_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gtk_color_editor_new (void);
void gtk_color_editor_popup_menu (GtkWidget *control);
G_END_DECLS
#endif /* __GTK_COLOR_EDITOR_H__ */
......@@ -28,6 +28,7 @@
#include "gtksnapshot.h"
#include "gtkprivate.h"
#include "gtkeventcontrollerkey.h"
#include "gtkcoloreditorprivate.h"
struct _GtkColorPlanePrivate
{
......@@ -244,11 +245,18 @@ static void
hold_action (GtkGestureLongPress *gesture,
gdouble x,
gdouble y,
GtkColorPlane *plane)
GtkWidget *plane)
{
gboolean handled;
gtk_color_editor_popup_menu (plane);
}
g_signal_emit_by_name (plane, "popup-menu", &handled);
static gboolean
popup_menu (GtkWidget *widget,
GVariant *args,
gpointer user_data)
{
gtk_color_editor_popup_menu (widget);
return TRUE;
}
static void
......@@ -530,6 +538,13 @@ gtk_color_plane_class_init (GtkColorPlaneClass *class)
GTK_TYPE_ADJUSTMENT,
GTK_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
gtk_widget_class_add_binding (GTK_WIDGET_CLASS (class),
GDK_KEY_F10, GDK_SHIFT_MASK,
popup_menu, NULL);
gtk_widget_class_add_binding (GTK_WIDGET_CLASS (class),
GDK_KEY_Menu, 0,
popup_menu, NULL);
}
GtkWidget *
......
......@@ -29,6 +29,7 @@
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtksnapshot.h"
#include "gtkcoloreditorprivate.h"
#include <math.h>
......@@ -48,7 +49,7 @@ enum
static void hold_action (GtkGestureLongPress *gesture,
gdouble x,
gdouble y,
GtkColorScale *scale);
GtkWidget *scale);
G_DEFINE_TYPE_WITH_PRIVATE (GtkColorScale, gtk_color_scale, GTK_TYPE_SCALE)
......@@ -250,11 +251,18 @@ static void
hold_action (GtkGestureLongPress *gesture,
gdouble x,
gdouble y,
GtkColorScale *scale)
GtkWidget *scale)
{
gboolean handled;
gtk_color_editor_popup_menu (scale);
}
g_signal_emit_by_name (scale, "popup-menu", &handled);
static gboolean
popup_menu (GtkWidget *widget,
GVariant *args,
gpointer user_data)
{
gtk_color_editor_popup_menu (widget);
return TRUE;
}
static void
......@@ -280,6 +288,13 @@ gtk_color_scale_class_init (GtkColorScaleClass *class)
g_param_spec_int ("scale-type", P_("Scale type"), P_("Scale type"),
0, 1, 0,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
gtk_widget_class_add_binding (GTK_WIDGET_CLASS (class),
GDK_KEY_F10, GDK_SHIFT_MASK,
popup_menu, NULL);
gtk_widget_class_add_binding (GTK_WIDGET_CLASS (class),
GDK_KEY_Menu, 0,
popup_menu, NULL);
}
void
......
......@@ -88,7 +88,6 @@
<property name="adjustment">h_adj</property>
<property name="draw-value">False</property>
<property name="has-origin">False</property>
<signal name="popup-menu" handler="popup_edit" swapped="no"/>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
......@@ -105,7 +104,6 @@
<style>
<class name="marks-before"/>
</style>
<signal name="popup-menu" handler="popup_edit" swapped="no"/>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
......@@ -121,7 +119,6 @@
<property name="h-adjustment">h_adj</property>
<property name="s-adjustment">s_adj</property>
<property name="v-adjustment">v_adj</property>
<signal name="popup-menu" handler="popup_edit" swapped="no"/>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment