From 8c312c5e02f69c224eea03412efdcc68ca729067 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 29 Jul 2022 01:45:25 +0300 Subject: [PATCH 55/55] gtk4: Add chat tools bar No color selection tools yet See osdn #45258 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/chatline.c | 55 ++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/client/gui-gtk-4.0/chatline.c b/client/gui-gtk-4.0/chatline.c index 9d2d6a9e32..98f73fd804 100644 --- a/client/gui-gtk-4.0/chatline.c +++ b/client/gui-gtk-4.0/chatline.c @@ -1044,17 +1044,17 @@ void chatline_scroll_to_bottom(bool delayed) } } -#ifdef TOOLBUTTON_GTK3 /**********************************************************************//** Tool button clicked. **************************************************************************/ -static void make_tag_callback(GtkToolButton *button, gpointer data) +static void make_tag_callback(GtkButton *button, gpointer data) { inputline_make_tag(GTK_ENTRY(data), GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "text_tag_type"))); } +#ifdef TOOLBUTTON_GTK3 /**********************************************************************//** Set the color for an object. Update the button if not NULL. **************************************************************************/ @@ -1318,9 +1318,9 @@ void chatline_init(void) { GtkWidget *vbox, *hgrid, *entry, *bbox; GtkWidget *button; -#ifdef TOOLBUTTON_GTK3 GtkWidget *toolbar; - GtkToolItem *item; + GtkWidget *item; +#ifdef TOOLBUTTON_GTK3 GdkRGBA color; #endif /* TOOLBUTTON_GTK3 */ int grid_col = 0; @@ -1352,53 +1352,56 @@ void chatline_init(void) hgrid = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); -#ifdef TOOLBUTTON_GTK3 /* First line: toolbar */ - toolbar = gtk_toolbar_new(); - gtk_box_append(GTK_GRID(vbox), toolbar); - gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), FALSE); - gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ); - gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), - GTK_ORIENTATION_HORIZONTAL); + toolbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); + gtk_box_append(GTK_BOX(vbox), toolbar); toolkit.toolbar = toolbar; + // #ifdef TOOLBUTTON_GTK3 + /* Bold button. */ - item = gtk_tool_button_new(gtk_image_new_from_icon_name("format-text-bold"), - _("Bold")); + item = gtk_button_new_from_icon_name("format-text-bold"); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); + /* _("Bold")); */ + + gtk_box_append(GTK_BOX(toolbar), item); g_object_set_data(G_OBJECT(item), "text_tag_type", GINT_TO_POINTER(TTT_BOLD)); g_signal_connect(item, "clicked", G_CALLBACK(make_tag_callback), entry); gtk_widget_set_tooltip_text(GTK_WIDGET(item), _("Bold (Ctrl-B)")); /* Italic button. */ - item = gtk_tool_button_new(gtk_image_new_from_icon_name("format-text-italic"), - _("Italic")); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); + item = gtk_button_new_from_icon_name("format-text-italic"); + + /* _("Italic")); */ + + gtk_box_append(GTK_BOX(toolbar), item); g_object_set_data(G_OBJECT(item), "text_tag_type", GINT_TO_POINTER(TTT_ITALIC)); g_signal_connect(item, "clicked", G_CALLBACK(make_tag_callback), entry); gtk_widget_set_tooltip_text(GTK_WIDGET(item), _("Italic (Ctrl-I)")); /* Strike button. */ - item = gtk_tool_button_new(gtk_image_new_from_icon_name("format-text-strikethrough"), - _("Strikethrough")); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); + item = gtk_button_new_from_icon_name("format-text-strikethrough"); + + /* _("Strikethrough")); */ + gtk_box_append(GTK_BOX(toolbar), item); g_object_set_data(G_OBJECT(item), "text_tag_type", GINT_TO_POINTER(TTT_STRIKE)); g_signal_connect(item, "clicked", G_CALLBACK(make_tag_callback), entry); gtk_widget_set_tooltip_text(GTK_WIDGET(item), _("Strikethrough (Ctrl-S)")); /* Underline button. */ - item = gtk_tool_button_new(gtk_image_new_from_icon_name("format-text-underline"), - _("Underline")); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); + item = gtk_button_new_from_icon_name("format-text-underline"); + + /* _("Underline")); */ + gtk_box_append(GTK_BOX(toolbar), item); g_object_set_data(G_OBJECT(item), "text_tag_type", GINT_TO_POINTER(TTT_UNDERLINE)); g_signal_connect(item, "clicked", G_CALLBACK(make_tag_callback), entry); gtk_widget_set_tooltip_text(GTK_WIDGET(item), _("Underline (Ctrl-U)")); +#ifdef TOOLBUTTON_GTK3 /* Color button. */ item = gtk_tool_button_new(NULL, _("Color")); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); @@ -1445,16 +1448,16 @@ void chatline_init(void) gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), -1); +#endif /* TOOLBUTTON_GTK3 */ /* Return button. */ - item = gtk_tool_button_new(NULL, _("OK")); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); + item = gtk_button_new_with_label(_("OK")); + gtk_box_append(GTK_BOX(toolbar), item); g_signal_connect_swapped(item, "clicked", G_CALLBACK(inputline_return), entry); gtk_widget_set_tooltip_text(GTK_WIDGET(item), /* TRANS: "Return" means the return key. */ _("Send the chat (Return)")); -#endif /* TOOLBUTTON_GTK3 */ /* Second line */ gtk_box_append(GTK_BOX(vbox), hgrid); -- 2.35.1