2014-05-14 00:36:02 +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-05-14 00:36:02 +00:00
|
|
|
#include "actions.h"
|
2014-06-05 09:48:26 +00:00
|
|
|
#include "action-editor.h"
|
2019-12-08 06:09:59 +00:00
|
|
|
#include "action-holder.h"
|
2014-07-12 03:14:04 +00:00
|
|
|
|
|
|
|
#include "gtkapplication.h"
|
|
|
|
#include "gtkapplicationwindow.h"
|
|
|
|
#include "gtktreeview.h"
|
|
|
|
#include "gtkliststore.h"
|
2014-05-14 00:36:02 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
2019-06-15 21:54:45 +00:00
|
|
|
#include "gtkactionmuxerprivate.h"
|
2014-07-12 03:14:04 +00:00
|
|
|
#include "gtkpopover.h"
|
2014-11-22 20:40:24 +00:00
|
|
|
#include "gtklabel.h"
|
2019-04-02 23:24:57 +00:00
|
|
|
#include "gtkstack.h"
|
2019-05-08 02:20:18 +00:00
|
|
|
#include "gtklistbox.h"
|
|
|
|
#include "gtkstylecontext.h"
|
|
|
|
#include "gtksizegroup.h"
|
2020-07-18 03:59:49 +00:00
|
|
|
#include "gtkboxlayout.h"
|
2014-05-14 00:36:02 +00:00
|
|
|
|
2020-07-18 03:59:49 +00:00
|
|
|
|
|
|
|
struct _GtkInspectorActions
|
2014-05-14 00:36:02 +00:00
|
|
|
{
|
2020-07-18 03:59:49 +00:00
|
|
|
GtkWidget parent;
|
|
|
|
|
2019-05-08 02:20:18 +00:00
|
|
|
GtkWidget *list;
|
2019-06-17 02:10:33 +00:00
|
|
|
GtkWidget *button;
|
2019-12-08 06:09:59 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
GObject *object;
|
|
|
|
|
2020-07-26 20:25:12 +00:00
|
|
|
GListStore *actions;
|
2019-12-08 06:09:59 +00:00
|
|
|
GtkColumnViewColumn *name;
|
2019-06-17 02:10:33 +00:00
|
|
|
};
|
|
|
|
|
2020-07-18 03:59:49 +00:00
|
|
|
typedef struct _GtkInspectorActionsClass
|
|
|
|
{
|
|
|
|
GtkWidgetClass parent;
|
|
|
|
} GtkInspectorActionsClass;
|
|
|
|
|
2019-06-17 02:10:33 +00:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_BUTTON
|
2014-05-14 00:36:02 +00:00
|
|
|
};
|
|
|
|
|
2020-07-18 03:59:49 +00:00
|
|
|
G_DEFINE_TYPE (GtkInspectorActions, gtk_inspector_actions, GTK_TYPE_WIDGET)
|
2014-05-14 00:36:02 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_inspector_actions_init (GtkInspectorActions *sl)
|
|
|
|
{
|
2020-07-18 03:59:49 +00:00
|
|
|
GtkBoxLayout *layout;
|
|
|
|
|
2014-05-14 00:36:02 +00:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (sl));
|
2020-07-18 03:59:49 +00:00
|
|
|
|
|
|
|
layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (sl)));
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), GTK_ORIENTATION_VERTICAL);
|
2014-05-14 00:36:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-19 05:56:00 +00:00
|
|
|
action_added (GObject *owner,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *action_name,
|
2020-07-19 05:56:00 +00:00
|
|
|
GtkInspectorActions *sl)
|
2014-05-14 00:36:02 +00:00
|
|
|
{
|
2020-07-19 05:56:00 +00:00
|
|
|
ActionHolder *holder = action_holder_new (owner, action_name);
|
2020-07-26 20:25:12 +00:00
|
|
|
g_list_store_append (sl->actions, holder);
|
2019-12-08 06:09:59 +00:00
|
|
|
g_object_unref (holder);
|
|
|
|
}
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
static void
|
|
|
|
setup_name_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_list_item_set_child (list_item, label);
|
|
|
|
}
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
static void
|
|
|
|
bind_name_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
|
|
|
{
|
|
|
|
gpointer item;
|
|
|
|
GtkWidget *label;
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
item = gtk_list_item_get_item (list_item);
|
|
|
|
label = gtk_list_item_get_child (list_item);
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
gtk_label_set_label (GTK_LABEL (label), action_holder_get_name (ACTION_HOLDER (item)));
|
2014-05-16 02:36:48 +00:00
|
|
|
}
|
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
static void
|
|
|
|
setup_enabled_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2019-05-08 02:20:18 +00:00
|
|
|
{
|
2019-12-08 06:09:59 +00:00
|
|
|
GtkWidget *label;
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.5);
|
|
|
|
gtk_list_item_set_child (list_item, label);
|
2019-05-08 02:20:18 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 02:36:48 +00:00
|
|
|
static void
|
2019-12-08 06:09:59 +00:00
|
|
|
bind_enabled_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2014-05-16 02:36:48 +00:00
|
|
|
{
|
2019-12-08 06:09:59 +00:00
|
|
|
gpointer item;
|
|
|
|
GtkWidget *label;
|
2020-07-19 05:56:00 +00:00
|
|
|
GObject *owner;
|
2019-12-08 06:09:59 +00:00
|
|
|
const char *name;
|
2020-07-19 05:56:00 +00:00
|
|
|
gboolean enabled = FALSE;
|
2019-12-08 06:09:59 +00:00
|
|
|
|
|
|
|
item = gtk_list_item_get_item (list_item);
|
|
|
|
label = gtk_list_item_get_child (list_item);
|
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
owner = action_holder_get_owner (ACTION_HOLDER (item));
|
2019-12-08 06:09:59 +00:00
|
|
|
name = action_holder_get_name (ACTION_HOLDER (item));
|
2020-07-19 05:56:00 +00:00
|
|
|
if (G_IS_ACTION_GROUP (owner))
|
|
|
|
enabled = g_action_group_get_action_enabled (G_ACTION_GROUP (owner), name);
|
|
|
|
else if (GTK_IS_ACTION_MUXER (owner))
|
|
|
|
gtk_action_muxer_query_action (GTK_ACTION_MUXER (owner), name,
|
|
|
|
&enabled, NULL, NULL, NULL, NULL);
|
2019-12-08 06:09:59 +00:00
|
|
|
|
|
|
|
gtk_label_set_label (GTK_LABEL (label), enabled ? "+" : "-");
|
2014-05-16 02:36:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-12-08 06:09:59 +00:00
|
|
|
setup_parameter_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2014-05-16 02:36:48 +00:00
|
|
|
{
|
2019-12-08 06:09:59 +00:00
|
|
|
GtkWidget *label;
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.5);
|
|
|
|
gtk_list_item_set_child (list_item, label);
|
2020-06-30 21:39:37 +00:00
|
|
|
gtk_widget_add_css_class (label, "cell");
|
2014-05-16 02:36:48 +00:00
|
|
|
}
|
|
|
|
|
2019-06-17 02:10:33 +00:00
|
|
|
static void
|
2019-12-08 06:09:59 +00:00
|
|
|
bind_parameter_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2019-06-17 02:10:33 +00:00
|
|
|
{
|
2019-12-08 06:09:59 +00:00
|
|
|
gpointer item;
|
2019-06-17 02:10:33 +00:00
|
|
|
GtkWidget *label;
|
2020-07-19 05:56:00 +00:00
|
|
|
GObject *owner;
|
2019-12-08 06:09:59 +00:00
|
|
|
const char *name;
|
|
|
|
const char *parameter;
|
2019-06-17 02:10:33 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
item = gtk_list_item_get_item (list_item);
|
|
|
|
label = gtk_list_item_get_child (list_item);
|
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
owner = action_holder_get_owner (ACTION_HOLDER (item));
|
2019-12-08 06:09:59 +00:00
|
|
|
name = action_holder_get_name (ACTION_HOLDER (item));
|
2020-07-19 05:56:00 +00:00
|
|
|
if (G_IS_ACTION_GROUP (owner))
|
2020-07-24 18:40:36 +00:00
|
|
|
parameter = (const char *)g_action_group_get_action_parameter_type (G_ACTION_GROUP (owner), name);
|
2020-07-19 05:56:00 +00:00
|
|
|
else if (GTK_IS_ACTION_MUXER (owner))
|
|
|
|
gtk_action_muxer_query_action (GTK_ACTION_MUXER (owner), name,
|
|
|
|
NULL, (const GVariantType **)¶meter, NULL, NULL, NULL);
|
2020-07-24 18:02:26 +00:00
|
|
|
else
|
|
|
|
parameter = "(Unknown)";
|
2019-12-08 06:09:59 +00:00
|
|
|
|
|
|
|
gtk_label_set_label (GTK_LABEL (label), parameter);
|
2019-06-17 02:10:33 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 02:36:48 +00:00
|
|
|
static void
|
2019-12-08 06:09:59 +00:00
|
|
|
setup_state_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2014-05-16 02:36:48 +00:00
|
|
|
{
|
2019-12-08 06:09:59 +00:00
|
|
|
GtkWidget *label;
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_widget_set_margin_start (label, 5);
|
|
|
|
gtk_widget_set_margin_end (label, 5);
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
|
|
|
gtk_list_item_set_child (list_item, label);
|
2020-06-30 21:39:37 +00:00
|
|
|
gtk_widget_add_css_class (label, "cell");
|
2014-05-16 02:36:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-12-08 06:09:59 +00:00
|
|
|
bind_state_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2014-05-16 02:36:48 +00:00
|
|
|
{
|
2019-12-08 06:09:59 +00:00
|
|
|
gpointer item;
|
2019-05-08 02:20:18 +00:00
|
|
|
GtkWidget *label;
|
2020-07-19 05:56:00 +00:00
|
|
|
GObject *owner;
|
2019-12-08 06:09:59 +00:00
|
|
|
const char *name;
|
|
|
|
GVariant *state;
|
|
|
|
char *state_string;
|
|
|
|
|
|
|
|
item = gtk_list_item_get_item (list_item);
|
|
|
|
label = gtk_list_item_get_child (list_item);
|
2019-05-08 02:20:18 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
owner = action_holder_get_owner (ACTION_HOLDER (item));
|
2019-12-08 06:09:59 +00:00
|
|
|
name = action_holder_get_name (ACTION_HOLDER (item));
|
2020-07-19 05:56:00 +00:00
|
|
|
if (G_IS_ACTION_GROUP (owner))
|
|
|
|
state = g_action_group_get_action_state (G_ACTION_GROUP (owner), name);
|
|
|
|
else if (GTK_IS_ACTION_MUXER (owner))
|
|
|
|
gtk_action_muxer_query_action (GTK_ACTION_MUXER (owner), name,
|
|
|
|
NULL, NULL, NULL, NULL, &state);
|
|
|
|
else
|
|
|
|
state = NULL;
|
|
|
|
|
2014-05-16 02:36:48 +00:00
|
|
|
if (state)
|
|
|
|
state_string = g_variant_print (state, FALSE);
|
|
|
|
else
|
|
|
|
state_string = g_strdup ("");
|
2019-12-08 06:09:59 +00:00
|
|
|
|
2019-05-08 02:20:18 +00:00
|
|
|
gtk_label_set_label (GTK_LABEL (label), state_string);
|
2019-12-08 06:09:59 +00:00
|
|
|
|
2014-05-16 02:36:48 +00:00
|
|
|
g_free (state_string);
|
2019-12-08 06:09:59 +00:00
|
|
|
if (state)
|
|
|
|
g_variant_unref (state);
|
2014-05-16 02:36:48 +00:00
|
|
|
}
|
|
|
|
|
2019-06-17 02:10:33 +00:00
|
|
|
static void
|
2019-12-08 06:09:59 +00:00
|
|
|
bind_changes_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2019-06-17 02:10:33 +00:00
|
|
|
{
|
2019-12-08 06:09:59 +00:00
|
|
|
gpointer item;
|
2020-07-19 05:56:00 +00:00
|
|
|
GObject *owner;
|
2019-12-08 06:09:59 +00:00
|
|
|
const char *name;
|
|
|
|
GtkWidget *editor;
|
|
|
|
|
|
|
|
item = gtk_list_item_get_item (list_item);
|
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
owner = action_holder_get_owner (ACTION_HOLDER (item));
|
2019-12-08 06:09:59 +00:00
|
|
|
name = action_holder_get_name (ACTION_HOLDER (item));
|
2019-06-17 02:10:33 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
editor = gtk_inspector_action_editor_new (owner, name, NULL);
|
2020-06-30 21:39:37 +00:00
|
|
|
gtk_widget_add_css_class (editor, "cell");
|
2019-12-08 06:09:59 +00:00
|
|
|
gtk_list_item_set_child (list_item, editor);
|
2019-06-17 02:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-12-08 06:09:59 +00:00
|
|
|
unbind_changes_cb (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2019-06-17 02:10:33 +00:00
|
|
|
{
|
2019-12-08 06:09:59 +00:00
|
|
|
gtk_list_item_set_child (list_item, NULL);
|
|
|
|
}
|
2019-06-17 02:10:33 +00:00
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
static void
|
2020-07-19 05:56:00 +00:00
|
|
|
add_group (GtkInspectorActions *sl,
|
|
|
|
GActionGroup *group)
|
2019-12-08 06:09:59 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2020-07-24 18:40:36 +00:00
|
|
|
char **names;
|
2019-12-08 06:09:59 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
names = g_action_group_list_actions (group);
|
|
|
|
for (i = 0; names[i]; i++)
|
|
|
|
action_added (G_OBJECT (group), names[i], sl);
|
|
|
|
g_strfreev (names);
|
2019-12-08 06:09:59 +00:00
|
|
|
}
|
|
|
|
|
2019-06-15 21:54:45 +00:00
|
|
|
static void
|
2020-07-19 05:56:00 +00:00
|
|
|
add_muxer (GtkInspectorActions *sl,
|
|
|
|
GtkActionMuxer *muxer)
|
2019-06-15 21:54:45 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2020-07-24 18:40:36 +00:00
|
|
|
char **names;
|
2019-06-15 21:54:45 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
names = gtk_action_muxer_list_actions (muxer);
|
|
|
|
for (i = 0; names[i]; i++)
|
|
|
|
action_added (G_OBJECT (muxer), names[i], sl);
|
|
|
|
g_strfreev (names);
|
2019-06-15 21:54:45 +00:00
|
|
|
}
|
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
static gboolean
|
|
|
|
reload (GtkInspectorActions *sl)
|
2014-05-16 02:36:48 +00:00
|
|
|
{
|
2020-07-26 20:25:12 +00:00
|
|
|
g_list_store_remove_all (sl->actions);
|
2014-05-14 00:36:02 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
if (GTK_IS_APPLICATION (sl->object))
|
|
|
|
{
|
|
|
|
add_group (sl, G_ACTION_GROUP (sl->object));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (GTK_IS_WIDGET (sl->object))
|
|
|
|
{
|
|
|
|
GtkActionMuxer *muxer;
|
2014-05-16 02:36:48 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
muxer = _gtk_widget_get_action_muxer (GTK_WIDGET (sl->object), FALSE);
|
|
|
|
if (muxer)
|
|
|
|
{
|
|
|
|
add_muxer (sl, muxer);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2019-06-15 21:54:45 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
return FALSE;
|
2014-05-14 00:36:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 02:36:48 +00:00
|
|
|
static void
|
2020-07-19 05:56:00 +00:00
|
|
|
refresh_all (GtkInspectorActions *sl)
|
2014-05-16 02:36:48 +00:00
|
|
|
{
|
2020-07-19 05:56:00 +00:00
|
|
|
reload (sl);
|
2014-05-16 02:36:48 +00:00
|
|
|
}
|
|
|
|
|
2014-05-14 00:36:02 +00:00
|
|
|
void
|
|
|
|
gtk_inspector_actions_set_object (GtkInspectorActions *sl,
|
|
|
|
GObject *object)
|
|
|
|
{
|
2019-04-02 23:24:57 +00:00
|
|
|
GtkWidget *stack;
|
|
|
|
GtkStackPage *page;
|
2020-07-19 05:56:00 +00:00
|
|
|
gboolean loaded;
|
2019-04-02 23:24:57 +00:00
|
|
|
|
|
|
|
stack = gtk_widget_get_parent (GTK_WIDGET (sl));
|
|
|
|
page = gtk_stack_get_page (GTK_STACK (stack), GTK_WIDGET (sl));
|
2020-07-19 05:56:00 +00:00
|
|
|
gtk_stack_page_set_visible (page, FALSE);
|
2019-04-02 23:24:57 +00:00
|
|
|
|
2020-07-19 05:56:00 +00:00
|
|
|
g_set_object (&sl->object, object);
|
|
|
|
loaded = reload (sl);
|
|
|
|
gtk_stack_page_set_visible (page, loaded);
|
2019-12-08 06:09:59 +00:00
|
|
|
|
2020-07-18 03:59:49 +00:00
|
|
|
gtk_column_view_sort_by_column (GTK_COLUMN_VIEW (sl->list), sl->name, GTK_SORT_ASCENDING);
|
2014-05-14 00:36:02 +00:00
|
|
|
}
|
|
|
|
|
2019-06-17 02:10:33 +00:00
|
|
|
static void
|
|
|
|
get_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkInspectorActions *sl = GTK_INSPECTOR_ACTIONS (object);
|
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
|
|
|
case PROP_BUTTON:
|
2020-07-18 03:59:49 +00:00
|
|
|
g_value_set_object (value, sl->button);
|
2019-06-17 02:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
GtkInspectorActions *sl = GTK_INSPECTOR_ACTIONS (object);
|
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
|
|
|
case PROP_BUTTON:
|
2020-07-18 03:59:49 +00:00
|
|
|
sl->button = g_value_get_object (value);
|
2019-06-17 02:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-08 06:09:59 +00:00
|
|
|
static char *
|
|
|
|
holder_name (gpointer item)
|
|
|
|
{
|
|
|
|
return g_strdup (action_holder_get_name (ACTION_HOLDER (item)));
|
|
|
|
}
|
|
|
|
|
2019-06-17 02:10:33 +00:00
|
|
|
static void
|
|
|
|
constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GtkInspectorActions *sl = GTK_INSPECTOR_ACTIONS (object);
|
2019-12-08 06:09:59 +00:00
|
|
|
GtkSorter *sorter;
|
|
|
|
GListModel *sorted;
|
|
|
|
GListModel *model;
|
2019-06-17 02:10:33 +00:00
|
|
|
|
2020-07-18 03:59:49 +00:00
|
|
|
g_signal_connect_swapped (sl->button, "clicked",
|
2019-06-17 02:10:33 +00:00
|
|
|
G_CALLBACK (refresh_all), sl);
|
2019-12-08 06:09:59 +00:00
|
|
|
|
2020-08-03 19:54:42 +00:00
|
|
|
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING,
|
2019-12-08 06:09:59 +00:00
|
|
|
NULL,
|
|
|
|
0, NULL,
|
|
|
|
(GCallback)holder_name,
|
2020-08-03 19:54:42 +00:00
|
|
|
NULL, NULL)));
|
2020-07-18 03:59:49 +00:00
|
|
|
gtk_column_view_column_set_sorter (sl->name, sorter);
|
2019-12-08 06:09:59 +00:00
|
|
|
g_object_unref (sorter);
|
2020-07-19 05:56:00 +00:00
|
|
|
|
2020-07-26 20:25:12 +00:00
|
|
|
sl->actions = g_list_store_new (ACTION_TYPE_HOLDER);
|
|
|
|
sorted = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (sl->actions)),
|
|
|
|
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list)))));
|
2019-12-08 06:09:59 +00:00
|
|
|
model = G_LIST_MODEL (gtk_no_selection_new (sorted));
|
2020-08-31 21:06:48 +00:00
|
|
|
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->list), GTK_SELECTION_MODEL (model));
|
2019-12-08 06:09:59 +00:00
|
|
|
g_object_unref (model);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-18 03:59:49 +00:00
|
|
|
dispose (GObject *object)
|
2019-12-08 06:09:59 +00:00
|
|
|
{
|
|
|
|
GtkInspectorActions *sl = GTK_INSPECTOR_ACTIONS (object);
|
2020-07-18 03:59:49 +00:00
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
g_clear_object (&sl->actions);
|
2020-07-19 05:56:00 +00:00
|
|
|
g_clear_object (&sl->object);
|
2019-12-08 06:09:59 +00:00
|
|
|
|
2020-07-18 03:59:49 +00:00
|
|
|
while ((child = gtk_widget_get_first_child (GTK_WIDGET (sl))))
|
|
|
|
gtk_widget_unparent (child);
|
2019-12-08 06:09:59 +00:00
|
|
|
|
2020-07-18 03:59:49 +00:00
|
|
|
G_OBJECT_CLASS (gtk_inspector_actions_parent_class)->dispose (object);
|
2019-06-17 02:10:33 +00:00
|
|
|
}
|
|
|
|
|
2014-05-14 00:36:02 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_actions_class_init (GtkInspectorActionsClass *klass)
|
|
|
|
{
|
2019-06-17 02:10:33 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2014-05-14 00:36:02 +00:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2020-07-18 03:59:49 +00:00
|
|
|
|
|
|
|
object_class->dispose = dispose;
|
2019-06-17 02:10:33 +00:00
|
|
|
object_class->get_property = get_property;
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
object_class->constructed = constructed;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_BUTTON,
|
|
|
|
g_param_spec_object ("button", NULL, NULL,
|
|
|
|
GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2014-05-14 00:36:02 +00:00
|
|
|
|
2014-11-30 20:59:53 +00:00
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/actions.ui");
|
2020-07-18 03:59:49 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorActions, list);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorActions, name);
|
2019-12-08 06:09:59 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, setup_name_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, bind_name_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, setup_enabled_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, bind_enabled_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, setup_parameter_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, bind_parameter_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, setup_state_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, bind_state_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, bind_changes_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, unbind_changes_cb);
|
2020-07-18 03:59:49 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
2014-05-14 00:36:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// vim: set et sw=2 ts=2:
|