Create a new PidginConversationWindow widget

Sun, 01 Nov 2020 04:48:35 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Sun, 01 Nov 2020 04:48:35 -0600
changeset 40577
953d563429b8
parent 40576
9616360d5943
child 40578
4118acc90778

Create a new PidginConversationWindow widget

Testing Done:
ran and created a conversation, checked the docs, ran `ninja pidgin-pot`.

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

doc/reference/pidgin/pidgin-docs.xml file | annotate | diff | comparison | revisions
pidgin/glade/pidgin3.xml.in file | annotate | diff | comparison | revisions
pidgin/gtkconv.c file | annotate | diff | comparison | revisions
pidgin/meson.build file | annotate | diff | comparison | revisions
pidgin/pidginconversationwindow.c file | annotate | diff | comparison | revisions
pidgin/pidginconversationwindow.h file | annotate | diff | comparison | revisions
pidgin/resources/Conversations/window.ui file | annotate | diff | comparison | revisions
pidgin/resources/pidgin.gresource.xml file | annotate | diff | comparison | revisions
po/POTFILES.in file | annotate | diff | comparison | revisions
--- a/doc/reference/pidgin/pidgin-docs.xml	Sun Nov 01 04:47:52 2020 -0600
+++ b/doc/reference/pidgin/pidgin-docs.xml	Sun Nov 01 04:48:35 2020 -0600
@@ -65,6 +65,7 @@
       <xi:include href="xml/pidginbuddylistmenu.xml" />
       <xi:include href="xml/pidginclosebutton.xml" />
       <xi:include href="xml/pidgincontactcompletion.xml" />
+      <xi:include href="xml/pidginconversationwindow.xml" />
       <xi:include href="xml/pidgindebug.xml" />
       <xi:include href="xml/pidgindialog.xml" />
       <xi:include href="xml/pidgingdkpixbuf.xml" />
--- a/pidgin/glade/pidgin3.xml.in	Sun Nov 01 04:47:52 2020 -0600
+++ b/pidgin/glade/pidgin3.xml.in	Sun Nov 01 04:48:35 2020 -0600
@@ -7,6 +7,7 @@
     <glade-widget-class name="PidginAccountFilterConnected" generic-name="account_filter_connected" title="FilterConnected"/>
     <glade-widget-class name="PidginAccountFilterProtocol" generic-name="account_filter_protocol" title="FilterProtocol"/>
     <glade-widget-class name="PidginCloseButton" generic-name="close-button" title="CloseButton"/>
+    <glade-widget-class name="PidginConversationWindow" generic-name="conversation_window" title="ConversationWindow"/>
     <glade-widget-class name="PidginDialog" generic-name="dialog" title="Dialog"/>
     <glade-widget-class name="PidginInviteDialog" generic-name="invite_dialog" title="InviteDialog"/>
     <glade-widget-class name="PidginMenuTray" generic-name="menu_tray" title="MenuTray"/>
@@ -21,6 +22,7 @@
     <glade-widget-class-ref name="PidginAccountFilterConnected"/>
     <glade-widget-class-ref name="PidginAccountFilterProtocol"/>
     <glade-widget-class-ref name="PidginCloseButton"/>
+    <glade-widget-class-ref name="PidginConversationWindow"/>
     <glade-widget-class-ref name="PidginDialog"/>
     <glade-widget-class-ref name="PidginInviteDialog"/>
     <glade-widget-class-ref name="PidginMenuTray"/>
--- a/pidgin/gtkconv.c	Sun Nov 01 04:47:52 2020 -0600
+++ b/pidgin/gtkconv.c	Sun Nov 01 04:48:35 2020 -0600
@@ -52,6 +52,7 @@
 #include "gtkstyle.h"
 #include "gtkutils.h"
 #include "pidginclosebutton.h"
+#include "pidginconversationwindow.h"
 #include "pidgincore.h"
 #include "pidgingdkpixbuf.h"
 #include "pidgininvitedialog.h"
