2020-09-13 21:37:05 +00:00
|
|
|
|
/* GTK Demo
|
|
|
|
|
*
|
|
|
|
|
* GTK Demo is a collection of useful examples to demonstrate
|
|
|
|
|
* GTK widgets and features. It is a useful example in itself.
|
|
|
|
|
*
|
|
|
|
|
* You can select examples in the sidebar or search for them by
|
|
|
|
|
* typing a search term. Double-clicking or hitting the “Run” button
|
|
|
|
|
* will run the demo. The source code and other resources used in the
|
|
|
|
|
* demo are shown in this area.
|
|
|
|
|
*
|
|
|
|
|
* You can also use the GTK Inspector, available from the menu on the
|
|
|
|
|
* top right, to poke at the running demos, and see how they are put
|
|
|
|
|
* together.
|
|
|
|
|
*/
|
2000-10-18 15:50:13 +00:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
2001-05-18 18:30:59 +00:00
|
|
|
|
#include <stdlib.h>
|
2000-10-18 15:50:13 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2013-12-03 00:42:04 +00:00
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
|
#include <gtk/gtk.h>
|
2004-12-05 12:47:42 +00:00
|
|
|
|
#include <glib/gstdio.h>
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2008-12-26 21:57:55 +00:00
|
|
|
|
#include "demos.h"
|
2020-08-13 17:08:57 +00:00
|
|
|
|
#include "fontify.h"
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2013-02-26 14:55:29 +00:00
|
|
|
|
static GtkWidget *info_view;
|
|
|
|
|
static GtkWidget *source_view;
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
static char *current_file = NULL;
|
2000-10-26 00:36:47 +00:00
|
|
|
|
|
2012-05-18 04:48:57 +00:00
|
|
|
|
static GtkWidget *notebook;
|
2019-10-15 13:39:59 +00:00
|
|
|
|
static GtkSingleSelection *selection;
|
2020-04-30 23:04:08 +00:00
|
|
|
|
static GtkWidget *toplevel;
|
2020-07-12 15:39:27 +00:00
|
|
|
|
static char **search_needle;
|
2001-11-23 21:46:44 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
typedef struct _GtkDemo GtkDemo;
|
|
|
|
|
struct _GtkDemo
|
|
|
|
|
{
|
|
|
|
|
GObject parent_instance;
|
|
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
|
const char *title;
|
2020-09-13 15:37:23 +00:00
|
|
|
|
const char **keywords;
|
2019-10-15 13:39:59 +00:00
|
|
|
|
const char *filename;
|
|
|
|
|
GDoDemoFunc func;
|
|
|
|
|
GListModel *children_model;
|
|
|
|
|
};
|
|
|
|
|
|
2000-10-26 00:36:47 +00:00
|
|
|
|
enum {
|
2019-10-15 13:39:59 +00:00
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_FILENAME,
|
|
|
|
|
PROP_NAME,
|
|
|
|
|
PROP_TITLE,
|
2020-09-13 15:37:23 +00:00
|
|
|
|
PROP_KEYWORDS,
|
2019-10-15 13:39:59 +00:00
|
|
|
|
|
|
|
|
|
N_PROPS
|
2000-10-26 00:36:47 +00:00
|
|
|
|
};
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
# define GTK_TYPE_DEMO (gtk_demo_get_type ())
|
|
|
|
|
G_DECLARE_FINAL_TYPE (GtkDemo, gtk_demo, GTK, DEMO, GObject);
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkDemo, gtk_demo, G_TYPE_OBJECT);
|
|
|
|
|
static GParamSpec *properties[N_PROPS] = { NULL, };
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_demo_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkDemo *self = GTK_DEMO (object);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_FILENAME:
|
|
|
|
|
g_value_set_string (value, self->filename);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_NAME:
|
|
|
|
|
g_value_set_string (value, self->name);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_TITLE:
|
|
|
|
|
g_value_set_string (value, self->title);
|
|
|
|
|
break;
|
|
|
|
|
|
2020-09-13 15:37:23 +00:00
|
|
|
|
case PROP_KEYWORDS:
|
|
|
|
|
g_value_set_boxed (value, self->keywords);
|
|
|
|
|
break;
|
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void gtk_demo_class_init (GtkDemoClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
gobject_class->get_property = gtk_demo_get_property;
|
|
|
|
|
|
|
|
|
|
properties[PROP_FILENAME] =
|
|
|
|
|
g_param_spec_string ("filename",
|
|
|
|
|
"filename",
|
|
|
|
|
"filename",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
properties[PROP_NAME] =
|
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
|
"name",
|
|
|
|
|
"name",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
properties[PROP_TITLE] =
|
|
|
|
|
g_param_spec_string ("title",
|
|
|
|
|
"title",
|
|
|
|
|
"title",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE);
|
2020-09-13 15:37:23 +00:00
|
|
|
|
properties[PROP_KEYWORDS] =
|
|
|
|
|
g_param_spec_string ("keywords",
|
|
|
|
|
"keywords",
|
|
|
|
|
"keywords",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE);
|
2019-10-15 13:39:59 +00:00
|
|
|
|
|
|
|
|
|
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void gtk_demo_init (GtkDemo *self)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-18 23:59:30 +00:00
|
|
|
|
typedef struct _CallbackData CallbackData;
|
|
|
|
|
struct _CallbackData
|
|
|
|
|
{
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_demo_run (GtkDemo *self,
|
|
|
|
|
GtkWidget *window)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *result;
|
|
|
|
|
|
|
|
|
|
if (!self->func)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
result = self->func (window);
|
|
|
|
|
if (result == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_WINDOW (result))
|
|
|
|
|
{
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (result), GTK_WINDOW (window));
|
|
|
|
|
gtk_window_set_modal (GTK_WINDOW (result), TRUE);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2020-06-29 03:36:35 +00:00
|
|
|
|
|
2013-12-03 00:42:04 +00:00
|
|
|
|
static void
|
|
|
|
|
activate_about (GSimpleAction *action,
|
|
|
|
|
GVariant *parameter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkApplication *app = user_data;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *authors[] = {
|
2019-02-05 09:19:57 +00:00
|
|
|
|
"The GTK Team",
|
2013-12-03 00:42:04 +00:00
|
|
|
|
NULL
|
|
|
|
|
};
|
2019-04-17 00:34:59 +00:00
|
|
|
|
char *version;
|
2020-08-07 02:17:36 +00:00
|
|
|
|
char *os_name;
|
|
|
|
|
char *os_version;
|
2019-04-17 00:34:59 +00:00
|
|
|
|
GString *s;
|
|
|
|
|
|
|
|
|
|
s = g_string_new ("");
|
|
|
|
|
|
2020-08-07 02:17:36 +00:00
|
|
|
|
os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
|
|
|
|
|
os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
|
|
|
|
|
if (os_name && os_version)
|
|
|
|
|
g_string_append_printf (s, "OS\t%s %s\n\n", os_name, os_version);
|
2019-04-17 00:34:59 +00:00
|
|
|
|
g_string_append (s, "System libraries\n");
|
|
|
|
|
g_string_append_printf (s, "\tGLib\t%d.%d.%d\n",
|
|
|
|
|
glib_major_version,
|
|
|
|
|
glib_minor_version,
|
|
|
|
|
glib_micro_version);
|
2020-04-27 00:02:10 +00:00
|
|
|
|
g_string_append_printf (s, "\tPango\t%s\n",
|
|
|
|
|
pango_version_string ());
|
2019-04-17 00:34:59 +00:00
|
|
|
|
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
|
|
|
|
|
gtk_get_major_version (),
|
|
|
|
|
gtk_get_minor_version (),
|
|
|
|
|
gtk_get_micro_version ());
|
2020-05-28 08:00:03 +00:00
|
|
|
|
g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
|
2019-04-17 00:34:59 +00:00
|
|
|
|
|
|
|
|
|
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
|
|
|
|
|
PACKAGE_VERSION,
|
|
|
|
|
gtk_get_major_version (),
|
|
|
|
|
gtk_get_minor_version (),
|
|
|
|
|
gtk_get_micro_version ());
|
2013-12-03 00:42:04 +00:00
|
|
|
|
|
|
|
|
|
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
|
2019-02-05 09:19:57 +00:00
|
|
|
|
"program-name", "GTK Demo",
|
2019-04-17 00:34:59 +00:00
|
|
|
|
"version", version,
|
2020-04-26 04:44:48 +00:00
|
|
|
|
"copyright", "© 1997—2020 The GTK Team",
|
2013-12-03 00:42:04 +00:00
|
|
|
|
"license-type", GTK_LICENSE_LGPL_2_1,
|
|
|
|
|
"website", "http://www.gtk.org",
|
2019-02-05 09:19:57 +00:00
|
|
|
|
"comments", "Program to demonstrate GTK widgets",
|
2013-12-03 00:42:04 +00:00
|
|
|
|
"authors", authors,
|
2019-04-01 22:49:09 +00:00
|
|
|
|
"logo-icon-name", "org.gtk.Demo4",
|
2019-02-05 09:19:57 +00:00
|
|
|
|
"title", "About GTK Demo",
|
2019-04-17 00:34:59 +00:00
|
|
|
|
"system-information", s->str,
|
2013-12-03 00:42:04 +00:00
|
|
|
|
NULL);
|
2019-04-17 00:34:59 +00:00
|
|
|
|
|
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
|
g_free (version);
|
2020-08-07 02:17:36 +00:00
|
|
|
|
g_free (os_name);
|
|
|
|
|
g_free (os_version);
|
2013-12-03 00:42:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
activate_quit (GSimpleAction *action,
|
|
|
|
|
GVariant *parameter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkApplication *app = user_data;
|
|
|
|
|
GtkWidget *win;
|
|
|
|
|
GList *list, *next;
|
|
|
|
|
|
|
|
|
|
list = gtk_application_get_windows (app);
|
|
|
|
|
while (list)
|
|
|
|
|
{
|
|
|
|
|
win = list->data;
|
|
|
|
|
next = list->next;
|
|
|
|
|
|
2020-05-09 14:26:22 +00:00
|
|
|
|
gtk_window_destroy (GTK_WINDOW (win));
|
2013-12-03 00:42:04 +00:00
|
|
|
|
|
|
|
|
|
list = next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 00:34:59 +00:00
|
|
|
|
static void
|
|
|
|
|
activate_inspector (GSimpleAction *action,
|
|
|
|
|
GVariant *parameter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
gtk_window_set_interactive_debugging (TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 15:01:18 +00:00
|
|
|
|
static void
|
|
|
|
|
activate_run (GSimpleAction *action,
|
|
|
|
|
GVariant *parameter,
|
2019-10-15 13:39:59 +00:00
|
|
|
|
gpointer window)
|
2013-12-13 15:01:18 +00:00
|
|
|
|
{
|
2019-10-15 13:39:59 +00:00
|
|
|
|
GtkTreeListRow *row = gtk_single_selection_get_selected_item (selection);
|
|
|
|
|
GtkDemo *demo = gtk_tree_list_row_get_item (row);
|
2013-12-13 15:01:18 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
gtk_demo_run (demo, window);
|
2013-12-13 15:01:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 22:42:17 +00:00
|
|
|
|
static GtkWidget *
|
2020-08-13 00:04:35 +00:00
|
|
|
|
display_image (const char *format,
|
|
|
|
|
const char *resource,
|
|
|
|
|
char **label)
|
2018-04-05 22:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *sw, *image;
|
|
|
|
|
|
2020-06-07 02:06:58 +00:00
|
|
|
|
image = gtk_picture_new_for_resource (resource);
|
2018-04-05 22:42:17 +00:00
|
|
|
|
gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
|
|
|
|
|
gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
|
2020-06-24 15:25:09 +00:00
|
|
|
|
sw = gtk_scrolled_window_new ();
|
2020-05-02 04:51:20 +00:00
|
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), image);
|
2018-04-05 22:42:17 +00:00
|
|
|
|
|
|
|
|
|
return sw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
2020-08-13 00:04:35 +00:00
|
|
|
|
display_images (const char *format,
|
|
|
|
|
const char *resource_dir,
|
|
|
|
|
char **label)
|
|
|
|
|
{
|
|
|
|
|
char **resources;
|
|
|
|
|
GtkWidget *grid;
|
|
|
|
|
GtkWidget *sw;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
resources = g_resources_enumerate_children (resource_dir, 0, NULL);
|
|
|
|
|
if (resources == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
sw = gtk_scrolled_window_new ();
|
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
grid = gtk_flow_box_new ();
|
|
|
|
|
gtk_flow_box_set_selection_mode (GTK_FLOW_BOX (grid), GTK_SELECTION_NONE);
|
|
|
|
|
gtk_widget_set_valign (grid, GTK_ALIGN_START);
|
|
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), grid);
|
|
|
|
|
|
|
|
|
|
for (i = 0; resources[i]; i++)
|
|
|
|
|
{
|
|
|
|
|
char *resource_name;
|
|
|
|
|
GtkWidget *box;
|
|
|
|
|
|
|
|
|
|
resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
|
|
|
|
|
|
|
|
|
|
widget = display_image (NULL, resource_name, NULL);
|
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
|
|
|
|
gtk_box_append (GTK_BOX (box), widget);
|
|
|
|
|
gtk_box_append (GTK_BOX (box), gtk_label_new (resources[i]));
|
|
|
|
|
gtk_flow_box_insert (GTK_FLOW_BOX (grid), box, -1);
|
|
|
|
|
|
|
|
|
|
g_free (resource_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_strfreev (resources);
|
|
|
|
|
|
|
|
|
|
*label = g_strdup ("Images");
|
|
|
|
|
|
|
|
|
|
return sw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
|
display_text (const char *format,
|
|
|
|
|
const char *resource,
|
|
|
|
|
char **label)
|
2018-04-05 22:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
|
GtkWidget *textview, *sw;
|
|
|
|
|
GBytes *bytes;
|
2020-08-13 04:45:52 +00:00
|
|
|
|
const char *text;
|
|
|
|
|
gsize len;
|
2018-04-05 22:42:17 +00:00
|
|
|
|
|
|
|
|
|
bytes = g_resources_lookup_data (resource, 0, NULL);
|
|
|
|
|
g_assert (bytes);
|
|
|
|
|
|
|
|
|
|
g_assert (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL));
|
|
|
|
|
|
|
|
|
|
textview = gtk_text_view_new ();
|
2020-09-14 20:20:52 +00:00
|
|
|
|
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 20);
|
|
|
|
|
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (textview), 20);
|
|
|
|
|
gtk_text_view_set_top_margin (GTK_TEXT_VIEW (textview), 20);
|
|
|
|
|
gtk_text_view_set_bottom_margin (GTK_TEXT_VIEW (textview), 20);
|
2018-04-05 22:42:17 +00:00
|
|
|
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
|
|
|
|
|
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), FALSE);
|
|
|
|
|
/* Make it a bit nicer for text. */
|
|
|
|
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_WORD);
|
|
|
|
|
gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (textview), 2);
|
|
|
|
|
gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (textview), 2);
|
2020-08-09 03:41:05 +00:00
|
|
|
|
gtk_text_view_set_monospace (GTK_TEXT_VIEW (textview), TRUE);
|
2018-04-05 22:42:17 +00:00
|
|
|
|
|
|
|
|
|
buffer = gtk_text_buffer_new (NULL);
|
2020-08-13 04:45:52 +00:00
|
|
|
|
|
|
|
|
|
text = g_bytes_unref_to_data (bytes, &len);
|
|
|
|
|
gtk_text_buffer_set_text (buffer, text, len);
|
2020-08-07 13:21:29 +00:00
|
|
|
|
|
|
|
|
|
if (format)
|
|
|
|
|
fontify (format, buffer);
|
|
|
|
|
|
2018-04-05 22:42:17 +00:00
|
|
|
|
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
|
|
|
|
|
|
2020-06-24 15:25:09 +00:00
|
|
|
|
sw = gtk_scrolled_window_new ();
|
2018-04-05 22:42:17 +00:00
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
2020-05-02 04:51:20 +00:00
|
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), textview);
|
2018-04-05 22:42:17 +00:00
|
|
|
|
|
|
|
|
|
return sw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
2020-08-13 00:04:35 +00:00
|
|
|
|
display_video (const char *format,
|
|
|
|
|
const char *resource,
|
|
|
|
|
char **label)
|
2018-04-05 22:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *video;
|
|
|
|
|
|
|
|
|
|
video = gtk_video_new_for_resource (resource);
|
|
|
|
|
gtk_video_set_loop (GTK_VIDEO (video), TRUE);
|
|
|
|
|
|
|
|
|
|
return video;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
|
display_nothing (const char *resource)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
|
|
str = g_strdup_printf ("The lazy GTK developers forgot to add a way to display the resource '%s'", resource);
|
|
|
|
|
widget = gtk_label_new (str);
|
2019-08-22 10:41:39 +00:00
|
|
|
|
gtk_label_set_wrap (GTK_LABEL (widget), TRUE);
|
2018-04-05 22:42:17 +00:00
|
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
|
const char *extension;
|
2020-08-07 13:21:29 +00:00
|
|
|
|
const char *format;
|
2020-08-13 00:04:35 +00:00
|
|
|
|
GtkWidget * (* display_func) (const char *format,
|
|
|
|
|
const char *resource,
|
|
|
|
|
char **label);
|
2018-04-05 22:42:17 +00:00
|
|
|
|
} display_funcs[] = {
|
2020-08-07 13:21:29 +00:00
|
|
|
|
{ ".gif", NULL, display_image },
|
|
|
|
|
{ ".jpg", NULL, display_image },
|
|
|
|
|
{ ".png", NULL, display_image },
|
2020-10-06 19:11:08 +00:00
|
|
|
|
{ ".svg", NULL, display_image },
|
2020-08-07 13:21:29 +00:00
|
|
|
|
{ ".c", "c", display_text },
|
|
|
|
|
{ ".css", "css", display_text },
|
|
|
|
|
{ ".glsl", NULL, display_text },
|
|
|
|
|
{ ".h", "c", display_text },
|
|
|
|
|
{ ".txt", NULL, display_text },
|
|
|
|
|
{ ".ui", "xml", display_text },
|
2020-08-13 00:04:35 +00:00
|
|
|
|
{ ".webm", NULL, display_video },
|
|
|
|
|
{ "images/", NULL, display_images }
|
2018-04-05 22:42:17 +00:00
|
|
|
|
};
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2020-07-24 18:40:36 +00:00
|
|
|
|
add_data_tab (const char *demoname)
|
2012-05-18 04:48:57 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *resource_dir, *resource_name;
|
|
|
|
|
char **resources;
|
2012-05-18 04:48:57 +00:00
|
|
|
|
GtkWidget *widget, *label;
|
2018-04-05 22:42:17 +00:00
|
|
|
|
guint i, j;
|
2020-08-13 00:04:35 +00:00
|
|
|
|
char *label_string;
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
2013-02-01 17:21:56 +00:00
|
|
|
|
resource_dir = g_strconcat ("/", demoname, NULL);
|
|
|
|
|
resources = g_resources_enumerate_children (resource_dir, 0, NULL);
|
|
|
|
|
if (resources == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_free (resource_dir);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; resources[i]; i++)
|
|
|
|
|
{
|
|
|
|
|
resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
|
2013-02-26 14:55:29 +00:00
|
|
|
|
|
2020-08-13 00:04:35 +00:00
|
|
|
|
for (j = 0; j < G_N_ELEMENTS (display_funcs); j++)
|
2013-02-01 17:21:56 +00:00
|
|
|
|
{
|
2018-04-05 22:42:17 +00:00
|
|
|
|
if (g_str_has_suffix (resource_name, display_funcs[j].extension))
|
|
|
|
|
break;
|
2013-02-01 17:21:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-13 00:04:35 +00:00
|
|
|
|
label_string = NULL;
|
|
|
|
|
|
|
|
|
|
if (j < G_N_ELEMENTS (display_funcs))
|
|
|
|
|
widget = display_funcs[j].display_func (display_funcs[j].format,
|
|
|
|
|
resource_name,
|
|
|
|
|
&label_string);
|
2018-04-05 22:42:17 +00:00
|
|
|
|
else
|
|
|
|
|
widget = display_nothing (resource_name);
|
2017-10-07 01:59:34 +00:00
|
|
|
|
|
2020-08-13 00:04:35 +00:00
|
|
|
|
label = gtk_label_new (label_string ? label_string : resources[i]);
|
2013-02-01 17:21:56 +00:00
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
|
2019-02-21 16:13:53 +00:00
|
|
|
|
g_object_set (gtk_notebook_get_page (GTK_NOTEBOOK (notebook), widget),
|
2019-04-02 21:32:14 +00:00
|
|
|
|
"tab-expand", FALSE,
|
2019-02-21 16:13:53 +00:00
|
|
|
|
NULL);
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
2013-02-01 17:21:56 +00:00
|
|
|
|
g_free (resource_name);
|
2020-08-13 00:04:35 +00:00
|
|
|
|
g_free (label_string);
|
2013-02-01 17:21:56 +00:00
|
|
|
|
}
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
2013-02-01 17:21:56 +00:00
|
|
|
|
g_strfreev (resources);
|
|
|
|
|
g_free (resource_dir);
|
2012-05-18 04:48:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
remove_data_tabs (void)
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i;
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
|
|
|
|
for (i = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) - 1; i > 1; i--)
|
|
|
|
|
gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), i);
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
|
void
|
2020-07-24 18:40:36 +00:00
|
|
|
|
load_file (const char *demoname,
|
|
|
|
|
const char *filename)
|
2000-10-18 15:50:13 +00:00
|
|
|
|
{
|
2013-02-26 14:55:29 +00:00
|
|
|
|
GtkTextBuffer *info_buffer, *source_buffer;
|
2000-10-18 15:50:13 +00:00
|
|
|
|
GtkTextIter start, end;
|
2013-01-29 13:51:06 +00:00
|
|
|
|
char *resource_filename;
|
2001-11-23 21:46:44 +00:00
|
|
|
|
GError *err = NULL;
|
2000-10-18 15:50:13 +00:00
|
|
|
|
int state = 0;
|
|
|
|
|
gboolean in_para = 0;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char **lines;
|
2013-01-29 13:51:06 +00:00
|
|
|
|
GBytes *bytes;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i;
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
2013-02-01 17:56:10 +00:00
|
|
|
|
if (!g_strcmp0 (current_file, filename))
|
|
|
|
|
return;
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
2013-02-01 17:56:10 +00:00
|
|
|
|
remove_data_tabs ();
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
2013-02-01 17:21:56 +00:00
|
|
|
|
add_data_tab (demoname);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2000-10-26 00:36:47 +00:00
|
|
|
|
g_free (current_file);
|
2013-02-01 17:56:10 +00:00
|
|
|
|
current_file = g_strdup (filename);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
|
2013-02-26 14:55:29 +00:00
|
|
|
|
info_buffer = gtk_text_buffer_new (NULL);
|
|
|
|
|
gtk_text_buffer_create_tag (info_buffer, "title",
|
|
|
|
|
"font", "Sans 18",
|
|
|
|
|
"pixels-below-lines", 10,
|
|
|
|
|
NULL);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2013-02-26 14:55:29 +00:00
|
|
|
|
source_buffer = gtk_text_buffer_new (NULL);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2019-11-01 18:18:21 +00:00
|
|
|
|
gtk_text_buffer_begin_irreversible_action (info_buffer);
|
|
|
|
|
gtk_text_buffer_begin_irreversible_action (source_buffer);
|
|
|
|
|
|
2013-02-01 17:56:10 +00:00
|
|
|
|
resource_filename = g_strconcat ("/sources/", filename, NULL);
|
2013-01-29 13:51:06 +00:00
|
|
|
|
bytes = g_resources_lookup_data (resource_filename, 0, &err);
|
|
|
|
|
g_free (resource_filename);
|
2001-11-23 21:46:44 +00:00
|
|
|
|
|
2013-01-29 13:51:06 +00:00
|
|
|
|
if (bytes == NULL)
|
2013-01-29 13:08:47 +00:00
|
|
|
|
{
|
2016-02-28 17:18:36 +00:00
|
|
|
|
g_warning ("Cannot open source for %s: %s", filename, err->message);
|
2013-01-29 13:08:47 +00:00
|
|
|
|
g_error_free (err);
|
2013-02-01 17:56:10 +00:00
|
|
|
|
return;
|
2013-01-29 13:08:47 +00:00
|
|
|
|
}
|
2000-11-13 04:36:38 +00:00
|
|
|
|
|
2013-01-29 13:51:06 +00:00
|
|
|
|
lines = g_strsplit (g_bytes_get_data (bytes, NULL), "\n", -1);
|
|
|
|
|
g_bytes_unref (bytes);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
|
|
|
|
gtk_text_buffer_get_iter_at_offset (info_buffer, &start, 0);
|
2013-01-29 13:08:47 +00:00
|
|
|
|
for (i = 0; lines[i] != NULL; i++)
|
2000-10-18 15:50:13 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *p;
|
|
|
|
|
char *q;
|
|
|
|
|
char *r;
|
2011-09-02 03:55:47 +00:00
|
|
|
|
|
2013-01-29 13:08:47 +00:00
|
|
|
|
/* Make sure \r is stripped at the end for the poor windows people */
|
|
|
|
|
lines[i] = g_strchomp (lines[i]);
|
|
|
|
|
|
|
|
|
|
p = lines[i];
|
2000-10-18 15:50:13 +00:00
|
|
|
|
switch (state)
|
2011-09-02 03:55:47 +00:00
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
/* Reading title */
|
|
|
|
|
while (*p == '/' || *p == '*' || g_ascii_isspace (*p))
|
|
|
|
|
p++;
|
|
|
|
|
r = p;
|
2012-05-26 00:39:59 +00:00
|
|
|
|
while (*r != '\0')
|
|
|
|
|
{
|
|
|
|
|
while (*r != '/' && *r != ':' && *r != '\0')
|
|
|
|
|
r++;
|
|
|
|
|
if (*r == '/')
|
|
|
|
|
{
|
|
|
|
|
r++;
|
|
|
|
|
p = r;
|
|
|
|
|
}
|
|
|
|
|
if (r[0] == ':' && r[1] == ':')
|
|
|
|
|
*r = '\0';
|
|
|
|
|
}
|
2011-09-02 03:55:47 +00:00
|
|
|
|
q = p + strlen (p);
|
|
|
|
|
while (q > p && g_ascii_isspace (*(q - 1)))
|
|
|
|
|
q--;
|
|
|
|
|
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
|
if (q > p)
|
|
|
|
|
{
|
|
|
|
|
int len_chars = g_utf8_pointer_to_offset (p, q);
|
|
|
|
|
|
|
|
|
|
end = start;
|
|
|
|
|
|
|
|
|
|
g_assert (strlen (p) >= q - p);
|
|
|
|
|
gtk_text_buffer_insert (info_buffer, &end, p, q - p);
|
|
|
|
|
start = end;
|
|
|
|
|
|
|
|
|
|
gtk_text_iter_backward_chars (&start, len_chars);
|
|
|
|
|
gtk_text_buffer_apply_tag_by_name (info_buffer, "title", &start, &end);
|
|
|
|
|
|
|
|
|
|
start = end;
|
|
|
|
|
|
2012-05-23 17:39:47 +00:00
|
|
|
|
while (*p && *p != '\n') p++;
|
2012-05-18 04:48:57 +00:00
|
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
|
state++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
/* Reading body of info section */
|
|
|
|
|
while (g_ascii_isspace (*p))
|
|
|
|
|
p++;
|
|
|
|
|
if (*p == '*' && *(p + 1) == '/')
|
|
|
|
|
{
|
|
|
|
|
gtk_text_buffer_get_iter_at_offset (source_buffer, &start, 0);
|
|
|
|
|
state++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
while (*p == '*' || g_ascii_isspace (*p))
|
|
|
|
|
p++;
|
|
|
|
|
|
|
|
|
|
len = strlen (p);
|
|
|
|
|
while (g_ascii_isspace (*(p + len - 1)))
|
|
|
|
|
len--;
|
|
|
|
|
|
2020-09-13 14:45:03 +00:00
|
|
|
|
if (*p == '#')
|
|
|
|
|
break;
|
|
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
|
if (len > 0)
|
|
|
|
|
{
|
|
|
|
|
if (in_para)
|
|
|
|
|
gtk_text_buffer_insert (info_buffer, &start, " ", 1);
|
|
|
|
|
|
|
|
|
|
g_assert (strlen (p) >= len);
|
|
|
|
|
gtk_text_buffer_insert (info_buffer, &start, p, len);
|
|
|
|
|
in_para = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_text_buffer_insert (info_buffer, &start, "\n", 1);
|
|
|
|
|
in_para = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
/* Skipping blank lines */
|
|
|
|
|
while (g_ascii_isspace (*p))
|
|
|
|
|
p++;
|
2018-10-12 21:09:42 +00:00
|
|
|
|
|
|
|
|
|
if (!*p)
|
2011-09-02 03:55:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2018-10-12 21:09:42 +00:00
|
|
|
|
p = lines[i];
|
|
|
|
|
state++;
|
2020-03-07 14:01:21 +00:00
|
|
|
|
G_GNUC_FALLTHROUGH;
|
2018-10-12 21:09:42 +00:00
|
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
|
case 3:
|
|
|
|
|
/* Reading program body */
|
|
|
|
|
gtk_text_buffer_insert (source_buffer, &start, p, -1);
|
2014-11-12 21:05:49 +00:00
|
|
|
|
if (lines[i+1] != NULL)
|
|
|
|
|
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
break;
|
2020-03-07 14:01:21 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
2011-09-02 03:55:47 +00:00
|
|
|
|
}
|
2000-10-18 15:50:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-12 21:05:49 +00:00
|
|
|
|
g_strfreev (lines);
|
|
|
|
|
|
2020-08-07 13:21:29 +00:00
|
|
|
|
fontify ("c", source_buffer);
|
2001-02-13 05:44:47 +00:00
|
|
|
|
|
2019-11-01 18:18:21 +00:00
|
|
|
|
gtk_text_buffer_end_irreversible_action (source_buffer);
|
2013-02-26 14:55:29 +00:00
|
|
|
|
gtk_text_view_set_buffer (GTK_TEXT_VIEW (source_view), source_buffer);
|
|
|
|
|
g_object_unref (source_buffer);
|
2014-11-12 21:05:49 +00:00
|
|
|
|
|
2019-11-01 18:18:21 +00:00
|
|
|
|
gtk_text_buffer_end_irreversible_action (info_buffer);
|
2014-11-12 21:05:49 +00:00
|
|
|
|
gtk_text_view_set_buffer (GTK_TEXT_VIEW (info_view), info_buffer);
|
|
|
|
|
g_object_unref (info_buffer);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-10-26 00:36:47 +00:00
|
|
|
|
static void
|
2019-10-15 13:39:59 +00:00
|
|
|
|
activate_cb (GtkWidget *widget,
|
|
|
|
|
guint position,
|
|
|
|
|
gpointer window)
|
2000-10-18 15:50:13 +00:00
|
|
|
|
{
|
2020-08-31 21:06:48 +00:00
|
|
|
|
GListModel *model = G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (widget)));
|
|
|
|
|
GtkTreeListRow *row = g_list_model_get_item (model, position);
|
2019-10-15 13:39:59 +00:00
|
|
|
|
GtkDemo *demo = gtk_tree_list_row_get_item (row);
|
2000-10-26 00:36:47 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
gtk_demo_run (demo, window);
|
2000-10-26 00:36:47 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
g_object_unref (row);
|
|
|
|
|
}
|
2013-01-30 22:16:16 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
static void
|
|
|
|
|
selection_cb (GtkSingleSelection *sel,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeListRow *row = gtk_single_selection_get_selected_item (sel);
|
2020-07-12 15:39:27 +00:00
|
|
|
|
GtkDemo *demo;
|
2020-09-13 21:55:10 +00:00
|
|
|
|
GAction *action;
|
2020-07-12 15:39:27 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (notebook), !!row);
|
|
|
|
|
|
|
|
|
|
if (!row)
|
|
|
|
|
{
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (toplevel), "No match");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
demo = gtk_tree_list_row_get_item (row);
|
2013-01-30 22:16:16 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
if (demo->filename)
|
|
|
|
|
load_file (demo->name, demo->filename);
|
2013-12-03 01:35:57 +00:00
|
|
|
|
|
2020-09-13 21:55:10 +00:00
|
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (toplevel), "run");
|
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), demo->func != NULL);
|
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
gtk_window_set_title (GTK_WINDOW (toplevel), demo->title);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-12 22:24:04 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
filter_demo (GtkDemo *demo)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2020-08-21 12:41:13 +00:00
|
|
|
|
/* Show only if the name matches every needle */
|
2020-07-12 22:24:04 +00:00
|
|
|
|
for (i = 0; search_needle[i]; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!demo->title)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (g_str_match_string (search_needle[i], demo->title, TRUE))
|
|
|
|
|
continue;
|
|
|
|
|
|
2020-09-13 15:37:23 +00:00
|
|
|
|
if (demo->keywords)
|
|
|
|
|
{
|
|
|
|
|
int j;
|
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
|
|
for (j = 0; !found && demo->keywords[j]; j++)
|
|
|
|
|
{
|
|
|
|
|
if (strstr (demo->keywords[j], search_needle[i]))
|
|
|
|
|
found = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-12 22:24:04 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-12 15:39:27 +00:00
|
|
|
|
static gboolean
|
2020-08-03 19:04:33 +00:00
|
|
|
|
demo_filter_by_name (gpointer item,
|
|
|
|
|
gpointer user_data)
|
2020-07-12 15:39:27 +00:00
|
|
|
|
{
|
2020-08-03 19:04:33 +00:00
|
|
|
|
GtkTreeListRow *row = item;
|
|
|
|
|
GtkFilterListModel *model = user_data;
|
2020-07-12 22:24:04 +00:00
|
|
|
|
GListModel *children;
|
2020-07-12 15:39:27 +00:00
|
|
|
|
GtkDemo *demo;
|
2020-07-12 22:24:04 +00:00
|
|
|
|
guint i, n;
|
2020-08-09 14:53:48 +00:00
|
|
|
|
GtkTreeListRow *parent;
|
2020-07-12 15:39:27 +00:00
|
|
|
|
|
|
|
|
|
/* Show all items if search is empty */
|
|
|
|
|
if (!search_needle || !search_needle[0] || !*search_needle[0])
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
g_assert (GTK_IS_TREE_LIST_ROW (row));
|
|
|
|
|
g_assert (GTK_IS_FILTER_LIST_MODEL (model));
|
|
|
|
|
|
2020-08-09 14:53:48 +00:00
|
|
|
|
/* Show a row if itself of any parent matches */
|
|
|
|
|
for (parent = row; parent; parent = gtk_tree_list_row_get_parent (parent))
|
|
|
|
|
{
|
|
|
|
|
demo = gtk_tree_list_row_get_item (parent);
|
|
|
|
|
g_assert (GTK_IS_DEMO (demo));
|
|
|
|
|
|
|
|
|
|
if (filter_demo (demo))
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Show a row if any child matches */
|
2020-07-12 22:24:04 +00:00
|
|
|
|
children = gtk_tree_list_row_get_children (row);
|
|
|
|
|
if (children)
|
2020-07-12 15:39:27 +00:00
|
|
|
|
{
|
2020-07-12 22:24:04 +00:00
|
|
|
|
n = g_list_model_get_n_items (children);
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
{
|
|
|
|
|
demo = g_list_model_get_item (children, i);
|
|
|
|
|
g_assert (GTK_IS_DEMO (demo));
|
2020-07-12 15:39:27 +00:00
|
|
|
|
|
2020-07-12 22:24:04 +00:00
|
|
|
|
if (filter_demo (demo))
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (demo);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
g_object_unref (demo);
|
|
|
|
|
}
|
2020-07-12 15:39:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-09 14:53:48 +00:00
|
|
|
|
return FALSE;
|
2020-07-12 15:39:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
demo_search_changed_cb (GtkSearchEntry *entry,
|
|
|
|
|
GtkFilter *filter)
|
|
|
|
|
{
|
|
|
|
|
const char *text;
|
|
|
|
|
|
|
|
|
|
g_assert (GTK_IS_SEARCH_ENTRY (entry));
|
|
|
|
|
g_assert (GTK_IS_FILTER (filter));
|
|
|
|
|
|
|
|
|
|
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
|
|
|
|
|
|
|
|
|
g_clear_pointer (&search_needle, g_strfreev);
|
|
|
|
|
|
|
|
|
|
if (text && *text)
|
2020-09-13 15:37:23 +00:00
|
|
|
|
search_needle = g_str_tokenize_and_fold (text, NULL, NULL);
|
2020-07-12 15:39:27 +00:00
|
|
|
|
|
|
|
|
|
gtk_filter_changed (filter, GTK_FILTER_CHANGE_DIFFERENT);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
static GListModel *
|
|
|
|
|
create_demo_model (void)
|
2000-10-26 00:36:47 +00:00
|
|
|
|
{
|
2019-10-15 13:39:59 +00:00
|
|
|
|
GListStore *store = g_list_store_new (GTK_TYPE_DEMO);
|
|
|
|
|
DemoData *demo = gtk_demos;
|
2020-09-13 21:37:05 +00:00
|
|
|
|
GtkDemo *d;
|
|
|
|
|
|
|
|
|
|
d = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
|
|
|
|
|
d->name = "main";
|
|
|
|
|
d->title = "GTK Demo";
|
|
|
|
|
d->keywords = NULL;
|
|
|
|
|
d->filename = "main.c";
|
|
|
|
|
d->func = NULL;
|
|
|
|
|
|
|
|
|
|
g_list_store_append (store, d);
|
2000-10-26 00:36:47 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
while (demo->title)
|
2000-10-26 00:36:47 +00:00
|
|
|
|
{
|
2020-09-13 21:37:05 +00:00
|
|
|
|
d = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
|
2019-10-15 13:39:59 +00:00
|
|
|
|
DemoData *children = demo->children;
|
2001-10-02 18:54:05 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
d->name = demo->name;
|
|
|
|
|
d->title = demo->title;
|
2020-09-13 15:37:23 +00:00
|
|
|
|
d->keywords = demo->keywords;
|
2019-10-15 13:39:59 +00:00
|
|
|
|
d->filename = demo->filename;
|
|
|
|
|
d->func = demo->func;
|
2000-10-27 23:34:58 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
g_list_store_append (store, d);
|
2001-10-02 18:54:05 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
if (children)
|
2011-09-02 03:55:47 +00:00
|
|
|
|
{
|
2019-10-15 13:39:59 +00:00
|
|
|
|
d->children_model = G_LIST_MODEL (g_list_store_new (GTK_TYPE_DEMO));
|
2011-09-02 03:55:47 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
while (children->title)
|
|
|
|
|
{
|
|
|
|
|
GtkDemo *child = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
|
2011-09-02 03:55:47 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
child->name = children->name;
|
|
|
|
|
child->title = children->title;
|
2020-09-13 15:37:23 +00:00
|
|
|
|
child->keywords = children->keywords;
|
2019-10-15 13:39:59 +00:00
|
|
|
|
child->filename = children->filename;
|
|
|
|
|
child->func = children->func;
|
2011-09-02 03:55:47 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
g_list_store_append (G_LIST_STORE (d->children_model), child);
|
|
|
|
|
children++;
|
|
|
|
|
}
|
2011-09-02 03:55:47 +00:00
|
|
|
|
}
|
2019-10-15 13:39:59 +00:00
|
|
|
|
|
|
|
|
|
demo++;
|
2000-10-26 00:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
return G_LIST_MODEL (store);
|
2013-12-03 00:42:04 +00:00
|
|
|
|
}
|
remove validation idle
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy_layout): remove
validation idle
* demos/gtk-demo/main.c (create_tree): adjust to changes in text
cell renderer
* demos/pixbuf-demo.c (timeout): remove deprecated
gtk_widget_draw
* demos/testpixbuf-save.c (main): remove deprecated
gtk_drawing_area_size
* gtk/gtktreeview.c (gtk_tree_view_size_allocate): allocate
buttons even if the model isn't setup. gtk_tree_view_check_dirty()
at the start of the allocation.
(gtk_tree_view_check_dirty): handle column->button == NULL, handle
unsetup or NULL model.
* gtk/gtkstyle.c (gtk_default_draw_flat_box): drawing for the
even/odd/sorted cells in the tree view.
* gtk/gtktreeselection.c (gtk_tree_selection_real_unselect_all):
bugfixes
* gtk/gtktreeview.c: assorted bugfixy stuff. Draw the row
backgrounds with draw_flat_box using different detail for even/odd
rows.
* gtk/gtkrbtree.c, gtkrbtree.h: Keep track of the parity of each
row, so we can draw the alternating colors thing
* gtk/gtktexttag.c (gtk_text_tag_set_property): if we change a
property from a synonym property, notify for the synonym.
Also, nuke the background_gdk_set and foreground_gdk_set synonyms
(gtk_text_tag_get_property): Always return the font, even if
all its fields aren't set
* gtk/gtkcellrenderertext.h (struct _GtkCellRendererText): don't
store the attr list; it leaves us with no way to change attributes
in _render according to the render flags, and no way to implement
get_property. Instead store all the specific text attributes.
Separate whether an attribute is enabled from its value. Sync all
properties with GtkTextTag, make them all consistent, etc.
* gtk/gtkcellrenderer.h: Add a flag GTK_CELL_RENDERER_SORTED so
renderers can highlight the sort row/column
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_property): use
accessor functions to get values; this has the side effect of
showing up which accessor functions were missing. Added those.
* gtk/gtktreeviewcolumn.h: Replace set_justification with
set_alignment, to be consistent with GtkLabel, GtkMisc
* gtk/gtktreeviewcolumn.c: Added code to display sort indicator
arrow.
* gtk/Makefile.am (gtk_public_h_sources): add gtktreesortable.h
* gtk/gtktreesortable.h: updates in here
2001-02-08 23:36:53 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
static GListModel *
|
|
|
|
|
get_child_model (gpointer item,
|
|
|
|
|
gpointer user_data)
|
2013-12-13 15:01:18 +00:00
|
|
|
|
{
|
2019-10-15 13:39:59 +00:00
|
|
|
|
GtkDemo *demo = item;
|
2013-12-13 15:01:18 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
if (demo->children_model)
|
|
|
|
|
return g_object_ref (G_LIST_MODEL (demo->children_model));
|
2013-12-13 15:01:18 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
return NULL;
|
2013-12-13 15:01:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-12 20:47:51 +00:00
|
|
|
|
static void
|
|
|
|
|
clear_search (GtkSearchBar *bar)
|
|
|
|
|
{
|
|
|
|
|
if (!gtk_search_bar_get_search_mode (bar))
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *entry = gtk_search_bar_get_child (GTK_SEARCH_BAR (bar));
|
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 00:42:04 +00:00
|
|
|
|
static void
|
|
|
|
|
activate (GApplication *app)
|
|
|
|
|
{
|
|
|
|
|
GtkBuilder *builder;
|
2019-10-15 13:39:59 +00:00
|
|
|
|
GListModel *listmodel;
|
|
|
|
|
GtkTreeListModel *treemodel;
|
2020-07-12 20:47:51 +00:00
|
|
|
|
GtkWidget *window, *listview, *search_entry, *search_bar;
|
2020-07-12 15:39:27 +00:00
|
|
|
|
GtkFilterListModel *filter_model;
|
|
|
|
|
GtkFilter *filter;
|
2020-09-13 21:55:10 +00:00
|
|
|
|
GSimpleAction *action;
|
2005-06-28 03:42:55 +00:00
|
|
|
|
|
2019-11-29 07:48:48 +00:00
|
|
|
|
builder = gtk_builder_new_from_resource ("/ui/main.ui");
|
2013-12-03 00:42:04 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
|
|
|
|
|
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
|
2020-09-13 21:55:10 +00:00
|
|
|
|
|
|
|
|
|
action = g_simple_action_new ("run", NULL);
|
|
|
|
|
g_signal_connect (action, "activate", G_CALLBACK (activate_run), window);
|
|
|
|
|
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));
|
2013-12-03 00:42:04 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
|
2005-06-28 03:42:55 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
info_view = GTK_WIDGET (gtk_builder_get_object (builder, "info-textview"));
|
|
|
|
|
source_view = GTK_WIDGET (gtk_builder_get_object (builder, "source-textview"));
|
2020-04-30 23:04:08 +00:00
|
|
|
|
toplevel = GTK_WIDGET (window);
|
2019-10-15 13:39:59 +00:00
|
|
|
|
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
|
|
|
|
|
g_signal_connect (listview, "activate", G_CALLBACK (activate_cb), window);
|
2020-07-12 20:47:51 +00:00
|
|
|
|
search_bar = GTK_WIDGET (gtk_builder_get_object (builder, "searchbar"));
|
|
|
|
|
g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL);
|
2013-12-03 00:42:04 +00:00
|
|
|
|
|
2019-10-15 13:39:59 +00:00
|
|
|
|
listmodel = create_demo_model ();
|
2020-07-26 20:38:53 +00:00
|
|
|
|
treemodel = gtk_tree_list_model_new (G_LIST_MODEL (listmodel),
|
|
|
|
|
FALSE,
|
2020-06-07 02:07:38 +00:00
|
|
|
|
TRUE,
|
2019-10-15 13:39:59 +00:00
|
|
|
|
get_child_model,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
2020-07-12 15:39:27 +00:00
|
|
|
|
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
|
2020-08-03 19:04:33 +00:00
|
|
|
|
filter = GTK_FILTER (gtk_custom_filter_new (demo_filter_by_name, filter_model, NULL));
|
2020-07-12 15:39:27 +00:00
|
|
|
|
gtk_filter_list_model_set_filter (filter_model, filter);
|
2020-07-26 19:55:44 +00:00
|
|
|
|
g_object_unref (filter);
|
2020-08-03 19:04:33 +00:00
|
|
|
|
|
2020-07-12 15:39:27 +00:00
|
|
|
|
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
|
|
|
|
|
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
|
|
|
|
|
|
|
|
|
|
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
|
2019-10-15 13:39:59 +00:00
|
|
|
|
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
|
2020-08-31 21:06:48 +00:00
|
|
|
|
gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selection));
|
2020-06-17 16:25:28 +00:00
|
|
|
|
|
|
|
|
|
selection_cb (selection, NULL, NULL);
|
2020-08-31 21:06:48 +00:00
|
|
|
|
g_object_unref (selection);
|
2013-12-03 00:42:04 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (builder);
|
2000-10-26 00:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-06 02:36:00 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
auto_quit (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
g_application_quit (G_APPLICATION (data));
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-09 14:14:17 +00:00
|
|
|
|
static void
|
|
|
|
|
list_demos (void)
|
|
|
|
|
{
|
2019-10-15 13:39:59 +00:00
|
|
|
|
DemoData *d, *c;
|
2015-09-09 14:14:17 +00:00
|
|
|
|
|
|
|
|
|
d = gtk_demos;
|
|
|
|
|
|
|
|
|
|
while (d->title)
|
|
|
|
|
{
|
|
|
|
|
c = d->children;
|
|
|
|
|
if (d->name)
|
|
|
|
|
g_print ("%s\n", d->name);
|
|
|
|
|
d++;
|
|
|
|
|
while (c && c->title)
|
|
|
|
|
{
|
|
|
|
|
if (c->name)
|
|
|
|
|
g_print ("%s\n", c->name);
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2015-09-06 02:36:00 +00:00
|
|
|
|
command_line (GApplication *app,
|
|
|
|
|
GApplicationCommandLine *cmdline)
|
|
|
|
|
{
|
|
|
|
|
GVariantDict *options;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *name = NULL;
|
2015-09-09 12:07:20 +00:00
|
|
|
|
gboolean autoquit = FALSE;
|
2015-09-09 14:14:17 +00:00
|
|
|
|
gboolean list = FALSE;
|
2019-10-15 13:39:59 +00:00
|
|
|
|
DemoData *d, *c;
|
2015-09-06 02:36:00 +00:00
|
|
|
|
GDoDemoFunc func = 0;
|
|
|
|
|
GtkWidget *window, *demo;
|
|
|
|
|
|
|
|
|
|
activate (app);
|
|
|
|
|
|
|
|
|
|
options = g_application_command_line_get_options_dict (cmdline);
|
|
|
|
|
g_variant_dict_lookup (options, "run", "&s", &name);
|
2015-09-09 12:07:20 +00:00
|
|
|
|
g_variant_dict_lookup (options, "autoquit", "b", &autoquit);
|
2015-09-09 14:14:17 +00:00
|
|
|
|
g_variant_dict_lookup (options, "list", "b", &list);
|
|
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
|
{
|
|
|
|
|
list_demos ();
|
|
|
|
|
g_application_quit (app);
|
2015-09-28 10:28:51 +00:00
|
|
|
|
return 0;
|
2015-09-09 14:14:17 +00:00
|
|
|
|
}
|
2015-09-06 02:36:00 +00:00
|
|
|
|
|
2020-05-29 11:51:11 +00:00
|
|
|
|
window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
|
|
|
|
|
|
2015-09-06 02:36:00 +00:00
|
|
|
|
if (name == NULL)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
d = gtk_demos;
|
|
|
|
|
|
|
|
|
|
while (d->title)
|
|
|
|
|
{
|
|
|
|
|
c = d->children;
|
|
|
|
|
if (g_strcmp0 (d->name, name) == 0)
|
|
|
|
|
{
|
|
|
|
|
func = d->func;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
d++;
|
|
|
|
|
while (c && c->title)
|
|
|
|
|
{
|
|
|
|
|
if (g_strcmp0 (c->name, name) == 0)
|
|
|
|
|
{
|
|
|
|
|
func = c->func;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (func)
|
|
|
|
|
{
|
|
|
|
|
demo = (func) (window);
|
|
|
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
|
2020-05-29 11:51:11 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app);
|
2015-09-06 02:36:00 +00:00
|
|
|
|
}
|
2020-05-29 11:51:11 +00:00
|
|
|
|
else
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (window));
|
2015-09-06 02:36:00 +00:00
|
|
|
|
|
2015-09-09 12:07:20 +00:00
|
|
|
|
if (autoquit)
|
|
|
|
|
g_timeout_add_seconds (1, auto_quit, app);
|
2015-09-28 10:28:51 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
2015-09-06 02:36:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-11 15:04:40 +00:00
|
|
|
|
static void
|
|
|
|
|
print_version (void)
|
|
|
|
|
{
|
2020-06-29 03:36:35 +00:00
|
|
|
|
g_print ("gtk4-demo %d.%d.%d\n",
|
2016-09-11 15:04:40 +00:00
|
|
|
|
gtk_get_major_version (),
|
|
|
|
|
gtk_get_minor_version (),
|
|
|
|
|
gtk_get_micro_version ());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
local_options (GApplication *app,
|
|
|
|
|
GVariantDict *options,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
gboolean version = FALSE;
|
|
|
|
|
|
|
|
|
|
g_variant_dict_lookup (options, "version", "b", &version);
|
|
|
|
|
|
|
|
|
|
if (version)
|
|
|
|
|
{
|
|
|
|
|
print_version ();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
|
int
|
|
|
|
|
main (int argc, char **argv)
|
|
|
|
|
{
|
2013-12-03 00:42:04 +00:00
|
|
|
|
GtkApplication *app;
|
|
|
|
|
static GActionEntry app_entries[] = {
|
|
|
|
|
{ "about", activate_about, NULL, NULL, NULL },
|
|
|
|
|
{ "quit", activate_quit, NULL, NULL, NULL },
|
2019-04-17 00:34:59 +00:00
|
|
|
|
{ "inspector", activate_inspector, NULL, NULL, NULL },
|
2013-12-03 00:42:04 +00:00
|
|
|
|
};
|
2020-04-27 02:14:10 +00:00
|
|
|
|
struct {
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *action_and_target;
|
|
|
|
|
const char *accelerators[2];
|
2020-04-27 02:14:10 +00:00
|
|
|
|
} accels[] = {
|
|
|
|
|
{ "app.about", { "F1", NULL } },
|
|
|
|
|
{ "app.quit", { "<Control>q", NULL } },
|
|
|
|
|
};
|
|
|
|
|
int i;
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2019-04-01 22:49:09 +00:00
|
|
|
|
app = gtk_application_new ("org.gtk.Demo4", G_APPLICATION_NON_UNIQUE|G_APPLICATION_HANDLES_COMMAND_LINE);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2013-12-03 00:42:04 +00:00
|
|
|
|
g_action_map_add_action_entries (G_ACTION_MAP (app),
|
|
|
|
|
app_entries, G_N_ELEMENTS (app_entries),
|
|
|
|
|
app);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
2020-04-27 02:14:10 +00:00
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (accels); i++)
|
|
|
|
|
gtk_application_set_accels_for_action (app, accels[i].action_and_target, accels[i].accelerators);
|
|
|
|
|
|
2016-09-11 15:04:40 +00:00
|
|
|
|
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0, G_OPTION_ARG_NONE, "Show program version", NULL);
|
2015-09-06 02:36:00 +00:00
|
|
|
|
g_application_add_main_option (G_APPLICATION (app), "run", 0, 0, G_OPTION_ARG_STRING, "Run an example", "EXAMPLE");
|
2015-09-09 14:14:17 +00:00
|
|
|
|
g_application_add_main_option (G_APPLICATION (app), "list", 0, 0, G_OPTION_ARG_NONE, "List examples", NULL);
|
2015-09-09 12:07:20 +00:00
|
|
|
|
g_application_add_main_option (G_APPLICATION (app), "autoquit", 0, 0, G_OPTION_ARG_NONE, "Quit after a delay", NULL);
|
2015-09-06 02:36:00 +00:00
|
|
|
|
|
2013-12-03 00:42:04 +00:00
|
|
|
|
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
2015-09-06 02:36:00 +00:00
|
|
|
|
g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
|
2016-09-11 15:04:40 +00:00
|
|
|
|
g_signal_connect (app, "handle-local-options", G_CALLBACK (local_options), NULL);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
|
2013-12-03 00:42:04 +00:00
|
|
|
|
g_application_run (G_APPLICATION (app), argc, argv);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|