gtk-demo: Drop the modelbutton demo

Not a public api, so shouldn't be featured in a demo.
This commit is contained in:
Matthias Clasen 2020-08-09 10:59:22 -04:00
parent c80a612af7
commit 79f0687929
4 changed files with 0 additions and 204 deletions

View File

@ -229,7 +229,6 @@
<file>listview_words.c</file> <file>listview_words.c</file>
<file>list_store.c</file> <file>list_store.c</file>
<file>markup.c</file> <file>markup.c</file>
<file>modelbutton.c</file>
<file>overlay.c</file> <file>overlay.c</file>
<file>overlay2.c</file> <file>overlay2.c</file>
<file>paint.c</file> <file>paint.c</file>
@ -310,9 +309,6 @@
<gresource prefix="/scale"> <gresource prefix="/scale">
<file>scale.ui</file> <file>scale.ui</file>
</gresource> </gresource>
<gresource prefix="/modelbutton">
<file>modelbutton.ui</file>
</gresource>
<gresource prefix="/tagged_entry"> <gresource prefix="/tagged_entry">
<file>demotaggedentry.c</file> <file>demotaggedentry.c</file>
<file>demotaggedentry.h</file> <file>demotaggedentry.h</file>

View File

@ -51,7 +51,6 @@ demos = files([
'listview_weather.c', 'listview_weather.c',
'listview_words.c', 'listview_words.c',
'markup.c', 'markup.c',
'modelbutton.c',
'overlay.c', 'overlay.c',
'overlay2.c', 'overlay2.c',
'paint.c', 'paint.c',

View File

@ -1,66 +0,0 @@
/* Model Button
*
* GtkModelButton is a button widget that is designed to be used with
* a GAction as model. The button will adjust its appearance according
* to the kind of action it is connected to.
*
* It is also possible to use GtkModelButton without a GAction. In this
* case, you should set the "role" attribute yourself, and connect to the
* "clicked" signal as you would for any other button.
*
* A common use of GtkModelButton is to implement menu-like content
* in popovers.
*/
#include <gtk/gtk.h>
void
modelbutton_tool_clicked (GtkButton *button)
{
gboolean active;
g_object_get (button, "active", &active, NULL);
g_object_set (button, "active", !active, NULL);
}
GtkWidget *
do_modelbutton (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
static GActionEntry win_entries[] = {
{ "color", NULL, "s", "'red'", NULL },
{ "chocolate", NULL, NULL, "true", NULL },
{ "vanilla", NULL, NULL, "false", NULL },
{ "sprinkles", NULL, NULL, NULL, NULL }
};
if (!window)
{
GtkBuilder *builder;
GActionGroup *actions;
builder = gtk_builder_new_from_resource ("/modelbutton/modelbutton.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
actions = (GActionGroup*)g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions),
win_entries, G_N_ELEMENTS (win_entries),
window);
gtk_widget_insert_action_group (window, "win", actions);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@ -1,133 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="title" translatable="yes">Model Button</property>
<property name="resizable">0</property>
<child type="titlebar">
<object class="GtkHeaderBar"/>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin-start">80</property>
<property name="margin-end">80</property>
<property name="margin-top">80</property>
<property name="margin-bottom">80</property>
<child>
<object class="GtkMenuButton">
<property name="popover">thing_a</property>
<property name="label">_Color</property>
<property name="use-underline">1</property>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="popover">thing_b</property>
<property name="label">_Flavors</property>
<property name="use-underline">1</property>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="popover">thing_c</property>
<property name="label">_Tools</property>
<property name="use-underline">1</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="thing_a">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
<property name="action-name">win.color</property>
<property name="action-target">&apos;red&apos;</property>
<property name="text">Red</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="action-name">win.color</property>
<property name="action-target">&apos;green&apos;</property>
<property name="text">Green</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="action-name">win.color</property>
<property name="action-target">&apos;blue&apos;</property>
<property name="text">Blue</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="thing_b">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
<property name="action-name">win.chocolate</property>
<property name="text">Chocolate</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="action-name">win.vanilla</property>
<property name="text">Vanilla</property>
</object>
</child>
<child>
<object class="GtkSeparator"/>
</child>
<child>
<object class="GtkModelButton">
<property name="action-name">win.sprinkles</property>
<property name="text">Add Sprinkles</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="thing_c">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
<property name="text">Hammer</property>
<property name="role">check</property>
<signal name="clicked" handler="modelbutton_tool_clicked"/>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="text">Screwdriver</property>
<property name="role">check</property>
<signal name="clicked" handler="modelbutton_tool_clicked"/>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="text">Drill</property>
<property name="role">check</property>
<signal name="clicked" handler="modelbutton_tool_clicked"/>
</object>
</child>
</object>
</child>
</object>
</interface>