@@ -7621,10 +7622,11 @@
 	window_list = g_list_append(window_list, win);
 
 	/* Create the window. */
-	win->window = pidgin_window_new(NULL, 0, "conversation", TRUE);
+	win->window = pidgin_conversation_window_new();
 	/*_pidgin_widget_set_accessible_name(win->window, "Conversations");*/
-	if (!gtk_get_current_event_state(&state))
+	if(!gtk_get_current_event_state(&state)) {
 		gtk_window_set_focus_on_map(GTK_WINDOW(win->window), FALSE);
+	}
 
 	/* Etan: I really think this entire function call should happen only
 	 * when we are on Windows but I was informed that back before we used
@@ -7713,7 +7715,8 @@
 	g_signal_connect(G_OBJECT(win->notebook), "button_release_event",
 	                 G_CALLBACK(notebook_release_cb), win);
 
-	testidea = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+	testidea = pidgin_conversation_window_get_vbox(PIDGIN_CONVERSATION_WINDOW(win->window));
+	gtk_container_add(GTK_CONTAINER(win->window), testidea);
 
 	/* Setup the menubar. */
 	menubar = setup_menubar(win);
@@ -7721,10 +7724,6 @@
 
 	gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0);
 
-	gtk_container_add(GTK_CONTAINER(win->window), testidea);
-
-	gtk_widget_show(testidea);
-
 	/* Update the plugin actions when plugins are (un)loaded */
 	purple_signal_connect(purple_plugins_get_handle(), "plugin-load",
 			win, PURPLE_CALLBACK(plugin_changed_cb), win);
--- a/pidgin/meson.build	Sun Nov 01 04:47:52 2020 -0600
+++ b/pidgin/meson.build	Sun Nov 01 04:48:35 2020 -0600
@@ -45,6 +45,7 @@
 	'pidginbuddylistmenu.c',
 	'pidginclosebutton.c',
 	'pidgincontactcompletion.c',
+	'pidginconversationwindow.c',
 	'pidgindebug.c',
 	'pidgindialog.c',
 	'pidgingdkpixbuf.c',
@@ -111,6 +112,7 @@
 	'pidginbuddylistmenu.h',
 	'pidginclosebutton.h',
 	'pidgincontactcompletion.h',
