Set name on GTK widgets

GTK+3 themes can use widget names as a selector, so add names to some
windows and widgets to make positively identifying CSS nodes easier
This commit is contained in:
Jonathan Boeing 2021-08-14 18:44:35 -07:00
parent 5e237aee3c
commit 2816d7dbdc
9 changed files with 19 additions and 0 deletions

View file

@ -455,6 +455,8 @@ static GtkWidget *folderview_ctree_create(FolderView *folderview)
ctree = gtk_sctree_new_with_titles(N_FOLDER_COLS, col_pos[F_COL_FOLDER], ctree = gtk_sctree_new_with_titles(N_FOLDER_COLS, col_pos[F_COL_FOLDER],
titles); titles);
gtk_widget_set_name(GTK_WIDGET(ctree), "folderview_sctree");
if (prefs_common.show_col_headers == FALSE) if (prefs_common.show_col_headers == FALSE)
gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree)); gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree));
@ -608,6 +610,7 @@ FolderView *folderview_create(MainWindow *mainwin)
folderview = g_new0(FolderView, 1); folderview = g_new0(FolderView, 1);
scrolledwin = gtk_scrolled_window_new(NULL, NULL); scrolledwin = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_set_name(GTK_WIDGET(scrolledwin), "folderview");
gtk_scrolled_window_set_policy gtk_scrolled_window_set_policy
(GTK_SCROLLED_WINDOW(scrolledwin), (GTK_SCROLLED_WINDOW(scrolledwin),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC,

View file

@ -1524,6 +1524,7 @@ GtkWidget *gtkut_window_new (GtkWindowType type,
{ {
GtkWidget *window = gtk_window_new(type); GtkWidget *window = gtk_window_new(type);
gtk_window_set_role(GTK_WINDOW(window), class); gtk_window_set_role(GTK_WINDOW(window), class);
gtk_widget_set_name(GTK_WIDGET(window), class);
return window; return window;
} }

View file

@ -72,6 +72,7 @@ HeaderView *headerview_create(void)
headerview = g_new0(HeaderView, 1); headerview = g_new0(HeaderView, 1);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_name(GTK_WIDGET(hbox), "headerview");
gtk_container_set_border_width(GTK_CONTAINER(hbox), 2); gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);

View file

@ -1916,6 +1916,7 @@ MainWindow *main_window_create()
#ifndef GENERIC_UMPC #ifndef GENERIC_UMPC
hbox_stat = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); hbox_stat = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
gtk_widget_set_name(GTK_WIDGET(hbox_stat), "hbox_stat");
gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
warning_icon = gtkut_stock_button("dialog-warning", NULL); warning_icon = gtkut_stock_button("dialog-warning", NULL);

View file

@ -416,6 +416,7 @@ MessageView *messageview_create(MainWindow *mainwin)
mimeview->messageview = messageview; mimeview->messageview = messageview;
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_name(GTK_WIDGET(vbox), "messageview");
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(headerview), gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(headerview),
FALSE, FALSE, 0); FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(noticeview), gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(noticeview),

View file

@ -362,6 +362,7 @@ MimeView *mimeview_create(MainWindow *mainwin)
G_CALLBACK(mimeview_drag_data_get), mimeview); G_CALLBACK(mimeview_drag_data_get), mimeview);
mime_notebook = gtk_notebook_new(); mime_notebook = gtk_notebook_new();
gtk_widget_set_name(GTK_WIDGET(mime_notebook), "mime_notebook");
gtk_widget_show(mime_notebook); gtk_widget_show(mime_notebook);
gtk_widget_set_can_focus(mime_notebook, FALSE); gtk_widget_set_can_focus(mime_notebook, FALSE);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(mime_notebook), FALSE); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(mime_notebook), FALSE);
@ -401,6 +402,7 @@ MimeView *mimeview_create(MainWindow *mainwin)
G_CALLBACK(mime_toggle_button_cb), mimeview); G_CALLBACK(mime_toggle_button_cb), mimeview);
icon_mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); icon_mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_name(GTK_WIDGET(icon_mainbox), "mimeview_icon_mainbox");
gtk_widget_show(icon_mainbox); gtk_widget_show(icon_mainbox);
gtk_widget_set_size_request(icon_mainbox, 32, -1); gtk_widget_set_size_request(icon_mainbox, 32, -1);
gtk_box_pack_start(GTK_BOX(icon_mainbox), mime_toggle, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(icon_mainbox), mime_toggle, FALSE, FALSE, 0);
@ -410,6 +412,7 @@ MimeView *mimeview_create(MainWindow *mainwin)
G_CALLBACK(icon_scroll_size_allocate_cb), mimeview); G_CALLBACK(icon_scroll_size_allocate_cb), mimeview);
ctree_mainbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); ctree_mainbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_name(GTK_WIDGET(ctree_mainbox), "mimeview_ctree_mainbox");
gtk_box_pack_start(GTK_BOX(ctree_mainbox), scrolledwin, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(ctree_mainbox), scrolledwin, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(ctree_mainbox), "size_allocate", g_signal_connect(G_OBJECT(ctree_mainbox), "size_allocate",
G_CALLBACK(ctree_size_allocate_cb), mimeview); G_CALLBACK(ctree_size_allocate_cb), mimeview);
@ -459,6 +462,7 @@ MimeView *mimeview_create(MainWindow *mainwin)
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show(vbox); gtk_widget_show(vbox);
siginfoview = noticeview_create(mainwin); siginfoview = noticeview_create(mainwin);
gtk_widget_set_name(GTK_WIDGET(siginfoview->vgrid), "siginfoview");
noticeview_hide(siginfoview); noticeview_hide(siginfoview);
noticeview_set_icon_clickable(siginfoview, TRUE); noticeview_set_icon_clickable(siginfoview, TRUE);
gtk_box_pack_start(GTK_BOX(vbox), mime_notebook, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), mime_notebook, TRUE, TRUE, 0);
@ -470,6 +474,7 @@ MimeView *mimeview_create(MainWindow *mainwin)
gtk_paned_pack2(GTK_PANED(paned), vbox, TRUE, TRUE); gtk_paned_pack2(GTK_PANED(paned), vbox, TRUE, TRUE);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_name(GTK_WIDGET(hbox), "mimeview");
gtk_box_pack_start(GTK_BOX(hbox), paned, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), paned, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox), icon_mainbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), icon_mainbox, FALSE, FALSE, 0);

