* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkorientable.h"
#include "gtkstylecontext.h"
#include "gtkaccessible.h"
+#include "gtkpressandholdprivate.h"
#include "gtkprivate.h"
#include "gtkintl.h"
gint width, height;
GdkRGBA color;
GtkColorScaleType type;
+
+ GtkPressAndHold *press_and_hold;
};
enum
scale->priv = G_TYPE_INSTANCE_GET_PRIVATE (scale,
GTK_TYPE_COLOR_SCALE,
GtkColorScalePrivate);
+ gtk_widget_add_events (GTK_WIDGET (scale), GDK_TOUCH_MASK);
}
static void
if (scale->priv->surface)
cairo_surface_destroy (scale->priv->surface);
+ g_clear_object (&scale->priv->press_and_hold);
+
G_OBJECT_CLASS (gtk_color_scale_parent_class)->finalize (object);
}
}
}
+static void
+hold_action (GtkPressAndHold *pah,
+ gint x,
+ gint y,
+ GtkColorScale *scale)
+{
+ gboolean handled;
+
+ g_signal_emit_by_name (scale, "popup-menu", &handled);
+}
+
+static gboolean
+scale_touch (GtkWidget *widget,
+ GdkEventTouch *event)
+{
+ GtkColorScale *scale = GTK_COLOR_SCALE (widget);
+
+ if (!scale->priv->press_and_hold)
+ {
+ gint drag_threshold;
+
+ g_object_get (gtk_widget_get_settings (widget),
+ "gtk-dnd-drag-threshold", &drag_threshold,
+ NULL);
+
+ scale->priv->press_and_hold = gtk_press_and_hold_new ();
+
+ g_object_set (scale->priv->press_and_hold,
+ "drag-threshold", drag_threshold,
+ "hold-time", 1000,
+ NULL);
+
+ g_signal_connect (scale->priv->press_and_hold, "hold",
+ G_CALLBACK (hold_action), scale);
+ }
+
+ gtk_press_and_hold_process_event (scale->priv->press_and_hold, (GdkEvent *)event);
+
+ return GTK_WIDGET_CLASS (gtk_color_scale_parent_class)->touch_event (widget, event);
+}
+
+
static void
gtk_color_scale_class_init (GtkColorScaleClass *class)
{
object_class->set_property = scale_set_property;
widget_class->draw = scale_draw;
+ widget_class->touch_event = scale_touch;
g_object_class_install_property (object_class, PROP_SCALE_TYPE,
g_param_spec_int ("scale-type", P_("Scale type"), P_("Scale type"),