2014-06-05 09:48:26 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser 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
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <glib/gi18n-lib.h>
|
2014-07-12 03:14:04 +00:00
|
|
|
|
2014-06-05 09:48:26 +00:00
|
|
|
#include "action-editor.h"
|
|
|
|
|
2014-07-12 03:14:04 +00:00
|
|
|
#include "gtksizegroup.h"
|
|
|
|
#include "gtktogglebutton.h"
|
|
|
|
#include "gtkentry.h"
|
|
|
|
#include "gtklabel.h"
|
2020-07-18 03:36:05 +00:00
|
|
|
#include "gtkbox.h"
|
|
|
|
#include "gtkboxlayout.h"
|
|
|
|
#include "gtkorientable.h"
|
2020-07-19 05:56:00 +00:00
|
|
|
#include "gtkactionmuxerprivate.h"
|
2014-07-12 03:14:04 +00:00
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
struct _GtkInspectorActionEditor
|
2014-06-05 09:48:26 +00:00
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
GtkWidget parent;
|
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
GObject *owner;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *name;
|
2014-06-05 09:48:26 +00:00
|
|
|
gboolean enabled;
|
|
|
|
const GVariantType *parameter_type;
|
|
|
|
GVariantType *state_type;
|
|
|
|
GtkWidget *activate_button;
|
|
|
|
GtkWidget *parameter_entry;
|
|
|
|
GtkWidget *state_entry;
|
|
|
|
GtkSizeGroup *sg;
|
|
|
|
};
|
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GtkWidgetClass parent;
|
|
|
|
} GtkInspectorActionEditorClass;
|
|
|
|
|
2014-06-05 09:48:26 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2020-07-19 05:56:00 +00:00
|
|
|
PROP_OWNER,
|
2019-05-08 03:34:14 +00:00
|
|
|
PROP_NAME,
|
|
|
|
PROP_SIZEGROUP
|
2014-06-05 09:48:26 +00:00
|
|
|
};
|
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
G_DEFINE_TYPE (GtkInspectorActionEditor, gtk_inspector_action_editor, GTK_TYPE_WIDGET)
|
2014-06-05 09:48:26 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_inspector_action_editor_init (GtkInspectorActionEditor *editor)
|
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
GtkBoxLayout *layout;
|
|
|
|
|
|
|
|
layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (editor)));
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_box_layout_set_spacing (layout, 10);
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef void (*VariantEditorChanged) (GtkWidget *editor, gpointer data);
|
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2014-06-05 09:48:26 +00:00
|
|
|
GtkWidget *editor;
|
|
|
|
VariantEditorChanged callback;
|
|
|
|
gpointer data;
|
|
|
|
} VariantEditorData;
|
|
|
|
|
|
|
|
static void
|
|
|
|
variant_editor_changed_cb (GObject *obj,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
VariantEditorData *data)
|
|
|
|
{
|
|
|
|
data->callback (data->editor, data->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
variant_editor_new (const GVariantType *type,
|
|
|
|
VariantEditorChanged callback,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *editor;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *entry;
|
|
|
|
VariantEditorData *d;
|
|
|
|
|
|
|
|
d = g_new (VariantEditorData, 1);
|
|
|
|
d->callback = callback;
|
|
|
|
d->data = data;
|
|
|
|
|
|
|
|
if (g_variant_type_equal (type, G_VARIANT_TYPE_BOOLEAN))
|
|
|
|
{
|
|
|
|
editor = gtk_toggle_button_new_with_label ("FALSE");
|
|
|
|
g_signal_connect (editor, "notify::active", G_CALLBACK (variant_editor_changed_cb), d);
|
2020-07-18 03:36:05 +00:00
|
|
|
}
|
2014-06-05 09:48:26 +00:00
|
|
|
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
|
|
|
|
{
|
|
|
|
editor = gtk_entry_new ();
|
2019-12-08 06:09:59 +00:00
|
|
|
gtk_editable_set_width_chars (GTK_EDITABLE (editor), 10);
|
2014-06-05 09:48:26 +00:00
|
|
|
g_signal_connect (editor, "notify::text", G_CALLBACK (variant_editor_changed_cb), d);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
editor = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
|
|
|
entry = gtk_entry_new ();
|
2019-12-08 06:09:59 +00:00
|
|
|
gtk_editable_set_width_chars (GTK_EDITABLE (entry), 10);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (editor), entry);
|
2014-06-05 09:48:26 +00:00
|
|
|
label = gtk_label_new (g_variant_type_peek_string (type));
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (editor), label);
|
2014-06-05 09:48:26 +00:00
|
|
|
g_signal_connect (entry, "notify::text", G_CALLBACK (variant_editor_changed_cb), d);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (editor), "type", (gpointer)type);
|
|
|
|
d->editor = editor;
|
|
|
|
g_object_set_data_full (G_OBJECT (editor), "callback", d, g_free);
|
|
|
|
|
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
variant_editor_set_value (GtkWidget *editor,
|
|
|
|
GVariant *value)
|
|
|
|
{
|
|
|
|
const GVariantType *type;
|
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
data = g_object_get_data (G_OBJECT (editor), "callback");
|
|
|
|
g_signal_handlers_block_by_func (editor, variant_editor_changed_cb, data);
|
|
|
|
|
|
|
|
type = g_variant_get_type (value);
|
|
|
|
if (g_variant_type_equal (type, G_VARIANT_TYPE_BOOLEAN))
|
|
|
|
{
|
|
|
|
GtkToggleButton *tb = GTK_TOGGLE_BUTTON (editor);
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active (tb, g_variant_get_boolean (value));
|
2020-05-02 07:05:19 +00:00
|
|
|
child = gtk_button_get_child (GTK_BUTTON (tb));
|
2014-06-05 09:48:26 +00:00
|
|
|
gtk_label_set_text (GTK_LABEL (child),
|
2020-05-02 07:05:19 +00:00
|
|
|
g_variant_get_boolean (value) ? "TRUE" : "FALSE");
|
|
|
|
}
|
2014-06-05 09:48:26 +00:00
|
|
|
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
|
|
|
|
{
|
|
|
|
GtkEntry *entry = GTK_ENTRY (editor);
|
2019-02-28 19:31:36 +00:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (entry), g_variant_get_string (value, NULL));
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-08 06:19:18 +00:00
|
|
|
GtkWidget *entry;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *text;
|
2014-06-05 09:48:26 +00:00
|
|
|
|
2020-05-08 06:19:18 +00:00
|
|
|
entry = gtk_widget_get_first_child (editor);
|
2014-06-05 09:48:26 +00:00
|
|
|
|
|
|
|
text = g_variant_print (value, FALSE);
|
2019-02-28 19:31:36 +00:00
|
|
|
gtk_editable_set_text (GTK_EDITABLE (entry), text);
|
2014-06-05 09:48:26 +00:00
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (editor, variant_editor_changed_cb, data);
|
|
|
|
}
|
|
|
|
|
2014-09-06 00:52:03 +00:00
|
|
|
static GVariant *
|
2014-06-05 09:48:26 +00:00
|
|
|
variant_editor_get_value (GtkWidget *editor)
|
|
|
|
{
|
|
|
|
const GVariantType *type;
|
|
|
|
GVariant *value;
|
|
|
|
|
|
|
|
type = (const GVariantType *) g_object_get_data (G_OBJECT (editor), "type");
|
|
|
|
if (g_variant_type_equal (type, G_VARIANT_TYPE_BOOLEAN))
|
|
|
|
{
|
|
|
|
GtkToggleButton *tb = GTK_TOGGLE_BUTTON (editor);
|
|
|
|
value = g_variant_new_boolean (gtk_toggle_button_get_active (tb));
|
|
|
|
}
|
|
|
|
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
|
|
|
|
{
|
|
|
|
GtkEntry *entry = GTK_ENTRY (editor);
|
2019-02-28 19:31:36 +00:00
|
|
|
value = g_variant_new_string (gtk_editable_get_text (GTK_EDITABLE (entry)));
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-08 06:19:18 +00:00
|
|
|
GtkWidget *entry;
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *text;
|
2014-06-05 09:48:26 +00:00
|
|
|
|
2020-05-08 06:19:18 +00:00
|
|
|
entry = gtk_widget_get_first_child (editor);
|
2019-02-28 19:31:36 +00:00
|
|
|
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
2014-06-05 09:48:26 +00:00
|
|
|
|
|
|
|
value = g_variant_parse (type, text, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
activate_action (GtkWidget *button,
|
|
|
|
GtkInspectorActionEditor *r)
|
|
|
|
{
|
|
|
|
GVariant *parameter = NULL;
|
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
if (r->parameter_entry)
|
|
|
|
parameter = variant_editor_get_value (r->parameter_entry);
|
2020-07-19 05:56:00 +00:00
|
|
|
if (G_IS_ACTION_GROUP (r->owner))
|
|
|
|
g_action_group_activate_action (G_ACTION_GROUP (r->owner), r->name, parameter);
|
|
|
|
else if (GTK_IS_ACTION_MUXER (r->owner))
|
|
|
|
gtk_action_muxer_activate_action (GTK_ACTION_MUXER (r->owner), r->name, parameter);
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
parameter_changed (GtkWidget *editor,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkInspectorActionEditor *r = data;
|
|
|
|
GVariant *value;
|
|
|
|
|
|
|
|
value = variant_editor_get_value (editor);
|
2020-07-18 03:36:05 +00:00
|
|
|
gtk_widget_set_sensitive (r->activate_button, r->enabled && value != NULL);
|
2014-06-05 09:48:26 +00:00
|
|
|
if (value)
|
|
|
|
g_variant_unref (value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
state_changed (GtkWidget *editor,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkInspectorActionEditor *r = data;
|
|
|
|
GVariant *value;
|
|
|
|
|
|
|
|
value = variant_editor_get_value (editor);
|
|
|
|
if (value)
|
2020-07-19 05:56:00 +00:00
|
|
|
{
|
|
|
|
if (G_IS_ACTION_GROUP (r->owner))
|
|
|
|
g_action_group_change_action_state (G_ACTION_GROUP (r->owner), r->name, value);
|
|
|
|
else if (GTK_IS_ACTION_MUXER (r->owner))
|
|
|
|
gtk_action_muxer_change_action_state (GTK_ACTION_MUXER (r->owner), r->name, value);
|
|
|
|
}
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
2019-06-17 02:10:33 +00:00
|
|
|
static void
|
|
|
|
update_enabled (GtkInspectorActionEditor *r,
|
|
|
|
gboolean enabled)
|
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
r->enabled = enabled;
|
|
|
|
if (r->parameter_entry)
|
2019-06-17 02:10:33 +00:00
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
gtk_widget_set_sensitive (r->parameter_entry, enabled);
|
|
|
|
parameter_changed (r->parameter_entry, r);
|
2019-06-17 02:10:33 +00:00
|
|
|
}
|
2020-07-18 03:36:05 +00:00
|
|
|
if (r->activate_button)
|
|
|
|
gtk_widget_set_sensitive (r->activate_button, enabled);
|
2019-06-17 02:10:33 +00:00
|
|
|
}
|
|
|
|
|
2014-06-05 09:48:26 +00:00
|
|
|
static void
|
|
|
|
action_enabled_changed_cb (GActionGroup *group,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *action_name,
|
2014-06-05 09:48:26 +00:00
|
|
|
gboolean enabled,
|
|
|
|
GtkInspectorActionEditor *r)
|
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
if (g_str_equal (action_name, r->name))
|
|
|
|
update_enabled (r, enabled);
|
2019-06-17 02:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_state (GtkInspectorActionEditor *r,
|
|
|
|
GVariant *state)
|
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
if (r->state_entry)
|
|
|
|
variant_editor_set_value (r->state_entry, state);
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
action_state_changed_cb (GActionGroup *group,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *action_name,
|
2014-06-05 09:48:26 +00:00
|
|
|
GVariant *state,
|
|
|
|
GtkInspectorActionEditor *r)
|
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
if (g_str_equal (action_name, r->name))
|
|
|
|
update_state (r, state);
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GtkInspectorActionEditor *r = GTK_INSPECTOR_ACTION_EDITOR (object);
|
|
|
|
GVariant *state;
|
|
|
|
GtkWidget *row;
|
2019-05-08 03:34:14 +00:00
|
|
|
GtkWidget *activate;
|
2014-06-05 09:48:26 +00:00
|
|
|
GtkWidget *label;
|
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
if (G_IS_ACTION_GROUP (r->owner))
|
|
|
|
g_action_group_query_action (G_ACTION_GROUP (r->owner), r->name,
|
|
|
|
&r->enabled, &r->parameter_type, NULL, NULL,
|
|
|
|
&state);
|
|
|
|
else if (GTK_IS_ACTION_MUXER (r->owner))
|
|
|
|
gtk_action_muxer_query_action (GTK_ACTION_MUXER (r->owner), r->name,
|
|
|
|
&r->enabled, &r->parameter_type, NULL, NULL,
|
|
|
|
&state);
|
|
|
|
else
|
|
|
|
state = NULL;
|
2014-06-05 09:48:26 +00:00
|
|
|
|
|
|
|
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
2019-05-08 03:34:14 +00:00
|
|
|
activate = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (row), activate);
|
2020-07-18 03:36:05 +00:00
|
|
|
if (r->sg)
|
|
|
|
gtk_size_group_add_widget (r->sg, activate);
|
2014-06-05 09:48:26 +00:00
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
r->activate_button = gtk_button_new_with_label (_("Activate"));
|
|
|
|
g_signal_connect (r->activate_button, "clicked", G_CALLBACK (activate_action), r);
|
2014-06-05 09:48:26 +00:00
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
gtk_widget_set_sensitive (r->activate_button, r->enabled);
|
|
|
|
gtk_box_append (GTK_BOX (activate), r->activate_button);
|
2014-06-05 09:48:26 +00:00
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
if (r->parameter_type)
|
2014-06-05 09:48:26 +00:00
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
r->parameter_entry = variant_editor_new (r->parameter_type, parameter_changed, r);
|
|
|
|
gtk_widget_set_sensitive (r->parameter_entry, r->enabled);
|
|
|
|
gtk_box_append (GTK_BOX (activate), r->parameter_entry);
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
gtk_widget_set_parent (row, GTK_WIDGET (r));
|
2014-06-05 09:48:26 +00:00
|
|
|
|
|
|
|
if (state)
|
|
|
|
{
|
2020-07-18 03:36:05 +00:00
|
|
|
r->state_type = g_variant_type_copy (g_variant_get_type (state));
|
2014-06-05 09:48:26 +00:00
|
|
|
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
2019-05-08 02:20:18 +00:00
|
|
|
label = gtk_label_new (_("Set State"));
|
2020-07-18 03:36:05 +00:00
|
|
|
if (r->sg)
|
|
|
|
gtk_size_group_add_widget (r->sg, label);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (row), label);
|
2020-07-18 03:36:05 +00:00
|
|
|
r->state_entry = variant_editor_new (r->state_type, state_changed, r);
|
|
|
|
variant_editor_set_value (r->state_entry, state);
|
|
|
|
gtk_box_append (GTK_BOX (row), r->state_entry);
|
|
|
|
gtk_widget_set_parent (row, GTK_WIDGET (r));
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
if (G_IS_ACTION_GROUP (r->owner))
|
|
|
|
{
|
|
|
|
g_signal_connect (r->owner, "action-enabled-changed",
|
|
|
|
G_CALLBACK (action_enabled_changed_cb), r);
|
|
|
|
g_signal_connect (r->owner, "action-state-changed",
|
|
|
|
G_CALLBACK (action_state_changed_cb), r);
|
|
|
|
}
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-18 03:36:05 +00:00
|
|
|
dispose (GObject *object)
|
2014-06-05 09:48:26 +00:00
|
|
|
{
|
|
|
|
GtkInspectorActionEditor *r = GTK_INSPECTOR_ACTION_EDITOR (object);
|
2020-07-18 03:36:05 +00:00
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
g_free (r->name);
|
|
|
|
g_clear_object (&r->sg);
|
|
|
|
if (r->state_type)
|
|
|
|
g_variant_type_free (r->state_type);
|
2020-07-19 05:56:00 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (r->owner, action_enabled_changed_cb, r);
|
|
|
|
g_signal_handlers_disconnect_by_func (r->owner, action_state_changed_cb, r);
|
2014-06-05 09:48:26 +00:00
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
while ((child = gtk_widget_get_first_child (GTK_WIDGET (r))))
|
|
|
|
gtk_widget_unparent (child);
|
2014-06-05 09:48:26 +00:00
|
|
|
|
2020-07-18 03:36:05 +00:00
|
|
|
G_OBJECT_CLASS (gtk_inspector_action_editor_parent_class)->dispose (object);
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkInspectorActionEditor *r = GTK_INSPECTOR_ACTION_EDITOR (object);
|
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
2020-07-19 05:56:00 +00:00
|
|
|
case PROP_OWNER:
|
|
|
|
g_value_set_object (value, r->owner);
|
2014-06-05 09:48:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_NAME:
|
2020-07-18 03:36:05 +00:00
|
|
|
g_value_set_string (value, r->name);
|
2014-06-05 09:48:26 +00:00
|
|
|
break;
|
|
|
|
|
2019-05-08 03:34:14 +00:00
|
|
|
case PROP_SIZEGROUP:
|
2020-07-18 03:36:05 +00:00
|
|
|
g_value_set_object (value, r->sg);
|
2019-05-08 03:34:14 +00:00
|
|
|
break;
|
|
|
|
|
2014-06-05 09:48:26 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkInspectorActionEditor *r = GTK_INSPECTOR_ACTION_EDITOR (object);
|
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
2020-07-19 05:56:00 +00:00
|
|
|
case PROP_OWNER:
|
|
|
|
r->owner = g_value_get_object (value);
|
2014-06-05 09:48:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_NAME:
|
2020-07-18 03:36:05 +00:00
|
|
|
g_free (r->name);
|
|
|
|
r->name = g_value_dup_string (value);
|
2014-06-05 09:48:26 +00:00
|
|
|
break;
|
|
|
|
|
2019-05-08 03:34:14 +00:00
|
|
|
case PROP_SIZEGROUP:
|
2020-07-18 03:36:05 +00:00
|
|
|
r->sg = g_value_dup_object (value);
|
2019-05-08 03:34:14 +00:00
|
|
|
break;
|
|
|
|
|
2014-06-05 09:48:26 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_inspector_action_editor_class_init (GtkInspectorActionEditorClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2020-07-18 03:36:05 +00:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2014-06-05 09:48:26 +00:00
|
|
|
|
|
|
|
object_class->constructed = constructed;
|
2020-07-18 03:36:05 +00:00
|
|
|
object_class->dispose = dispose;
|
2014-06-05 09:48:26 +00:00
|
|
|
object_class->get_property = get_property;
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_OWNER,
|
|
|
|
g_param_spec_object ("owner", "Owner", "The owner of the action",
|
|
|
|
G_TYPE_OBJECT, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
2014-06-05 09:48:26 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_NAME,
|
|
|
|
g_param_spec_string ("name", "Name", "The action name",
|
|
|
|
NULL, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
2019-05-08 03:34:14 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_SIZEGROUP,
|
|
|
|
g_param_spec_object ("sizegroup", "Size Group", "The Size Group for activate",
|
|
|
|
GTK_TYPE_SIZE_GROUP, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
2020-07-18 03:36:05 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
2014-06-05 09:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2020-07-19 05:56:00 +00:00
|
|
|
gtk_inspector_action_editor_new (GObject *owner,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *name,
|
2019-05-08 03:34:14 +00:00
|
|
|
GtkSizeGroup *activate)
|
2014-06-05 09:48:26 +00:00
|
|
|
{
|
|
|
|
return g_object_new (GTK_TYPE_INSPECTOR_ACTION_EDITOR,
|
2020-07-19 05:56:00 +00:00
|
|
|
"owner", owner,
|
2014-06-05 09:48:26 +00:00
|
|
|
"name", name,
|
2019-05-08 03:34:14 +00:00
|
|
|
"sizegroup", activate,
|
2014-06-05 09:48:26 +00:00
|
|
|
NULL);
|
|
|
|
}
|
2019-06-17 02:10:33 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gtk_inspector_action_editor_update (GtkInspectorActionEditor *r,
|
|
|
|
gboolean enabled,
|
|
|
|
GVariant *state)
|
|
|
|
{
|
|
|
|
update_enabled (r, enabled);
|
|
|
|
update_state (r, state);
|
|
|
|
}
|