2013-12-12 21:09:34 +00:00
|
|
|
/* Header Bar
|
2020-09-13 18:59:33 +00:00
|
|
|
* #Keywords: GtkWindowHandle, GtkWindowControls
|
2013-12-12 21:09:34 +00:00
|
|
|
*
|
|
|
|
* GtkHeaderBar is a container that is suitable for implementing
|
|
|
|
* window titlebars. One of its features is that it can position
|
2020-04-30 20:27:05 +00:00
|
|
|
* a title centered with regard to the full width, regardless of
|
|
|
|
* variable-width content at the left or right.
|
2013-12-12 21:09:34 +00:00
|
|
|
*
|
|
|
|
* It is commonly used with gtk_window_set_titlebar()
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
do_headerbar (GtkWidget *do_widget)
|
|
|
|
{
|
|
|
|
static GtkWidget *window = NULL;
|
|
|
|
GtkWidget *header;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *box;
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
2020-02-14 19:55:36 +00:00
|
|
|
window = gtk_window_new ();
|
2017-10-31 06:41:15 +00:00
|
|
|
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
2022-05-27 21:34:55 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Welcome to the Hotel California");
|
2020-05-09 16:03:11 +00:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
|
|
|
|
2013-12-12 21:09:34 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
|
|
|
|
|
|
|
header = gtk_header_bar_new ();
|
|
|
|
|
2021-05-09 15:53:05 +00:00
|
|
|
button = gtk_button_new_from_icon_name ("mail-send-receive-symbolic");
|
2022-05-27 21:34:55 +00:00
|
|
|
gtk_widget_set_tooltip_text (button, "Check out");
|
2013-12-12 21:09:34 +00:00
|
|
|
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
|
|
|
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2020-04-10 16:08:16 +00:00
|
|
|
gtk_widget_add_css_class (box, "linked");
|
2021-05-09 15:53:05 +00:00
|
|
|
button = gtk_button_new_from_icon_name ("go-previous-symbolic");
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (box), button);
|
2021-05-09 15:53:05 +00:00
|
|
|
button = gtk_button_new_from_icon_name ("go-next-symbolic");
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (box), button);
|
2013-12-12 21:09:34 +00:00
|
|
|
|
|
|
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), box);
|
2020-09-14 05:45:20 +00:00
|
|
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), gtk_switch_new ());
|
2013-12-12 21:09:34 +00:00
|
|
|
|
|
|
|
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
|
|
|
|
2020-05-02 21:26:54 +00:00
|
|
|
gtk_window_set_child (GTK_WINDOW (window), gtk_text_view_new ());
|
2013-12-12 21:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!gtk_widget_get_visible (window))
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (window);
|
2013-12-12 21:09:34 +00:00
|
|
|
else
|
2020-05-09 14:26:22 +00:00
|
|
|
gtk_window_destroy (GTK_WINDOW (window));
|
2013-12-12 21:09:34 +00:00
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|