Tue, 22 Jul 2025 16:06:33 -0500
Move the input box to a GtkSourceView
We already depend on GtkSourceView for spell checking and this will allow us
to implement completions for nicks and commands and other stuff we haven't
thought of yet.
I'm not super happy about tracking the adwait style manager, but that seems to be the only way to make sure the style matches the rest of the application.
Testing Done:
Compiled and sent some messages.
Reviewed at https://reviews.imfreedom.org/r/4071/
--- a/meson.build Thu Jul 17 20:28:54 2025 -0500 +++ b/meson.build Tue Jul 22 16:06:33 2025 -0500 @@ -219,6 +219,8 @@ '-DADW_VERSION_MAX_ALLOWED=ADW_VERSION_1_5', language: 'c') + gtksourceview_dep = dependency('gtksourceview-5', version : '>= 5.10.0') + libspelling = dependency('libspelling-1', version : '>= 0.4.0', default_options : ['sysprof=false']) endif
--- a/pidgin/meson.build Thu Jul 17 20:28:54 2025 -0500 +++ b/pidgin/meson.build Tue Jul 22 16:06:33 2025 -0500 @@ -137,6 +137,7 @@ glib, gplugin_gtk_dep, gtk, + gtksourceview_dep, json, libadwaita, libspelling, @@ -215,7 +216,7 @@ include_directories : [toplevel_inc, libpidgin_inc], link_with : libpidgin, sources : libpidgin_built_headers, - dependencies : [gtk, glib, libadwaita, math, gplugin_gtk_dep]) + dependencies : _libpidgin_dependencies) executable('pidgin3', pidgin_SOURCES, @@ -234,7 +235,7 @@ version : meson.project_version(), filebase : pidgin_filebase, subdirs : pidgin_filebase, - libraries : [gtk, libadwaita, libpurple_dep, gplugin_gtk_dep], + libraries : _libpidgin_dependencies, variables : [f'plugindir=${libdir}/pidgin-@purple_api_major_version@']) if enable_introspection @@ -243,13 +244,13 @@ pidgin_gir = gnome.generate_gir(libpidgin, sources : introspection_sources, header : 'pidgin.h', - includes : ['Adw-1', 'GLib-2.0', 'GObject-2.0', 'Gtk-4.0', libpurple_gir[0]], + includes : ['Adw-1', 'GLib-2.0', 'GObject-2.0', 'Gtk-4.0', 'GtkSource-5', libpurple_gir[0]], namespace : 'Pidgin', symbol_prefix : 'pidgin', identifier_prefix : 'Pidgin', export_packages : f'pidgin-@purple_api_major_version@', nsversion : f'@purple_api_major_version@.@purple_api_minor_version@', - dependencies : [gplugin_dep, gplugin_gtk_dep, libpurple_dep], + dependencies : _libpidgin_dependencies, install : true, extra_args : ['-DPIDGIN_COMPILATION', '--quiet']) endif
--- a/pidgin/pidginconversation.c Thu Jul 17 20:28:54 2025 -0500 +++ b/pidgin/pidginconversation.c Tue Jul 22 16:06:33 2025 -0500 @@ -24,7 +24,7 @@ #include <libspelling.h> -#include <gtksourceview/gtksourceview.h> +#include <gtksourceview/gtksource.h> #include <purple.h> @@ -232,6 +232,22 @@ return conversation->notification_count; } +static void +pidgin_conversation_set_dark(PidginConversation *conversation, gboolean dark) { + GtkSourceStyleScheme *scheme = NULL; + GtkSourceStyleSchemeManager *manager = NULL; + const char *id = "Adwaita"; + + if(dark) { + id = "Adwaita-dark"; + } + + manager = gtk_source_style_scheme_manager_get_default(); + scheme = gtk_source_style_scheme_manager_get_scheme(manager, id); + + gtk_source_buffer_set_style_scheme(conversation->input_buffer, scheme); +} + /****************************************************************************** * Callbacks *****************************************************************************/ @@ -449,6 +465,17 @@ pidgin_conversation_set_notification_count(PIDGIN_CONVERSATION(self), 0); } +static void +pidgin_conversation_dark_cb(GObject *self, G_GNUC_UNUSED GParamSpec *pspec, + gpointer data) +{ + PidginConversation *conversation = data; + AdwStyleManager *style_manager = ADW_STYLE_MANAGER(self); + + pidgin_conversation_set_dark(conversation, + adw_style_manager_get_dark(style_manager)); +} + /****************************************************************************** * PidginNotifiable Implementation *****************************************************************************/ @@ -530,6 +557,7 @@ static void pidgin_conversation_init(PidginConversation *conversation) { + AdwStyleManager *style_manager = NULL; GMenuModel *menu = NULL; SpellingChecker *checker = NULL; SpellingTextBufferAdapter *adapter = NULL; @@ -565,6 +593,13 @@ /* Connect to our map signal to reset the notification-count property. */ g_signal_connect(conversation, "map", G_CALLBACK(pidgin_conversation_map_cb), NULL); + + style_manager = adw_style_manager_get_default(); + g_signal_connect_object(style_manager, "notify::dark", + G_CALLBACK(pidgin_conversation_dark_cb), + conversation, G_CONNECT_DEFAULT); + pidgin_conversation_set_dark(conversation, + adw_style_manager_get_dark(style_manager)); } static void
--- a/pidgin/resources/Conversations/conversation.ui Thu Jul 17 20:28:54 2025 -0500 +++ b/pidgin/resources/Conversations/conversation.ui Tue Jul 22 16:06:33 2025 -0500 @@ -224,12 +224,15 @@ <object class="GtkScrolledWindow"> <property name="vexpand">0</property> <child> - <object class="GtkTextView" id="input"> + <object class="GtkSourceView" id="input"> <property name="wrap-mode">word-char</property> <property name="input-purpose">free-form</property> <property name="input-hints">emoji|spellcheck|word-completion</property> <property name="buffer"> <object class="GtkSourceBuffer" id="input_buffer"> + <property name="highlight-matching-brackets">False</property> + <property name="highlight-syntax">False</property> + <property name="implicit-trailing-newline">False</property> <signal name="delete-range" handler="pidgin_conversation_input_delete_range_cb" after="yes"/> <signal name="insert-text" handler="pidgin_conversation_input_insert_text_cb"/> </object>