[gnome-builder] perspectives: allow perspectives to specify an accelerator



commit a66444cf0eb388382705696e861bfb22980e6559
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 27 19:10:11 2016 -0700

    perspectives: allow perspectives to specify an accelerator
    
    This gives an ability to hook in some features later on, even if it isn't
    strictly necessary to enforce perspectives to do this.

 libide/workbench/ide-perspective.c |   19 +++++++++++++++++++
 libide/workbench/ide-perspective.h |    2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/libide/workbench/ide-perspective.c b/libide/workbench/ide-perspective.c
index f28287f..4cec2ba 100644
--- a/libide/workbench/ide-perspective.c
+++ b/libide/workbench/ide-perspective.c
@@ -300,3 +300,22 @@ ide_perspective_is_early (IdePerspective *self)
     return IDE_PERSPECTIVE_GET_IFACE (self)->is_early (self);
   return FALSE;
 }
+
+/**
+ * ide_perspective_get_accelerator:
+ *
+ * Gets the accelerator to use to jump to the perspective. The workbench will
+ * register this accelerator on behalf of the perspective.
+ *
+ * Returns: (nullable) (transfer full): A newly allocated string or %NULL.
+ */
+gchar *
+ide_perspective_get_accelerator (IdePerspective *self)
+{
+  g_return_val_if_fail (IDE_IS_PERSPECTIVE (self), NULL);
+
+  if (IDE_PERSPECTIVE_GET_IFACE (self)->get_accelerator)
+   return IDE_PERSPECTIVE_GET_IFACE (self)->get_accelerator (self);
+
+  return NULL;
+}
diff --git a/libide/workbench/ide-perspective.h b/libide/workbench/ide-perspective.h
index 749324e..519aea8 100644
--- a/libide/workbench/ide-perspective.h
+++ b/libide/workbench/ide-perspective.h
@@ -45,6 +45,7 @@ struct _IdePerspectiveInterface
   void          (*views_foreach)       (IdePerspective *self,
                                         GtkCallback     callback,
                                         gpointer        user_data);
+  gchar        *(*get_accelerator)     (IdePerspective *self);
 };
 
 gboolean      ide_perspective_agree_to_shutdown   (IdePerspective *self);
@@ -61,6 +62,7 @@ void          ide_perspective_set_fullscreen      (IdePerspective *self,
 void          ide_perspective_views_foreach       (IdePerspective *self,
                                                    GtkCallback     callback,
                                                    gpointer        user_data);
+gchar        *ide_perspective_get_accelerator     (IdePerspective *self);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]