[gtk+] button: Remove GtkStock API
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] button: Remove GtkStock API
- Date: Sun, 16 Oct 2016 16:30:53 +0000 (UTC)
commit 590cd6a9f2df789839429c1bd77f84d23c074047
Author: Timm Bäder <mail baedert org>
Date: Sun Oct 2 19:03:29 2016 +0200
button: Remove GtkStock API
gtk/gtkbutton.c | 183 +++-----------------------------------------------
gtk/gtkbutton.h | 7 --
tests/testbuttons.c | 18 -----
tests/testflowbox.c | 36 +----------
tests/testgtk.c | 8 +--
5 files changed, 15 insertions(+), 237 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 89a2b5d..2246cf8 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -62,7 +62,6 @@
#include "gtkmarshalers.h"
#include "gtkimage.h"
#include "gtkbox.h"
-#include "deprecated/gtkstock.h"
#include "deprecated/gtkactivatable.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
@@ -97,7 +96,6 @@ enum {
PROP_IMAGE,
PROP_RELIEF,
PROP_USE_UNDERLINE,
- PROP_USE_STOCK,
PROP_IMAGE_POSITION,
PROP_ALWAYS_SHOW_IMAGE,
@@ -272,26 +270,14 @@ gtk_button_class_init (GtkButtonClass *klass)
P_("Text of the label widget inside the button, if the button contains a label
widget"),
NULL,
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY);
-
+
props[PROP_USE_UNDERLINE] =
g_param_spec_boolean ("use-underline",
P_("Use underline"),
P_("If set, an underline in the text indicates the next character should be used
for the mnemonic accelerator key"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY);
-
- /**
- * GtkButton:use-stock:
- *
- * Deprecated: 3.10
- */
- props[PROP_USE_STOCK] =
- g_param_spec_boolean ("use-stock",
- P_("Use stock"),
- P_("If set, the label is used to pick a stock item instead of being displayed"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED);
-
+
props[PROP_RELIEF] =
g_param_spec_enum ("relief",
P_("Border relief"),
@@ -676,10 +662,8 @@ gtk_button_init (GtkButton *button)
priv->constructed = FALSE;
priv->in_button = FALSE;
priv->button_down = FALSE;
- priv->use_stock = FALSE;
priv->use_underline = FALSE;
- priv->image_is_stock = TRUE;
priv->image_position = GTK_POS_LEFT;
priv->use_action_appearance = TRUE;
@@ -803,11 +787,6 @@ gtk_button_set_property (GObject *object,
case PROP_USE_UNDERLINE:
gtk_button_set_use_underline (button, g_value_get_boolean (value));
break;
- case PROP_USE_STOCK:
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_button_set_use_stock (button, g_value_get_boolean (value));
- G_GNUC_END_IGNORE_DEPRECATIONS;
- break;
case PROP_IMAGE_POSITION:
gtk_button_set_image_position (button, g_value_get_enum (value));
break;
@@ -855,9 +834,6 @@ gtk_button_get_property (GObject *object,
case PROP_USE_UNDERLINE:
g_value_set_boolean (value, priv->use_underline);
break;
- case PROP_USE_STOCK:
- g_value_set_boolean (value, priv->use_stock);
- break;
case PROP_IMAGE_POSITION:
g_value_set_enum (value, priv->image_position);
break;
@@ -912,37 +888,11 @@ gtk_button_activatable_interface_init (GtkActivatableIface *iface)
}
static void
-activatable_update_stock_id (GtkButton *button,
- GtkAction *action)
-{
- gboolean use_stock;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- use_stock = gtk_button_get_use_stock (button);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (!use_stock)
- return;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_button_set_label (button, gtk_action_get_stock_id (action));
- G_GNUC_END_IGNORE_DEPRECATIONS;
-}
-
-static void
activatable_update_short_label (GtkButton *button,
GtkAction *action)
{
GtkWidget *child;
GtkWidget *image;
- gboolean use_stock;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- use_stock = gtk_button_get_use_stock (button);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (use_stock)
- return;
image = gtk_button_get_image (button);
@@ -964,14 +914,6 @@ activatable_update_icon_name (GtkButton *button,
GtkAction *action)
{
GtkWidget *image;
- gboolean use_stock;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- use_stock = gtk_button_get_use_stock (button);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (use_stock)
- return;
image = gtk_button_get_image (button);
@@ -1030,9 +972,7 @@ gtk_button_update (GtkActivatable *activatable,
if (!priv->use_action_appearance)
return;
- if (strcmp (property_name, "stock-id") == 0)
- activatable_update_stock_id (GTK_BUTTON (activatable), action);
- else if (strcmp (property_name, "gicon") == 0)
+ if (strcmp (property_name, "gicon") == 0)
activatable_update_gicon (GTK_BUTTON (activatable), action);
else if (strcmp (property_name, "short-label") == 0)
activatable_update_short_label (GTK_BUTTON (activatable), action);
@@ -1057,14 +997,13 @@ gtk_button_sync_action_properties (GtkActivatable *activatable,
gtk_widget_show (GTK_WIDGET (activatable));
else
gtk_widget_hide (GTK_WIDGET (activatable));
-
+
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
always_show_image = gtk_action_get_always_show_image (action);
G_GNUC_END_IGNORE_DEPRECATIONS
if (priv->use_action_appearance)
{
- activatable_update_stock_id (GTK_BUTTON (activatable), action);
activatable_update_short_label (GTK_BUTTON (activatable), action);
activatable_update_gicon (GTK_BUTTON (activatable), action);
activatable_update_icon_name (GTK_BUTTON (activatable), action);
@@ -1156,12 +1095,10 @@ gtk_button_construct_child (GtkButton *button)
{
GtkButtonPrivate *priv = button->priv;
GtkStyleContext *context;
- GtkStockItem item;
GtkWidget *child;
GtkWidget *label;
GtkWidget *box;
GtkWidget *image = NULL;
- gchar *label_text = NULL;
gint image_spacing;
context = gtk_widget_get_style_context (GTK_WIDGET (button));
@@ -1178,7 +1115,7 @@ gtk_button_construct_child (GtkButton *button)
"image-spacing", &image_spacing,
NULL);
- if (priv->image && !priv->image_is_stock)
+ if (priv->image)
{
GtkWidget *parent;
@@ -1195,22 +1132,6 @@ gtk_button_construct_child (GtkButton *button)
if (child)
gtk_container_remove (GTK_CONTAINER (button), child);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (priv->use_stock &&
- priv->label_text &&
- gtk_stock_lookup (priv->label_text, &item))
- {
- if (!image)
- image = g_object_ref (gtk_image_new_from_stock (priv->label_text, GTK_ICON_SIZE_BUTTON));
-
- label_text = item.label;
- }
- else
- label_text = priv->label_text;
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
if (image)
{
priv->image = image;
@@ -1234,16 +1155,16 @@ gtk_button_construct_child (GtkButton *button)
else
gtk_box_pack_end (GTK_BOX (box), priv->image, FALSE, FALSE);
- if (label_text)
+ if (priv->label_text)
{
- if (priv->use_underline || priv->use_stock)
+ if (priv->use_underline)
{
- label = gtk_label_new_with_mnemonic (label_text);
+ label = gtk_label_new_with_mnemonic (priv->label_text);
gtk_label_set_mnemonic_widget (GTK_LABEL (label),
GTK_WIDGET (button));
}
else
- label = gtk_label_new (label_text);
+ label = gtk_label_new (priv->label_text);
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
@@ -1266,7 +1187,7 @@ gtk_button_construct_child (GtkButton *button)
return;
}
- if (priv->use_underline || priv->use_stock)
+ if (priv->use_underline)
{
label = gtk_label_new_with_mnemonic (priv->label_text);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
@@ -1332,31 +1253,6 @@ gtk_button_new_from_icon_name (const gchar *icon_name,
}
/**
- * gtk_button_new_from_stock:
- * @stock_id: the name of the stock item
- *
- * Creates a new #GtkButton containing the image and text from a stock item.
- * Some stock ids have preprocessor macros like #GTK_STOCK_OK and
- * #GTK_STOCK_APPLY.
- *
- * If @stock_id is unknown, then it will be treated as a mnemonic
- * label (as for gtk_button_new_with_mnemonic()).
- *
- * Returns: a new #GtkButton
- *
- * Deprecated: 3.10: Use gtk_button_new_with_label() instead.
- */
-GtkWidget*
-gtk_button_new_from_stock (const gchar *stock_id)
-{
- return g_object_new (GTK_TYPE_BUTTON,
- "label", stock_id,
- "use-stock", TRUE,
- "use-underline", TRUE,
- NULL);
-}
-
-/**
* gtk_button_new_with_mnemonic:
* @label: The text of the button, with an underscore in front of the
* mnemonic character
@@ -1997,9 +1893,7 @@ gtk_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
* @button: a #GtkButton
* @label: a string
*
- * Sets the text of the label of the button to @str. This text is
- * also used to select the stock item if gtk_button_set_use_stock()
- * is used.
+ * Sets the text of the label of the button to @str.
*
* This will also clear any previously set labels.
*/
@@ -2093,58 +1987,6 @@ gtk_button_get_use_underline (GtkButton *button)
}
/**
- * gtk_button_set_use_stock:
- * @button: a #GtkButton
- * @use_stock: %TRUE if the button should use a stock item
- *
- * If %TRUE, the label set on the button is used as a
- * stock id to select the stock item for the button.
- *
- * Deprecated: 3.10
- */
-void
-gtk_button_set_use_stock (GtkButton *button,
- gboolean use_stock)
-{
- GtkButtonPrivate *priv;
-
- g_return_if_fail (GTK_IS_BUTTON (button));
-
- priv = button->priv;
-
- use_stock = use_stock != FALSE;
-
- if (use_stock != priv->use_stock)
- {
- priv->use_stock = use_stock;
-
- gtk_button_construct_child (button);
-
- g_object_notify_by_pspec (G_OBJECT (button), props[PROP_USE_STOCK]);
- }
-}
-
-/**
- * gtk_button_get_use_stock:
- * @button: a #GtkButton
- *
- * Returns whether the button label is a stock item.
- *
- * Returns: %TRUE if the button label is used to
- * select a stock item instead of being
- * used directly as the label text.
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_button_get_use_stock (GtkButton *button)
-{
- g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
-
- return button->priv->use_stock;
-}
-
-/**
* gtk_button_set_focus_on_click:
* @button: a #GtkButton
* @focus_on_click: whether the button grabs focus when clicked with the mouse
@@ -2353,7 +2195,6 @@ gtk_button_set_image (GtkButton *button,
}
priv->image = image;
- priv->image_is_stock = (image == NULL);
gtk_button_construct_child (button);
@@ -2365,8 +2206,6 @@ gtk_button_set_image (GtkButton *button,
* @button: a #GtkButton
*
* Gets the widget that is currenty set as the image of @button.
- * This may have been explicitly set by gtk_button_set_image()
- * or constructed by gtk_button_new_from_stock().
*
* Returns: (nullable) (transfer none): a #GtkWidget or %NULL in case
* there is no image
diff --git a/gtk/gtkbutton.h b/gtk/gtkbutton.h
index b733d5c..8ed718b 100644
--- a/gtk/gtkbutton.h
+++ b/gtk/gtkbutton.h
@@ -99,8 +99,6 @@ GtkWidget* gtk_button_new_with_label (const gchar *label);
GDK_AVAILABLE_IN_3_10
GtkWidget* gtk_button_new_from_icon_name (const gchar *icon_name,
GtkIconSize size);
-GDK_DEPRECATED_IN_3_10_FOR(gtk_button_new_with_label)
-GtkWidget* gtk_button_new_from_stock (const gchar *stock_id);
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_button_new_with_mnemonic (const gchar *label);
GDK_AVAILABLE_IN_ALL
@@ -129,11 +127,6 @@ void gtk_button_set_use_underline (GtkButton *button,
gboolean use_underline);
GDK_AVAILABLE_IN_ALL
gboolean gtk_button_get_use_underline (GtkButton *button);
-GDK_DEPRECATED_IN_3_10
-void gtk_button_set_use_stock (GtkButton *button,
- gboolean use_stock);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_button_get_use_stock (GtkButton *button);
GDK_DEPRECATED_IN_3_20_FOR(gtk_widget_set_focus_on_click)
void gtk_button_set_focus_on_click (GtkButton *button,
gboolean focus_on_click);
diff --git a/tests/testbuttons.c b/tests/testbuttons.c
index 8fbe22e..58e5f98 100644
--- a/tests/testbuttons.c
+++ b/tests/testbuttons.c
@@ -36,24 +36,6 @@ int main (int argc, char *argv[])
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (box), hbox);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- gtk_container_add (GTK_CONTAINER (hbox), button);
-
- g_object_get (button,
- "label", &text,
- "use-stock", &use_stock,
- "use-underline", &use_underline,
- "image", &image,
- NULL);
- text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image,
use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
- label = gtk_label_new (text);
- g_free (text);
- gtk_container_add (GTK_CONTAINER (hbox), label);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_container_add (GTK_CONTAINER (box), hbox);
button = g_object_new (GTK_TYPE_BUTTON,
"label", "document-save",
"use-stock", TRUE,
diff --git a/tests/testflowbox.c b/tests/testflowbox.c
index 3cccd6e..ce79ba7 100644
--- a/tests/testflowbox.c
+++ b/tests/testflowbox.c
@@ -21,7 +21,6 @@ enum {
SIMPLE_ITEMS = 0,
FOCUS_ITEMS,
WRAPPY_ITEMS,
- STOCK_ITEMS,
IMAGE_ITEMS,
BUTTON_ITEMS
};
@@ -166,36 +165,6 @@ populate_flowbox_wrappy (GtkFlowBox *flowbox)
}
static void
-populate_flowbox_stock (GtkFlowBox *flowbox)
-{
- GtkWidget *widget;
- static GSList *stock_ids = NULL;
- GSList *l;
- gint i;
-
- if (!stock_ids)
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- stock_ids = gtk_stock_list_ids ();
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
-
- for (i = 0, l = stock_ids; i < 30 && l != NULL; i++, l = l->next)
- {
- gchar *stock_id = l->data;
- gchar *text = g_strdup_printf ("Item %02d", i);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- widget = gtk_button_new_from_stock (stock_id);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- gtk_widget_show (widget);
-
- g_object_set_data_full (G_OBJECT (widget), "id", (gpointer)g_strdup (text), g_free);
- gtk_container_add (GTK_CONTAINER (flowbox), widget);
- }
-}
-
-static void
populate_flowbox_images (GtkFlowBox *flowbox)
{
GtkWidget *widget, *image, *label;
@@ -249,8 +218,6 @@ populate_items (GtkFlowBox *flowbox)
populate_flowbox_focus (flowbox);
else if (items_type == WRAPPY_ITEMS)
populate_flowbox_wrappy (flowbox);
- else if (items_type == STOCK_ITEMS)
- populate_flowbox_stock (flowbox);
else if (items_type == IMAGE_ITEMS)
populate_flowbox_images (flowbox);
else if (items_type == BUTTON_ITEMS)
@@ -660,7 +627,6 @@ create_window (void)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Simple");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Focus");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Wrappy");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Stock");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Images");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Buttons");
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
@@ -680,7 +646,7 @@ create_window (void)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
gtk_widget_show (widget);
- gtk_widget_set_tooltip_text (widget, "Set the item's text orientation (cant be done for stock buttons)");
+ gtk_widget_set_tooltip_text (widget, "Set the item's text orientation");
gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE);
g_signal_connect (G_OBJECT (widget), "changed",
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 989a21c..dc878ad 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -339,18 +339,16 @@ create_buttons (GtkWidget *widget)
gtk_container_set_border_width (GTK_CONTAINER (grid), 10);
gtk_box_pack_start (GTK_BOX (box1), grid, TRUE, TRUE);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
button[0] = gtk_button_new_with_label ("button1");
button[1] = gtk_button_new_with_mnemonic ("_button2");
button[2] = gtk_button_new_with_mnemonic ("_button3");
- button[3] = gtk_button_new_from_stock (GTK_STOCK_OK);
+ button[3] = gtk_button_new_with_mnemonic ("_button4");
button[4] = gtk_button_new_with_label ("button5");
button[5] = gtk_button_new_with_label ("button6");
button[6] = gtk_button_new_with_label ("button7");
- button[7] = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ button[7] = gtk_button_new_with_label ("button8");
button[8] = gtk_button_new_with_label ("button9");
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
+
for (i = 0; i < 9; i++)
{
g_signal_connect (button[i], "clicked",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]