[gnome-builder/wip/gtk4-port: 523/736] libide/sourceview: add API to add/remove extra menus
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 523/736] libide/sourceview: add API to add/remove extra menus
- Date: Tue, 26 Apr 2022 01:46:29 +0000 (UTC)
commit c7e407464e4b6d9c66f9c641856a53f95def6327
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 7 17:07:48 2022 -0700
libide/sourceview: add API to add/remove extra menus
src/libide/sourceview/ide-source-view.c | 26 ++++++++++++++++++++++++++
src/libide/sourceview/ide-source-view.h | 6 ++++++
2 files changed, 32 insertions(+)
---
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index 5f0e59bb6..6ed34a636 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -36,6 +36,7 @@ struct _IdeSourceView
PangoFontDescription *font_desc;
int font_scale;
double line_height;
+ IdeJoinedMenu *joined_menu;
};
enum {
@@ -168,6 +169,7 @@ ide_source_view_dispose (GObject *object)
{
IdeSourceView *self = (IdeSourceView *)object;
+ g_clear_object (&self->joined_menu);
g_clear_object (&self->css_provider);
g_clear_pointer (&self->font_desc, pango_font_description_free);
@@ -286,6 +288,10 @@ ide_source_view_init (IdeSourceView *self)
{
GtkStyleContext *style_context;
+ self->joined_menu = ide_joined_menu_new ();
+ gtk_text_view_set_extra_menu (GTK_TEXT_VIEW (self),
+ G_MENU_MODEL (self->joined_menu));
+
g_signal_connect_object (g_application_get_default (),
"notify::system-font-name",
G_CALLBACK (ide_source_view_update_css),
@@ -402,3 +408,23 @@ ide_source_view_get_zoom_level (IdeSourceView *self)
return (double)alt_size / (double)size;
}
+
+void
+ide_source_view_append_menu (IdeSourceView *self,
+ GMenuModel *menu_model)
+{
+ g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
+ g_return_if_fail (G_IS_MENU_MODEL (menu_model));
+
+ ide_joined_menu_append_menu (self->joined_menu, menu_model);
+}
+
+void
+ide_source_view_remove_menu (IdeSourceView *self,
+ GMenuModel *menu_model)
+{
+ g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
+ g_return_if_fail (G_IS_MENU_MODEL (menu_model));
+
+ ide_joined_menu_remove_menu (self->joined_menu, menu_model);
+}
diff --git a/src/libide/sourceview/ide-source-view.h b/src/libide/sourceview/ide-source-view.h
index cf7d48108..bcb3a09ec 100644
--- a/src/libide/sourceview/ide-source-view.h
+++ b/src/libide/sourceview/ide-source-view.h
@@ -52,5 +52,11 @@ void ide_source_view_set_font_desc (IdeSourceView
const PangoFontDescription *font_desc);
IDE_AVAILABLE_IN_ALL
const PangoFontDescription *ide_source_view_get_font_desc (IdeSourceView *self);
+IDE_AVAILABLE_IN_ALL
+void ide_source_view_append_menu (IdeSourceView *self,
+ GMenuModel *menu_model);
+IDE_AVAILABLE_IN_ALL
+void ide_source_view_remove_menu (IdeSourceView *self,
+ GMenuModel *menu_model);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]