[gnome-builder] libide/tweaks: drop create and use create-for-item
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/tweaks: drop create and use create-for-item
- Date: Tue, 16 Aug 2022 01:07:26 +0000 (UTC)
commit 092bb2bad597275afe5d1251bf4008fade92990e
Author: Christian Hergert <chergert redhat com>
Date: Mon Aug 15 18:07:00 2022 -0700
libide/tweaks: drop create and use create-for-item
That way we always have the real parent chain to find settings.
src/libide/tweaks/ide-tweaks-combo.c | 5 ++-
src/libide/tweaks/ide-tweaks-font.c | 5 ++-
src/libide/tweaks/ide-tweaks-panel.c | 2 +-
src/libide/tweaks/ide-tweaks-radio.c | 7 +--
src/libide/tweaks/ide-tweaks-spin.c | 5 ++-
src/libide/tweaks/ide-tweaks-switch.c | 5 ++-
src/libide/tweaks/ide-tweaks-widget-private.h | 3 +-
src/libide/tweaks/ide-tweaks-widget.c | 50 ++--------------------
src/libide/tweaks/ide-tweaks-widget.h | 1 -
src/plugins/editorui/gbp-editorui-tweaks-addin.c | 11 +++--
src/plugins/editorui/tweaks-language.ui | 2 +-
src/plugins/editorui/tweaks.ui | 6 +--
.../platformui/gbp-platformui-tweaks-addin.c | 3 +-
src/plugins/platformui/tweaks.ui | 2 +-
14 files changed, 36 insertions(+), 71 deletions(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-combo.c b/src/libide/tweaks/ide-tweaks-combo.c
index 3026f912b..c8f7a379b 100644
--- a/src/libide/tweaks/ide-tweaks-combo.c
+++ b/src/libide/tweaks/ide-tweaks-combo.c
@@ -52,7 +52,8 @@ G_DEFINE_FINAL_TYPE (IdeTweaksCombo, ide_tweaks_combo, IDE_TYPE_TWEAKS_WIDGET)
static GParamSpec *properties [N_PROPS];
static GtkWidget *
-ide_tweaks_combo_create (IdeTweaksWidget *widget)
+ide_tweaks_combo_create_for_item (IdeTweaksWidget *instance,
+ IdeTweaksItem *widget)
{
IdeTweaksCombo *self = (IdeTweaksCombo *)widget;
g_autoptr(IdeSettings) settings = NULL;
@@ -192,7 +193,7 @@ ide_tweaks_combo_class_init (IdeTweaksComboClass *klass)
item_class->accepts = ide_tweaks_combo_accepts;
- widget_class->create = ide_tweaks_combo_create;
+ widget_class->create_for_item = ide_tweaks_combo_create_for_item;
properties[PROP_SETTINGS] =
g_param_spec_object ("settings", NULL, NULL,
diff --git a/src/libide/tweaks/ide-tweaks-font.c b/src/libide/tweaks/ide-tweaks-font.c
index 8a97d2de9..d5c806648 100644
--- a/src/libide/tweaks/ide-tweaks-font.c
+++ b/src/libide/tweaks/ide-tweaks-font.c
@@ -112,7 +112,8 @@ ide_tweaks_font_button_clicked_cb (IdeTweaksFont *self,
}
static GtkWidget *
-ide_tweaks_font_create (IdeTweaksWidget *widget)
+ide_tweaks_font_create_for_item (IdeTweaksWidget *instance,
+ IdeTweaksItem *widget)
{
IdeTweaksFont *self = (IdeTweaksFont *)widget;
g_autoptr(IdeSettings) settings = NULL;
@@ -249,7 +250,7 @@ ide_tweaks_font_class_init (IdeTweaksFontClass *klass)
object_class->get_property = ide_tweaks_font_get_property;
object_class->set_property = ide_tweaks_font_set_property;
- widget_class->create = ide_tweaks_font_create;
+ widget_class->create_for_item = ide_tweaks_font_create_for_item;
properties[PROP_KEY] =
g_param_spec_string ("key", NULL, NULL,
diff --git a/src/libide/tweaks/ide-tweaks-panel.c b/src/libide/tweaks/ide-tweaks-panel.c
index e1c8bc4e3..c3d33b3be 100644
--- a/src/libide/tweaks/ide-tweaks-panel.c
+++ b/src/libide/tweaks/ide-tweaks-panel.c
@@ -116,7 +116,7 @@ ide_tweaks_panel_visitor_cb (IdeTweaksItem *item,
}
else if (IDE_IS_TWEAKS_WIDGET (item))
{
- GtkWidget *child = _ide_tweaks_widget_create (IDE_TWEAKS_WIDGET (item));
+ GtkWidget *child = _ide_tweaks_widget_create_for_item (IDE_TWEAKS_WIDGET (item), item);
if (child == NULL)
{
diff --git a/src/libide/tweaks/ide-tweaks-radio.c b/src/libide/tweaks/ide-tweaks-radio.c
index c1e5ed7dc..d56495555 100644
--- a/src/libide/tweaks/ide-tweaks-radio.c
+++ b/src/libide/tweaks/ide-tweaks-radio.c
@@ -49,13 +49,14 @@ G_DEFINE_FINAL_TYPE (IdeTweaksRadio, ide_tweaks_radio, IDE_TYPE_TWEAKS_WIDGET)
static GParamSpec *properties [N_PROPS];
static GtkWidget *
-ide_tweaks_radio_create (IdeTweaksWidget *widget)
+ide_tweaks_radio_create_for_item (IdeTweaksWidget *instance,
+ IdeTweaksItem *widget)
{
IdeTweaksRadio *self = (IdeTweaksRadio *)widget;
AdwActionRow *row;
GtkWidget *radio;
- g_assert (IDE_IS_TWEAKS_WIDGET (widget));
+ g_assert (IDE_IS_TWEAKS_RADIO (self));
radio = g_object_new (GTK_TYPE_CHECK_BUTTON,
"action-name", self->action_name,
@@ -160,7 +161,7 @@ ide_tweaks_radio_class_init (IdeTweaksRadioClass *klass)
object_class->get_property = ide_tweaks_radio_get_property;
object_class->set_property = ide_tweaks_radio_set_property;
- widget_class->create = ide_tweaks_radio_create;
+ widget_class->create_for_item = ide_tweaks_radio_create_for_item;
properties[PROP_ACTION_NAME] =
g_param_spec_string ("action-name", NULL, NULL,
diff --git a/src/libide/tweaks/ide-tweaks-spin.c b/src/libide/tweaks/ide-tweaks-spin.c
index f5b2be020..5cac691a4 100644
--- a/src/libide/tweaks/ide-tweaks-spin.c
+++ b/src/libide/tweaks/ide-tweaks-spin.c
@@ -145,7 +145,8 @@ cleanup:
}
static GtkWidget *
-ide_tweaks_spin_create (IdeTweaksWidget *widget)
+ide_tweaks_spin_create_for_item (IdeTweaksWidget *instance,
+ IdeTweaksItem *widget)
{
IdeTweaksSpin *self = (IdeTweaksSpin *)widget;
GtkAdjustment *adjustment;
@@ -265,7 +266,7 @@ ide_tweaks_spin_class_init (IdeTweaksSpinClass *klass)
object_class->get_property = ide_tweaks_spin_get_property;
object_class->set_property = ide_tweaks_spin_set_property;
- widget_class->create = ide_tweaks_spin_create;
+ widget_class->create_for_item = ide_tweaks_spin_create_for_item;
properties[PROP_KEY] =
g_param_spec_string ("key", NULL, NULL,
diff --git a/src/libide/tweaks/ide-tweaks-switch.c b/src/libide/tweaks/ide-tweaks-switch.c
index e8e33d521..f89d844d1 100644
--- a/src/libide/tweaks/ide-tweaks-switch.c
+++ b/src/libide/tweaks/ide-tweaks-switch.c
@@ -49,7 +49,8 @@ G_DEFINE_FINAL_TYPE (IdeTweaksSwitch, ide_tweaks_switch, IDE_TYPE_TWEAKS_WIDGET)
static GParamSpec *properties [N_PROPS];
static GtkWidget *
-ide_tweaks_switch_create (IdeTweaksWidget *widget)
+ide_tweaks_switch_create_for_item (IdeTweaksWidget *instance,
+ IdeTweaksItem *widget)
{
IdeTweaksSwitch *self = (IdeTweaksSwitch *)widget;
AdwActionRow *row;
@@ -157,7 +158,7 @@ ide_tweaks_switch_class_init (IdeTweaksSwitchClass *klass)
object_class->get_property = ide_tweaks_switch_get_property;
object_class->set_property = ide_tweaks_switch_set_property;
- widget_class->create = ide_tweaks_switch_create;
+ widget_class->create_for_item = ide_tweaks_switch_create_for_item;
properties[PROP_ACTION_NAME] =
g_param_spec_string ("action-name", NULL, NULL,
diff --git a/src/libide/tweaks/ide-tweaks-widget-private.h b/src/libide/tweaks/ide-tweaks-widget-private.h
index 9fa1a5148..0e8e81e9f 100644
--- a/src/libide/tweaks/ide-tweaks-widget-private.h
+++ b/src/libide/tweaks/ide-tweaks-widget-private.h
@@ -25,6 +25,7 @@
G_BEGIN_DECLS
-GtkWidget *_ide_tweaks_widget_create (IdeTweaksWidget *self);
+GtkWidget *_ide_tweaks_widget_create_for_item (IdeTweaksWidget *self,
+ IdeTweaksItem *item);
G_END_DECLS
diff --git a/src/libide/tweaks/ide-tweaks-widget.c b/src/libide/tweaks/ide-tweaks-widget.c
index a0fe675e4..93cec3b26 100644
--- a/src/libide/tweaks/ide-tweaks-widget.c
+++ b/src/libide/tweaks/ide-tweaks-widget.c
@@ -32,7 +32,6 @@ typedef struct
G_DEFINE_TYPE_WITH_PRIVATE (IdeTweaksWidget, ide_tweaks_widget, IDE_TYPE_TWEAKS_ITEM)
enum {
- CREATE,
CREATE_FOR_ITEM,
N_SIGNALS
};
@@ -55,15 +54,6 @@ ide_tweaks_widget_copy (IdeTweaksItem *item)
return copy;
}
-static GtkWidget *
-ide_tweaks_widget_real_create_for_item (IdeTweaksWidget *self,
- IdeTweaksItem *item)
-{
- GtkWidget *ret = NULL;
- g_signal_emit (self, signals [CREATE], 0, &ret);
- return ret;
-}
-
static void
ide_tweaks_widget_dispose (GObject *object)
{
@@ -85,27 +75,6 @@ ide_tweaks_widget_class_init (IdeTweaksWidgetClass *klass)
object_class->dispose = ide_tweaks_widget_dispose;
- klass->create_for_item = ide_tweaks_widget_real_create_for_item;
-
- /**
- * IdeTweaksWidget::create:
- *
- * Creates a new #GtkWidget that can be inserted into the #IdeTweaksWindow
- * representing the item.
- *
- * Only the first signal handler is used.
- *
- * Returns: (transfer full) (nullable): a #GtkWidget or %NULL
- */
- signals [CREATE] =
- g_signal_new ("create",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IdeTweaksWidgetClass, create),
- g_signal_accumulator_first_wins, NULL,
- NULL,
- GTK_TYPE_WIDGET, 0);
-
/**
* IdeTweaksWidget::create-for-item:
* @self: an #IdeTweaksWidget
@@ -138,33 +107,20 @@ ide_tweaks_widget_init (IdeTweaksWidget *self)
{
}
-static GtkWidget *
+GtkWidget *
_ide_tweaks_widget_create_for_item (IdeTweaksWidget *self,
IdeTweaksItem *item)
-{
- GtkWidget *ret = NULL;
-
- g_return_val_if_fail (IDE_IS_TWEAKS_WIDGET (self), NULL);
-
- g_signal_emit (self, signals [CREATE_FOR_ITEM], 0, item, &ret);
-
- g_return_val_if_fail (!ret || GTK_IS_WIDGET (ret), NULL);
-
- return ret;
-}
-
-GtkWidget *
-_ide_tweaks_widget_create (IdeTweaksWidget *self)
{
IdeTweaksWidgetPrivate *priv = ide_tweaks_widget_get_instance_private (self);
GtkWidget *ret = NULL;
g_return_val_if_fail (IDE_IS_TWEAKS_WIDGET (self), NULL);
+ g_return_val_if_fail (IDE_IS_TWEAKS_WIDGET (item), NULL);
if (priv->cloned != NULL)
return _ide_tweaks_widget_create_for_item (priv->cloned, IDE_TWEAKS_ITEM (self));
- g_signal_emit (self, signals [CREATE], 0, &ret);
+ g_signal_emit (self, signals [CREATE_FOR_ITEM], 0, item, &ret);
g_return_val_if_fail (!ret || GTK_IS_WIDGET (ret), NULL);
diff --git a/src/libide/tweaks/ide-tweaks-widget.h b/src/libide/tweaks/ide-tweaks-widget.h
index 0d9fa0402..89e9b2e6e 100644
--- a/src/libide/tweaks/ide-tweaks-widget.h
+++ b/src/libide/tweaks/ide-tweaks-widget.h
@@ -39,7 +39,6 @@ struct _IdeTweaksWidgetClass
{
IdeTweaksItemClass parent_class;
- GtkWidget *(*create) (IdeTweaksWidget *self);
GtkWidget *(*create_for_item) (IdeTweaksWidget *self,
IdeTweaksItem *item);
};
diff --git a/src/plugins/editorui/gbp-editorui-tweaks-addin.c
b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
index dd414b43f..38ec49433 100644
--- a/src/plugins/editorui/gbp-editorui-tweaks-addin.c
+++ b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
@@ -39,7 +39,8 @@ G_DEFINE_FINAL_TYPE (GbpEditoruiTweaksAddin, gbp_editorui_tweaks_addin, IDE_TYPE
static GtkWidget *
editorui_create_style_scheme_preview (GbpEditoruiTweaksAddin *self,
- IdeTweaksWidget *widget)
+ IdeTweaksWidget *widget,
+ IdeTweaksWidget *instance)
{
g_assert (GBP_IS_EDITORUI_TWEAKS_ADDIN (self));
g_assert (IDE_IS_TWEAKS_WIDGET (widget));
@@ -58,7 +59,8 @@ editorui_create_style_scheme_preview (GbpEditoruiTweaksAddin *self,
static GtkWidget *
editorui_create_style_scheme_selector (GbpEditoruiTweaksAddin *self,
- IdeTweaksWidget *widget)
+ IdeTweaksWidget *widget,
+ IdeTweaksWidget *instance)
{
g_assert (GBP_IS_EDITORUI_TWEAKS_ADDIN (self));
g_assert (IDE_IS_TWEAKS_WIDGET (widget));
@@ -70,7 +72,8 @@ editorui_create_style_scheme_selector (GbpEditoruiTweaksAddin *self,
static GtkWidget *
create_language_caption (IdeTweaks *tweaks,
- IdeTweaksWidget *widget)
+ IdeTweaksWidget *widget,
+ IdeTweaksWidget *instance)
{
return g_object_new (GTK_TYPE_LABEL,
"css-classes", IDE_STRV_INIT ("caption", "dim-label"),
@@ -83,7 +86,7 @@ create_language_caption (IdeTweaks *tweaks,
static GtkWidget *
create_spaces_style (IdeTweaks *tweaks,
IdeTweaksWidget *widget,
- IdeTweaksWidget *self)
+ IdeTweaksWidget *instance)
{
static const struct {
const char *nick;
diff --git a/src/plugins/editorui/tweaks-language.ui b/src/plugins/editorui/tweaks-language.ui
index 8c56b7f13..1d4815193 100644
--- a/src/plugins/editorui/tweaks-language.ui
+++ b/src/plugins/editorui/tweaks-language.ui
@@ -34,7 +34,7 @@
<object class="IdeTweaksGroup" id="language_top_group">
<child>
<object class="IdeTweaksWidget" id="language_caption">
- <signal name="create" handler="create_language_caption" swapped="true"
object="IdeTweaks"/>
+ <signal name="create-for-item" handler="create_language_caption" swapped="true"
object="IdeTweaks"/>
</object>
</child>
</object>
diff --git a/src/plugins/editorui/tweaks.ui b/src/plugins/editorui/tweaks.ui
index 9c216ec56..c7d3c73a8 100644
--- a/src/plugins/editorui/tweaks.ui
+++ b/src/plugins/editorui/tweaks.ui
@@ -16,12 +16,12 @@
<property name="title" translatable="yes">Color</property>
<child>
<object class="IdeTweaksWidget" id="appearance_page_preview_widget">
- <signal name="create" handler="editorui_create_style_scheme_preview"
object="GbpEditoruiTweaksAddin" swapped="true"/>
+ <signal name="create-for-item" handler="editorui_create_style_scheme_preview"
object="GbpEditoruiTweaksAddin" swapped="true"/>
</object>
</child>
<child>
<object class="IdeTweaksWidget" id="style_scheme_selector">
- <signal name="create" handler="editorui_create_style_scheme_selector"
object="GbpEditoruiTweaksAddin" swapped="true"/>
+ <signal name="create-for-item" handler="editorui_create_style_scheme_selector"
object="GbpEditoruiTweaksAddin" swapped="true"/>
</object>
</child>
</object>
@@ -38,7 +38,7 @@
<property name="title" translatable="yes">Preview</property>
<child>
<object class="IdeTweaksWidget" id="editor_page_preview_widget">
- <signal name="create" handler="editorui_create_style_scheme_preview"
object="GbpEditoruiTweaksAddin" swapped="true"/>
+ <signal name="create-for-item" handler="editorui_create_style_scheme_preview"
object="GbpEditoruiTweaksAddin" swapped="true"/>
</object>
</child>
</object>
diff --git a/src/plugins/platformui/gbp-platformui-tweaks-addin.c
b/src/plugins/platformui/gbp-platformui-tweaks-addin.c
index 612469b72..2a3768924 100644
--- a/src/plugins/platformui/gbp-platformui-tweaks-addin.c
+++ b/src/plugins/platformui/gbp-platformui-tweaks-addin.c
@@ -49,7 +49,8 @@ static const struct {
static GtkWidget *
platformui_create_style_selector (IdeTweaks *tweaks,
- IdeTweaksWidget *widget)
+ IdeTweaksWidget *widget,
+ IdeTweaksWidget *instance)
{
GtkBox *box;
GtkBox *options;
diff --git a/src/plugins/platformui/tweaks.ui b/src/plugins/platformui/tweaks.ui
index 1344fd727..b9e138180 100644
--- a/src/plugins/platformui/tweaks.ui
+++ b/src/plugins/platformui/tweaks.ui
@@ -16,7 +16,7 @@
<property name="title" translatable="yes">Interface</property>
<child>
<object class="IdeTweaksWidget" id="style_selector">
- <signal name="create" handler="platformui_create_style_selector" object="IdeTweaks"
swapped="true"/>
+ <signal name="create-for-item" handler="platformui_create_style_selector"
object="IdeTweaks" swapped="true"/>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]