Commit f6efb428 authored by Zander Brown's avatar Zander Brown 🔄 Committed by Guido Gunther

Implement HdyDialog, an adaptive GtkDialog

Librem5/libhandy#52
parent 1ff1b3ca
......@@ -6,3 +6,4 @@ Heather Ellsworth <heather.ellsworth@puri.sm>
Julian Richen <julian@richen.io>
Julian Sparber <julian@sparber.net>
Sebastien Lafargue <slafargue@gnome.org>
Zander Brown <zbrown@gnome.org>
......@@ -43,6 +43,7 @@
<xi:include href="xml/hdy-dialer.xml"/>
<xi:include href="xml/hdy-dialer-button.xml"/>
<xi:include href="xml/hdy-dialer-cycle-button.xml"/>
<xi:include href="xml/hdy-dialog.xml"/>
<xi:include href="xml/hdy-enum-value-object.xml"/>
<xi:include href="xml/hdy-expander-row.xml"/>
<xi:include href="xml/hdy-header-group.xml"/>
......
......@@ -6,6 +6,7 @@
<glade-widget-class name="HdyColumn" generic-name="column" title="Column"/>
<glade-widget-class name="HdyComboRow" generic-name="comborow" title="Combo Row" since="0.0.6"/>
<glade-widget-class name="HdyDialer" generic-name="dialer" title="Dialer"/>
<glade-widget-class name="HdyDialog" generic-name="dialog" title="Dialog" since="0.0.7"/>
<glade-widget-class name="HdyExpanderRow" generic-name="expanderrow" title="Expander Row" since="0.0.6"/>
<glade-widget-class name="HdyHeaderGroup" generic-name="headergroup" title="Header Group" toplevel="True">
<read-widget-function>glade_hdy_header_group_read_widget</read-widget-function>
......@@ -32,6 +33,7 @@
<glade-widget-class-ref name="HdyColumn"/>
<glade-widget-class-ref name="HdyComboRow"/>
<glade-widget-class-ref name="HdyDialer"/>
<glade-widget-class-ref name="HdyDialog"/>
<glade-widget-class-ref name="HdyExpanderRow"/>
<glade-widget-class-ref name="HdyHeaderGroup"/>
<glade-widget-class-ref name="HdyLeaflet"/>
......
......@@ -32,6 +32,7 @@ G_BEGIN_DECLS
#include "hdy-dialer-button.h"
#include "hdy-dialer-cycle-button.h"
#include "hdy-dialer.h"
#include "hdy-dialog.h"
#include "hdy-enum-value-object.h"
#include "hdy-expander-row.h"
#include "hdy-fold.h"
......
This diff is collapsed.
/*
* Copyright © 2018 Zander Brown <zbrown@gnome.org>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#if !defined(_HANDY_INSIDE) && !defined(HANDY_COMPILATION)
#error "Only <handy.h> can be included directly."
#endif
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define HDY_TYPE_DIALOG (hdy_dialog_get_type())
struct _HdyDialogClass {
GtkDialogClass parent_class;
};
G_DECLARE_DERIVABLE_TYPE (HdyDialog, hdy_dialog, HDY, DIALOG, GtkDialog)
GtkWidget *hdy_dialog_new (GtkWindow *parent);
G_END_DECLS
......@@ -55,6 +55,7 @@ src_headers = [
'hdy-dialer-button.h',
'hdy-dialer-cycle-button.h',
'hdy-dialer.h',
'hdy-dialog.h',
'hdy-enum-value-object.h',
'hdy-expander-row.h',
'hdy-fold.h',
......@@ -86,6 +87,7 @@ src_sources = [
'hdy-dialer-button.c',
'hdy-dialer-cycle-button.c',
'hdy-dialer.c',
'hdy-dialog.c',
'hdy-enum-value-object.c',
'hdy-expander-row.c',
'hdy-fold.c',
......
......@@ -24,6 +24,7 @@ test_names = [
'test-combo-row',
'test-dialer',
'test-dialer-cycle-button',
'test-dialog',
'test-expander-row',
'test-header-group',
'test-search-bar',
......
/*
* Copyright © 2018 Zander Brown <zbrown@gnome.org>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
gint win_width = 0;
gint win_height = 0;
gint dlg_width = 0;
gint dlg_height = 0;
static void
win_size_cb (GtkWidget *widget,
GdkRectangle *allocation,
gpointer user_data)
{
gtk_window_get_size (GTK_WINDOW (widget), &win_width, &win_height);
}
static void
dlg_size_cb (GtkWidget *widget,
GdkRectangle *allocation,
gpointer user_data)
{
gtk_window_get_size (GTK_WINDOW (widget), &dlg_width, &dlg_height);
}
static void
test_hdy_dialog_is_small (void)
{
GtkWidget *window;
GtkWidget *dialog;
win_width = 0;
win_height = 0;
dlg_width = 0;
dlg_height = 0;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_resize (GTK_WINDOW (window), 400, 400);
g_signal_connect (window, "size-allocate", G_CALLBACK (win_size_cb), NULL);
gtk_widget_show (window);
dialog = hdy_dialog_new (GTK_WINDOW (window));
g_signal_connect (dialog, "size-allocate", G_CALLBACK (dlg_size_cb), NULL);
gtk_widget_show (dialog);
g_assert_cmpint (win_height, ==, dlg_height);
g_assert_cmpint (win_width, ==, dlg_width);
}
static void
test_hdy_dialog_normal (void)
{
GtkWidget *window;
GtkWidget *dialog;
win_width = 0;
win_height = 0;
dlg_width = 0;
dlg_height = 0;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_resize (GTK_WINDOW (window), 800, 800);
g_signal_connect (window, "size-allocate", G_CALLBACK (win_size_cb), NULL);
gtk_widget_show (window);
dialog = hdy_dialog_new (GTK_WINDOW (window));
g_signal_connect (dialog, "size-allocate", G_CALLBACK (dlg_size_cb), NULL);
gtk_widget_show (dialog);
g_assert_cmpint (win_height, !=, dlg_height);
g_assert_cmpint (win_width, !=, dlg_width);
}
gint
main (gint argc,
gchar *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func("/Handy/Dialog/is_small", test_hdy_dialog_is_small);
g_test_add_func("/Handy/Dialog/normal", test_hdy_dialog_normal);
return g_test_run();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment