Make the text in the infopanes selectable

Fri, 01 Nov 2024 01:31:09 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 01 Nov 2024 01:31:09 -0500
changeset 43041
ea212a081e9c
parent 43040
30a19ec025e9
child 43042
8135b5752cec

Make the text in the infopanes selectable

This also removes the tooltip and instead expands the widget out while hovering
the cursor over the label.

Testing Done:
Joined a channel on a local ergo server that had a long topic with links. Link behavior works in all cases except when text is selected which is fine. If you click some where in the label to clear the selection links work again. Also verified the hover behavior. I'm not a fan of using 10 lines as a magic number, but it should be fine for now.

Bugs closed: PIDGIN-2582

Reviewed at https://reviews.imfreedom.org/r/3610/

pidgin/pidgininfopane.c file | annotate | diff | comparison | revisions
pidgin/resources/Conversations/conversation.ui file | annotate | diff | comparison | revisions
pidgin/resources/infopane.ui file | annotate | diff | comparison | revisions
--- a/pidgin/pidgininfopane.c	Fri Nov 01 01:13:23 2024 -0500
+++ b/pidgin/pidgininfopane.c	Fri Nov 01 01:31:09 2024 -0500
@@ -59,6 +59,30 @@
 	return ret;
 }
 
+static void
+pidgin_info_pane_subtitle_enter_cb(GtkEventControllerMotion *self,
+                                   G_GNUC_UNUSED gdouble x,
+                                   G_GNUC_UNUSED gdouble y,
+                                   G_GNUC_UNUSED gpointer data)
+{
+	GtkWidget *label = NULL;
+
+	label = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(self));
+	gtk_label_set_lines(GTK_LABEL(label), 10);
+}
+
+static void
+pidgin_info_pane_subtitle_leave_cb(GtkEventControllerMotion *self,
+                                   G_GNUC_UNUSED gdouble x,
+                                   G_GNUC_UNUSED gdouble y,
+                                   G_GNUC_UNUSED gpointer data)
+{
+	GtkWidget *label = NULL;
+
+	label = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(self));
+	gtk_label_set_lines(GTK_LABEL(label), 2);
+}
+
 /******************************************************************************
  * GObject Implementation
  *****************************************************************************/
@@ -176,6 +200,10 @@
 
 	gtk_widget_class_bind_template_callback(widget_class,
 	                                        pidgin_info_pane_linkify_text_cb);
+	gtk_widget_class_bind_template_callback(widget_class,
+	                                        pidgin_info_pane_subtitle_enter_cb);
+	gtk_widget_class_bind_template_callback(widget_class,
+	                                        pidgin_info_pane_subtitle_leave_cb);
 }
 
 /******************************************************************************
--- a/pidgin/resources/Conversations/conversation.ui	Fri Nov 01 01:13:23 2024 -0500
+++ b/pidgin/resources/Conversations/conversation.ui	Fri Nov 01 01:31:09 2024 -0500
@@ -43,16 +43,10 @@
                 </lookup>
               </closure>
             </binding>
-            <binding name="tooltip-markup">
-              <closure type="gchararray" function="pidgin_conversation_escape_topic">
-                <lookup name="topic" type="PurpleConversation">
-                  <lookup name="conversation">PidginConversation</lookup>
-                </lookup>
-              </closure>
-            </binding>
             <property name="child">
               <object class="GtkBox">
                 <property name="orientation">horizontal</property>
+                <property name="valign">start</property>
                 <child>
                   <object class="GtkToggleButton" id="toggle_flap">
                     <property name="icon-name">view-dual-symbolic</property>
--- a/pidgin/resources/infopane.ui	Fri Nov 01 01:13:23 2024 -0500
+++ b/pidgin/resources/infopane.ui	Fri Nov 01 01:31:09 2024 -0500
@@ -37,6 +37,7 @@
             <property name="valign">center</property>
             <child>
               <object class="GtkLabel" id="title">
+                <property name="selectable">true</property>
                 <binding name="label">
                   <lookup name="title">PidginInfoPane</lookup>
                 </binding>
@@ -48,6 +49,7 @@
             </child>
             <child>
               <object class="GtkLabel" id="subtitle_label">
+                <property name="selectable">true</property>
                 <binding name="label">
                   <closure type="gchararray" function="pidgin_info_pane_linkify_text_cb" object="subtitle_label">
                       <lookup name="subtitle">PidginInfoPane</lookup>
@@ -59,6 +61,12 @@
                 <property name="wrap">yes</property>
                 <property name="wrap-mode">word-char</property>
                 <property name="xalign">0</property>
+                <child>
+                  <object class="GtkEventControllerMotion">
+                    <signal name="enter" handler="pidgin_info_pane_subtitle_enter_cb"/>
+                    <signal name="leave" handler="pidgin_info_pane_subtitle_leave_cb"/>
+                  </object>
+                </child>
               </object>
             </child>
           </object>

mercurial