Commit 4ba23f14 authored by Gabriele Musco's avatar Gabriele Musco
Browse files

Merge branch 'master' of source.puri.sm:gabmus/libhandy into patch-2

parents 17f2e225 9e4bb03d
Pipeline #25163 passed with stages
in 9 minutes and 10 seconds
......@@ -3,12 +3,14 @@ Section: libs
Priority: optional
Maintainer: Guido Günther <agx@sigxcpu.org>
Build-Depends:
debhelper (>= 11),
gobject-introspection,
debhelper-compat (= 12),
dh-sequence-gir,
gtk-doc-tools,
libgirepository1.0-dev,
libgladeui-dev,
libglib2.0-doc,
libgnome-desktop-3-dev,
libgtk-3-doc,
libgtk-3-dev,
libxml2-utils,
meson,
......@@ -19,6 +21,8 @@ Build-Depends:
xauth <!nocheck>,
Standards-Version: 4.1.3
Homepage: https://source.puri.sm/Librem5/libhandy
Vcs-Browser: https://salsa.debian.org/DebianOnMobile-team/libhandy
Vcs-Git: https://salsa.debian.org/DebianOnMobile-team/libhandy.git
Package: libhandy-0.0-0
Architecture: any
......@@ -56,11 +60,22 @@ Section: introspection
Depends:
${gir:Depends},
${misc:Depends},
${shlibs:Depends},
Description: GObject introspection files for libhandy
libhandy provides GTK widgets and GObjects to ease developing
applications for mobile phones.
.
This package contains the GObject-introspection data in binary typelib format.
Package: handy-0.0-examples
Section: x11
Architecture: any
Depends: ${misc:Depends},
${shlibs:Depends},
libhandy-0.0-0 (= ${binary:Version})
Description: Example programs for libhandy
libhandy provides GTK widgets and GObjects to ease developing
applications for mobile phones.
.
This package contains example files and the demonstration program for
libhandy.
......@@ -3,7 +3,7 @@
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh $@ --with gir
dh $@
override_dh_auto_configure:
dh_auto_configure -- -Dgtk_doc=true
......@@ -11,6 +11,3 @@ override_dh_auto_configure:
override_dh_auto_test:
xvfb-run -s -noreset dh_auto_test
override_dh_makeshlibs:
dh_makeshlibs -VUpstream-Version
......@@ -56,6 +56,9 @@
#define DEFAULT_SPACING 6
#define MIN_TITLE_CHARS 5
#define MOBILE_WINDOW_WIDTH 400
#define MOBILE_WINDOW_HEIGHT 800
typedef struct {
gchar *title;
gchar *subtitle;
......@@ -90,7 +93,9 @@ typedef struct {
guint transition_duration;
gboolean interpolate_size;
gulong toplevel_dialog_notify_narrow_id;
gboolean is_mobile_window;
gulong window_size_allocated_id;
} HdyHeaderBarPrivate;
typedef struct _Child Child;
......@@ -364,7 +369,7 @@ hdy_header_bar_update_window_buttons (HdyHeaderBar *self)
GMenuModel *menu;
gboolean shown_by_shell;
gboolean is_sovereign_window;
gboolean is_mobile;
gboolean is_mobile_dialog;
toplevel = gtk_widget_get_toplevel (widget);
if (!gtk_widget_is_toplevel (toplevel))
......@@ -393,13 +398,7 @@ hdy_header_bar_update_window_buttons (HdyHeaderBar *self)
"gtk-decoration-layout", &layout_desc,
NULL);
is_mobile = HDY_IS_DIALOG (toplevel) &&
hdy_dialog_get_narrow (HDY_DIALOG (toplevel));
if (is_mobile) {
g_free (layout_desc);
layout_desc = g_strdup ("back:");
} else if (priv->decoration_layout_set) {
if (priv->decoration_layout_set) {
g_free (layout_desc);
layout_desc = g_strdup (priv->decoration_layout);
}
......@@ -415,6 +414,8 @@ hdy_header_bar_update_window_buttons (HdyHeaderBar *self)
gtk_window_get_transient_for (window) == NULL &&
gtk_window_get_type_hint (window) == GDK_WINDOW_TYPE_HINT_NORMAL);
is_mobile_dialog= (priv->is_mobile_window && !is_sovereign_window);
tokens = g_strsplit (layout_desc, ":", 2);
if (tokens) {
for (i = 0; i < 2; i++) {
......@@ -516,7 +517,8 @@ hdy_header_bar_update_window_buttons (HdyHeaderBar *self)
if (GTK_IS_ACCESSIBLE (accessible))
atk_object_set_name (accessible, maximized ? _("Restore") : _("Maximize"));
} else if (strcmp (t[j], "close") == 0 &&
gtk_window_get_deletable (window)) {
gtk_window_get_deletable (window) &&
!is_mobile_dialog) {
button = gtk_button_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
image = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU);
......@@ -532,8 +534,9 @@ hdy_header_bar_update_window_buttons (HdyHeaderBar *self)
accessible = gtk_widget_get_accessible (button);
if (GTK_IS_ACCESSIBLE (accessible))
atk_object_set_name (accessible, _("Close"));
} else if (strcmp (t[j], "back") == 0 &&
gtk_window_get_deletable (window)) {
} else if (i == 0 && /* Only at the start. */
gtk_window_get_deletable (window) &&
is_mobile_dialog) {
button = gtk_button_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
image = gtk_image_new_from_icon_name ("go-previous-symbolic", GTK_ICON_SIZE_BUTTON);
......@@ -592,6 +595,42 @@ hdy_header_bar_update_window_buttons (HdyHeaderBar *self)
_hdy_header_bar_update_separator_visibility (self);
}
static gboolean
compute_is_mobile_window (GtkWindow *window)
{
gint window_width, window_height;
gtk_window_get_size (window, &window_width, &window_height);
if (window_width <= MOBILE_WINDOW_WIDTH &&
window_height <= MOBILE_WINDOW_HEIGHT)
return TRUE;
/* Mobile landscape mode. */
if (window_width <= MOBILE_WINDOW_HEIGHT &&
window_height <= MOBILE_WINDOW_WIDTH &&
gtk_window_is_maximized (window))
return TRUE;
return FALSE;
}
static void
update_is_mobile_window (HdyHeaderBar *self)
{
HdyHeaderBarPrivate *priv = hdy_header_bar_get_instance_private (self);
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
gboolean was_mobile_window = priv->is_mobile_window;
if (!gtk_widget_is_toplevel (toplevel))
return;
priv->is_mobile_window = compute_is_mobile_window (GTK_WINDOW (toplevel));
if (priv->is_mobile_window != was_mobile_window)
hdy_header_bar_update_window_buttons (self);
}
static void
construct_label_box (HdyHeaderBar *self)
{
......@@ -1932,6 +1971,7 @@ hdy_header_bar_realize (GtkWidget *widget)
G_CALLBACK (hdy_header_bar_update_window_buttons), widget);
g_signal_connect_swapped (settings, "notify::gtk-decoration-layout",
G_CALLBACK (hdy_header_bar_update_window_buttons), widget);
update_is_mobile_window (HDY_HEADER_BAR (widget));
hdy_header_bar_update_window_buttons (HDY_HEADER_BAR (widget));
}
......@@ -1984,16 +2024,17 @@ hdy_header_bar_hierarchy_changed (GtkWidget *widget,
g_signal_connect_after (toplevel, "window-state-event",
G_CALLBACK (window_state_changed), widget);
if (priv->toplevel_dialog_notify_narrow_id > 0) {
g_signal_handler_disconnect (previous_toplevel, priv->toplevel_dialog_notify_narrow_id);
priv->toplevel_dialog_notify_narrow_id = 0;
if (priv->window_size_allocated_id > 0) {
g_signal_handler_disconnect (previous_toplevel, priv->window_size_allocated_id);
priv->window_size_allocated_id = 0;
}
if (HDY_IS_DIALOG (toplevel))
priv->toplevel_dialog_notify_narrow_id =
g_signal_connect_swapped (toplevel, "notify::narrow",
G_CALLBACK (hdy_header_bar_update_window_buttons), self);
if (GTK_IS_WINDOW (toplevel))
priv->window_size_allocated_id =
g_signal_connect_swapped (toplevel, "size-allocate",
G_CALLBACK (update_is_mobile_window), self);
update_is_mobile_window (self);
hdy_header_bar_update_window_buttons (self);
}
......
......@@ -159,7 +159,9 @@ libhandy_deps = [
cc.find_library('rt', required: false),
]
libhandy_c_args = []
libhandy_c_args = [
'-DG_LOG_DOMAIN="Handy"',
]
libhandy_link_args = []
libhandy_symbols_file = 'libhandy.syms'
......
......@@ -11,6 +11,7 @@ test_env = [
test_cflags = [
'-fPIE',
'-DHDY_LOG_DOMAIN="Handy"',
'-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()),
]
......
......@@ -24,7 +24,7 @@ test_hdy_preferences_page_add (void)
widget = gtk_switch_new ();
g_assert_nonnull (widget);
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't add children of type GtkSwitch to HdyPreferencesPage");
g_test_expect_message (HDY_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't add children of type GtkSwitch to HdyPreferencesPage");
gtk_container_add (GTK_CONTAINER (page), widget);
g_test_assert_expected_messages ();
}
......
......@@ -24,7 +24,7 @@ test_hdy_preferences_window_add (void)
widget = gtk_switch_new ();
g_assert_nonnull (widget);
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't add children of type GtkSwitch to HdyPreferencesWindow");
g_test_expect_message (HDY_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't add children of type GtkSwitch to HdyPreferencesWindow");
gtk_container_add (GTK_CONTAINER (window), widget);
g_test_assert_expected_messages ();
}
......
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