talkatu/talkatu

Parents b6ad374a15c6
Children 0cef8587d507
Remove a bunch of incomplete widgets instead of porting them to GTK4

TalkatuMenuToolButton and TalkatuToolDrawer were mean to be used to mimic the
condensed format bar that is in Pidgin 2, but it never worked right and we'll
probably revisit the toolbar in the near future.

TalkatuMessageActions was intended to be used as an anchor widget in the
history when the history was still GtkTextView based. Now that the history is
based on GtkListBox this is no longer necessary.

Testing Done:
This was originally built against the default branch where it was compiled without any warning/errors and passed the unit tests.

Reviewed at https://reviews.imfreedom.org/r/1237/
--- a/talkatu/meson.build Sun Jan 16 00:10:38 2022 -0600
+++ b/talkatu/meson.build Sun Jan 16 01:56:34 2022 -0600
@@ -21,15 +21,12 @@
'talkatulinkdialog.h',
'talkatumarkdownbuffer.h',
'talkatumarkup.h',
- 'talkatumenutoolbutton.h',
'talkatumessage.h',
- 'talkatumessageactions.h',
'talkatuscrolledwindow.h',
'talkatusimpleattachment.h',
'talkatutag.h',
'talkatutagtable.h',
'talkatutoolbar.h',
- 'talkatutooldrawer.h',
'talkatutypinglabel.h',
'talkatuview.h',
'talkatuwholebuffer.h',
@@ -53,15 +50,12 @@
'talkatulinkdialog.c',
'talkatumarkdownbuffer.c',
'talkatumarkup.c',
- 'talkatumenutoolbutton.c',
'talkatumessage.c',
- 'talkatumessageactions.c',
'talkatuscrolledwindow.c',
'talkatusimpleattachment.c',
'talkatutag.c',
'talkatutagtable.c',
'talkatutoolbar.c',
- 'talkatutooldrawer.c',
'talkatutypinglabel.c',
'talkatuview.c',
'talkatuwholebuffer.c',
--- a/talkatu/talkatumenutoolbutton.c Sun Jan 16 00:10:38 2022 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-/*
- * Talkatu - GTK widgets for chat applications
- * Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library 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 library 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 library; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-
-#include "talkatu/talkatumenutoolbutton.h"
-
-/**
- * TalkatuMenuToolButton:
- *
- * A #GtkToolButton subclass that behaves like a #GtkComboBox.
- */
-
-struct _TalkatuMenuToolButton {
- GtkToolButton parent;
-
- GtkWidget *menu;
-};
-
-G_DEFINE_TYPE(TalkatuMenuToolButton, talkatu_menu_tool_button, GTK_TYPE_TOOL_BUTTON)
-
-enum {
- PROP_0 = 0,
- PROP_MENU,
- N_PROPERTIES,
-};
-
-static GParamSpec *properties[N_PROPERTIES] = {NULL,};
-
-/******************************************************************************
- * GObject Stuff
- *****************************************************************************/
-
-static void
-talkatu_menu_tool_button_clicked(GtkToolButton *button) {
- TalkatuMenuToolButton *menu_button = TALKATU_MENU_TOOL_BUTTON(button);
-
- gtk_menu_popup_at_widget(GTK_MENU(menu_button->menu),
- GTK_WIDGET(button),
- GDK_GRAVITY_SOUTH_WEST,
- GDK_GRAVITY_NORTH_WEST,
- NULL);
-}
-
-static void
-talkatu_menu_tool_button_get_property(GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec) {
- TalkatuMenuToolButton *menu_button = TALKATU_MENU_TOOL_BUTTON(obj);
-
- switch(prop_id) {
- case PROP_MENU:
- g_value_set_object(value, talkatu_menu_tool_button_get_menu(menu_button));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
- break;
- }
-}
-
-static void
-talkatu_menu_tool_button_set_property(GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec) {
- TalkatuMenuToolButton *menu_button = TALKATU_MENU_TOOL_BUTTON(obj);
-
- switch(prop_id) {
- case PROP_MENU:
- talkatu_menu_tool_button_set_menu(menu_button, g_value_get_object(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
- break;
- }
-}
-
-static void
-talkatu_menu_tool_button_init(TalkatuMenuToolButton *menu_button) {
-}
-
-static void
-talkatu_menu_tool_button_class_init(TalkatuMenuToolButtonClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- GtkToolButtonClass *button_class = GTK_TOOL_BUTTON_CLASS(klass);
-
- obj_class->get_property = talkatu_menu_tool_button_get_property;
- obj_class->set_property = talkatu_menu_tool_button_set_property;
-
- button_class->clicked = talkatu_menu_tool_button_clicked;
-
- properties[PROP_MENU] = g_param_spec_object(
- "menu", "menu", "The menu to show",
- GTK_TYPE_MENU,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT
- );
-
- g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
-}
-
-/******************************************************************************
- * Public API
- *****************************************************************************/
-
-/**
- * talkatu_menu_tool_button_new:
- * @label: The label to display.
- * @icon_name: The optional name of the icon to display.
- * @menu: The menu to display.
- *
- * Creates a new #TalkatuMenuToolButton with the given @label, @icon_name, and
- * @menu.
- *
- * Returns: (transfer full): The new #TalkatuMenuToolButton instance.
- */
-GtkToolItem *
-talkatu_menu_tool_button_new(const gchar *label, const gchar *icon_name, GtkWidget *menu) {
- return g_object_new(
- TALKATU_TYPE_MENU_TOOL_BUTTON,
- "label", label,
- "icon-name", icon_name,
- "menu", menu,
- NULL
- );
-}
-
-/**
- * talkatu_menu_tool_button_get_menu:
- * @menu_button: The #TalkatuMenuToolButton instance.
- *
- * Gets the menu that this tool button will display on click or #NULL if no
- * menu is set.
- *
- * Returns: (transfer full): The menu.
- */
-GtkWidget *
-talkatu_menu_tool_button_get_menu(TalkatuMenuToolButton *menu_button) {
- g_return_val_if_fail(TALKATU_IS_MENU_TOOL_BUTTON(menu_button), FALSE);
-
- if(menu_button->menu) {
- return g_object_ref(menu_button->menu);
- }
-
- return NULL;
-}
-
-/**
- * talkatu_menu_tool_button_set_menu:
- * @menu_button: The #TalkatuMenuToolButton instance.
- * @menu: The menu to set.
- *
- * Sets the menu to be displayed when the user clicks the button.
- */
-void
-talkatu_menu_tool_button_set_menu(TalkatuMenuToolButton *menu_button, GtkWidget *menu) {
- g_return_if_fail(TALKATU_IS_MENU_TOOL_BUTTON(menu_button));
-
- if(menu_button->menu) {
- gtk_menu_detach(GTK_MENU(menu_button->menu));
- g_object_unref(G_OBJECT(menu_button->menu));
- }
-
- if(menu) {
- menu_button->menu = GTK_WIDGET(g_object_ref(G_OBJECT(menu)));
- gtk_menu_attach_to_widget(GTK_MENU(menu_button->menu), GTK_WIDGET(menu_button), NULL);
- } else {
- menu_button->menu = NULL;
- }
-}
--- a/talkatu/talkatumenutoolbutton.h Sun Jan 16 00:10:38 2022 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Talkatu - GTK widgets for chat applications
- * Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library 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 library 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 library; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#if !defined(TALKATU_GLOBAL_HEADER_INSIDE) && !defined(TALKATU_COMPILATION)
-#error "only <talkatu.h> may be included directly"
-#endif
-
-#ifndef TALKATU_MENU_TOOL_BUTTON_H
-#define TALKATU_MENU_TOOL_BUTTON_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define TALKATU_TYPE_MENU_TOOL_BUTTON (talkatu_menu_tool_button_get_type())
-
-G_DECLARE_FINAL_TYPE(TalkatuMenuToolButton, talkatu_menu_tool_button, TALKATU, MENU_TOOL_BUTTON, GtkToolButton)
-
-GtkToolItem *talkatu_menu_tool_button_new(const gchar *label, const gchar *icon_name, GtkWidget *menu);
-
-GtkWidget *talkatu_menu_tool_button_get_menu(TalkatuMenuToolButton *menu_button);
-void talkatu_menu_tool_button_set_menu(TalkatuMenuToolButton *menu_button, GtkWidget *menu);
-
-G_END_DECLS
-
-#endif /* TALKATU_MENU_TOOL_BUTTON_H */
--- a/talkatu/talkatumessageactions.c Sun Jan 16 00:10:38 2022 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-/*
- * Talkatu - GTK widgets for chat applications
- * Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library 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 library 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 library; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#include <gtk/gtk.h>
-
-#include "talkatu/talkatumessageactions.h"
-
-/**
- * TalkatuMessageActions:
- *
- * A composite #GtkWidget to allow the user to interact with a message in a
- * #TalkatuHistory.
- */
-struct _TalkatuMessageActions {
- GtkBox parent;
-
- TalkatuMessage *message;
-};
-
-enum {
- PROP_0,
- PROP_MESSAGE,
- N_PROPERTIES,
-};
-
-static GParamSpec *properties[N_PROPERTIES] = {NULL,};
-
-G_DEFINE_TYPE(TalkatuMessageActions, talkatu_message_actions, GTK_TYPE_BOX)
-
-/******************************************************************************
- * Helpers
- *****************************************************************************/
-static void
-talkatu_message_actions_set_message(TalkatuMessageActions *message_actions,
- TalkatuMessage *message)
-{
- if(message_actions->message) {
- g_object_unref(G_OBJECT(message_actions->message));
- }
-
- if(g_set_object(&message_actions->message, message)) {
- g_object_notify_by_pspec(G_OBJECT(message_actions), properties[PROP_MESSAGE]);
- }
-}
-
-/******************************************************************************
- * GObject Stuff
- *****************************************************************************/
-static void
-talkatu_message_actions_get_property(GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- TalkatuMessageActions *message_actions = TALKATU_MESSAGE_ACTIONS(obj);
-
- switch(prop_id) {
- case PROP_MESSAGE:
- g_value_set_object(value, talkatu_message_actions_get_message(message_actions));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
- break;
- }
-}
-
-static void
-talkatu_message_actions_set_property(GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- TalkatuMessageActions *message_actions = TALKATU_MESSAGE_ACTIONS(obj);
-
- switch(prop_id) {
- case PROP_MESSAGE:
- talkatu_message_actions_set_message(message_actions, g_value_get_object(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
- break;
- }
-}
-
-static void
-talkatu_message_actions_finalize(GObject *obj) {
- TalkatuMessageActions *message_actions = TALKATU_MESSAGE_ACTIONS(obj);
-
- g_object_unref(G_OBJECT(message_actions->message));
-
- G_OBJECT_CLASS(talkatu_message_actions_parent_class)->finalize(obj);
-}
-
-static void
-talkatu_message_actions_init(TalkatuMessageActions *message_actions) {
- gtk_widget_init_template(GTK_WIDGET(message_actions));
-}
-
-static void
-talkatu_message_actions_class_init(TalkatuMessageActionsClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
- obj_class->get_property = talkatu_message_actions_get_property;
- obj_class->set_property = talkatu_message_actions_set_property;
- obj_class->finalize = talkatu_message_actions_finalize;
-
- properties[PROP_MESSAGE] = g_param_spec_object(
- "message", "message", "The message that this widget is for",
- G_TYPE_OBJECT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- );
-
- g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
-
- gtk_widget_class_set_template_from_resource(
- GTK_WIDGET_CLASS(klass),
- "/org/imfreedom/keep/talkatu/talkatu/ui/messageactions.ui"
- );
-}
-
-/******************************************************************************
- * Public API
- *****************************************************************************/
-
-/**
- * talkatu_message_actions_new:
- * @message: The #TalkatuMessage instance.
- *
- * Creates a new #TalkatuMessageActions that provides the user with an interface to
- * control the formatting of a #TalkatuBuffer.
- *
- * Returns: (transfer full): The new #TalkatuMessageActions instance.
- */
-GtkWidget *
-talkatu_message_actions_new(TalkatuMessage *message) {
- return GTK_WIDGET(g_object_new(
- TALKATU_TYPE_MESSAGE_ACTIONS,
- "message", message,
- NULL
- ));
-}
-
-/**
- * talkatu_message_actions_get_message:
- * @message_actions: The #TalkatuMessageActions instance.
- *
- * Gets the #TalkatuMessage associated with @message_action.
- *
- * Returns: (transfer none): The #TalkatuMessage associated with @message_action.
- */
-TalkatuMessage *
-talkatu_message_actions_get_message(TalkatuMessageActions *message_actions) {
- g_return_val_if_fail(TALKATU_IS_MESSAGE_ACTIONS(message_actions), NULL);
-
- return message_actions->message;
-}
--- a/talkatu/talkatumessageactions.h Sun Jan 16 00:10:38 2022 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Talkatu - GTK widgets for chat applications
- * Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library 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 library 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 library; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#if !defined(TALKATU_GLOBAL_HEADER_INSIDE) && !defined(TALKATU_COMPILATION)
-#error "only <talkatu.h> may be included directly"
-#endif
-
-#ifndef TALKATU_MESSAGE_ACTIONS_H
-#define TALKATU_MESSAGE_ACTIONS_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <gtk/gtk.h>
-
-#include <talkatu/talkatumessage.h>
-
-G_BEGIN_DECLS
-
-#define TALKATU_TYPE_MESSAGE_ACTIONS (talkatu_message_actions_get_type())
-
-G_DECLARE_FINAL_TYPE(TalkatuMessageActions, talkatu_message_actions, TALKATU, MESSAGE_ACTIONS, GtkBox)
-
-GtkWidget *talkatu_message_actions_new(TalkatuMessage *message);
-
-TalkatuMessage *talkatu_message_actions_get_message(TalkatuMessageActions *message_actions);
-
-G_END_DECLS
-
-#endif /* TALKATU_MESSAGE_ACTIONS_H */
--- a/talkatu/talkatutooldrawer.c Sun Jan 16 00:10:38 2022 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,357 +0,0 @@
-/*
- * Talkatu - GTK widgets for chat applications
- * Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library 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 library 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 library; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-
-#include "talkatu/talkatutooldrawer.h"
-#include "talkatu/talkatumenutoolbutton.h"
-
-typedef struct {
- GAction *action;
- gchar *markup;
- gchar *icon_name;
- gchar *tooltip;
- GCallback callback;
-} TalkatuToolDrawerItem;
-
-/**
- * TalkatuToolDrawer:
- *
- * A #GtkToolItem subclass that displays a menu of items or can be expanded
- * to show all of the items as a toolbar.
- *
- * Stability: Unstable
- */
-struct _TalkatuToolDrawer {
- GtkToolItem parent;
-
- gchar *label;
- gchar *icon_name;
- gboolean expanded;
-
- GtkWidget *menu;
-
- GtkToolItem *menu_button;
- GtkWidget *box;
- GtkWidget *icons;
-};
-
-enum {
- PROP_0 = 0,
- PROP_LABEL,
- PROP_ICON_NAME,
- PROP_EXPANDED,
- N_PROPERTIES,
-};
-
-static GParamSpec *properties[N_PROPERTIES] = {NULL,};
-
-G_DEFINE_TYPE(TalkatuToolDrawer, talkatu_tool_drawer, GTK_TYPE_TOOL_ITEM)
-
-/******************************************************************************
- * GObject Stuff
- *****************************************************************************/
-static void
-talkatu_tool_drawer_get_property(GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec) {
- TalkatuToolDrawer *drawer = TALKATU_TOOL_DRAWER(obj);
-
- switch(prop_id) {
- case PROP_LABEL:
- g_value_set_string(value, talkatu_tool_drawer_get_label(drawer));
- break;
- case PROP_ICON_NAME:
- g_value_set_string(value, talkatu_tool_drawer_get_icon_name(drawer));
- break;
- case PROP_EXPANDED:
- g_value_set_boolean(value, talkatu_tool_drawer_get_expanded(drawer));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
- break;
- }
-}
-
-static void
-talkatu_tool_drawer_set_property(GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec) {
- TalkatuToolDrawer *drawer = TALKATU_TOOL_DRAWER(obj);
-
- switch(prop_id) {
- case PROP_LABEL:
- talkatu_tool_drawer_set_label(drawer, g_value_get_string(value));
- break;
- case PROP_ICON_NAME:
- talkatu_tool_drawer_set_icon_name(drawer, g_value_get_string(value));
- break;
- case PROP_EXPANDED:
- talkatu_tool_drawer_set_expanded(drawer, g_value_get_boolean(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec);
- break;
- }
-}
-
-static void
-talkatu_tool_drawer_init(TalkatuToolDrawer *drawer) {
-}
-
-static void
-talkatu_tool_drawer_constructed(GObject *obj) {
- TalkatuToolDrawer *drawer = TALKATU_TOOL_DRAWER(obj);
-
- drawer->menu = gtk_menu_new();
-
- drawer->box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_container_add(GTK_CONTAINER(drawer), drawer->box);
-
- drawer->menu_button = talkatu_menu_tool_button_new(drawer->label, drawer->icon_name, drawer->menu);
- gtk_box_pack_start(GTK_BOX(drawer->box), GTK_WIDGET(drawer->menu_button), FALSE, FALSE, 0);
-
- drawer->icons = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
- gtk_box_pack_start(GTK_BOX(drawer->box), drawer->icons, FALSE, FALSE, 0);
-
- /* Start collapsed. */
- g_object_set(G_OBJECT(drawer->menu_button), "no-show-all", FALSE, NULL);
- gtk_widget_show_all(GTK_WIDGET(drawer->menu_button));
- g_object_set(G_OBJECT(drawer->icons), "no-show-all", TRUE, NULL);
-}
-
-static void
-talkatu_tool_drawer_class_init(TalkatuToolDrawerClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
- obj_class->get_property = talkatu_tool_drawer_get_property;
- obj_class->set_property = talkatu_tool_drawer_set_property;
- obj_class->constructed = talkatu_tool_drawer_constructed;
-
- properties[PROP_LABEL] = g_param_spec_string(
- "label", "label", "The label to display when not expanded",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- );
- properties[PROP_ICON_NAME] = g_param_spec_string(
- "icon-name", "icon-name", "The name of the icon to display when not expanded",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- );
- properties[PROP_EXPANDED] = g_param_spec_boolean(
- "expanded", "expanded", "Whether or not the drawer is expanded",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT
- );
-
- g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
-}
-
-/******************************************************************************
- * Public API
- *****************************************************************************/
-
-/**
- * talkatu_tool_drawer_new:
- * @label: The label to give item.
- * @icon_name: The name of the icon for this item.
- *
- * Creates a new #TalkatuToolDrawer instance.
- *
- * Returns: (transfer full): The new #TalkatuToolDrawer instance.
- */
-GtkToolItem *
-talkatu_tool_drawer_new(const gchar *label, const gchar *icon_name) {
- return g_object_new(
- TALKATU_TYPE_TOOL_DRAWER,
- "label", label,
- "icon-name", icon_name,
- NULL
- );
-}
-
-/**
- * talkatu_tool_drawer_add_item:
- * @drawer: The #TalkatuToolDrawer instance.
- * @action: The #GAction to add.
- * @markup: Pango markup to use as a label.
- * @icon_name: The name of the icon to display.
- * @tooltip: UTF-8 text to display as a tooltip.
- * @callback: (scope notified): The callback to call when the item is
- * activated.
- *
- * Adds a new item to @drawer.
- */
-void
-talkatu_tool_drawer_add_item(TalkatuToolDrawer *drawer, GAction *action, const gchar *markup, const gchar *icon_name, gchar *tooltip, GCallback callback) {
- GtkWidget *button = NULL, *item = NULL, *label = NULL, *image = NULL;
- const GVariantType *state_type = NULL;
-
- g_return_if_fail(TALKATU_IS_TOOL_DRAWER(drawer));
-
- /* create the menu item */
- state_type = g_action_get_state_type(action);
- if(state_type) {
- item = gtk_check_menu_item_new();
- } else {
- item = gtk_menu_item_new();
- }
-
- label = gtk_label_new(markup);
- gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
- gtk_label_set_xalign(GTK_LABEL(label), 0);
- gtk_container_add(GTK_CONTAINER(item), label);
-
- gtk_menu_shell_append(GTK_MENU_SHELL(drawer->menu), item);
- gtk_widget_show_all(item);
-
- /* create the toolbar button and add it to the toolbar */
- if(state_type) {
- button = gtk_toggle_button_new();
- } else {
- button = gtk_button_new();
- }
-
- gtk_widget_set_can_focus(button, FALSE);
- gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-
- image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
- gtk_container_add(GTK_CONTAINER(button), image);
-
- gtk_box_pack_start(GTK_BOX(drawer->icons), button, FALSE, FALSE, 0);
-}
-
-/**
- * talkatu_tool_drawer_add_separator:
- * @drawer: The #TalkatuToolDrawer instance.
- *
- * Adds a separator to the end of @drawer.
- */
-void
-talkatu_tool_drawer_add_separator(TalkatuToolDrawer *drawer) {
- g_return_if_fail(TALKATU_IS_TOOL_DRAWER(drawer));
-
- gtk_menu_shell_append(GTK_MENU_SHELL(drawer->menu), gtk_separator_menu_item_new());
-
- gtk_box_pack_start(GTK_BOX(drawer->icons), gtk_separator_new(GTK_ORIENTATION_VERTICAL), FALSE, FALSE, 0);
-}
-
-/**
- * talkatu_tool_drawer_get_label:
- * @drawer: The #TalkatuToolDrawer instance.
- *
- * Gets the label that's displayed when @drawer is collapsed.
- *
- * Returns: The label to use when @drawer is collapsed.
- */
-const gchar *
-talkatu_tool_drawer_get_label(TalkatuToolDrawer *drawer) {
- g_return_val_if_fail(TALKATU_IS_TOOL_DRAWER(drawer), FALSE);
-
- return drawer->label;
-}
-
-/**
- * talkatu_tool_drawer_set_label:
- * @drawer: The #TalkatuToolDrawer instance.
- * @label: The label to use when @drawer is collapsed.
- *
- * Sets the label to be displayed when @drawer is collapsed.
- */
-void
-talkatu_tool_drawer_set_label(TalkatuToolDrawer *drawer, const gchar *label) {
- g_return_if_fail(TALKATU_IS_TOOL_DRAWER(drawer));
-
- g_free(drawer->label);
-
- drawer->label = g_strdup(label);
-
- g_object_notify_by_pspec(G_OBJECT(drawer), properties[PROP_LABEL]);
-}
-
-/**
- * talkatu_tool_drawer_get_icon_name:
- * @drawer: The #TalkatuToolDrawer instance.
- *
- * Gets the icon name for @drawer.
- *
- * Returns: The icon name for @drawer.
- */
-const gchar *
-talkatu_tool_drawer_get_icon_name(TalkatuToolDrawer *drawer) {
- g_return_val_if_fail(TALKATU_IS_TOOL_DRAWER(drawer), FALSE);
-
- return drawer->icon_name;
-}
-
-/**
- * talkatu_tool_drawer_set_icon_name:
- * @drawer: The #TalkatuToolDrawer instance.
- * @icon_name: The name of the icon to display when collapse.
- *
- * Sets the name of the icon to be displayed when @drawer is collapsed.
- */
-void
-talkatu_tool_drawer_set_icon_name(TalkatuToolDrawer *drawer, const gchar *icon_name) {
- g_return_if_fail(TALKATU_IS_TOOL_DRAWER(drawer));
-
- g_free(drawer->icon_name);
-
- drawer->icon_name = g_strdup(icon_name);
-
- g_object_notify_by_pspec(G_OBJECT(drawer), properties[PROP_ICON_NAME]);
-}
-
-/**
- * talkatu_tool_drawer_set_expanded:
- * @drawer: The #TalkatuToolDrawer instance.
- * @expanded: %TRUE to expand @drawer, %FALSE to collapse.
- *
- * Sets whether or not @drawer is expanded.
- */
-void
-talkatu_tool_drawer_set_expanded(TalkatuToolDrawer *drawer, gboolean expanded) {
- g_return_if_fail(TALKATU_IS_TOOL_DRAWER(drawer));
-
- if(expanded != drawer->expanded) {
- drawer->expanded = expanded;
-
- g_object_set(G_OBJECT(drawer->menu_button), "no-show-all", drawer->expanded, NULL);
- g_object_set(G_OBJECT(drawer->icons), "no-show-all", !drawer->expanded, NULL);
- if(expanded) {
- gtk_widget_hide(GTK_WIDGET(drawer->menu_button));
- gtk_widget_show_all(drawer->icons);
- } else {
- gtk_widget_show_all(GTK_WIDGET(drawer->menu_button));
- gtk_widget_hide(drawer->icons);
- }
-
- g_object_notify_by_pspec(G_OBJECT(drawer), properties[PROP_EXPANDED]);
- }
-}
-
-/**
- * talkatu_tool_drawer_get_expanded:
- * @drawer: The #TalkatuToolDrawer instance.
- *
- * Gets whether or not @drawer is expanded.
- *
- * Returns: %TRUE if @drawer is expanded, %FALSE otherwise.
- */
-gboolean
-talkatu_tool_drawer_get_expanded(TalkatuToolDrawer *drawer) {
- g_return_val_if_fail(TALKATU_IS_TOOL_DRAWER(drawer), FALSE);
-
- return drawer->expanded;
-}
--- a/talkatu/talkatutooldrawer.h Sun Jan 16 00:10:38 2022 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Talkatu - GTK widgets for chat applications
- * Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library 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 library 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 library; if not, see <https://www.gnu.org/licenses/>.
- */
-
-#if !defined(TALKATU_GLOBAL_HEADER_INSIDE) && !defined(TALKATU_COMPILATION)
-#error "only <talkatu.h> may be included directly"
-#endif
-
-#ifndef TALKATU_TOOL_DRAWER_H
-#define TALKATU_TOOL_DRAWER_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define TALKATU_TYPE_TOOL_DRAWER (talkatu_tool_drawer_get_type())
-
-G_DECLARE_FINAL_TYPE(TalkatuToolDrawer, talkatu_tool_drawer, TALKATU, TOOL_DRAWER, GtkToolItem)
-
-GtkToolItem *talkatu_tool_drawer_new(const gchar *label, const gchar *icon_name);
-
-void talkatu_tool_drawer_add_item(TalkatuToolDrawer *drawer, GAction *action, const gchar *markup, const gchar *icon_name, gchar *tooltip, GCallback callback);
-void talkatu_tool_drawer_add_separator(TalkatuToolDrawer *drawer);
-
-const gchar *talkatu_tool_drawer_get_label(TalkatuToolDrawer *drawer);
-void talkatu_tool_drawer_set_label(TalkatuToolDrawer *drawer, const gchar *label);
-
-const gchar *talkatu_tool_drawer_get_icon_name(TalkatuToolDrawer *drawer);
-void talkatu_tool_drawer_set_icon_name(TalkatuToolDrawer *drawer, const gchar *icon_name);
-
-void talkatu_tool_drawer_set_expanded(TalkatuToolDrawer *drawer, gboolean expanded);
-gboolean talkatu_tool_drawer_get_expanded(TalkatuToolDrawer *drawer);
-
-G_END_DECLS
-
-#endif /* TALKATU_TOOL_DRAWER_H */