[gnome-builder] comment code plugin: move to DzlShortcut classes
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] comment code plugin: move to DzlShortcut classes
- Date: Tue, 15 Aug 2017 21:57:48 +0000 (UTC)
commit 9f0106176405ba884234bc28750395902e5f771c
Author: Sebastien Lafargue <slafargue gnome org>
Date: Tue Aug 15 23:56:44 2017 +0200
comment code plugin: move to DzlShortcut classes
plugins/comment-code/gbp-comment-code-view-addin.c | 41 ++++++++++++++++++--
1 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/plugins/comment-code/gbp-comment-code-view-addin.c
b/plugins/comment-code/gbp-comment-code-view-addin.c
index 3b8103f..95d0c36 100644
--- a/plugins/comment-code/gbp-comment-code-view-addin.c
+++ b/plugins/comment-code/gbp-comment-code-view-addin.c
@@ -16,8 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
+
#include <glib.h>
#include <glib/gi18n.h>
+#include <dazzle.h>
#include <gtksourceview/gtksource.h>
#include <ide.h>
@@ -25,6 +28,8 @@
#include "gbp-comment-code-view-addin.h"
+#define I_(s) g_intern_static_string(s)
+
struct _GbpCommentCodeViewAddin
{
GObject parent_instance;
@@ -359,12 +364,26 @@ gbp_comment_code_view_addin_comment_action (GSimpleAction *action,
g_assert_not_reached ();
}
+ static const DzlShortcutEntry comment_code_shortcut_entry[] = {
+ { "org.gnome.builder.editor-view.comment-code",
+ 0, NULL,
+ NC_("shortcut window", "Editor shortcuts"),
+ NC_("shortcut window", "Editing"),
+ NC_("shortcut window", "Comment the code") },
+
+ { "org.gnome.builder.editor-view.uncomment-code",
+ 0, NULL,
+ NC_("shortcut window", "Editor shortcuts"),
+ NC_("shortcut window", "Editing"),
+ NC_("shortcut window", "Uncomment the code") },
+ };
+
static void
gbp_comment_code_view_addin_load (IdeEditorViewAddin *addin,
IdeEditorView *view)
{
GbpCommentCodeViewAddin *self;
- GtkApplication *app;
+ DzlShortcutController *controller;
GActionGroup *group;
GSimpleAction *action;
@@ -380,9 +399,23 @@ gbp_comment_code_view_addin_load (IdeEditorViewAddin *addin,
group = gtk_widget_get_action_group (GTK_WIDGET (view), "view");
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
- app = GTK_APPLICATION (g_application_get_default ());
- gtk_application_set_accels_for_action (app, "view.comment-code::0", (const gchar*[]) {"<Control>m", NULL});
- gtk_application_set_accels_for_action (app, "view.comment-code::1", (const gchar*[]) {"<Control><Shift>m",
NULL});
+ controller = dzl_shortcut_controller_find (GTK_WIDGET (view));
+ dzl_shortcut_controller_add_command_action (controller,
+ "org.gnome.builder.editor-view.comment-code",
+ I_("<primary>m"),
+ DZL_SHORTCUT_PHASE_CAPTURE,
+ "view.comment-code::0");
+
+ dzl_shortcut_controller_add_command_action (controller,
+ "org.gnome.builder.editor-view.uncomment-code",
+ I_("<primary><shift>m"),
+ DZL_SHORTCUT_PHASE_CAPTURE,
+ "view.comment-code::1");
+
+ dzl_shortcut_manager_add_shortcut_entries (NULL,
+ comment_code_shortcut_entry,
+ G_N_ELEMENTS (comment_code_shortcut_entry),
+ GETTEXT_PACKAGE);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]