View file

@ -86,6 +86,7 @@ NoticeView *noticeview_create(MainWindow *mainwin)
noticeview->window = mainwin->window; noticeview->window = mainwin->window;
vgrid = gtk_grid_new(); vgrid = gtk_grid_new();
gtk_widget_set_name(GTK_WIDGET(vgrid), "noticeview");
gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
GTK_ORIENTATION_VERTICAL); GTK_ORIENTATION_VERTICAL);
gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4); gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4);

View file

@ -570,6 +570,7 @@ SummaryView *summary_create(MainWindow *mainwin)
#define SUMMARY_VBOX_SPACING 3 #define SUMMARY_VBOX_SPACING 3
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, SUMMARY_VBOX_SPACING); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, SUMMARY_VBOX_SPACING);
gtk_widget_set_name(GTK_WIDGET(vbox), "summaryview");
/* create status label */ /* create status label */
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
@ -6692,6 +6693,8 @@ static GtkWidget *summary_ctree_create(SummaryView *summaryview)
ctree = gtk_sctree_new_with_titles ctree = gtk_sctree_new_with_titles
(N_SUMMARY_COLS, col_pos[S_COL_SUBJECT], titles); (N_SUMMARY_COLS, col_pos[S_COL_SUBJECT], titles);
gtk_widget_set_name(GTK_WIDGET(ctree), "summaryview_sctree");
if (prefs_common.show_col_headers == FALSE) if (prefs_common.show_col_headers == FALSE)
gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree)); gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree));

View file

@ -1959,6 +1959,7 @@ static void textview_show_avatar(TextView *textview)
avatarr->image = NULL; /* avoid destroying */ avatarr->image = NULL; /* avoid destroying */
avatars_avatarrender_free(avatarr); avatars_avatarrender_free(avatarr);
gtk_widget_set_name(GTK_WIDGET(textview->image), "textview_avatar");
gtk_widget_show(textview->image); gtk_widget_show(textview->image);
gtk_widget_get_allocation(textview->text, &allocation); gtk_widget_get_allocation(textview->text, &allocation);
@ -1989,6 +1990,7 @@ void textview_show_icon(TextView *textview, const gchar *stock_id)
textview->image = gtk_image_new_from_icon_name(stock_id, GTK_ICON_SIZE_DIALOG); textview->image = gtk_image_new_from_icon_name(stock_id, GTK_ICON_SIZE_DIALOG);
cm_return_if_fail(textview->image != NULL); cm_return_if_fail(textview->image != NULL);
gtk_widget_set_name(GTK_WIDGET(textview->image), "textview_icon");
gtk_widget_show(textview->image); gtk_widget_show(textview->image);
gtk_widget_get_allocation(textview->text, &allocation); gtk_widget_get_allocation(textview->text, &allocation);
@ -2090,6 +2092,7 @@ static void textview_show_contact_pic(TextView *textview)
} }
cm_return_if_fail(textview->image != NULL); cm_return_if_fail(textview->image != NULL);
gtk_widget_set_name(GTK_WIDGET(textview->image), "textview_contact_pic");
gtk_widget_show(textview->image); gtk_widget_show(textview->image);
gtk_widget_get_allocation(textview->text, &allocation); gtk_widget_get_allocation(textview->text, &allocation);