Commit c07be1d8 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

Add GtkHdyViewSwitcherButton

This is imported from HdyViewSwitcherButton from libhandy 0.0.10.
parent 33dac505
......@@ -602,6 +602,7 @@ gtk_private_h_sources = \
gtktreemenu.h \
gdkpixbufutilsprivate.h \
hdy-style-private.h \
hdy-view-switcher-button-private.h \
open-type-layout.h \
language-names.h \
script-names.h
......@@ -977,6 +978,7 @@ gtk_base_c_sources = \
gtkwin32draw.c \
gtkwin32theme.c \
gdkpixbufutils.c \
hdy-view-switcher-button.c \
language-names.c \
script-names.c
......@@ -1231,7 +1233,8 @@ templates = \
ui/gtkstatusbar.ui \
ui/gtktooltipwindow.ui \
ui/gtkvolumebutton.ui \
ui/gtksidebarrow.ui
ui/gtksidebarrow.ui \
ui/hdy-view-switcher-button.ui
#
# rules to generate built sources
......
/*
* Copyright (C) 2019 Zander Brown <zbrown@gnome.org>
* Copyright (C) 2019 Purism SPC
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include "gtkbin.h"
#include "gtkhdytype.h"
#include "gtkradiobutton.h"
G_BEGIN_DECLS
#define GTK_TYPE_HDY_VIEW_SWITCHER_BUTTON (gtk_hdy_view_switcher_button_get_type())
struct _GtkHdyViewSwitcherButtonClass {
GtkRadioButtonClass parent_class;
};
GTK_HDY_DECLARE_DERIVABLE_TYPE (GtkHdyViewSwitcherButton, gtk_hdy_view_switcher_button, GTK, HDY_VIEW_SWITCHER_BUTTON, GtkRadioButton)
GtkHdyViewSwitcherButton *gtk_hdy_view_switcher_button_new (void);
const gchar *gtk_hdy_view_switcher_button_get_icon_name (GtkHdyViewSwitcherButton *self);
void gtk_hdy_view_switcher_button_set_icon_name (GtkHdyViewSwitcherButton *self,
const gchar *icon_name);
GtkIconSize gtk_hdy_view_switcher_button_get_icon_size (GtkHdyViewSwitcherButton *self);
void gtk_hdy_view_switcher_button_set_icon_size (GtkHdyViewSwitcherButton *self,
GtkIconSize icon_size);
gboolean gtk_hdy_view_switcher_button_get_needs_attention (GtkHdyViewSwitcherButton *self);
void gtk_hdy_view_switcher_button_set_needs_attention (GtkHdyViewSwitcherButton *self,
gboolean needs_attention);
const gchar *gtk_hdy_view_switcher_button_get_label (GtkHdyViewSwitcherButton *self);
void gtk_hdy_view_switcher_button_set_label (GtkHdyViewSwitcherButton *self,
const gchar *label);
void gtk_hdy_view_switcher_button_set_narrow_ellipsize (GtkHdyViewSwitcherButton *self,
PangoEllipsizeMode mode);
void gtk_hdy_view_switcher_button_get_size (GtkHdyViewSwitcherButton *self,
gint *h_min_width,
gint *h_nat_width,
gint *v_min_width,
gint *v_nat_width);
G_END_DECLS
This diff is collapsed.
hdyviewswitcher > button {
padding: 0;
margin: 0;
border-radius: 0;
border-top: 0;
border-bottom: 0;
box-shadow: none;
font-size: 1rem;
}
hdyviewswitcher > button:not(:checked) {
background: transparent;
border-left-color: transparent;
border-right-color: transparent;
}
hdyviewswitcher > button:hover:not(:checked) {
background: lighter(@theme_base_color);
}
hdyviewswitcher > button > stack > box.narrow {
font-size: 0.75rem;
padding-top: 7px;
padding-bottom: 5px;
}
hdyviewswitcher > button > stack > box.narrow image,
hdyviewswitcher > button > stack > box.narrow label {
padding-left: 8px;
padding-right: 8px;
}
hdyviewswitcher > button box.wide {
padding: 8px 12px;
}
hdyviewswitcher > button > stack > box.wide label:dir(ltr) {
padding-right: 7px;
}
hdyviewswitcher > button > stack > box.wide label:dir(rtl) {
padding-left: 7px;
}
hdyviewswitcher > button > stack > box label.active {
font-weight: bold;
}
hdyviewswitcher > button.needs-attention:active > stack > box label,
hdyviewswitcher > button.needs-attention:checked > stack > box label {
animation: none;
background-image: none;
}
hdyviewswitcher > button.needs-attention > stack > box label {
animation: needs_attention 150ms ease-in;
background-image: -gtk-gradient(radial, center center, 0, center center, 0.5, to(#3584e4), to(transparent)), -gtk-gradient(radial, center center, 0, center center, 0.5, to(rgba(255, 255, 255, 0.769231)), to(transparent));
background-size: 6px 6px, 6px 6px;
background-repeat: no-repeat;
background-position: right 0px, right 1px;
}
hdyviewswitcher > button.needs-attention > stack > box label:backdrop {
background-size: 6px 6px, 0 0;
}
hdyviewswitcher > button.needs-attention > stack > box label:dir(rtl) {
background-position: left 0px, left 1px;
}
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.0"/>
<template class="GtkHdyViewSwitcherButton" parent="GtkRadioButton">
<signal name="notify::active" handler="on_active_changed" after="yes"/>
<child>
<object class="GtkStack" id="stack">
<property name="hhomogeneous">False</property>
<property name="transition-type">crossfade</property>
<property name="vhomogeneous">True</property>
<property name="visible">True</property>
<child>
<object class="GtkBox" id="horizontal_box">
<property name="halign">center</property>
<property name="orientation">horizontal</property>
<property name="spacing">8</property>
<property name="valign">center</property>
<property name="visible">True</property>
<style>
<class name="wide"/>
</style>
<child>
<object class="GtkImage" id="horizontal_image">
<property name="icon-name" bind-source="GtkHdyViewSwitcherButton" bind-property="icon-name" bind-flags="sync-create" />
<property name="icon-size" bind-source="GtkHdyViewSwitcherButton" bind-property="icon-size" bind-flags="sync-create" />
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkStack" id="horizontal_label_stack">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="horizontal_label_inactive">
<property name="label" bind-source="GtkHdyViewSwitcherButton" bind-property="label" bind-flags="sync-create|bidirectional" />
<property name="visible">True</property>
</object>
<packing>
<property name="name">inactive</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="horizontal_label_active">
<property name="label" bind-source="GtkHdyViewSwitcherButton" bind-property="label" bind-flags="sync-create|bidirectional" />
<property name="visible">True</property>
<style>
<class name="active"/>
</style>
</object>
<packing>
<property name="name">active</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="vertical_box">
<property name="halign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<property name="valign">center</property>
<property name="visible">True</property>
<style>
<class name="narrow"/>
</style>
<child>
<object class="GtkImage" id="vertical_image">
<property name="icon-name" bind-source="GtkHdyViewSwitcherButton" bind-property="icon-name" bind-flags="sync-create" />
<property name="icon-size" bind-source="GtkHdyViewSwitcherButton" bind-property="icon-size" bind-flags="sync-create" />
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkStack" id="vertical_label_stack">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="vertical_label_inactive">
<property name="label" bind-source="GtkHdyViewSwitcherButton" bind-property="label" bind-flags="sync-create|bidirectional" />
<property name="visible">True</property>
</object>
<packing>
<property name="name">inactive</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="vertical_label_active">
<property name="label" bind-source="GtkHdyViewSwitcherButton" bind-property="label" bind-flags="sync-create|bidirectional" />
<property name="visible">True</property>
<style>
<class name="active"/>
</style>
</object>
<packing>
<property name="name">active</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
Supports Markdown
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