# HG changeset patch # User Elliott Sales de Andrade # Date 1660882972 18000 # Node ID bdacc88a9562f141bbb33d9becbda6a577ed62a8 # Parent fff3a446f76d1e4c16210fa29c945f661cb3499a Remove use of PidginCellRendererExpander The point of this renderer is to draw an expander manually, thereby allowing the tree view's expander to be hidden. This makes the contact appear at the same indent level as the group. But if we're re-designing the whole widget, there's probably not going to be a need for this manual work. And it drops another file we'd need to port to GTK4. Testing Done: Compiled and opened the buddy list; expanders were still there on groups. The contacts were just indented a bit more. Reviewed at https://reviews.imfreedom.org/r/1607/ diff -r fff3a446f76d -r bdacc88a9562 ChangeLog.API --- a/ChangeLog.API Thu Aug 18 23:16:24 2022 -0500 +++ b/ChangeLog.API Thu Aug 18 23:22:52 2022 -0500 @@ -874,6 +874,9 @@ * pidgin_buddy_icon_chooser_new * PidginBuddyList.connection_errors * PidginButtonStyle + * PidginCellRendererExpander + * PIDGIN_TYPE_CELL_RENDERER_EXPANDER + * pidgin_cell_renderer_expander_new * pidgin_check_if_dir * pidgin_clear_cursor * PidginConversation.sg diff -r fff3a446f76d -r bdacc88a9562 pidgin/gtkblist.c --- a/pidgin/gtkblist.c Thu Aug 18 23:16:24 2022 -0500 +++ b/pidgin/gtkblist.c Thu Aug 18 23:22:52 2022 -0500 @@ -41,7 +41,6 @@ #include "pidgin/pidginaccountstore.h" #include "pidgin/pidginactiongroup.h" #include "pidgin/pidginaddbuddydialog.h" -#include "pidgin/pidgincellrendererexpander.h" #include "pidgin/pidgincontactlistwindow.h" #include "pidgin/pidgincore.h" #include "pidgin/pidgindebug.h" @@ -90,10 +89,6 @@ NAME_COLUMN, BUDDY_ICON_COLUMN, NODE_COLUMN, - GROUP_EXPANDER_COLUMN, - GROUP_EXPANDER_VISIBLE_COLUMN, - CONTACT_EXPANDER_COLUMN, - CONTACT_EXPANDER_VISIBLE_COLUMN, EMBLEM_COLUMN, EMBLEM_VISIBLE_COLUMN, PROTOCOL_ICON_COLUMN, @@ -2960,24 +2955,6 @@ gtk_tree_view_column_clear(column); - /* group */ - rend = pidgin_cell_renderer_expander_new(); - gtk_tree_view_column_pack_start(column, rend, FALSE); - gtk_tree_view_column_set_attributes(column, rend, - "visible", GROUP_EXPANDER_VISIBLE_COLUMN, - "is-expanded", GROUP_EXPANDER_COLUMN, - "sensitive", GROUP_EXPANDER_COLUMN, - NULL); - - /* contact */ - rend = pidgin_cell_renderer_expander_new(); - gtk_tree_view_column_pack_start(column, rend, FALSE); - gtk_tree_view_column_set_attributes(column, rend, - "visible", CONTACT_EXPANDER_VISIBLE_COLUMN, - "is-expanded", CONTACT_EXPANDER_COLUMN, - "sensitive", CONTACT_EXPANDER_COLUMN, - NULL); - /* status icons */ rend = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(column, rend, FALSE); @@ -3110,7 +3087,6 @@ { GSimpleActionGroup *action_group = NULL; void *handle; - GtkTreeViewColumn *column; GtkWidget *sep; GtkEventController *key_controller = NULL; GtkTreeSelection *selection; @@ -3163,12 +3139,6 @@ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE); - /* expander columns */ - column = gtk_tree_view_column_new(); - gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column); - gtk_tree_view_column_set_visible(column, FALSE); - gtk_tree_view_set_expander_column(GTK_TREE_VIEW(gtkblist->treeview), column); - /* everything else column */ gtkblist->text_column = gtk_tree_view_column_new (); gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->text_column); @@ -3471,9 +3441,6 @@ STATUS_ICON_COLUMN, NULL, NAME_COLUMN, title, NODE_COLUMN, gnode, - GROUP_EXPANDER_COLUMN, TRUE, - GROUP_EXPANDER_VISIBLE_COLUMN, TRUE, - CONTACT_EXPANDER_VISIBLE_COLUMN, FALSE, BUDDY_ICON_COLUMN, avatar, EMBLEM_VISIBLE_COLUMN, FALSE, -1); @@ -3519,7 +3486,6 @@ static void buddy_node(PurpleBuddy *buddy, GtkTreeIter *iter, PurpleBlistNode *node) { PurplePresence *presence = purple_buddy_get_presence(buddy); - PidginBlistNode *pidgin_node = NULL; GdkPixbuf *status, *avatar, *emblem, *protocol_icon; char *mark; char *idle = NULL; @@ -3529,8 +3495,6 @@ return; } - pidgin_node = g_object_get_data(G_OBJECT(node->parent), UI_DATA); - status = pidgin_blist_get_status_icon(PURPLE_BLIST_NODE(buddy), PIDGIN_STATUS_ICON_LARGE); avatar = pidgin_blist_get_buddy_icon(PURPLE_BLIST_NODE(buddy), TRUE, TRUE); @@ -3554,9 +3518,6 @@ EMBLEM_COLUMN, emblem, EMBLEM_VISIBLE_COLUMN, (emblem != NULL), PROTOCOL_ICON_COLUMN, protocol_icon, - CONTACT_EXPANDER_COLUMN, NULL, - CONTACT_EXPANDER_VISIBLE_COLUMN, pidgin_node->contact_expanded, - GROUP_EXPANDER_VISIBLE_COLUMN, FALSE, -1); g_free(mark); @@ -3622,9 +3583,6 @@ STATUS_ICON_VISIBLE_COLUMN, TRUE, NAME_COLUMN, mark, BUDDY_ICON_COLUMN, NULL, - CONTACT_EXPANDER_COLUMN, TRUE, - CONTACT_EXPANDER_VISIBLE_COLUMN, TRUE, - GROUP_EXPANDER_VISIBLE_COLUMN, FALSE, -1); g_free(mark); if(status) @@ -3723,7 +3681,6 @@ EMBLEM_VISIBLE_COLUMN, emblem != NULL, PROTOCOL_ICON_COLUMN, protocol_icon, NAME_COLUMN, mark, - GROUP_EXPANDER_VISIBLE_COLUMN, FALSE, -1); g_free(mark); diff -r fff3a446f76d -r bdacc88a9562 pidgin/meson.build --- a/pidgin/meson.build Thu Aug 18 23:16:24 2022 -0500 +++ b/pidgin/meson.build Thu Aug 18 23:22:52 2022 -0500 @@ -31,7 +31,6 @@ 'pidginapplication.c', 'pidginattachment.c', 'pidginavatar.c', - 'pidgincellrendererexpander.c', 'pidgincolor.c', 'pidgincommands.c', 'pidginconversationwindow.c', @@ -103,7 +102,6 @@ 'pidginapplication.h', 'pidginattachment.h', 'pidginavatar.h', - 'pidgincellrendererexpander.h', 'pidgincolor.h', 'pidginconversationwindow.h', 'pidgincontactlistwindow.h', diff -r fff3a446f76d -r bdacc88a9562 pidgin/pidgincellrendererexpander.c --- a/pidgin/pidgincellrendererexpander.c Thu Aug 18 23:16:24 2022 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ -/* - * Pidgin - Internet Messenger - * Copyright (C) Pidgin Developers - * - * 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 . - */ - -#include "pidgin/pidgincellrendererexpander.h" - -struct _PidginCellRendererExpander { - GtkCellRenderer parent; -}; - -G_DEFINE_TYPE(PidginCellRendererExpander, pidgin_cell_renderer_expander, - GTK_TYPE_CELL_RENDERER) - -/****************************************************************************** - * GtkCellRenderer Implementation - *****************************************************************************/ -static void -pidgin_cell_renderer_expander_get_size(GtkCellRenderer *renderer, - GtkWidget *widget, - const GdkRectangle *cell_area, - gint *x_offset, gint *y_offset, - gint *width, gint *height) -{ - gint calc_width = 0, calc_height = 0; - gint xpad = 0, ypad = 0; - gint expander_size = 0; - - gtk_widget_style_get(widget, "expander-size", &expander_size, NULL); - - gtk_cell_renderer_get_padding(renderer, &xpad, &ypad); - calc_width = (xpad * 2) + expander_size; - calc_height = (ypad * 2) + expander_size; - - if(width) { - *width = calc_width; - } - - if(height) { - *height = calc_height; - } - - if(cell_area) { - gfloat xalign = 0.0f, yalign = 0.0f; - - gtk_cell_renderer_get_alignment(renderer, &xalign, &yalign); - - if(x_offset) { - *x_offset = (gint)(xalign * (cell_area->width - calc_width)); - *x_offset = MAX (*x_offset, 0); - } - - if(y_offset) { - *y_offset = (gint)(yalign * (cell_area->height - calc_height)); - *y_offset = MAX (*y_offset, 0); - } - } -} - -static void -pidgin_cell_renderer_expander_render(GtkCellRenderer *renderer, cairo_t *cr, - GtkWidget *widget, - const GdkRectangle *background_area, - const GdkRectangle *cell_area, - GtkCellRendererState flags) -{ - GtkStateFlags state; - GtkStyleContext *context = NULL; - gboolean is_expanded = FALSE, is_expander = FALSE; - gint xpad = 0, ypad = 0; - gint width = cell_area->width, height = cell_area->height; - - /* if the row doesn't have children, bail out. */ - g_object_get(G_OBJECT(renderer), "is-expander", &is_expander, NULL); - if(!is_expander) { - return; - } - - /* Figure out the state of the renderer. */ - if(!gtk_widget_get_sensitive(widget)) { - state = GTK_STATE_FLAG_INSENSITIVE; - } else if(flags & GTK_CELL_RENDERER_PRELIT) { - state = GTK_STATE_FLAG_PRELIGHT; - } else if(gtk_widget_has_focus(widget) && flags & GTK_CELL_RENDERER_SELECTED) { - state = GTK_STATE_FLAG_ACTIVE; - } else { - state = GTK_STATE_FLAG_NORMAL; - } - - g_object_get(G_OBJECT(renderer), "is-expanded", &is_expanded, NULL); - if(is_expanded) { - state |= GTK_STATE_FLAG_CHECKED; - } else { - state &= ~GTK_STATE_FLAG_CHECKED; - } - - /* Build our style context */ - context = gtk_widget_get_style_context(widget); - gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW); - gtk_style_context_add_class(context, GTK_STYLE_CLASS_EXPANDER); - gtk_style_context_set_state(context, state); - - /* Adjust the width and height according to the padding. */ - gtk_cell_renderer_get_padding(renderer, &xpad, &ypad); - width -= xpad * 2; - height -= ypad * 2; - - /* Render the arrow. */ - gtk_render_expander(context, cr, - cell_area->x + xpad, cell_area->y + ypad, - width, height); -} - -static gboolean -pidgin_cell_renderer_expander_activate(GtkCellRenderer *r, GdkEvent *event, - GtkWidget *widget, const gchar *p, - const GdkRectangle *bg, - const GdkRectangle *cell, - GtkCellRendererState flags) -{ - GtkTreePath *path = gtk_tree_path_new_from_string(p); - - if(gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path)) { - gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path); - } else { - gtk_tree_view_expand_row(GTK_TREE_VIEW(widget),path,FALSE); - } - - gtk_tree_path_free(path); - - return FALSE; -} - -/****************************************************************************** - * GObject Implementation - *****************************************************************************/ -static void -pidgin_cell_renderer_expander_init (PidginCellRendererExpander *renderer) { - /* there's no accessor for setting the mode, so we have to set the property - * explicitly. - */ - g_object_set(G_OBJECT(renderer), "mode", - GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); - - gtk_cell_renderer_set_padding(GTK_CELL_RENDERER(renderer), 0, 2); -} - -static void -pidgin_cell_renderer_expander_class_init(PidginCellRendererExpanderClass *klass) -{ - GtkCellRendererClass *renderer_class = GTK_CELL_RENDERER_CLASS(klass); - - renderer_class->get_size = pidgin_cell_renderer_expander_get_size; - renderer_class->render = pidgin_cell_renderer_expander_render; - renderer_class->activate = pidgin_cell_renderer_expander_activate; -} - -/****************************************************************************** - * Public API - *****************************************************************************/ -GtkCellRenderer * -pidgin_cell_renderer_expander_new(void) { - return g_object_new(PIDGIN_TYPE_CELL_RENDERER_EXPANDER, NULL); -} diff -r fff3a446f76d -r bdacc88a9562 pidgin/pidgincellrendererexpander.h --- a/pidgin/pidgincellrendererexpander.h Thu Aug 18 23:16:24 2022 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Pidgin - Internet Messenger - * Copyright (C) Pidgin Developers - * - * 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 . - */ - -#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION) -# error "only may be included directly" -#endif - -#ifndef PIDGIN_CELL_RENDERER_EXPANDER_H -#define PIDGIN_CELL_RENDERER_EXPANDER_H - -#include - -/** - * PidginCellRendererExpander: - * - * A #GtkCellRenderer that can hide its children. - */ - -#define PIDGIN_TYPE_CELL_RENDERER_EXPANDER (pidgin_cell_renderer_expander_get_type()) -G_DECLARE_FINAL_TYPE(PidginCellRendererExpander, pidgin_cell_renderer_expander, - PIDGIN, CELL_RENDERER_EXPANDER, GtkCellRenderer) - -G_BEGIN_DECLS - -/** - * pidgin_cell_renderer_expander_new: - * - * Creates a new #PidginCellRendererExpander. - * - * Returns: (transfer full): The new cell renderer. - */ -GtkCellRenderer *pidgin_cell_renderer_expander_new(void); - -G_END_DECLS - -#endif /* PIDGIN_CELL_RENDERER_EXPANDER_H */ diff -r fff3a446f76d -r bdacc88a9562 po/POTFILES.in --- a/po/POTFILES.in Thu Aug 18 23:16:24 2022 -0500 +++ b/po/POTFILES.in Thu Aug 18 23:22:52 2022 -0500 @@ -348,7 +348,6 @@ pidgin/pidginattachment.c pidgin/pidginavatar.c pidgin/pidgin.c -pidgin/pidgincellrendererexpander.c pidgin/pidgincolor.c pidgin/pidgincommands.c pidgin/pidgincontactlistwindow.c