Commit c83ab242 authored by Matthias Clasen's avatar Matthias Clasen

Remove GtkShortcutsGesture

The gesture functionality was taken over by GtkShortcutsShortcut,
so this widget is no longer needed, and it never was in a stable
release, so lets get rid of it.
parent 830b6f10
......@@ -8538,17 +8538,3 @@ GTK_GET_SHORTCUTS_SHORTCUT_CLASS
GtkShortcutsShortcutClass
gtk_shortcuts_shortcut_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcutsgesture</FILE>
GtkShortcutsGesture
<SUBSECTION Standard>
GTK_TYPE_SHORTCUTS_GESTURE
GTK_SHORTCUTS_GESTURE
GTK_IS_SHORTCUTS_GESTURE
GTK_SHORTCUTS_GESTURE_CLASS
GTK_IS_SHORTCUTS_GESTURE_CLASS
GTK_GET_SHORTCUTS_GESTURE_CLASS
<SUBSECTION Private>
gtk_shortcuts_gesture_get_type
</SECTION>
......@@ -177,7 +177,6 @@ gtk_shortcuts_window_get_type
gtk_shortcuts_section_get_type
gtk_shortcuts_group_get_type
gtk_shortcuts_shortcut_get_type
gtk_shortcuts_gesture_get_type
gtk_size_group_get_type
@ENABLE_ON_X11@gtk_socket_get_type
gtk_spin_button_get_type
......
......@@ -272,7 +272,6 @@ gtk_public_h_sources = \
gtkseparatormenuitem.h \
gtkseparatortoolitem.h \
gtksettings.h \
gtkshortcutsgesture.h \
gtkshortcutsgroup.h \
gtkshortcutssection.h \
gtkshortcutsshortcut.h \
......@@ -827,7 +826,6 @@ gtk_base_c_sources = \
gtkseparatormenuitem.c \
gtkseparatortoolitem.c \
gtksettings.c \
gtkshortcutsgesture.c \
gtkshortcutsgroup.c \
gtkshortcutlabel.c \
gtkshortcutsshortcut.c \
......
......@@ -186,7 +186,6 @@
#include <gtk/gtkseparatormenuitem.h>
#include <gtk/gtkseparatortoolitem.h>
#include <gtk/gtksettings.h>
#include <gtk/gtkshortcutsgesture.h>
#include <gtk/gtkshortcutsgroup.h>
#include <gtk/gtkshortcutssection.h>
#include <gtk/gtkshortcutsshortcut.h>
......
/* gtkshortcutsgesture.c
*
* Copyright (C) 2015 Christian Hergert <christian@hergert.me>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkshortcutsgesture.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtksizegroup.h"
#include "gtkorientable.h"
#include "gtkstylecontext.h"
#include "gtkprivate.h"
#include "gtkintl.h"
/**
* SECTION:gtkshortcutsgesture
* @Title: GtkShortcutsGesture
* @Short_description: Represents a gesture in a GtkShortcutsWindow
*
* A GtkShortcutsGesture represents a single gesture with an image
* an a short text.
*
* This widget is only meant to be used with #GtkShortcutsWindow.
*/
struct _GtkShortcutsGesture
{
GtkBox parent_instance;
GtkImage *image;
GtkLabel *title;
GtkLabel *subtitle;
GtkBox *title_box;
GtkSizeGroup *title_size_group;
GtkSizeGroup *icon_size_group;
};
struct _GtkShortcutsGestureClass
{
GtkBoxClass parent_class;
};
G_DEFINE_TYPE (GtkShortcutsGesture, gtk_shortcuts_gesture, GTK_TYPE_BOX)
enum {
PROP_0,
PROP_ICON,
PROP_TITLE,
PROP_SUBTITLE,
PROP_ICON_SIZE_GROUP,
PROP_TITLE_SIZE_GROUP,
LAST_PROP
};
static GParamSpec *properties[LAST_PROP];
static void
gtk_shortcuts_gesture_set_title_size_group (GtkShortcutsGesture *self,
GtkSizeGroup *group)
{
if (self->title_size_group)
gtk_size_group_remove_widget (self->title_size_group, GTK_WIDGET (self->title_box));
if (group)
gtk_size_group_add_widget (group, GTK_WIDGET (self->title_box));
g_set_object (&self->title_size_group, group);
}
static void
gtk_shortcuts_gesture_set_icon_size_group (GtkShortcutsGesture *self,
GtkSizeGroup *group)
{
if (self->icon_size_group)
gtk_size_group_remove_widget (self->icon_size_group, GTK_WIDGET (self->image));
if (group)
gtk_size_group_add_widget (group, GTK_WIDGET (self->image));
g_set_object (&self->icon_size_group, group);
}
static void
gtk_shortcuts_gesture_set_icon (GtkShortcutsGesture *self,
GIcon *gicon)
{
gtk_image_set_from_gicon (self->image, gicon, GTK_ICON_SIZE_DIALOG);
}
static void
gtk_shortcuts_gesture_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkShortcutsGesture *self = GTK_SHORTCUTS_GESTURE (object);
switch (prop_id)
{
case PROP_ICON:
{
GIcon *icon;
gtk_image_get_gicon (self->image, &icon, NULL);
g_value_set_object (value, icon);
}
break;
case PROP_TITLE:
g_value_set_string (value, gtk_label_get_label (self->title));
break;
case PROP_SUBTITLE:
g_value_set_string (value, gtk_label_get_label (self->subtitle));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gtk_shortcuts_gesture_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkShortcutsGesture *self = GTK_SHORTCUTS_GESTURE (object);
switch (prop_id)
{
case PROP_ICON:
gtk_shortcuts_gesture_set_icon (self, g_value_get_object (value));
break;
case PROP_TITLE:
gtk_label_set_label (self->title, g_value_get_string (value));
break;
case PROP_SUBTITLE:
gtk_label_set_label (self->subtitle, g_value_get_string (value));
break;
case PROP_TITLE_SIZE_GROUP:
gtk_shortcuts_gesture_set_title_size_group (self, GTK_SIZE_GROUP (g_value_get_object (value)));
break;
case PROP_ICON_SIZE_GROUP:
gtk_shortcuts_gesture_set_icon_size_group (self, GTK_SIZE_GROUP (g_value_get_object (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gtk_shortcuts_gesture_finalize (GObject *object)
{
GtkShortcutsGesture *self = GTK_SHORTCUTS_GESTURE (object);
g_clear_object (&self->title_size_group);
g_clear_object (&self->icon_size_group);
G_OBJECT_CLASS (gtk_shortcuts_gesture_parent_class)->finalize (object);
}
static void
gtk_shortcuts_gesture_add (GtkContainer *container,
GtkWidget *widget)
{
g_warning ("Can't add children to %s", G_OBJECT_TYPE_NAME (container));
}
static GType
gtk_shortcuts_gesture_child_type (GtkContainer *container)
{
return G_TYPE_NONE;
}
static void
gtk_shortcuts_gesture_class_init (GtkShortcutsGestureClass *klass)
{
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_shortcuts_gesture_finalize;
object_class->get_property = gtk_shortcuts_gesture_get_property;
object_class->set_property = gtk_shortcuts_gesture_set_property;
container_class->add = gtk_shortcuts_gesture_add;
container_class->child_type = gtk_shortcuts_gesture_child_type;
/**
* GtkShortcutsGesture:icon:
*
* The icon used to represent the gesture.
*/
properties[PROP_ICON] =
g_param_spec_object ("icon",
P_("Icon"),
P_("Icon"),
G_TYPE_ICON,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GtkShortcutsGesture:title:
*
* The title for the gesture.
*
* This should be a short, one-line text that describes the action
* associated with the gesture.
*/
properties[PROP_TITLE] =
g_param_spec_string ("title",
P_("Title"),
P_("Title"),
"",
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GtkShortcutsGesture:subtitle:
*
* The subtitle for the gesture.
*
* This should be a short, one-line text that describes the gesture
* itself, e.g. "Two-finger swipe".
*/
properties[PROP_SUBTITLE] =
g_param_spec_string ("subtitle",
P_("Subtitle"),
P_("Subtitle"),
"",
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GtkShortcutsGesture:title-size-group:
*
* The size group for the textual portion of this gesture.
*
* This is used internally by GTK+, and must not be modified by applications.
*/
properties[PROP_TITLE_SIZE_GROUP] =
g_param_spec_object ("title-size-group",
P_("Title Size Group"),
P_("Title Size Group"),
GTK_TYPE_SIZE_GROUP,
(G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
/**
* GtkShortcutsShortcut:icon-size-group:
*
* The size group for the image portion of this gesture.
*
* This is used internally by GTK+, and must not be modified by applications.
*/
properties[PROP_ICON_SIZE_GROUP] =
g_param_spec_object ("icon-size-group",
P_("Icon Size Group"),
P_("Icon Size Group"),
GTK_TYPE_SIZE_GROUP,
(G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, LAST_PROP, properties);
}
static void
gtk_shortcuts_gesture_init (GtkShortcutsGesture *self)
{
gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL);
gtk_box_set_spacing (GTK_BOX (self), 12);
self->image = g_object_new (GTK_TYPE_IMAGE,
"visible", TRUE,
NULL);
GTK_CONTAINER_CLASS (gtk_shortcuts_gesture_parent_class)->add (GTK_CONTAINER (self), GTK_WIDGET (self->image));
self->title_box = g_object_new (GTK_TYPE_BOX,
"hexpand", TRUE,
"orientation", GTK_ORIENTATION_VERTICAL,
"visible", TRUE,
NULL);
GTK_CONTAINER_CLASS (gtk_shortcuts_gesture_parent_class)->add (GTK_CONTAINER (self), GTK_WIDGET (self->title_box));
self->title = g_object_new (GTK_TYPE_LABEL,
"visible", TRUE,
"xalign", 0.0f,
NULL);
gtk_container_add (GTK_CONTAINER (self->title_box), GTK_WIDGET (self->title));
self->subtitle = g_object_new (GTK_TYPE_LABEL,
"visible", TRUE,
"xalign", 0.0f,
NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self->subtitle)),
"dim-label");
gtk_container_add (GTK_CONTAINER (self->title_box), GTK_WIDGET (self->subtitle));
}
/* gtkshortcutsgestureprivate.h
*
* Copyright (C) 2015 Christian Hergert <christian@hergert.me>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_SHORTCUTS_GESTURE_H__
#define __GTK_SHORTCUTS_GESTURE_H__
#include <gtk/gtkbox.h>
G_BEGIN_DECLS
#define GTK_TYPE_SHORTCUTS_GESTURE (gtk_shortcuts_gesture_get_type())
#define GTK_SHORTCUTS_GESTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SHORTCUTS_GESTURE, GtkShortcutsGesture))
#define GTK_SHORTCUTS_GESTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SHORTCUTS_GESTURE, GtkShortcutsGestureClass))
#define GTK_IS_SHORTCUTS_GESTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SHORTCUTS_GESTURE))
#define GTK_IS_SHORTCUTS_GESTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SHORTCUTS_GESTURE))
#define GTK_SHORTCUTS_GESTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SHORTCUTS_GESTURE, GtkShortcutsGestureClass))
typedef struct _GtkShortcutsGesture GtkShortcutsGesture;
typedef struct _GtkShortcutsGestureClass GtkShortcutsGestureClass;
GDK_AVAILABLE_IN_3_20
GType gtk_shortcuts_gesture_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GTK_SHORTCUTS_GESTURE_H__ */
......@@ -21,7 +21,6 @@
#include "gtkshortcutsgroup.h"
#include "gtkshortcutsshortcut.h"
#include "gtkshortcutsgesture.h"
#include "gtklabel.h"
#include "gtkorientable.h"
#include "gtksizegroup.h"
......@@ -78,8 +77,6 @@ gtk_shortcuts_group_apply_accel_size_group (GtkShortcutsGroup *group,
{
if (GTK_IS_SHORTCUTS_SHORTCUT (child))
g_object_set (child, "accel-size-group", group->accel_size_group, NULL);
else if (GTK_IS_SHORTCUTS_GESTURE (child))
g_object_set (child, "icon-size-group", group->accel_size_group, NULL);
}
static void
......@@ -88,8 +85,6 @@ gtk_shortcuts_group_apply_title_size_group (GtkShortcutsGroup *group,
{
if (GTK_IS_SHORTCUTS_SHORTCUT (child))
g_object_set (child, "title-size-group", group->title_size_group, NULL);
else if (GTK_IS_SHORTCUTS_GESTURE (child))
g_object_set (child, "title-size-group", group->title_size_group, NULL);
}
static void
......@@ -137,8 +132,6 @@ gtk_shortcuts_group_get_height (GtkShortcutsGroup *group)
continue;
else if (GTK_IS_SHORTCUTS_SHORTCUT (child))
height += 1;
else if (GTK_IS_SHORTCUTS_GESTURE (child))
height += 2;
}
g_list_free (children);
......@@ -149,8 +142,7 @@ static void
gtk_shortcuts_group_add (GtkContainer *container,
GtkWidget *widget)
{
if (GTK_IS_SHORTCUTS_SHORTCUT (widget) ||
GTK_IS_SHORTCUTS_GESTURE (widget))
if (GTK_IS_SHORTCUTS_SHORTCUT (widget))
{
GTK_CONTAINER_CLASS (gtk_shortcuts_group_parent_class)->add (container, widget);
gtk_shortcuts_group_apply_accel_size_group (GTK_SHORTCUTS_GROUP (container), widget);
......
......@@ -22,7 +22,6 @@
#include "gtkscrolledwindow.h"
#include "gtkshortcutssection.h"
#include "gtkshortcutsgroup.h"
#include "gtkshortcutsgesture.h"
#include "gtkshortcutsshortcut.h"
#include "gtksearchbar.h"
#include "gtksearchentry.h"
......@@ -180,11 +179,9 @@ gtk_shortcuts_window_add_search_item (GtkWidget *child, gpointer data)
GtkShortcutsWindow *self = data;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
GtkWidget *item;
gchar *subtitle = NULL;
gchar *accelerator = NULL;
gchar *title = NULL;
gchar *hash_key = NULL;
GIcon *icon = NULL;
GtkTextDirection direction;
gchar *str;
gchar *keywords;
......@@ -226,45 +223,6 @@ gtk_shortcuts_window_add_search_item (GtkWidget *child, gpointer data)
g_free (accelerator);
g_free (str);
}
else if (GTK_IS_SHORTCUTS_GESTURE (child))
{
g_object_get (child,
"title", &title,
"subtitle", &subtitle,
"icon", &icon,
NULL);
hash_key = g_strdup_printf ("%s-%s", title, subtitle);
if (g_hash_table_contains (priv->search_items_hash, hash_key))
{
g_free (subtitle);
g_free (title);
g_free (hash_key);
g_clear_object (&icon);
return;
}
g_hash_table_insert (priv->search_items_hash, hash_key, GINT_TO_POINTER (1));
item = g_object_new (GTK_TYPE_SHORTCUTS_GESTURE,
"title", title,
"subtitle", subtitle,
"icon", icon,
"icon-size-group", priv->search_image_group,
"title-size-group", priv->search_text_group,
NULL);
str = g_strdup_printf ("%s %s", title, subtitle);
keywords = g_utf8_strdown (str, -1);
g_hash_table_insert (priv->keywords, item, keywords);
gtk_container_add (GTK_CONTAINER (priv->search_gestures), item);
g_free (subtitle);
g_free (title);
g_clear_object (&icon);
g_free (str);
}
else if (GTK_IS_CONTAINER (child))
{
gtk_container_foreach (GTK_CONTAINER (child), gtk_shortcuts_window_add_search_item, self);
......@@ -782,8 +740,6 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass)
gtk_binding_entry_add_signal (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, "search", 0);
g_type_ensure (GTK_TYPE_SHORTCUTS_GROUP);
g_type_ensure (GTK_TYPE_SHORTCUTS_GROUP);
g_type_ensure (GTK_TYPE_SHORTCUTS_GESTURE);
g_type_ensure (GTK_TYPE_SHORTCUTS_SHORTCUT);
}
......
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