[gnome-builder/wip/gtk4-port: 1497/1774] libide/foundry: add accelerator to run command
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1497/1774] libide/foundry: add accelerator to run command
- Date: Mon, 11 Jul 2022 22:31:47 +0000 (UTC)
commit 14791b7a4521ce03b112b2cbbcc489a11e316f41
Author: Christian Hergert <chergert redhat com>
Date: Tue Jun 14 01:30:05 2022 -0700
libide/foundry: add accelerator to run command
Nothing ties this up to shortcuts yet, but the goal is for that eventually.
src/libide/foundry/ide-run-command.c | 42 ++++++++++++++++++++++++++++++++++++
src/libide/foundry/ide-run-command.h | 5 +++++
2 files changed, 47 insertions(+)
---
diff --git a/src/libide/foundry/ide-run-command.c b/src/libide/foundry/ide-run-command.c
index f06934d07..8b2870514 100644
--- a/src/libide/foundry/ide-run-command.c
+++ b/src/libide/foundry/ide-run-command.c
@@ -27,6 +27,7 @@
typedef struct
{
+ char *accelerator;
char *id;
char *cwd;
char *display_name;
@@ -38,6 +39,7 @@ typedef struct
enum {
PROP_0,
+ PROP_ACCELERATOR,
PROP_ARGV,
PROP_CWD,
PROP_DISPLAY_NAME,
@@ -84,6 +86,7 @@ ide_run_command_finalize (GObject *object)
IdeRunCommand *self = (IdeRunCommand *)object;
IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+ g_clear_pointer (&priv->accelerator, g_free);
g_clear_pointer (&priv->id, g_free);
g_clear_pointer (&priv->cwd, g_free);
g_clear_pointer (&priv->display_name, g_free);
@@ -103,6 +106,10 @@ ide_run_command_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_ACCELERATOR:
+ g_value_set_string (value, ide_run_command_get_accelerator (self));
+ break;
+
case PROP_CWD:
g_value_set_string (value, ide_run_command_get_cwd (self));
break;
@@ -146,6 +153,10 @@ ide_run_command_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_ACCELERATOR:
+ ide_run_command_set_accelerator (self, g_value_get_string (value));
+ break;
+
case PROP_CWD:
ide_run_command_set_cwd (self, g_value_get_string (value));
break;
@@ -190,6 +201,11 @@ ide_run_command_class_init (IdeRunCommandClass *klass)
klass->get_arguments = ide_run_command_real_get_arguments;
+ properties [PROP_ACCELERATOR] =
+ g_param_spec_string ("accelerator", NULL, NULL,
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
properties [PROP_ARGV] =
g_param_spec_boxed ("argv", NULL, NULL,
G_TYPE_STRV,
@@ -266,6 +282,32 @@ ide_run_command_set_id (IdeRunCommand *self,
}
}
+const char *
+ide_run_command_get_accelerator (IdeRunCommand *self)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_RUN_COMMAND (self), NULL);
+
+ return priv->accelerator;
+}
+
+void
+ide_run_command_set_accelerator (IdeRunCommand *self,
+ const char *accelerator)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_RUN_COMMAND (self));
+
+ if (g_strcmp0 (priv->accelerator, accelerator) != 0)
+ {
+ g_free (priv->accelerator);
+ priv->accelerator = g_strdup (accelerator);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ACCELERATOR]);
+ }
+}
+
const char *
ide_run_command_get_cwd (IdeRunCommand *self)
{
diff --git a/src/libide/foundry/ide-run-command.h b/src/libide/foundry/ide-run-command.h
index c97edbb63..60b6e1d12 100644
--- a/src/libide/foundry/ide-run-command.h
+++ b/src/libide/foundry/ide-run-command.h
@@ -64,6 +64,11 @@ IDE_AVAILABLE_IN_ALL
void ide_run_command_set_cwd (IdeRunCommand *self,
const char *cwd);
IDE_AVAILABLE_IN_ALL
+const char *ide_run_command_get_accelerator (IdeRunCommand *self);
+IDE_AVAILABLE_IN_ALL
+void ide_run_command_set_accelerator (IdeRunCommand *self,
+ const char *accelerator);
+IDE_AVAILABLE_IN_ALL
const char *ide_run_command_get_display_name (IdeRunCommand *self);
IDE_AVAILABLE_IN_ALL
void ide_run_command_set_display_name (IdeRunCommand *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]