+	'pidginconversationwindow.h',
 	'pidgincore.h',
 	'pidgindialog.h',
 	'pidgindebug.h',
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginconversationwindow.c	Sun Nov 01 04:48:35 2020 -0600
@@ -0,0 +1,71 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "pidginconversationwindow.h"
+
+struct _PidginConversationWindow {
+	GtkApplicationWindow parent;
+
+	GtkWidget *vbox;
+};
+
+G_DEFINE_TYPE(PidginConversationWindow, pidgin_conversation_window,
+              GTK_TYPE_APPLICATION_WINDOW)
+
+/******************************************************************************
+ * GObjectImplementation
+ *****************************************************************************/
+static void
+pidgin_conversation_window_init(PidginConversationWindow *window) {
+	gtk_widget_init_template(GTK_WIDGET(window));
+
+	gtk_window_set_application(GTK_WINDOW(window),
+	                           GTK_APPLICATION(g_application_get_default()));
+}
+
+static void
+pidgin_conversation_window_class_init(PidginConversationWindowClass *klass) {
+	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+	gtk_widget_class_set_template_from_resource(
+	    widget_class,
+	    "/im/pidgin/Pidgin/Conversations/window.ui"
+	);
+
+	gtk_widget_class_bind_template_child(widget_class, PidginConversationWindow,
+	                                     vbox);
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+GtkWidget *
+pidgin_conversation_window_new(void) {
+	return GTK_WIDGET(g_object_new(PIDGIN_TYPE_CONVERSATION_WINDOW, NULL));
+}
+
+GtkWidget *
+pidgin_conversation_window_get_vbox(PidginConversationWindow *window) {
+	g_return_val_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window), NULL);
+
+	return window->vbox;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginconversationwindow.h	Sun Nov 01 04:48:35 2020 -0600
@@ -0,0 +1,73 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
+# error "only <pidgin.h> may be included directly"
+#endif
+
+#ifndef PIDGIN_CONVERSATION_WINDOW_H
+#define PIDGIN_CONVERSATION_WINDOW_H
+
+/**
+ * SECTION:pidginconversationwindow
+ * @section_id: pidgin-pidginconversationwindow
+ * @short_description: The main conversation window widget.
+ * @title: Conversation window widget
+ *
+ * #PidginConversationWindow is a widget that contains #PidginConversations.
+ */
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PIDGIN_TYPE_CONVERSATION_WINDOW (pidgin_conversation_window_get_type())
+G_DECLARE_FINAL_TYPE(PidginConversationWindow, pidgin_conversation_window,
+                     PIDGIN, CONVERSATION_WINDOW, GtkApplicationWindow)
+
+/**
+ * pidgin_conversation_window_new:
+ *
+ * Creates a new #PidginConversationWindow instance.
+ *
+ * Returns: (transfer full): The new #PidginConversationWindow instance.
+ */
+GtkWidget *pidgin_conversation_window_new(void);
+
+/**
+ * pidgin_conversation_window_get_vbox:
+ * @window: The #PidginConversationWindow instance.
+ *
+ * Gets the main vertical box of @window.
+ *
+ * Returns: (transfer none): The main vertical box of @window.
+ *
+ * Since: 3.0.0
+ * Deprecated: 3.0.0
+ */
+GtkWidget *pidgin_conversation_window_get_vbox(PidginConversationWindow *window);
+
+G_END_DECLS
+
+#endif /* PIDGIN_CONVERSATION_WINDOW_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/Conversations/window.ui	Sun Nov 01 04:48:35 2020 -0600
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 
+
+Pidgin - Internet Messenger
+Copyright (C) Pidgin Developers <devel@pidgin.im>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, see <https://www.gnu.org/licenses/>.
+
+-->
+<interface>
+  <requires lib="gtk+" version="3.20"/>
+  <!-- interface-license-type gplv2 -->
+  <!-- interface-name Pidgin -->
+  <!-- interface-description Internet Messenger -->
+  <!-- interface-copyright Pidgin Developers <devel@pidgin.im> -->
+  <template class="PidginConversationWindow" parent="GtkApplicationWindow">
+    <property name="can_focus">False</property>
+    <property name="role">conversation</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
+    <child>
+      <object class="GtkBox" id="vbox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
--- a/pidgin/resources/pidgin.gresource.xml	Sun Nov 01 04:47:52 2020 -0600
+++ b/pidgin/resources/pidgin.gresource.xml	Sun Nov 01 04:48:35 2020 -0600
@@ -12,6 +12,7 @@
     <file compressed="true">BuddyList/menu.ui</file>
     <file compressed="true">Conversations/invite_dialog.ui</file>
     <file compressed="true">Conversations/tab-label.css</file>
+    <file compressed="true">Conversations/window.ui</file>
     <file compressed="true">Debug/debug.ui</file>
     <file compressed="true">Debug/filter.css</file>
     <file compressed="true">Debug/plugininfo.ui</file>
--- a/po/POTFILES.in	Sun Nov 01 04:47:52 2020 -0600
+++ b/po/POTFILES.in	Sun Nov 01 04:48:35 2020 -0600
@@ -351,6 +351,7 @@
 pidgin/pidginattachment.c
 pidgin/pidginclosebutton.c
 pidgin/pidgincontactcompletion.c
+pidgin/pidginconversationwindow.c
 pidgin/pidgindebug.c
 pidgin/pidgindialog.c
 pidgin/pidgingdkpixbuf.c

mercurial