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;
|
|
|
|
GtkWidget *image;
|
|
|
|
GIcon *icon;
|
|
|
|
|
|
|
|
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));
|
2020-04-30 23:04:08 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Welcome to Facebook - Log in, sign up or learn more");
|
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 ();
|
|
|
|
|
|
|
|
button = gtk_button_new ();
|
|
|
|
icon = g_themed_icon_new ("mail-send-receive-symbolic");
|
2017-11-15 00:43:13 +00:00
|
|
|
image = gtk_image_new_from_gicon (icon);
|
2013-12-12 21:09:34 +00:00
|
|
|
g_object_unref (icon);
|
2020-05-02 07:05:19 +00:00
|
|
|
gtk_button_set_child (GTK_BUTTON (button), image);
|
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");
|
2013-12-12 21:09:34 +00:00
|
|
|
button = gtk_button_new ();
|
2020-05-02 07:05:19 +00:00
|
|
|
gtk_button_set_child (GTK_BUTTON (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (box), button);
|
2013-12-12 21:09:34 +00:00
|
|
|
button = gtk_button_new ();
|
2020-05-02 07:05:19 +00:00
|
|
|
gtk_button_set_child (GTK_BUTTON (button), gtk_image_new_from_icon_name ("pan-end-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;
|
|
|
|
}
|