1/*
2 * Copyright (C) 2017 Igalia S.L.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "WebKitInspectorWindow.h"
28
29#include "WebInspectorProxy.h"
30#include <glib/gi18n-lib.h>
31#include <wtf/glib/GUniquePtr.h>
32
33using namespace WebKit;
34
35struct _WebKitInspectorWindow {
36 GtkWindow parent;
37
38#if GTK_CHECK_VERSION(3, 10, 0)
39 GtkWidget* headerBar;
40#endif
41};
42
43struct _WebKitInspectorWindowClass {
44 GtkWindowClass parent;
45};
46
47G_DEFINE_TYPE(WebKitInspectorWindow, webkit_inspector_window, GTK_TYPE_WINDOW)
48
49static void webkit_inspector_window_class_init(WebKitInspectorWindowClass*)
50{
51}
52
53static void webkit_inspector_window_init(WebKitInspectorWindow* window)
54{
55#if GTK_CHECK_VERSION(3, 10, 0)
56 window->headerBar = gtk_header_bar_new();
57 gtk_header_bar_set_title(GTK_HEADER_BAR(window->headerBar), _("Web Inspector"));
58 gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(window->headerBar), TRUE);
59 gtk_window_set_titlebar(GTK_WINDOW(window), window->headerBar);
60 gtk_widget_show(window->headerBar);
61#else
62 gtk_window_set_title(GTK_WINDOW(window), _("Web Inspector"));
63#endif
64}
65
66GtkWidget* webkitInspectorWindowNew(GtkWindow* parent)
67{
68 return GTK_WIDGET(g_object_new(WEBKIT_TYPE_INSPECTOR_WINDOW, "type", GTK_WINDOW_TOPLEVEL, "transient-for", parent,
69 "default-width", WebInspectorProxy::initialWindowWidth, "default-height", WebInspectorProxy::initialWindowHeight, nullptr));
70}
71
72void webkitInspectorWindowSetSubtitle(WebKitInspectorWindow* window, const char* subtitle)
73{
74 g_return_if_fail(WEBKIT_IS_INSPECTOR_WINDOW(window));
75
76#if GTK_CHECK_VERSION(3, 10, 0)
77 gtk_header_bar_set_subtitle(GTK_HEADER_BAR(window->headerBar), subtitle);
78#else
79 if (subtitle) {
80 GUniquePtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), subtitle));
81 gtk_window_set_title(GTK_WINDOW(window), title.get());
82 } else
83 gtk_window_set_title(GTK_WINDOW(window), _("Web Inspector"));
84#endif
85}
86
87