diff --git a/2023-10-11-035253-5786-1/index.html b/2023-10-11-035253-5786-1/index.html new file mode 100644 index 0000000..1e37a40 --- /dev/null +++ b/2023-10-11-035253-5786-1/index.html @@ -0,0 +1,97 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@cb652a28f28e
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-3.fc38) +
Date:Wed Oct 11 03:52:53 2023
+

Bug Summary

+ + + + +
Bug TypeQuantityDisplay?
All Bugs2
Unused code
Dead nested assignment2
+

Reports

+ + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead nested assignmentpluma-bookmarks-plugin.cadd_bookmark10481View Report
Unused codeDead nested assignmentpluma-bookmarks-plugin.ctoggle_bookmark10641View Report
+ + diff --git a/2023-10-11-035253-5786-1/report-6f0dd3.html b/2023-10-11-035253-5786-1/report-6f0dd3.html new file mode 100644 index 0000000..edee057 --- /dev/null +++ b/2023-10-11-035253-5786-1/report-6f0dd3.html @@ -0,0 +1,1859 @@ + + + +pluma-bookmarks-plugin.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:pluma-bookmarks-plugin.c
Warning:line 1048, column 7
Although the value stored to 'bookmark' is used in the enclosing expression, the value is never actually read from 'bookmark'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name pluma-bookmarks-plugin.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/plugins/bookmarks -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtksourceview-4 -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/pluma -D PIC -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/rootdir/plugins/bookmarks -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-11-035253-5786-1 -x c pluma-bookmarks-plugin.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * pluma-bookmarks-plugin.c - Bookmarking for pluma
3 *
4 * Copyright (C) 2008 Jesse van den Kieboom
5 * Copyright (C) 2020-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#include <config.h>
23#include "pluma-bookmarks-plugin.h"
24
25#include <stdlib.h>
26#include <glib/gi18n-lib.h>
27#include <gtk/gtk.h>
28#include <gmodule.h>
29#include <gtksourceview/gtksource.h>
30
31#include <pluma/pluma-window-activatable.h>
32#include <pluma/pluma-debug.h>
33#include <pluma/pluma-window.h>
34#include <pluma/pluma-document.h>
35
36#define BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark" "PlumaBookmarksPluginBookmark"
37#define BOOKMARK_PRIORITY1 1
38
39#define INSERT_DATA_KEY"PlumaBookmarksInsertData" "PlumaBookmarksInsertData"
40#define METADATA_ATTR"metadata::pluma-bookmarks" "metadata::pluma-bookmarks"
41
42#define MESSAGE_OBJECT_PATH"/plugins/bookmarks" "/plugins/bookmarks"
43#define BUS_CONNECT(bus, name, data)pluma_message_bus_connect(bus, "/plugins/bookmarks", "name", (
PlumaMessageCallback) message_name_cb, data, ((void*)0))
pluma_message_bus_connect(bus, MESSAGE_OBJECT_PATH"/plugins/bookmarks", #name, (PlumaMessageCallback) message_##name##_cb, data, NULL((void*)0))
44
45typedef struct
46{
47 GtkSourceMark *bookmark;
48 GtkTextMark *mark;
49} InsertTracker;
50
51typedef struct
52{
53 GSList *trackers;
54 guint user_action;
55} InsertData;
56
57static void on_style_scheme_notify (GObject *object,
58 GParamSpec *pspec,
59 PlumaView *view);
60
61static void on_delete_range (GtkTextBuffer *buffer,
62 GtkTextIter *start,
63 GtkTextIter *end,
64 gpointer user_data);
65
66static void on_insert_text_before (GtkTextBuffer *buffer,
67 GtkTextIter *location,
68 gchar *text,
69 gint len,
70 InsertData *data);
71
72static void on_begin_user_action (GtkTextBuffer *buffer,
73 InsertData *data);
74
75static void on_end_user_action (GtkTextBuffer *buffer,
76 InsertData *data);
77
78static void on_toggle_bookmark_activate (GtkAction *action,
79 PlumaBookmarksPlugin *plugin);
80static void on_next_bookmark_activate (GtkAction *action,
81 PlumaBookmarksPlugin *plugin);
82static void on_previous_bookmark_activate (GtkAction *action,
83 PlumaBookmarksPlugin *plugin);
84static void on_tab_added (PlumaWindow *window,
85 PlumaTab *tab,
86 PlumaBookmarksPlugin *plugin);
87static void on_tab_removed (PlumaWindow *window,
88 PlumaTab *tab,
89 PlumaBookmarksPlugin *plugin);
90
91static void add_bookmark (GtkSourceBuffer *buffer, GtkTextIter *iter);
92static void remove_bookmark (GtkSourceBuffer *buffer, GtkTextIter *iter);
93static void toggle_bookmark (GtkSourceBuffer *buffer, GtkTextIter *iter);
94
95static void pluma_window_activatable_iface_init (PlumaWindowActivatableInterface *iface);
96
97struct _PlumaBookmarksPluginPrivate
98{
99 PlumaWindow *window;
100
101 GtkActionGroup *action_group;
102 guint ui_id;
103};
104
105G_DEFINE_DYNAMIC_TYPE_EXTENDED (PlumaBookmarksPlugin,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
106 pluma_bookmarks_plugin,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
107 PEAS_TYPE_EXTENSION_BASE,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
108 0,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
109 G_ADD_PRIVATE_DYNAMIC (PlumaBookmarksPlugin)static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
110 G_IMPLEMENT_INTERFACE_DYNAMIC (PLUMA_TYPE_WINDOW_ACTIVATABLE,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
111 pluma_window_activatable_iface_init))static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
112
113enum
114{
115 PROP_0,
116 PROP_WINDOW
117};
118
119static void
120pluma_bookmarks_plugin_init (PlumaBookmarksPlugin *plugin)
121{
122 pluma_debug_message (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 122, ((const
char*) (__func__))
, "PlumaBookmarksPlugin initializing");
123
124 plugin->priv = pluma_bookmarks_plugin_get_instance_private (plugin);
125}
126
127static void
128pluma_bookmarks_plugin_dispose (GObject *object)
129{
130 PlumaBookmarksPlugin *plugin = PLUMA_BOOKMARKS_PLUGIN (object)((((PlumaBookmarksPlugin*) (void *) ((object)))));
131
132 pluma_debug_message (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 132, ((const
char*) (__func__))
, "PlumaBookmarksPlugin disposing");
133
134 if (plugin->priv->action_group != NULL((void*)0))
135 {
136 g_object_unref (plugin->priv->action_group);
137 plugin->priv->action_group = NULL((void*)0);
138 }
139
140 if (plugin->priv->window != NULL((void*)0))
141 {
142 g_object_unref (plugin->priv->window);
143 plugin->priv->window = NULL((void*)0);
144 }
145
146 G_OBJECT_CLASS (pluma_bookmarks_plugin_parent_class)((((GObjectClass*) (void *) ((pluma_bookmarks_plugin_parent_class
)))))
->dispose (object);
147}
148
149static void
150pluma_bookmarks_plugin_set_property (GObject *object,
151 guint prop_id,
152 const GValue *value,
153 GParamSpec *pspec)
154{
155 PlumaBookmarksPlugin *plugin = PLUMA_BOOKMARKS_PLUGIN (object)((((PlumaBookmarksPlugin*) (void *) ((object)))));
156
157 switch (prop_id)
158 {
159 case PROP_WINDOW:
160 plugin->priv->window = PLUMA_WINDOW (g_value_dup_object (value))((((PlumaWindow*) (void *) ((g_value_dup_object (value))))));
161 break;
162
163 default:
164 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "pluma-bookmarks-plugin.c", 164, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
165 break;
166 }
167}
168
169static void
170pluma_bookmarks_plugin_get_property (GObject *object,
171 guint prop_id,
172 GValue *value,
173 GParamSpec *pspec)
174{
175 PlumaBookmarksPlugin *plugin = PLUMA_BOOKMARKS_PLUGIN (object)((((PlumaBookmarksPlugin*) (void *) ((object)))));
176
177 switch (prop_id)
178 {
179 case PROP_WINDOW:
180 g_value_set_object (value, plugin->priv->window);
181 break;
182
183 default:
184 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "pluma-bookmarks-plugin.c", 184, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
185 break;
186 }
187}
188
189static void
190free_insert_data (InsertData *data)
191{
192 g_slice_free (InsertData, data)do { if (1) g_slice_free1 (sizeof (InsertData), (data)); else
(void) ((InsertData*) 0 == (data)); } while (0)
;
193}
194
195static GtkActionEntry const action_entries[] = {
196 {"ToggleBookmark", NULL((void*)0), N_("Toggle Bookmark")("Toggle Bookmark"), "<Control><Alt>B",
197 N_("Toggle bookmark status of the current line")("Toggle bookmark status of the current line"),
198 G_CALLBACK (on_toggle_bookmark_activate)((GCallback) (on_toggle_bookmark_activate))},
199 {"NextBookmark", NULL((void*)0), N_("Go to Next Bookmark")("Go to Next Bookmark"), "<Control>B",
200 N_("Go to the next bookmark")("Go to the next bookmark"),
201 G_CALLBACK (on_next_bookmark_activate)((GCallback) (on_next_bookmark_activate))},
202 {"PreviousBookmark", NULL((void*)0), N_("Go to Previous Bookmark")("Go to Previous Bookmark"), "<Control><Shift>B",
203 N_("Go to the previous bookmark")("Go to the previous bookmark"),
204 G_CALLBACK (on_previous_bookmark_activate)((GCallback) (on_previous_bookmark_activate))}
205};
206
207static gchar const uidefinition[] = ""
208"<ui>"
209" <menubar name='MenuBar'>"
210" <menu name='EditMenu' action='Edit'>"
211" <placeholder name='EditOps_6'>"
212" <menuitem action='ToggleBookmark'/>"
213" <menuitem action='PreviousBookmark'/>"
214" <menuitem action='NextBookmark'/>"
215" </placeholder>"
216" </menu>"
217" </menubar>"
218"</ui>";
219
220static void
221install_menu (PlumaBookmarksPlugin *plugin)
222{
223 PlumaBookmarksPluginPrivate *priv;
224 GtkUIManager *manager;
225 GError *error = NULL((void*)0);
226
227 priv = plugin->priv;
228 manager = pluma_window_get_ui_manager (priv->window);
229 priv->action_group = gtk_action_group_new ("PlumaBookmarksPluginActions");
230
231 gtk_action_group_set_translation_domain (priv->action_group,
232 GETTEXT_PACKAGE"pluma-plugins");
233
234 gtk_action_group_add_actions (priv->action_group,
235 action_entries,
236 G_N_ELEMENTS (action_entries)(sizeof (action_entries) / sizeof ((action_entries)[0])),
237 plugin);
238
239 gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
240 priv->ui_id = gtk_ui_manager_add_ui_from_string (manager, uidefinition, -1, &error);
241
242 if (!priv->ui_id)
243 {
244 g_warning ("Could not load UI: %s", error->message);
245 g_error_free (error);
246 }
247}
248
249static void
250uninstall_menu (PlumaBookmarksPlugin *plugin)
251{
252 PlumaBookmarksPluginPrivate *priv;
253 GtkUIManager *manager;
254
255 priv = plugin->priv;
256 manager = pluma_window_get_ui_manager (priv->window);
257
258 gtk_ui_manager_remove_ui (manager, priv->ui_id);
259 gtk_ui_manager_remove_action_group (manager, priv->action_group);
260
261 g_object_unref (priv->action_group);
262 priv->action_group = NULL((void*)0);
263}
264
265static void
266remove_all_bookmarks (GtkSourceBuffer *buffer)
267{
268 GtkTextIter start;
269 GtkTextIter end;
270
271 pluma_debug (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 271, ((const
char*) (__func__))
);
272
273 gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (buffer)((((GtkTextBuffer*) (void *) ((buffer))))), &start, &end);
274 gtk_source_buffer_remove_source_marks (buffer,
275 &start,
276 &end,
277 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
278}
279
280static void
281disable_bookmarks (PlumaView *view)
282{
283 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))));
284 gpointer data;
285
286 gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW (view)((((GtkSourceView*) (void *) ((view))))), FALSE(0));
287 remove_all_bookmarks (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))));
288
289 g_signal_handlers_disconnect_by_func (buffer, on_style_scheme_notify, view)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_style_scheme_notify), (view))
;
290 g_signal_handlers_disconnect_by_func (buffer, on_delete_range, NULL)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_delete_range), (((void*)0)))
;
291
292 data = g_object_get_data (G_OBJECT (buffer)((((GObject*) (void *) ((buffer))))), INSERT_DATA_KEY"PlumaBookmarksInsertData");
293
294 g_signal_handlers_disconnect_by_func (buffer, on_insert_text_before, data)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_insert_text_before), (data))
;
295 g_signal_handlers_disconnect_by_func (buffer, on_begin_user_action, data)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_begin_user_action), (data))
;
296 g_signal_handlers_disconnect_by_func (buffer, on_end_user_action, data)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_end_user_action), (data))
;
297
298 g_object_set_data (G_OBJECT (buffer)((((GObject*) (void *) ((buffer))))), INSERT_DATA_KEY"PlumaBookmarksInsertData", NULL((void*)0));
299}
300
301static GdkPixbuf *
302get_bookmark_pixbuf (PlumaBookmarksPlugin *plugin)
303{
304 GdkPixbuf *pixbuf;
305 gint width;
306 GError *error = NULL((void*)0);
307
308 gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL((void*)0));
309 pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
310 "user-bookmarks-symbolic",
311 (width * 2) / 3,
312 0,
313 &error);
314
315 if (error != NULL((void*)0))
316 {
317 g_warning ("Could not load theme icon user-bookmarks-symbolic: %s",
318 error->message);
319 g_error_free (error);
320 }
321
322 return pixbuf;
323}
324
325static void
326update_background_color (GtkSourceMarkAttributes *attrs,
327 GtkSourceBuffer *buffer)
328{
329 GtkSourceStyleScheme *scheme;
330 GtkSourceStyle *style;
331
332 scheme = gtk_source_buffer_get_style_scheme (buffer);
333 style = gtk_source_style_scheme_get_style (scheme, "search-match");
334
335 if (style)
336 {
337 gboolean bgset;
338 gchar *bg;
339
340 g_object_get (style, "background-set", &bgset, "background", &bg, NULL((void*)0));
341
342 if (bgset)
343 {
344 GdkRGBA color;
345
346 gdk_rgba_parse (&color, bg);
347 gtk_source_mark_attributes_set_background (attrs, &color);
348 g_free (bg);
349
350 return;
351 }
352 }
353
354 gtk_source_mark_attributes_set_background (attrs, NULL((void*)0));
355}
356
357static void
358enable_bookmarks (PlumaView *view,
359 PlumaBookmarksPlugin *plugin)
360{
361 GdkPixbuf *pixbuf;
362
363 pixbuf = get_bookmark_pixbuf (plugin);
364
365 /* Make sure the category pixbuf is set */
366 if (pixbuf)
367 {
368 GtkTextBuffer *buffer;
369 GtkSourceMarkAttributes *attrs;
370 InsertData *data;
371
372 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))));
373
374 attrs = gtk_source_mark_attributes_new ();
375
376 update_background_color (attrs, GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))));
377 gtk_source_mark_attributes_set_pixbuf (attrs, pixbuf);
378 g_object_unref (pixbuf);
379
380 gtk_source_view_set_mark_attributes (GTK_SOURCE_VIEW (view)((((GtkSourceView*) (void *) ((view))))),
381 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
382 attrs,
383 BOOKMARK_PRIORITY1);
384
385 gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW (view)((((GtkSourceView*) (void *) ((view))))), TRUE(!(0)));
386
387 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("notify::style-scheme"), ((
(GCallback) (on_style_scheme_notify))), (view), ((void*)0), (
GConnectFlags) 0)
388 "notify::style-scheme",g_signal_connect_data ((buffer), ("notify::style-scheme"), ((
(GCallback) (on_style_scheme_notify))), (view), ((void*)0), (
GConnectFlags) 0)
389 G_CALLBACK (on_style_scheme_notify),g_signal_connect_data ((buffer), ("notify::style-scheme"), ((
(GCallback) (on_style_scheme_notify))), (view), ((void*)0), (
GConnectFlags) 0)
390 view)g_signal_connect_data ((buffer), ("notify::style-scheme"), ((
(GCallback) (on_style_scheme_notify))), (view), ((void*)0), (
GConnectFlags) 0)
;
391
392 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("delete-range"), (((GCallback
) (on_delete_range))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
393 "delete-range",g_signal_connect_data ((buffer), ("delete-range"), (((GCallback
) (on_delete_range))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
394 G_CALLBACK (on_delete_range),g_signal_connect_data ((buffer), ("delete-range"), (((GCallback
) (on_delete_range))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
395 NULL)g_signal_connect_data ((buffer), ("delete-range"), (((GCallback
) (on_delete_range))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
396
397 data = g_slice_new0 (InsertData)(InsertData *) (__extension__ ({ gsize __s = sizeof (InsertData
); gpointer __p; __p = g_slice_alloc (__s); memset (__p, 0, __s
); __p; }))
;
398
399 g_object_set_data_full (G_OBJECT (buffer)((((GObject*) (void *) ((buffer))))),
400 INSERT_DATA_KEY"PlumaBookmarksInsertData",
401 data,
402 (GDestroyNotify) free_insert_data);
403
404 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("insert-text"), (((GCallback
) (on_insert_text_before))), (data), ((void*)0), (GConnectFlags
) 0)
405 "insert-text",g_signal_connect_data ((buffer), ("insert-text"), (((GCallback
) (on_insert_text_before))), (data), ((void*)0), (GConnectFlags
) 0)
406 G_CALLBACK (on_insert_text_before),g_signal_connect_data ((buffer), ("insert-text"), (((GCallback
) (on_insert_text_before))), (data), ((void*)0), (GConnectFlags
) 0)
407 data)g_signal_connect_data ((buffer), ("insert-text"), (((GCallback
) (on_insert_text_before))), (data), ((void*)0), (GConnectFlags
) 0)
;
408
409 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("begin-user-action"), (((GCallback
) (on_begin_user_action))), (data), ((void*)0), (GConnectFlags
) 0)
410 "begin-user-action",g_signal_connect_data ((buffer), ("begin-user-action"), (((GCallback
) (on_begin_user_action))), (data), ((void*)0), (GConnectFlags
) 0)
411 G_CALLBACK (on_begin_user_action),g_signal_connect_data ((buffer), ("begin-user-action"), (((GCallback
) (on_begin_user_action))), (data), ((void*)0), (GConnectFlags
) 0)
412 data)g_signal_connect_data ((buffer), ("begin-user-action"), (((GCallback
) (on_begin_user_action))), (data), ((void*)0), (GConnectFlags
) 0)
;
413
414 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("end-user-action"), (((GCallback
) (on_end_user_action))), (data), ((void*)0), (GConnectFlags)
0)
415 "end-user-action",g_signal_connect_data ((buffer), ("end-user-action"), (((GCallback
) (on_end_user_action))), (data), ((void*)0), (GConnectFlags)
0)
416 G_CALLBACK (on_end_user_action),g_signal_connect_data ((buffer), ("end-user-action"), (((GCallback
) (on_end_user_action))), (data), ((void*)0), (GConnectFlags)
0)
417 data)g_signal_connect_data ((buffer), ("end-user-action"), (((GCallback
) (on_end_user_action))), (data), ((void*)0), (GConnectFlags)
0)
;
418
419 }
420 else
421 {
422 g_warning ("Could not set bookmark icon!");
423 }
424}
425
426static void
427load_bookmarks (PlumaView *view,
428 gchar **bookmarks)
429{
430 GtkSourceBuffer *buf;
431 GtkTextIter iter;
432 gint tot_lines;
433 gint i;
434
435 pluma_debug (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 435, ((const
char*) (__func__))
);
436
437 buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((GtkSourceBuffer*) (void *) ((gtk_text_view_get_buffer (((
((GtkTextView*) (void *) ((view)))))))))))
;
438
439 gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (buf)((((GtkTextBuffer*) (void *) ((buf))))), &iter);
440 tot_lines = gtk_text_iter_get_line (&iter);
441
442 for (i = 0; bookmarks != NULL((void*)0) && bookmarks[i] != NULL((void*)0); i++)
443 {
444 gint line;
445
446 line = atoi (bookmarks[i]);
447
448 if (line >= 0 && line < tot_lines)
449 {
450 GSList *marks;
451
452 gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (buf)((((GtkTextBuffer*) (void *) ((buf))))),
453 &iter, line);
454
455 marks = gtk_source_buffer_get_source_marks_at_iter (buf, &iter,
456 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
457 if (marks == NULL((void*)0))
458 /* Add new bookmark */
459 gtk_source_buffer_create_source_mark (buf,
460 NULL((void*)0),
461 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
462 &iter);
463 else
464 g_slist_free (marks);
465 }
466 }
467}
468
469static void
470load_bookmark_metadata (PlumaView *view)
471{
472 PlumaDocument *doc;
473 gchar *bookmarks_attr;
474
475 doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((PlumaDocument*) (void *) ((gtk_text_view_get_buffer (((((
GtkTextView*) (void *) ((view)))))))))))
;
476 bookmarks_attr = pluma_document_get_metadata (doc, METADATA_ATTR"metadata::pluma-bookmarks");
477
478 if (bookmarks_attr != NULL((void*)0))
479 {
480 gchar **bookmarks;
481
482 bookmarks = g_strsplit (bookmarks_attr, ",", -1);
483 g_free (bookmarks_attr);
484
485 load_bookmarks (view, bookmarks);
486
487 g_strfreev (bookmarks);
488 }
489}
490
491typedef gboolean (*IterSearchFunc)(GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar *category);
492typedef void (*CycleFunc)(GtkTextBuffer *buffer, GtkTextIter *iter);
493
494static void
495goto_bookmark (PlumaWindow *window,
496 GtkSourceView *view,
497 GtkTextIter *iter,
498 IterSearchFunc func,
499 CycleFunc cycle_func)
500{
501 GtkTextBuffer *buffer;
502 GtkTextIter at;
503 GtkTextIter end;
504
505 if (view == NULL((void*)0))
506 view = GTK_SOURCE_VIEW (pluma_window_get_active_view (window))((((GtkSourceView*) (void *) ((pluma_window_get_active_view (
window))))))
;
507
508 g_return_if_fail (view != NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_18
; if (view != ((void*)0)) _g_boolean_var_18 = 1; else _g_boolean_var_18
= 0; _g_boolean_var_18; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view != NULL"); return
; } } while (0)
;
509
510 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))));
511
512 if (iter == NULL((void*)0))
513 gtk_text_buffer_get_iter_at_mark (buffer,
514 &at,
515 gtk_text_buffer_get_insert (buffer));
516 else
517 at = *iter;
518
519 /* Move the iter to the beginning of the line, where the bookmarks are */
520 gtk_text_iter_set_line_offset (&at, 0);
521
522 /* Try to find the next bookmark */
523 if (!func (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))), &at, BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark"))
524 {
525 GSList *marks;
526
527 /* cycle through */
528 cycle_func (buffer, &at);
529 gtk_text_iter_set_line_offset (&at, 0);
530
531 marks = gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
532 &at,
533 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
534
535 if (!marks && !func (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))), &at, BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark"))
536 return;
537
538 g_slist_free (marks);
539 }
540
541 end = at;
542 if (!gtk_text_iter_forward_visible_line (&end))
543 gtk_text_buffer_get_end_iter (buffer, &end);
544 else
545 gtk_text_iter_backward_char (&end);
546
547 gtk_text_buffer_select_range (buffer, &at, &end);
548 gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))), &at, 0.3, FALSE(0), 0, 0);
549}
550
551static void
552message_get_view_iter (PlumaWindow *window,
553 PlumaMessage *message,
554 GtkSourceView **view,
555 GtkTextIter *iter)
556{
557 if (pluma_message_has_key (message, "view"))
558 pluma_message_get (message, "view", view, NULL((void*)0));
559 else
560 *view = GTK_SOURCE_VIEW (pluma_window_get_active_view (window))((((GtkSourceView*) (void *) ((pluma_window_get_active_view (
window))))))
;
561
562 g_return_if_fail (*view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_19
; if (*view) _g_boolean_var_19 = 1; else _g_boolean_var_19 = 0
; _g_boolean_var_19; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "*view"); return;
} } while (0)
;
563
564 if (pluma_message_has_key (message, "iter"))
565 {
566 pluma_message_get (message, "iter", iter, NULL((void*)0));
567 }
568 else
569 {
570 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (*view)((((GtkTextView*) (void *) ((*view))))));
571 gtk_text_buffer_get_iter_at_mark (buffer,
572 iter,
573 gtk_text_buffer_get_insert (buffer));
574 }
575}
576
577static void
578message_toggle_cb (PlumaMessageBus *bus,
579 PlumaMessage *message,
580 PlumaWindow *window)
581{
582 GtkSourceView *view = NULL((void*)0);
583 GtkTextIter iter;
584
585 message_get_view_iter (window, message, &view, &iter);
586
587 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_20
; if (view) _g_boolean_var_20 = 1; else _g_boolean_var_20 = 0
; _g_boolean_var_20; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
588
589 toggle_bookmark (GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((GtkSourceBuffer*) (void *) ((gtk_text_view_get_buffer (((
((GtkTextView*) (void *) ((view)))))))))))
,
590 &iter);
591}
592
593static void
594message_add_cb (PlumaMessageBus *bus,
595 PlumaMessage *message,
596 PlumaWindow *window)
597{
598 GtkSourceView *view = NULL((void*)0);
599 GtkTextIter iter;
600
601 message_get_view_iter (window, message, &view, &iter);
602
603 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_21
; if (view) _g_boolean_var_21 = 1; else _g_boolean_var_21 = 0
; _g_boolean_var_21; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
604
605 add_bookmark (GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((GtkSourceBuffer*) (void *) ((gtk_text_view_get_buffer (((
((GtkTextView*) (void *) ((view)))))))))))
,
606 &iter);
607}
608
609static void
610message_remove_cb (PlumaMessageBus *bus,
611 PlumaMessage *message,
612 PlumaWindow *window)
613{
614 GtkSourceView *view = NULL((void*)0);
615 GtkTextIter iter;
616
617 message_get_view_iter (window, message, &view, &iter);
618
619 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_22
; if (view) _g_boolean_var_22 = 1; else _g_boolean_var_22 = 0
; _g_boolean_var_22; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
620
621 remove_bookmark (GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((GtkSourceBuffer*) (void *) ((gtk_text_view_get_buffer (((
((GtkTextView*) (void *) ((view)))))))))))
,
622 &iter);
623}
624
625static void
626message_goto_next_cb (PlumaMessageBus *bus,
627 PlumaMessage *message,
628 PlumaWindow *window)
629{
630 GtkSourceView *view = NULL((void*)0);
631 GtkTextIter iter;
632
633 message_get_view_iter (window, message, &view, &iter);
634
635 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_23
; if (view) _g_boolean_var_23 = 1; else _g_boolean_var_23 = 0
; _g_boolean_var_23; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
636
637 goto_bookmark (window,
638 view,
639 &iter,
640 gtk_source_buffer_forward_iter_to_source_mark,
641 gtk_text_buffer_get_start_iter);
642}
643
644static void
645message_goto_previous_cb (PlumaMessageBus *bus,
646 PlumaMessage *message,
647 PlumaWindow *window)
648{
649 GtkSourceView *view = NULL((void*)0);
650 GtkTextIter iter;
651
652 message_get_view_iter (window, message, &view, &iter);
653
654 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_24
; if (view) _g_boolean_var_24 = 1; else _g_boolean_var_24 = 0
; _g_boolean_var_24; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
655
656 goto_bookmark (window,
657 view,
658 &iter,
659 gtk_source_buffer_backward_iter_to_source_mark,
660 gtk_text_buffer_get_end_iter);
661}
662
663static void
664install_messages (PlumaWindow *window)
665{
666 PlumaMessageBus *bus = pluma_window_get_message_bus (window);
667
668 pluma_message_bus_register (bus,
669 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
670 "toggle",
671 2,
672 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
673 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
674 NULL((void*)0));
675
676 pluma_message_bus_register (bus,
677 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
678 "add",
679 2,
680 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
681 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
682 NULL((void*)0));
683
684 pluma_message_bus_register (bus,
685 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
686 "remove",
687 2,
688 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
689 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
690 NULL((void*)0));
691
692 pluma_message_bus_register (bus,
693 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
694 "goto_next",
695 2,
696 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
697 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
698 NULL((void*)0));
699
700 pluma_message_bus_register (bus,
701 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
702 "goto_previous",
703 2,
704 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
705 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
706 NULL((void*)0));
707
708 BUS_CONNECT (bus, toggle, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "toggle"
, (PlumaMessageCallback) message_toggle_cb, window, ((void*)0
))
;
709 BUS_CONNECT (bus, add, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "add", (
PlumaMessageCallback) message_add_cb, window, ((void*)0))
;
710 BUS_CONNECT (bus, remove, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "remove"
, (PlumaMessageCallback) message_remove_cb, window, ((void*)0
))
;
711 BUS_CONNECT (bus, goto_next, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "goto_next"
, (PlumaMessageCallback) message_goto_next_cb, window, ((void
*)0))
;
712 BUS_CONNECT (bus, goto_previous, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "goto_previous"
, (PlumaMessageCallback) message_goto_previous_cb, window, ((
void*)0))
;
713}
714
715static void
716uninstall_messages (PlumaWindow *window)
717{
718 PlumaMessageBus *bus = pluma_window_get_message_bus (window);
719 pluma_message_bus_unregister_all (bus, MESSAGE_OBJECT_PATH"/plugins/bookmarks");
720}
721
722static void
723pluma_bookmarks_plugin_activate (PlumaWindowActivatable *activatable)
724{
725 PlumaBookmarksPluginPrivate *priv;
726 GList *views;
727 GList *item;
728
729 pluma_debug (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 729, ((const
char*) (__func__))
);
730
731 priv = PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable)))))->priv;
732
733 views = pluma_window_get_views (priv->window);
734 for (item = views; item != NULL((void*)0); item = item->next)
735 {
736 enable_bookmarks (PLUMA_VIEW (item->data)((((PlumaView*) (void *) ((item->data))))),
737 PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable))))));
738 load_bookmark_metadata (PLUMA_VIEW (item->data)((((PlumaView*) (void *) ((item->data))))));
739 }
740
741 g_list_free (views);
742
743 g_signal_connect (priv->window, "tab-added",g_signal_connect_data ((priv->window), ("tab-added"), (((GCallback
) (on_tab_added))), (activatable), ((void*)0), (GConnectFlags
) 0)
744 G_CALLBACK (on_tab_added), activatable)g_signal_connect_data ((priv->window), ("tab-added"), (((GCallback
) (on_tab_added))), (activatable), ((void*)0), (GConnectFlags
) 0)
;
745
746 g_signal_connect (priv->window, "tab-removed",g_signal_connect_data ((priv->window), ("tab-removed"), ((
(GCallback) (on_tab_removed))), (activatable), ((void*)0), (GConnectFlags
) 0)
747 G_CALLBACK (on_tab_removed), activatable)g_signal_connect_data ((priv->window), ("tab-removed"), ((
(GCallback) (on_tab_removed))), (activatable), ((void*)0), (GConnectFlags
) 0)
;
748
749 install_menu (PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable))))));
750 install_messages (priv->window);
751}
752
753static void
754pluma_bookmarks_plugin_update_state (PlumaWindowActivatable *activatable)
755{
756 PlumaBookmarksPluginPrivate *priv;
757
758 priv = PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable)))))->priv;
759 gtk_action_group_set_sensitive (priv->action_group,
760 pluma_window_get_active_view (priv->window) != NULL((void*)0));
761}
762
763static void
764save_bookmark_metadata (PlumaView *view)
765{
766 GtkTextIter iter;
767 GtkTextBuffer *buf;
768 GString *string;
769 gchar *val = NULL((void*)0);
770 gboolean first = TRUE(!(0));
771
772 buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))));
773 gtk_text_buffer_get_start_iter (buf, &iter);
774 string = g_string_new (NULL((void*)0));
775
776 while (gtk_source_buffer_forward_iter_to_source_mark (GTK_SOURCE_BUFFER (buf)((((GtkSourceBuffer*) (void *) ((buf))))),
777 &iter,
778 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark"))
779 {
780 gint line;
781
782 line = gtk_text_iter_get_line (&iter);
783
784 if (!first)
785 {
786 g_string_append_printf (string, ",%d", line);
787 }
788 else
789 {
790 g_string_append_printf (string, "%d", line);
791 first = FALSE(0);
792 }
793 }
794
795 if (string->len == 0)
796 {
797 val = g_string_free (string, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(string), ((!(0)))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((!(0)))))
;
798 }
799 else
800 {
801 val = g_string_free (string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((string
), ((0))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((0))))
;
802 }
803
804 pluma_document_set_metadata (PLUMA_DOCUMENT (buf)((((PlumaDocument*) (void *) ((buf))))), METADATA_ATTR"metadata::pluma-bookmarks",
805 val, NULL((void*)0));
806
807 g_free (val);
808}
809
810static void
811pluma_bookmarks_plugin_deactivate (PlumaWindowActivatable *activatable)
812{
813 PlumaBookmarksPluginPrivate *priv;
814 GList *views;
815 GList *item;
816
817 pluma_debug (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 817, ((const
char*) (__func__))
);
818
819 priv = PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable)))))->priv;
820
821 uninstall_menu (PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable))))));
822 uninstall_messages (priv->window);
823
824 views = pluma_window_get_views (priv->window);
825
826 for (item = views; item != NULL((void*)0); item = item->next)
827 disable_bookmarks (PLUMA_VIEW (item->data)((((PlumaView*) (void *) ((item->data))))));
828
829 g_list_free (views);
830
831 g_signal_handlers_disconnect_by_func (priv->window, on_tab_added, activatable)g_signal_handlers_disconnect_matched ((priv->window), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_tab_added), (activatable))
;
832 g_signal_handlers_disconnect_by_func (priv->window, on_tab_removed, activatable)g_signal_handlers_disconnect_matched ((priv->window), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_tab_removed), (activatable))
;
833}
834
835static void
836pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass *klass)
837{
838 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) ((klass)))));
839
840 object_class->dispose = pluma_bookmarks_plugin_dispose;
841 object_class->set_property = pluma_bookmarks_plugin_set_property;
842 object_class->get_property = pluma_bookmarks_plugin_get_property;
843
844 g_object_class_override_property (object_class, PROP_WINDOW, "window");
845}
846
847static void
848pluma_bookmarks_plugin_class_finalize (PlumaBookmarksPluginClass *klass)
849{
850}
851
852static void
853on_style_scheme_notify (GObject *object,
854 GParamSpec *pspec,
855 PlumaView *view)
856{
857 GtkSourceMarkAttributes *attrs;
858
859 attrs = gtk_source_view_get_mark_attributes (GTK_SOURCE_VIEW (view)((((GtkSourceView*) (void *) ((view))))),
860 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
861 NULL((void*)0));
862
863 update_background_color (attrs, GTK_SOURCE_BUFFER (object)((((GtkSourceBuffer*) (void *) ((object))))));
864}
865
866static void
867on_delete_range (GtkTextBuffer *buffer,
868 GtkTextIter *start,
869 GtkTextIter *end,
870 gpointer user_data)
871{
872 GtkTextIter start_iter;
873 GtkTextIter end_iter;
874 gboolean keep_bookmark;
875
876 /* Nothing to do for us here. The bookmark, if any, will stay at the
877 beginning of the line due to its left gravity. */
878 if (gtk_text_iter_get_line (start) == gtk_text_iter_get_line (end))
879 return;
880
881 start_iter = *start;
882 gtk_text_iter_set_line_offset (&start_iter, 0);
883
884 end_iter = *end;
885 gtk_text_iter_set_line_offset (&end_iter, 0);
886
887 keep_bookmark = ((gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
888 &start_iter,
889 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark") != NULL((void*)0)) ||
890 (gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
891 &end_iter,
892 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark") != NULL((void*)0)));
893
894 /* Remove all bookmarks in the range. */
895 gtk_source_buffer_remove_source_marks (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
896 &start_iter,
897 &end_iter,
898 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
899
900 if (keep_bookmark)
901 gtk_source_buffer_create_source_mark (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
902 NULL((void*)0),
903 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
904 &start_iter);
905}
906
907static void
908on_begin_user_action (GtkTextBuffer *buffer,
909 InsertData *data)
910{
911 ++data->user_action;
912}
913
914static void
915on_end_user_action (GtkTextBuffer *buffer,
916 InsertData *data)
917{
918 GSList *item;
919
920 if (--data->user_action > 0)
921 return;
922
923 /* Remove trackers */
924 for (item = data->trackers; item; item = g_slist_next (item)((item) ? (((GSList *)(item))->next) : ((void*)0)))
925 {
926 InsertTracker *tracker = item->data;
927 GtkTextIter curloc;
928 GtkTextIter newloc;
929
930 /* Move the category to the line where the mark now is */
931 gtk_text_buffer_get_iter_at_mark (buffer,
932 &curloc,
933 GTK_TEXT_MARK (tracker->bookmark)((((GtkTextMark*) (void *) ((tracker->bookmark))))));
934
935 gtk_text_buffer_get_iter_at_mark (buffer,
936 &newloc,
937 tracker->mark);
938
939 if (gtk_text_iter_get_line (&curloc) != gtk_text_iter_get_line (&newloc))
940 {
941 gtk_text_iter_set_line_offset (&newloc, 0);
942 gtk_text_buffer_move_mark (buffer,
943 GTK_TEXT_MARK (tracker->bookmark)((((GtkTextMark*) (void *) ((tracker->bookmark))))),
944 &newloc);
945 }
946
947 gtk_text_buffer_delete_mark (buffer, tracker->mark);
948 g_slice_free (InsertTracker, tracker)do { if (1) g_slice_free1 (sizeof (InsertTracker), (tracker))
; else (void) ((InsertTracker*) 0 == (tracker)); } while (0)
;
949 }
950
951 g_slist_free (data->trackers);
952 data->trackers = NULL((void*)0);
953}
954
955static void
956add_tracker (GtkTextBuffer *buffer,
957 GtkTextIter *iter,
958 GtkSourceMark *bookmark,
959 InsertData *data)
960{
961 GSList *item;
962 InsertTracker *tracker;
963
964 for (item = data->trackers; item; item = g_slist_next (item)((item) ? (((GSList *)(item))->next) : ((void*)0)))
965 {
966 tracker = item->data;
967
968 if (tracker->bookmark == bookmark)
969 return;
970 }
971
972 tracker = g_slice_new (InsertTracker)((InsertTracker*) g_slice_alloc (sizeof (InsertTracker)));
973 tracker->bookmark = bookmark;
974 tracker->mark = gtk_text_buffer_create_mark (buffer,
975 NULL((void*)0),
976 iter,
977 FALSE(0));
978
979 data->trackers = g_slist_prepend (data->trackers, tracker);
980}
981
982static void
983on_insert_text_before (GtkTextBuffer *buffer,
984 GtkTextIter *location,
985 gchar *text,
986 gint len,
987 InsertData *data)
988{
989 if (gtk_text_iter_starts_line (location))
990 {
991 GSList *marks;
992 marks = gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
993 location,
994 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
995
996 if (marks != NULL((void*)0))
997 {
998 add_tracker (buffer, location, marks->data, data);
999 g_slist_free (marks);
1000 }
1001 }
1002}
1003
1004static GtkSourceMark *
1005get_bookmark_and_iter (GtkSourceBuffer *buffer,
1006 GtkTextIter *iter,
1007 GtkTextIter *start)
1008{
1009 GSList *marks;
1010 GtkSourceMark *ret = NULL((void*)0);
1011
1012 if (!iter)
1013 gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer)((((GtkTextBuffer*) (void *) ((buffer))))),
1014 start,
1015 gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (buffer)((((GtkTextBuffer*) (void *) ((buffer)))))));
1016 else
1017 *start = *iter;
1018
1019 gtk_text_iter_set_line_offset (start, 0);
1020
1021 marks = gtk_source_buffer_get_source_marks_at_iter (buffer, start, BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
1022 if (marks != NULL((void*)0))
1023 ret = GTK_SOURCE_MARK (marks->data)((((GtkSourceMark*) (void *) ((marks->data)))));
1024
1025 g_slist_free (marks);
1026 return ret;
1027}
1028
1029static void
1030remove_bookmark (GtkSourceBuffer *buffer,
1031 GtkTextIter *iter)
1032{
1033 GtkTextIter start;
1034 GtkSourceMark *bookmark;
1035
1036 if ((bookmark = get_bookmark_and_iter (buffer, iter, &start)) != NULL((void*)0))
1037 gtk_text_buffer_delete_mark (GTK_TEXT_BUFFER (buffer)((((GtkTextBuffer*) (void *) ((buffer))))),
1038 GTK_TEXT_MARK (bookmark)((((GtkTextMark*) (void *) ((bookmark))))));
1039}
1040
1041static void
1042add_bookmark (GtkSourceBuffer *buffer,
1043 GtkTextIter *iter)
1044{
1045 GtkTextIter start;
1046 GtkSourceMark *bookmark;
1047
1048 if ((bookmark = get_bookmark_and_iter (buffer, iter, &start)) == NULL((void*)0))
Although the value stored to 'bookmark' is used in the enclosing expression, the value is never actually read from 'bookmark'
1049 gtk_source_buffer_create_source_mark (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
1050 NULL((void*)0),
1051 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
1052 &start);
1053}
1054
1055static void
1056toggle_bookmark (GtkSourceBuffer *buffer,
1057 GtkTextIter *iter)
1058{
1059 GtkTextIter start;
1060 GtkSourceMark *bookmark = NULL((void*)0);
1061
1062 g_return_if_fail (buffer != NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_25
; if (buffer != ((void*)0)) _g_boolean_var_25 = 1; else _g_boolean_var_25
= 0; _g_boolean_var_25; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "buffer != NULL")
; return; } } while (0)
;
1063
1064 if ((bookmark = get_bookmark_and_iter (buffer, iter, &start)) != NULL((void*)0))
1065 remove_bookmark (buffer, &start);
1066 else
1067 add_bookmark (buffer, &start);
1068}
1069
1070static void
1071on_toggle_bookmark_activate (GtkAction *action,
1072 PlumaBookmarksPlugin *plugin)
1073{
1074 toggle_bookmark (GTK_SOURCE_BUFFER (pluma_window_get_active_document (plugin->priv->window))((((GtkSourceBuffer*) (void *) ((pluma_window_get_active_document
(plugin->priv->window))))))
,
1075 NULL((void*)0));
1076}
1077
1078static void
1079on_next_bookmark_activate (GtkAction *action,
1080 PlumaBookmarksPlugin *plugin)
1081{
1082 goto_bookmark (plugin->priv->window,
1083 NULL((void*)0),
1084 NULL((void*)0),
1085 gtk_source_buffer_forward_iter_to_source_mark,
1086 gtk_text_buffer_get_start_iter);
1087}
1088
1089static void
1090on_previous_bookmark_activate (GtkAction *action,
1091 PlumaBookmarksPlugin *plugin)
1092{
1093 goto_bookmark (plugin->priv->window,
1094 NULL((void*)0),
1095 NULL((void*)0),
1096 gtk_source_buffer_backward_iter_to_source_mark,
1097 gtk_text_buffer_get_end_iter);
1098}
1099
1100static void
1101on_document_loaded (PlumaDocument *doc,
1102 const GError *error,
1103 PlumaView *view)
1104{
1105 if (error == NULL((void*)0))
1106 {
1107 /* Reverting can leave one bookmark at the start, remove it. */
1108 remove_all_bookmarks (GTK_SOURCE_BUFFER (doc)((((GtkSourceBuffer*) (void *) ((doc))))));
1109
1110 load_bookmark_metadata (view);
1111 }
1112}
1113
1114static void
1115on_document_saved (PlumaDocument *doc,
1116 const GError *error,
1117 PlumaView *view)
1118{
1119 if (error == NULL((void*)0))
1120 save_bookmark_metadata (view);
1121}
1122
1123static void
1124on_tab_added (PlumaWindow *window,
1125 PlumaTab *tab,
1126 PlumaBookmarksPlugin *plugin)
1127{
1128 PlumaDocument *doc;
1129 PlumaView *view;
1130
1131 doc = pluma_tab_get_document (tab);
1132 view = pluma_tab_get_view (tab);
1133
1134 g_signal_connect (doc, "loaded",g_signal_connect_data ((doc), ("loaded"), (((GCallback) (on_document_loaded
))), (view), ((void*)0), (GConnectFlags) 0)
1135 G_CALLBACK (on_document_loaded),g_signal_connect_data ((doc), ("loaded"), (((GCallback) (on_document_loaded
))), (view), ((void*)0), (GConnectFlags) 0)
1136 view)g_signal_connect_data ((doc), ("loaded"), (((GCallback) (on_document_loaded
))), (view), ((void*)0), (GConnectFlags) 0)
;
1137 g_signal_connect (doc, "saved",g_signal_connect_data ((doc), ("saved"), (((GCallback) (on_document_saved
))), (view), ((void*)0), (GConnectFlags) 0)
1138 G_CALLBACK (on_document_saved),g_signal_connect_data ((doc), ("saved"), (((GCallback) (on_document_saved
))), (view), ((void*)0), (GConnectFlags) 0)
1139 view)g_signal_connect_data ((doc), ("saved"), (((GCallback) (on_document_saved
))), (view), ((void*)0), (GConnectFlags) 0)
;
1140
1141 enable_bookmarks (view, plugin);
1142}
1143
1144static void
1145on_tab_removed (PlumaWindow *window,
1146 PlumaTab *tab,
1147 PlumaBookmarksPlugin *plugin)
1148{
1149 PlumaDocument *doc;
1150 PlumaView *view;
1151
1152 doc = pluma_tab_get_document (tab);
1153 view = pluma_tab_get_view (tab);
1154
1155 g_signal_handlers_disconnect_by_func (doc, on_document_loaded, view)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_document_loaded), (view))
;
1156 g_signal_handlers_disconnect_by_func (doc, on_document_saved, view)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_document_saved), (view))
;
1157
1158 disable_bookmarks (view);
1159}
1160
1161static void
1162pluma_window_activatable_iface_init (PlumaWindowActivatableInterface *iface)
1163{
1164 iface->activate = pluma_bookmarks_plugin_activate;
1165 iface->deactivate = pluma_bookmarks_plugin_deactivate;
1166 iface->update_state = pluma_bookmarks_plugin_update_state;
1167}
1168
1169G_MODULE_EXPORT__attribute__((visibility("default"))) void
1170peas_register_types (PeasObjectModule *module)
1171{
1172 pluma_bookmarks_plugin_register_type (G_TYPE_MODULE (module)((((GTypeModule*) (void *) ((module))))));
1173
1174 peas_object_module_register_extension_type (module,
1175 PLUMA_TYPE_WINDOW_ACTIVATABLE(pluma_window_activatable_get_type ()),
1176 PLUMA_TYPE_BOOKMARKS_PLUGIN(pluma_bookmarks_plugin_get_type ()));
1177}
1178
1179/* ex:set ts=8 noet: */
diff --git a/2023-10-11-035253-5786-1/report-c25dca.html b/2023-10-11-035253-5786-1/report-c25dca.html new file mode 100644 index 0000000..36026c7 --- /dev/null +++ b/2023-10-11-035253-5786-1/report-c25dca.html @@ -0,0 +1,1859 @@ + + + +pluma-bookmarks-plugin.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:pluma-bookmarks-plugin.c
Warning:line 1064, column 7
Although the value stored to 'bookmark' is used in the enclosing expression, the value is never actually read from 'bookmark'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name pluma-bookmarks-plugin.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/plugins/bookmarks -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtksourceview-4 -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/pluma -D PIC -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/rootdir/plugins/bookmarks -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-11-035253-5786-1 -x c pluma-bookmarks-plugin.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * pluma-bookmarks-plugin.c - Bookmarking for pluma
3 *
4 * Copyright (C) 2008 Jesse van den Kieboom
5 * Copyright (C) 2020-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#include <config.h>
23#include "pluma-bookmarks-plugin.h"
24
25#include <stdlib.h>
26#include <glib/gi18n-lib.h>
27#include <gtk/gtk.h>
28#include <gmodule.h>
29#include <gtksourceview/gtksource.h>
30
31#include <pluma/pluma-window-activatable.h>
32#include <pluma/pluma-debug.h>
33#include <pluma/pluma-window.h>
34#include <pluma/pluma-document.h>
35
36#define BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark" "PlumaBookmarksPluginBookmark"
37#define BOOKMARK_PRIORITY1 1
38
39#define INSERT_DATA_KEY"PlumaBookmarksInsertData" "PlumaBookmarksInsertData"
40#define METADATA_ATTR"metadata::pluma-bookmarks" "metadata::pluma-bookmarks"
41
42#define MESSAGE_OBJECT_PATH"/plugins/bookmarks" "/plugins/bookmarks"
43#define BUS_CONNECT(bus, name, data)pluma_message_bus_connect(bus, "/plugins/bookmarks", "name", (
PlumaMessageCallback) message_name_cb, data, ((void*)0))
pluma_message_bus_connect(bus, MESSAGE_OBJECT_PATH"/plugins/bookmarks", #name, (PlumaMessageCallback) message_##name##_cb, data, NULL((void*)0))
44
45typedef struct
46{
47 GtkSourceMark *bookmark;
48 GtkTextMark *mark;
49} InsertTracker;
50
51typedef struct
52{
53 GSList *trackers;
54 guint user_action;
55} InsertData;
56
57static void on_style_scheme_notify (GObject *object,
58 GParamSpec *pspec,
59 PlumaView *view);
60
61static void on_delete_range (GtkTextBuffer *buffer,
62 GtkTextIter *start,
63 GtkTextIter *end,
64 gpointer user_data);
65
66static void on_insert_text_before (GtkTextBuffer *buffer,
67 GtkTextIter *location,
68 gchar *text,
69 gint len,
70 InsertData *data);
71
72static void on_begin_user_action (GtkTextBuffer *buffer,
73 InsertData *data);
74
75static void on_end_user_action (GtkTextBuffer *buffer,
76 InsertData *data);
77
78static void on_toggle_bookmark_activate (GtkAction *action,
79 PlumaBookmarksPlugin *plugin);
80static void on_next_bookmark_activate (GtkAction *action,
81 PlumaBookmarksPlugin *plugin);
82static void on_previous_bookmark_activate (GtkAction *action,
83 PlumaBookmarksPlugin *plugin);
84static void on_tab_added (PlumaWindow *window,
85 PlumaTab *tab,
86 PlumaBookmarksPlugin *plugin);
87static void on_tab_removed (PlumaWindow *window,
88 PlumaTab *tab,
89 PlumaBookmarksPlugin *plugin);
90
91static void add_bookmark (GtkSourceBuffer *buffer, GtkTextIter *iter);
92static void remove_bookmark (GtkSourceBuffer *buffer, GtkTextIter *iter);
93static void toggle_bookmark (GtkSourceBuffer *buffer, GtkTextIter *iter);
94
95static void pluma_window_activatable_iface_init (PlumaWindowActivatableInterface *iface);
96
97struct _PlumaBookmarksPluginPrivate
98{
99 PlumaWindow *window;
100
101 GtkActionGroup *action_group;
102 guint ui_id;
103};
104
105G_DEFINE_DYNAMIC_TYPE_EXTENDED (PlumaBookmarksPlugin,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
106 pluma_bookmarks_plugin,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
107 PEAS_TYPE_EXTENSION_BASE,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
108 0,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
109 G_ADD_PRIVATE_DYNAMIC (PlumaBookmarksPlugin)static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
110 G_IMPLEMENT_INTERFACE_DYNAMIC (PLUMA_TYPE_WINDOW_ACTIVATABLE,static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
111 pluma_window_activatable_iface_init))static void pluma_bookmarks_plugin_init (PlumaBookmarksPlugin
*self); static void pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass
*klass); static void pluma_bookmarks_plugin_class_finalize (
PlumaBookmarksPluginClass *klass); static gpointer pluma_bookmarks_plugin_parent_class
= ((void*)0); static GType pluma_bookmarks_plugin_type_id = 0
; static gint PlumaBookmarksPlugin_private_offset; static void
pluma_bookmarks_plugin_class_intern_init (gpointer klass) { pluma_bookmarks_plugin_parent_class
= g_type_class_peek_parent (klass); if (PlumaBookmarksPlugin_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PlumaBookmarksPlugin_private_offset
); pluma_bookmarks_plugin_class_init ((PlumaBookmarksPluginClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
pluma_bookmarks_plugin_get_instance_private (PlumaBookmarksPlugin
*self) { return (((gpointer) ((guint8*) (self) + (glong) (PlumaBookmarksPlugin_private_offset
)))); } GType pluma_bookmarks_plugin_get_type (void) { return
pluma_bookmarks_plugin_type_id; } static void pluma_bookmarks_plugin_register_type
(GTypeModule *type_module) { GType g_define_type_id __attribute__
((__unused__)); const GTypeInfo g_define_type_info = { sizeof
(PlumaBookmarksPluginClass), (GBaseInitFunc) ((void*)0), (GBaseFinalizeFunc
) ((void*)0), (GClassInitFunc)(void (*)(void)) pluma_bookmarks_plugin_class_intern_init
, (GClassFinalizeFunc)(void (*)(void)) pluma_bookmarks_plugin_class_finalize
, ((void*)0), sizeof (PlumaBookmarksPlugin), 0, (GInstanceInitFunc
)(void (*)(void)) pluma_bookmarks_plugin_init, ((void*)0) }; pluma_bookmarks_plugin_type_id
= g_type_module_register_type (type_module, (peas_extension_base_get_type
()), "PlumaBookmarksPlugin", &g_define_type_info, (GTypeFlags
) 0); g_define_type_id = pluma_bookmarks_plugin_type_id; { { PlumaBookmarksPlugin_private_offset
= sizeof (PlumaBookmarksPluginPrivate); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) pluma_window_activatable_iface_init, ((void*)0), ((void
*)0) }; g_type_module_add_interface (type_module, g_define_type_id
, (pluma_window_activatable_get_type ()), &g_implement_interface_info
); } ; } }
112
113enum
114{
115 PROP_0,
116 PROP_WINDOW
117};
118
119static void
120pluma_bookmarks_plugin_init (PlumaBookmarksPlugin *plugin)
121{
122 pluma_debug_message (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 122, ((const
char*) (__func__))
, "PlumaBookmarksPlugin initializing");
123
124 plugin->priv = pluma_bookmarks_plugin_get_instance_private (plugin);
125}
126
127static void
128pluma_bookmarks_plugin_dispose (GObject *object)
129{
130 PlumaBookmarksPlugin *plugin = PLUMA_BOOKMARKS_PLUGIN (object)((((PlumaBookmarksPlugin*) (void *) ((object)))));
131
132 pluma_debug_message (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 132, ((const
char*) (__func__))
, "PlumaBookmarksPlugin disposing");
133
134 if (plugin->priv->action_group != NULL((void*)0))
135 {
136 g_object_unref (plugin->priv->action_group);
137 plugin->priv->action_group = NULL((void*)0);
138 }
139
140 if (plugin->priv->window != NULL((void*)0))
141 {
142 g_object_unref (plugin->priv->window);
143 plugin->priv->window = NULL((void*)0);
144 }
145
146 G_OBJECT_CLASS (pluma_bookmarks_plugin_parent_class)((((GObjectClass*) (void *) ((pluma_bookmarks_plugin_parent_class
)))))
->dispose (object);
147}
148
149static void
150pluma_bookmarks_plugin_set_property (GObject *object,
151 guint prop_id,
152 const GValue *value,
153 GParamSpec *pspec)
154{
155 PlumaBookmarksPlugin *plugin = PLUMA_BOOKMARKS_PLUGIN (object)((((PlumaBookmarksPlugin*) (void *) ((object)))));
156
157 switch (prop_id)
158 {
159 case PROP_WINDOW:
160 plugin->priv->window = PLUMA_WINDOW (g_value_dup_object (value))((((PlumaWindow*) (void *) ((g_value_dup_object (value))))));
161 break;
162
163 default:
164 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "pluma-bookmarks-plugin.c", 164, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
165 break;
166 }
167}
168
169static void
170pluma_bookmarks_plugin_get_property (GObject *object,
171 guint prop_id,
172 GValue *value,
173 GParamSpec *pspec)
174{
175 PlumaBookmarksPlugin *plugin = PLUMA_BOOKMARKS_PLUGIN (object)((((PlumaBookmarksPlugin*) (void *) ((object)))));
176
177 switch (prop_id)
178 {
179 case PROP_WINDOW:
180 g_value_set_object (value, plugin->priv->window);
181 break;
182
183 default:
184 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "pluma-bookmarks-plugin.c", 184, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
185 break;
186 }
187}
188
189static void
190free_insert_data (InsertData *data)
191{
192 g_slice_free (InsertData, data)do { if (1) g_slice_free1 (sizeof (InsertData), (data)); else
(void) ((InsertData*) 0 == (data)); } while (0)
;
193}
194
195static GtkActionEntry const action_entries[] = {
196 {"ToggleBookmark", NULL((void*)0), N_("Toggle Bookmark")("Toggle Bookmark"), "<Control><Alt>B",
197 N_("Toggle bookmark status of the current line")("Toggle bookmark status of the current line"),
198 G_CALLBACK (on_toggle_bookmark_activate)((GCallback) (on_toggle_bookmark_activate))},
199 {"NextBookmark", NULL((void*)0), N_("Go to Next Bookmark")("Go to Next Bookmark"), "<Control>B",
200 N_("Go to the next bookmark")("Go to the next bookmark"),
201 G_CALLBACK (on_next_bookmark_activate)((GCallback) (on_next_bookmark_activate))},
202 {"PreviousBookmark", NULL((void*)0), N_("Go to Previous Bookmark")("Go to Previous Bookmark"), "<Control><Shift>B",
203 N_("Go to the previous bookmark")("Go to the previous bookmark"),
204 G_CALLBACK (on_previous_bookmark_activate)((GCallback) (on_previous_bookmark_activate))}
205};
206
207static gchar const uidefinition[] = ""
208"<ui>"
209" <menubar name='MenuBar'>"
210" <menu name='EditMenu' action='Edit'>"
211" <placeholder name='EditOps_6'>"
212" <menuitem action='ToggleBookmark'/>"
213" <menuitem action='PreviousBookmark'/>"
214" <menuitem action='NextBookmark'/>"
215" </placeholder>"
216" </menu>"
217" </menubar>"
218"</ui>";
219
220static void
221install_menu (PlumaBookmarksPlugin *plugin)
222{
223 PlumaBookmarksPluginPrivate *priv;
224 GtkUIManager *manager;
225 GError *error = NULL((void*)0);
226
227 priv = plugin->priv;
228 manager = pluma_window_get_ui_manager (priv->window);
229 priv->action_group = gtk_action_group_new ("PlumaBookmarksPluginActions");
230
231 gtk_action_group_set_translation_domain (priv->action_group,
232 GETTEXT_PACKAGE"pluma-plugins");
233
234 gtk_action_group_add_actions (priv->action_group,
235 action_entries,
236 G_N_ELEMENTS (action_entries)(sizeof (action_entries) / sizeof ((action_entries)[0])),
237 plugin);
238
239 gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
240 priv->ui_id = gtk_ui_manager_add_ui_from_string (manager, uidefinition, -1, &error);
241
242 if (!priv->ui_id)
243 {
244 g_warning ("Could not load UI: %s", error->message);
245 g_error_free (error);
246 }
247}
248
249static void
250uninstall_menu (PlumaBookmarksPlugin *plugin)
251{
252 PlumaBookmarksPluginPrivate *priv;
253 GtkUIManager *manager;
254
255 priv = plugin->priv;
256 manager = pluma_window_get_ui_manager (priv->window);
257
258 gtk_ui_manager_remove_ui (manager, priv->ui_id);
259 gtk_ui_manager_remove_action_group (manager, priv->action_group);
260
261 g_object_unref (priv->action_group);
262 priv->action_group = NULL((void*)0);
263}
264
265static void
266remove_all_bookmarks (GtkSourceBuffer *buffer)
267{
268 GtkTextIter start;
269 GtkTextIter end;
270
271 pluma_debug (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 271, ((const
char*) (__func__))
);
272
273 gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (buffer)((((GtkTextBuffer*) (void *) ((buffer))))), &start, &end);
274 gtk_source_buffer_remove_source_marks (buffer,
275 &start,
276 &end,
277 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
278}
279
280static void
281disable_bookmarks (PlumaView *view)
282{
283 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))));
284 gpointer data;
285
286 gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW (view)((((GtkSourceView*) (void *) ((view))))), FALSE(0));
287 remove_all_bookmarks (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))));
288
289 g_signal_handlers_disconnect_by_func (buffer, on_style_scheme_notify, view)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_style_scheme_notify), (view))
;
290 g_signal_handlers_disconnect_by_func (buffer, on_delete_range, NULL)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_delete_range), (((void*)0)))
;
291
292 data = g_object_get_data (G_OBJECT (buffer)((((GObject*) (void *) ((buffer))))), INSERT_DATA_KEY"PlumaBookmarksInsertData");
293
294 g_signal_handlers_disconnect_by_func (buffer, on_insert_text_before, data)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_insert_text_before), (data))
;
295 g_signal_handlers_disconnect_by_func (buffer, on_begin_user_action, data)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_begin_user_action), (data))
;
296 g_signal_handlers_disconnect_by_func (buffer, on_end_user_action, data)g_signal_handlers_disconnect_matched ((buffer), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_end_user_action), (data))
;
297
298 g_object_set_data (G_OBJECT (buffer)((((GObject*) (void *) ((buffer))))), INSERT_DATA_KEY"PlumaBookmarksInsertData", NULL((void*)0));
299}
300
301static GdkPixbuf *
302get_bookmark_pixbuf (PlumaBookmarksPlugin *plugin)
303{
304 GdkPixbuf *pixbuf;
305 gint width;
306 GError *error = NULL((void*)0);
307
308 gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL((void*)0));
309 pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
310 "user-bookmarks-symbolic",
311 (width * 2) / 3,
312 0,
313 &error);
314
315 if (error != NULL((void*)0))
316 {
317 g_warning ("Could not load theme icon user-bookmarks-symbolic: %s",
318 error->message);
319 g_error_free (error);
320 }
321
322 return pixbuf;
323}
324
325static void
326update_background_color (GtkSourceMarkAttributes *attrs,
327 GtkSourceBuffer *buffer)
328{
329 GtkSourceStyleScheme *scheme;
330 GtkSourceStyle *style;
331
332 scheme = gtk_source_buffer_get_style_scheme (buffer);
333 style = gtk_source_style_scheme_get_style (scheme, "search-match");
334
335 if (style)
336 {
337 gboolean bgset;
338 gchar *bg;
339
340 g_object_get (style, "background-set", &bgset, "background", &bg, NULL((void*)0));
341
342 if (bgset)
343 {
344 GdkRGBA color;
345
346 gdk_rgba_parse (&color, bg);
347 gtk_source_mark_attributes_set_background (attrs, &color);
348 g_free (bg);
349
350 return;
351 }
352 }
353
354 gtk_source_mark_attributes_set_background (attrs, NULL((void*)0));
355}
356
357static void
358enable_bookmarks (PlumaView *view,
359 PlumaBookmarksPlugin *plugin)
360{
361 GdkPixbuf *pixbuf;
362
363 pixbuf = get_bookmark_pixbuf (plugin);
364
365 /* Make sure the category pixbuf is set */
366 if (pixbuf)
367 {
368 GtkTextBuffer *buffer;
369 GtkSourceMarkAttributes *attrs;
370 InsertData *data;
371
372 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))));
373
374 attrs = gtk_source_mark_attributes_new ();
375
376 update_background_color (attrs, GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))));
377 gtk_source_mark_attributes_set_pixbuf (attrs, pixbuf);
378 g_object_unref (pixbuf);
379
380 gtk_source_view_set_mark_attributes (GTK_SOURCE_VIEW (view)((((GtkSourceView*) (void *) ((view))))),
381 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
382 attrs,
383 BOOKMARK_PRIORITY1);
384
385 gtk_source_view_set_show_line_marks (GTK_SOURCE_VIEW (view)((((GtkSourceView*) (void *) ((view))))), TRUE(!(0)));
386
387 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("notify::style-scheme"), ((
(GCallback) (on_style_scheme_notify))), (view), ((void*)0), (
GConnectFlags) 0)
388 "notify::style-scheme",g_signal_connect_data ((buffer), ("notify::style-scheme"), ((
(GCallback) (on_style_scheme_notify))), (view), ((void*)0), (
GConnectFlags) 0)
389 G_CALLBACK (on_style_scheme_notify),g_signal_connect_data ((buffer), ("notify::style-scheme"), ((
(GCallback) (on_style_scheme_notify))), (view), ((void*)0), (
GConnectFlags) 0)
390 view)g_signal_connect_data ((buffer), ("notify::style-scheme"), ((
(GCallback) (on_style_scheme_notify))), (view), ((void*)0), (
GConnectFlags) 0)
;
391
392 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("delete-range"), (((GCallback
) (on_delete_range))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
393 "delete-range",g_signal_connect_data ((buffer), ("delete-range"), (((GCallback
) (on_delete_range))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
394 G_CALLBACK (on_delete_range),g_signal_connect_data ((buffer), ("delete-range"), (((GCallback
) (on_delete_range))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
395 NULL)g_signal_connect_data ((buffer), ("delete-range"), (((GCallback
) (on_delete_range))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
396
397 data = g_slice_new0 (InsertData)(InsertData *) (__extension__ ({ gsize __s = sizeof (InsertData
); gpointer __p; __p = g_slice_alloc (__s); memset (__p, 0, __s
); __p; }))
;
398
399 g_object_set_data_full (G_OBJECT (buffer)((((GObject*) (void *) ((buffer))))),
400 INSERT_DATA_KEY"PlumaBookmarksInsertData",
401 data,
402 (GDestroyNotify) free_insert_data);
403
404 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("insert-text"), (((GCallback
) (on_insert_text_before))), (data), ((void*)0), (GConnectFlags
) 0)
405 "insert-text",g_signal_connect_data ((buffer), ("insert-text"), (((GCallback
) (on_insert_text_before))), (data), ((void*)0), (GConnectFlags
) 0)
406 G_CALLBACK (on_insert_text_before),g_signal_connect_data ((buffer), ("insert-text"), (((GCallback
) (on_insert_text_before))), (data), ((void*)0), (GConnectFlags
) 0)
407 data)g_signal_connect_data ((buffer), ("insert-text"), (((GCallback
) (on_insert_text_before))), (data), ((void*)0), (GConnectFlags
) 0)
;
408
409 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("begin-user-action"), (((GCallback
) (on_begin_user_action))), (data), ((void*)0), (GConnectFlags
) 0)
410 "begin-user-action",g_signal_connect_data ((buffer), ("begin-user-action"), (((GCallback
) (on_begin_user_action))), (data), ((void*)0), (GConnectFlags
) 0)
411 G_CALLBACK (on_begin_user_action),g_signal_connect_data ((buffer), ("begin-user-action"), (((GCallback
) (on_begin_user_action))), (data), ((void*)0), (GConnectFlags
) 0)
412 data)g_signal_connect_data ((buffer), ("begin-user-action"), (((GCallback
) (on_begin_user_action))), (data), ((void*)0), (GConnectFlags
) 0)
;
413
414 g_signal_connect (buffer,g_signal_connect_data ((buffer), ("end-user-action"), (((GCallback
) (on_end_user_action))), (data), ((void*)0), (GConnectFlags)
0)
415 "end-user-action",g_signal_connect_data ((buffer), ("end-user-action"), (((GCallback
) (on_end_user_action))), (data), ((void*)0), (GConnectFlags)
0)
416 G_CALLBACK (on_end_user_action),g_signal_connect_data ((buffer), ("end-user-action"), (((GCallback
) (on_end_user_action))), (data), ((void*)0), (GConnectFlags)
0)
417 data)g_signal_connect_data ((buffer), ("end-user-action"), (((GCallback
) (on_end_user_action))), (data), ((void*)0), (GConnectFlags)
0)
;
418
419 }
420 else
421 {
422 g_warning ("Could not set bookmark icon!");
423 }
424}
425
426static void
427load_bookmarks (PlumaView *view,
428 gchar **bookmarks)
429{
430 GtkSourceBuffer *buf;
431 GtkTextIter iter;
432 gint tot_lines;
433 gint i;
434
435 pluma_debug (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 435, ((const
char*) (__func__))
);
436
437 buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((GtkSourceBuffer*) (void *) ((gtk_text_view_get_buffer (((
((GtkTextView*) (void *) ((view)))))))))))
;
438
439 gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (buf)((((GtkTextBuffer*) (void *) ((buf))))), &iter);
440 tot_lines = gtk_text_iter_get_line (&iter);
441
442 for (i = 0; bookmarks != NULL((void*)0) && bookmarks[i] != NULL((void*)0); i++)
443 {
444 gint line;
445
446 line = atoi (bookmarks[i]);
447
448 if (line >= 0 && line < tot_lines)
449 {
450 GSList *marks;
451
452 gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (buf)((((GtkTextBuffer*) (void *) ((buf))))),
453 &iter, line);
454
455 marks = gtk_source_buffer_get_source_marks_at_iter (buf, &iter,
456 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
457 if (marks == NULL((void*)0))
458 /* Add new bookmark */
459 gtk_source_buffer_create_source_mark (buf,
460 NULL((void*)0),
461 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
462 &iter);
463 else
464 g_slist_free (marks);
465 }
466 }
467}
468
469static void
470load_bookmark_metadata (PlumaView *view)
471{
472 PlumaDocument *doc;
473 gchar *bookmarks_attr;
474
475 doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((PlumaDocument*) (void *) ((gtk_text_view_get_buffer (((((
GtkTextView*) (void *) ((view)))))))))))
;
476 bookmarks_attr = pluma_document_get_metadata (doc, METADATA_ATTR"metadata::pluma-bookmarks");
477
478 if (bookmarks_attr != NULL((void*)0))
479 {
480 gchar **bookmarks;
481
482 bookmarks = g_strsplit (bookmarks_attr, ",", -1);
483 g_free (bookmarks_attr);
484
485 load_bookmarks (view, bookmarks);
486
487 g_strfreev (bookmarks);
488 }
489}
490
491typedef gboolean (*IterSearchFunc)(GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar *category);
492typedef void (*CycleFunc)(GtkTextBuffer *buffer, GtkTextIter *iter);
493
494static void
495goto_bookmark (PlumaWindow *window,
496 GtkSourceView *view,
497 GtkTextIter *iter,
498 IterSearchFunc func,
499 CycleFunc cycle_func)
500{
501 GtkTextBuffer *buffer;
502 GtkTextIter at;
503 GtkTextIter end;
504
505 if (view == NULL((void*)0))
506 view = GTK_SOURCE_VIEW (pluma_window_get_active_view (window))((((GtkSourceView*) (void *) ((pluma_window_get_active_view (
window))))))
;
507
508 g_return_if_fail (view != NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_26
; if (view != ((void*)0)) _g_boolean_var_26 = 1; else _g_boolean_var_26
= 0; _g_boolean_var_26; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view != NULL"); return
; } } while (0)
;
509
510 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))));
511
512 if (iter == NULL((void*)0))
513 gtk_text_buffer_get_iter_at_mark (buffer,
514 &at,
515 gtk_text_buffer_get_insert (buffer));
516 else
517 at = *iter;
518
519 /* Move the iter to the beginning of the line, where the bookmarks are */
520 gtk_text_iter_set_line_offset (&at, 0);
521
522 /* Try to find the next bookmark */
523 if (!func (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))), &at, BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark"))
524 {
525 GSList *marks;
526
527 /* cycle through */
528 cycle_func (buffer, &at);
529 gtk_text_iter_set_line_offset (&at, 0);
530
531 marks = gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
532 &at,
533 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
534
535 if (!marks && !func (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))), &at, BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark"))
536 return;
537
538 g_slist_free (marks);
539 }
540
541 end = at;
542 if (!gtk_text_iter_forward_visible_line (&end))
543 gtk_text_buffer_get_end_iter (buffer, &end);
544 else
545 gtk_text_iter_backward_char (&end);
546
547 gtk_text_buffer_select_range (buffer, &at, &end);
548 gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))), &at, 0.3, FALSE(0), 0, 0);
549}
550
551static void
552message_get_view_iter (PlumaWindow *window,
553 PlumaMessage *message,
554 GtkSourceView **view,
555 GtkTextIter *iter)
556{
557 if (pluma_message_has_key (message, "view"))
558 pluma_message_get (message, "view", view, NULL((void*)0));
559 else
560 *view = GTK_SOURCE_VIEW (pluma_window_get_active_view (window))((((GtkSourceView*) (void *) ((pluma_window_get_active_view (
window))))))
;
561
562 g_return_if_fail (*view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_27
; if (*view) _g_boolean_var_27 = 1; else _g_boolean_var_27 = 0
; _g_boolean_var_27; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "*view"); return;
} } while (0)
;
563
564 if (pluma_message_has_key (message, "iter"))
565 {
566 pluma_message_get (message, "iter", iter, NULL((void*)0));
567 }
568 else
569 {
570 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (*view)((((GtkTextView*) (void *) ((*view))))));
571 gtk_text_buffer_get_iter_at_mark (buffer,
572 iter,
573 gtk_text_buffer_get_insert (buffer));
574 }
575}
576
577static void
578message_toggle_cb (PlumaMessageBus *bus,
579 PlumaMessage *message,
580 PlumaWindow *window)
581{
582 GtkSourceView *view = NULL((void*)0);
583 GtkTextIter iter;
584
585 message_get_view_iter (window, message, &view, &iter);
586
587 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_28
; if (view) _g_boolean_var_28 = 1; else _g_boolean_var_28 = 0
; _g_boolean_var_28; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
588
589 toggle_bookmark (GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((GtkSourceBuffer*) (void *) ((gtk_text_view_get_buffer (((
((GtkTextView*) (void *) ((view)))))))))))
,
590 &iter);
591}
592
593static void
594message_add_cb (PlumaMessageBus *bus,
595 PlumaMessage *message,
596 PlumaWindow *window)
597{
598 GtkSourceView *view = NULL((void*)0);
599 GtkTextIter iter;
600
601 message_get_view_iter (window, message, &view, &iter);
602
603 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_29
; if (view) _g_boolean_var_29 = 1; else _g_boolean_var_29 = 0
; _g_boolean_var_29; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
604
605 add_bookmark (GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((GtkSourceBuffer*) (void *) ((gtk_text_view_get_buffer (((
((GtkTextView*) (void *) ((view)))))))))))
,
606 &iter);
607}
608
609static void
610message_remove_cb (PlumaMessageBus *bus,
611 PlumaMessage *message,
612 PlumaWindow *window)
613{
614 GtkSourceView *view = NULL((void*)0);
615 GtkTextIter iter;
616
617 message_get_view_iter (window, message, &view, &iter);
618
619 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_30
; if (view) _g_boolean_var_30 = 1; else _g_boolean_var_30 = 0
; _g_boolean_var_30; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
620
621 remove_bookmark (GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))((((GtkSourceBuffer*) (void *) ((gtk_text_view_get_buffer (((
((GtkTextView*) (void *) ((view)))))))))))
,
622 &iter);
623}
624
625static void
626message_goto_next_cb (PlumaMessageBus *bus,
627 PlumaMessage *message,
628 PlumaWindow *window)
629{
630 GtkSourceView *view = NULL((void*)0);
631 GtkTextIter iter;
632
633 message_get_view_iter (window, message, &view, &iter);
634
635 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_31
; if (view) _g_boolean_var_31 = 1; else _g_boolean_var_31 = 0
; _g_boolean_var_31; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
636
637 goto_bookmark (window,
638 view,
639 &iter,
640 gtk_source_buffer_forward_iter_to_source_mark,
641 gtk_text_buffer_get_start_iter);
642}
643
644static void
645message_goto_previous_cb (PlumaMessageBus *bus,
646 PlumaMessage *message,
647 PlumaWindow *window)
648{
649 GtkSourceView *view = NULL((void*)0);
650 GtkTextIter iter;
651
652 message_get_view_iter (window, message, &view, &iter);
653
654 g_return_if_fail (view)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_32
; if (view) _g_boolean_var_32 = 1; else _g_boolean_var_32 = 0
; _g_boolean_var_32; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "view"); return; }
} while (0)
;
655
656 goto_bookmark (window,
657 view,
658 &iter,
659 gtk_source_buffer_backward_iter_to_source_mark,
660 gtk_text_buffer_get_end_iter);
661}
662
663static void
664install_messages (PlumaWindow *window)
665{
666 PlumaMessageBus *bus = pluma_window_get_message_bus (window);
667
668 pluma_message_bus_register (bus,
669 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
670 "toggle",
671 2,
672 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
673 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
674 NULL((void*)0));
675
676 pluma_message_bus_register (bus,
677 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
678 "add",
679 2,
680 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
681 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
682 NULL((void*)0));
683
684 pluma_message_bus_register (bus,
685 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
686 "remove",
687 2,
688 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
689 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
690 NULL((void*)0));
691
692 pluma_message_bus_register (bus,
693 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
694 "goto_next",
695 2,
696 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
697 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
698 NULL((void*)0));
699
700 pluma_message_bus_register (bus,
701 MESSAGE_OBJECT_PATH"/plugins/bookmarks",
702 "goto_previous",
703 2,
704 "view", GTK_SOURCE_TYPE_VIEW(gtk_source_view_get_type ()),
705 "iter", GTK_TYPE_TEXT_ITER(gtk_text_iter_get_type ()),
706 NULL((void*)0));
707
708 BUS_CONNECT (bus, toggle, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "toggle"
, (PlumaMessageCallback) message_toggle_cb, window, ((void*)0
))
;
709 BUS_CONNECT (bus, add, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "add", (
PlumaMessageCallback) message_add_cb, window, ((void*)0))
;
710 BUS_CONNECT (bus, remove, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "remove"
, (PlumaMessageCallback) message_remove_cb, window, ((void*)0
))
;
711 BUS_CONNECT (bus, goto_next, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "goto_next"
, (PlumaMessageCallback) message_goto_next_cb, window, ((void
*)0))
;
712 BUS_CONNECT (bus, goto_previous, window)pluma_message_bus_connect(bus, "/plugins/bookmarks", "goto_previous"
, (PlumaMessageCallback) message_goto_previous_cb, window, ((
void*)0))
;
713}
714
715static void
716uninstall_messages (PlumaWindow *window)
717{
718 PlumaMessageBus *bus = pluma_window_get_message_bus (window);
719 pluma_message_bus_unregister_all (bus, MESSAGE_OBJECT_PATH"/plugins/bookmarks");
720}
721
722static void
723pluma_bookmarks_plugin_activate (PlumaWindowActivatable *activatable)
724{
725 PlumaBookmarksPluginPrivate *priv;
726 GList *views;
727 GList *item;
728
729 pluma_debug (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 729, ((const
char*) (__func__))
);
730
731 priv = PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable)))))->priv;
732
733 views = pluma_window_get_views (priv->window);
734 for (item = views; item != NULL((void*)0); item = item->next)
735 {
736 enable_bookmarks (PLUMA_VIEW (item->data)((((PlumaView*) (void *) ((item->data))))),
737 PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable))))));
738 load_bookmark_metadata (PLUMA_VIEW (item->data)((((PlumaView*) (void *) ((item->data))))));
739 }
740
741 g_list_free (views);
742
743 g_signal_connect (priv->window, "tab-added",g_signal_connect_data ((priv->window), ("tab-added"), (((GCallback
) (on_tab_added))), (activatable), ((void*)0), (GConnectFlags
) 0)
744 G_CALLBACK (on_tab_added), activatable)g_signal_connect_data ((priv->window), ("tab-added"), (((GCallback
) (on_tab_added))), (activatable), ((void*)0), (GConnectFlags
) 0)
;
745
746 g_signal_connect (priv->window, "tab-removed",g_signal_connect_data ((priv->window), ("tab-removed"), ((
(GCallback) (on_tab_removed))), (activatable), ((void*)0), (GConnectFlags
) 0)
747 G_CALLBACK (on_tab_removed), activatable)g_signal_connect_data ((priv->window), ("tab-removed"), ((
(GCallback) (on_tab_removed))), (activatable), ((void*)0), (GConnectFlags
) 0)
;
748
749 install_menu (PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable))))));
750 install_messages (priv->window);
751}
752
753static void
754pluma_bookmarks_plugin_update_state (PlumaWindowActivatable *activatable)
755{
756 PlumaBookmarksPluginPrivate *priv;
757
758 priv = PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable)))))->priv;
759 gtk_action_group_set_sensitive (priv->action_group,
760 pluma_window_get_active_view (priv->window) != NULL((void*)0));
761}
762
763static void
764save_bookmark_metadata (PlumaView *view)
765{
766 GtkTextIter iter;
767 GtkTextBuffer *buf;
768 GString *string;
769 gchar *val = NULL((void*)0);
770 gboolean first = TRUE(!(0));
771
772 buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)((((GtkTextView*) (void *) ((view))))));
773 gtk_text_buffer_get_start_iter (buf, &iter);
774 string = g_string_new (NULL((void*)0));
775
776 while (gtk_source_buffer_forward_iter_to_source_mark (GTK_SOURCE_BUFFER (buf)((((GtkSourceBuffer*) (void *) ((buf))))),
777 &iter,
778 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark"))
779 {
780 gint line;
781
782 line = gtk_text_iter_get_line (&iter);
783
784 if (!first)
785 {
786 g_string_append_printf (string, ",%d", line);
787 }
788 else
789 {
790 g_string_append_printf (string, "%d", line);
791 first = FALSE(0);
792 }
793 }
794
795 if (string->len == 0)
796 {
797 val = g_string_free (string, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(string), ((!(0)))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((!(0)))))
;
798 }
799 else
800 {
801 val = g_string_free (string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((string
), ((0))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((0))))
;
802 }
803
804 pluma_document_set_metadata (PLUMA_DOCUMENT (buf)((((PlumaDocument*) (void *) ((buf))))), METADATA_ATTR"metadata::pluma-bookmarks",
805 val, NULL((void*)0));
806
807 g_free (val);
808}
809
810static void
811pluma_bookmarks_plugin_deactivate (PlumaWindowActivatable *activatable)
812{
813 PlumaBookmarksPluginPrivate *priv;
814 GList *views;
815 GList *item;
816
817 pluma_debug (DEBUG_PLUGINSPLUMA_DEBUG_PLUGINS, "pluma-bookmarks-plugin.c", 817, ((const
char*) (__func__))
);
818
819 priv = PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable)))))->priv;
820
821 uninstall_menu (PLUMA_BOOKMARKS_PLUGIN (activatable)((((PlumaBookmarksPlugin*) (void *) ((activatable))))));
822 uninstall_messages (priv->window);
823
824 views = pluma_window_get_views (priv->window);
825
826 for (item = views; item != NULL((void*)0); item = item->next)
827 disable_bookmarks (PLUMA_VIEW (item->data)((((PlumaView*) (void *) ((item->data))))));
828
829 g_list_free (views);
830
831 g_signal_handlers_disconnect_by_func (priv->window, on_tab_added, activatable)g_signal_handlers_disconnect_matched ((priv->window), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_tab_added), (activatable))
;
832 g_signal_handlers_disconnect_by_func (priv->window, on_tab_removed, activatable)g_signal_handlers_disconnect_matched ((priv->window), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_tab_removed), (activatable))
;
833}
834
835static void
836pluma_bookmarks_plugin_class_init (PlumaBookmarksPluginClass *klass)
837{
838 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) ((klass)))));
839
840 object_class->dispose = pluma_bookmarks_plugin_dispose;
841 object_class->set_property = pluma_bookmarks_plugin_set_property;
842 object_class->get_property = pluma_bookmarks_plugin_get_property;
843
844 g_object_class_override_property (object_class, PROP_WINDOW, "window");
845}
846
847static void
848pluma_bookmarks_plugin_class_finalize (PlumaBookmarksPluginClass *klass)
849{
850}
851
852static void
853on_style_scheme_notify (GObject *object,
854 GParamSpec *pspec,
855 PlumaView *view)
856{
857 GtkSourceMarkAttributes *attrs;
858
859 attrs = gtk_source_view_get_mark_attributes (GTK_SOURCE_VIEW (view)((((GtkSourceView*) (void *) ((view))))),
860 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
861 NULL((void*)0));
862
863 update_background_color (attrs, GTK_SOURCE_BUFFER (object)((((GtkSourceBuffer*) (void *) ((object))))));
864}
865
866static void
867on_delete_range (GtkTextBuffer *buffer,
868 GtkTextIter *start,
869 GtkTextIter *end,
870 gpointer user_data)
871{
872 GtkTextIter start_iter;
873 GtkTextIter end_iter;
874 gboolean keep_bookmark;
875
876 /* Nothing to do for us here. The bookmark, if any, will stay at the
877 beginning of the line due to its left gravity. */
878 if (gtk_text_iter_get_line (start) == gtk_text_iter_get_line (end))
879 return;
880
881 start_iter = *start;
882 gtk_text_iter_set_line_offset (&start_iter, 0);
883
884 end_iter = *end;
885 gtk_text_iter_set_line_offset (&end_iter, 0);
886
887 keep_bookmark = ((gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
888 &start_iter,
889 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark") != NULL((void*)0)) ||
890 (gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
891 &end_iter,
892 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark") != NULL((void*)0)));
893
894 /* Remove all bookmarks in the range. */
895 gtk_source_buffer_remove_source_marks (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
896 &start_iter,
897 &end_iter,
898 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
899
900 if (keep_bookmark)
901 gtk_source_buffer_create_source_mark (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
902 NULL((void*)0),
903 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
904 &start_iter);
905}
906
907static void
908on_begin_user_action (GtkTextBuffer *buffer,
909 InsertData *data)
910{
911 ++data->user_action;
912}
913
914static void
915on_end_user_action (GtkTextBuffer *buffer,
916 InsertData *data)
917{
918 GSList *item;
919
920 if (--data->user_action > 0)
921 return;
922
923 /* Remove trackers */
924 for (item = data->trackers; item; item = g_slist_next (item)((item) ? (((GSList *)(item))->next) : ((void*)0)))
925 {
926 InsertTracker *tracker = item->data;
927 GtkTextIter curloc;
928 GtkTextIter newloc;
929
930 /* Move the category to the line where the mark now is */
931 gtk_text_buffer_get_iter_at_mark (buffer,
932 &curloc,
933 GTK_TEXT_MARK (tracker->bookmark)((((GtkTextMark*) (void *) ((tracker->bookmark))))));
934
935 gtk_text_buffer_get_iter_at_mark (buffer,
936 &newloc,
937 tracker->mark);
938
939 if (gtk_text_iter_get_line (&curloc) != gtk_text_iter_get_line (&newloc))
940 {
941 gtk_text_iter_set_line_offset (&newloc, 0);
942 gtk_text_buffer_move_mark (buffer,
943 GTK_TEXT_MARK (tracker->bookmark)((((GtkTextMark*) (void *) ((tracker->bookmark))))),
944 &newloc);
945 }
946
947 gtk_text_buffer_delete_mark (buffer, tracker->mark);
948 g_slice_free (InsertTracker, tracker)do { if (1) g_slice_free1 (sizeof (InsertTracker), (tracker))
; else (void) ((InsertTracker*) 0 == (tracker)); } while (0)
;
949 }
950
951 g_slist_free (data->trackers);
952 data->trackers = NULL((void*)0);
953}
954
955static void
956add_tracker (GtkTextBuffer *buffer,
957 GtkTextIter *iter,
958 GtkSourceMark *bookmark,
959 InsertData *data)
960{
961 GSList *item;
962 InsertTracker *tracker;
963
964 for (item = data->trackers; item; item = g_slist_next (item)((item) ? (((GSList *)(item))->next) : ((void*)0)))
965 {
966 tracker = item->data;
967
968 if (tracker->bookmark == bookmark)
969 return;
970 }
971
972 tracker = g_slice_new (InsertTracker)((InsertTracker*) g_slice_alloc (sizeof (InsertTracker)));
973 tracker->bookmark = bookmark;
974 tracker->mark = gtk_text_buffer_create_mark (buffer,
975 NULL((void*)0),
976 iter,
977 FALSE(0));
978
979 data->trackers = g_slist_prepend (data->trackers, tracker);
980}
981
982static void
983on_insert_text_before (GtkTextBuffer *buffer,
984 GtkTextIter *location,
985 gchar *text,
986 gint len,
987 InsertData *data)
988{
989 if (gtk_text_iter_starts_line (location))
990 {
991 GSList *marks;
992 marks = gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
993 location,
994 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
995
996 if (marks != NULL((void*)0))
997 {
998 add_tracker (buffer, location, marks->data, data);
999 g_slist_free (marks);
1000 }
1001 }
1002}
1003
1004static GtkSourceMark *
1005get_bookmark_and_iter (GtkSourceBuffer *buffer,
1006 GtkTextIter *iter,
1007 GtkTextIter *start)
1008{
1009 GSList *marks;
1010 GtkSourceMark *ret = NULL((void*)0);
1011
1012 if (!iter)
1013 gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer)((((GtkTextBuffer*) (void *) ((buffer))))),
1014 start,
1015 gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (buffer)((((GtkTextBuffer*) (void *) ((buffer)))))));
1016 else
1017 *start = *iter;
1018
1019 gtk_text_iter_set_line_offset (start, 0);
1020
1021 marks = gtk_source_buffer_get_source_marks_at_iter (buffer, start, BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark");
1022 if (marks != NULL((void*)0))
1023 ret = GTK_SOURCE_MARK (marks->data)((((GtkSourceMark*) (void *) ((marks->data)))));
1024
1025 g_slist_free (marks);
1026 return ret;
1027}
1028
1029static void
1030remove_bookmark (GtkSourceBuffer *buffer,
1031 GtkTextIter *iter)
1032{
1033 GtkTextIter start;
1034 GtkSourceMark *bookmark;
1035
1036 if ((bookmark = get_bookmark_and_iter (buffer, iter, &start)) != NULL((void*)0))
1037 gtk_text_buffer_delete_mark (GTK_TEXT_BUFFER (buffer)((((GtkTextBuffer*) (void *) ((buffer))))),
1038 GTK_TEXT_MARK (bookmark)((((GtkTextMark*) (void *) ((bookmark))))));
1039}
1040
1041static void
1042add_bookmark (GtkSourceBuffer *buffer,
1043 GtkTextIter *iter)
1044{
1045 GtkTextIter start;
1046 GtkSourceMark *bookmark;
1047
1048 if ((bookmark = get_bookmark_and_iter (buffer, iter, &start)) == NULL((void*)0))
1049 gtk_source_buffer_create_source_mark (GTK_SOURCE_BUFFER (buffer)((((GtkSourceBuffer*) (void *) ((buffer))))),
1050 NULL((void*)0),
1051 BOOKMARK_CATEGORY"PlumaBookmarksPluginBookmark",
1052 &start);
1053}
1054
1055static void
1056toggle_bookmark (GtkSourceBuffer *buffer,
1057 GtkTextIter *iter)
1058{
1059 GtkTextIter start;
1060 GtkSourceMark *bookmark = NULL((void*)0);
1061
1062 g_return_if_fail (buffer != NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_33
; if (buffer != ((void*)0)) _g_boolean_var_33 = 1; else _g_boolean_var_33
= 0; _g_boolean_var_33; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "buffer != NULL")
; return; } } while (0)
;
1063
1064 if ((bookmark = get_bookmark_and_iter (buffer, iter, &start)) != NULL((void*)0))
Although the value stored to 'bookmark' is used in the enclosing expression, the value is never actually read from 'bookmark'
1065 remove_bookmark (buffer, &start);
1066 else
1067 add_bookmark (buffer, &start);
1068}
1069
1070static void
1071on_toggle_bookmark_activate (GtkAction *action,
1072 PlumaBookmarksPlugin *plugin)
1073{
1074 toggle_bookmark (GTK_SOURCE_BUFFER (pluma_window_get_active_document (plugin->priv->window))((((GtkSourceBuffer*) (void *) ((pluma_window_get_active_document
(plugin->priv->window))))))
,
1075 NULL((void*)0));
1076}
1077
1078static void
1079on_next_bookmark_activate (GtkAction *action,
1080 PlumaBookmarksPlugin *plugin)
1081{
1082 goto_bookmark (plugin->priv->window,
1083 NULL((void*)0),
1084 NULL((void*)0),
1085 gtk_source_buffer_forward_iter_to_source_mark,
1086 gtk_text_buffer_get_start_iter);
1087}
1088
1089static void
1090on_previous_bookmark_activate (GtkAction *action,
1091 PlumaBookmarksPlugin *plugin)
1092{
1093 goto_bookmark (plugin->priv->window,
1094 NULL((void*)0),
1095 NULL((void*)0),
1096 gtk_source_buffer_backward_iter_to_source_mark,
1097 gtk_text_buffer_get_end_iter);
1098}
1099
1100static void
1101on_document_loaded (PlumaDocument *doc,
1102 const GError *error,
1103 PlumaView *view)
1104{
1105 if (error == NULL((void*)0))
1106 {
1107 /* Reverting can leave one bookmark at the start, remove it. */
1108 remove_all_bookmarks (GTK_SOURCE_BUFFER (doc)((((GtkSourceBuffer*) (void *) ((doc))))));
1109
1110 load_bookmark_metadata (view);
1111 }
1112}
1113
1114static void
1115on_document_saved (PlumaDocument *doc,
1116 const GError *error,
1117 PlumaView *view)
1118{
1119 if (error == NULL((void*)0))
1120 save_bookmark_metadata (view);
1121}
1122
1123static void
1124on_tab_added (PlumaWindow *window,
1125 PlumaTab *tab,
1126 PlumaBookmarksPlugin *plugin)
1127{
1128 PlumaDocument *doc;
1129 PlumaView *view;
1130
1131 doc = pluma_tab_get_document (tab);
1132 view = pluma_tab_get_view (tab);
1133
1134 g_signal_connect (doc, "loaded",g_signal_connect_data ((doc), ("loaded"), (((GCallback) (on_document_loaded
))), (view), ((void*)0), (GConnectFlags) 0)
1135 G_CALLBACK (on_document_loaded),g_signal_connect_data ((doc), ("loaded"), (((GCallback) (on_document_loaded
))), (view), ((void*)0), (GConnectFlags) 0)
1136 view)g_signal_connect_data ((doc), ("loaded"), (((GCallback) (on_document_loaded
))), (view), ((void*)0), (GConnectFlags) 0)
;
1137 g_signal_connect (doc, "saved",g_signal_connect_data ((doc), ("saved"), (((GCallback) (on_document_saved
))), (view), ((void*)0), (GConnectFlags) 0)
1138 G_CALLBACK (on_document_saved),g_signal_connect_data ((doc), ("saved"), (((GCallback) (on_document_saved
))), (view), ((void*)0), (GConnectFlags) 0)
1139 view)g_signal_connect_data ((doc), ("saved"), (((GCallback) (on_document_saved
))), (view), ((void*)0), (GConnectFlags) 0)
;
1140
1141 enable_bookmarks (view, plugin);
1142}
1143
1144static void
1145on_tab_removed (PlumaWindow *window,
1146 PlumaTab *tab,
1147 PlumaBookmarksPlugin *plugin)
1148{
1149 PlumaDocument *doc;
1150 PlumaView *view;
1151
1152 doc = pluma_tab_get_document (tab);
1153 view = pluma_tab_get_view (tab);
1154
1155 g_signal_handlers_disconnect_by_func (doc, on_document_loaded, view)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_document_loaded), (view))
;
1156 g_signal_handlers_disconnect_by_func (doc, on_document_saved, view)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (on_document_saved), (view))
;
1157
1158 disable_bookmarks (view);
1159}
1160
1161static void
1162pluma_window_activatable_iface_init (PlumaWindowActivatableInterface *iface)
1163{
1164 iface->activate = pluma_bookmarks_plugin_activate;
1165 iface->deactivate = pluma_bookmarks_plugin_deactivate;
1166 iface->update_state = pluma_bookmarks_plugin_update_state;
1167}
1168
1169G_MODULE_EXPORT__attribute__((visibility("default"))) void
1170peas_register_types (PeasObjectModule *module)
1171{
1172 pluma_bookmarks_plugin_register_type (G_TYPE_MODULE (module)((((GTypeModule*) (void *) ((module))))));
1173
1174 peas_object_module_register_extension_type (module,
1175 PLUMA_TYPE_WINDOW_ACTIVATABLE(pluma_window_activatable_get_type ()),
1176 PLUMA_TYPE_BOOKMARKS_PLUGIN(pluma_bookmarks_plugin_get_type ()));
1177}
1178
1179/* ex:set ts=8 noet: */
diff --git a/2023-10-11-035253-5786-1/scanview.css b/2023-10-11-035253-5786-1/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2023-10-11-035253-5786-1/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-10-11-035253-5786-1/sorttable.js b/2023-10-11-035253-5786-1/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2023-10-11-035253-5786-1/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write("