File: app-buttons.c

package info (click to toggle)
phosh 0.53.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 9,868 kB
  • sloc: ansic: 83,377; xml: 3,981; python: 717; sh: 449; makefile: 34; lisp: 22; javascript: 6
file content (119 lines) | stat: -rw-r--r-- 4,176 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Copyright © 2019 Zander Brown <zbrown@gnome.org>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Author: Zander Brown <zbrown@gnome.org>
 */

#include <gtk/gtk.h>
#include <app-grid-button.h>

int
main (int argc, char **argv)
{
  GtkWidget *window = NULL;
  GtkWidget *wrap;
  GtkWidget *box = NULL;
  GtkWidget *btn = NULL;
  GtkCssProvider *provider = NULL;
  GFile *file = NULL;
  GError *error = NULL;
  GDesktopAppInfo *info = NULL;

  gtk_init (&argc, &argv);

  provider = gtk_css_provider_new ();
  file = g_file_new_for_uri ("resource:///mobi/phosh/stylesheet/adwaita-dark.css");

  if (!gtk_css_provider_load_from_file (provider, file, &error)) {
    g_warning ("Failed to load CSS file: %s", error->message);
    g_clear_error (&error);
    return 1;
  }
  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                             GTK_STYLE_PROVIDER (provider),
                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

  window = g_object_new (GTK_TYPE_WINDOW,
                         "visible", TRUE,
                         "default-height", 100,
                         "default-width", 360,
                         "height-request", 100,
                         "width-request", 360,
                         "title", "PhoshAppGridButton Demo",
                         NULL);
  g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
  gtk_window_set_deletable (GTK_WINDOW (window), FALSE);

  wrap = g_object_new (GTK_TYPE_BOX,
                      "spacing", 20,
                      "orientation", GTK_ORIENTATION_VERTICAL,
                      "margin-start", 6,
                      "margin-end", 6,
                      "margin-top", 6,
                      "margin-bottom", 6,
                      "halign", GTK_ALIGN_CENTER,
                      "valign", GTK_ALIGN_CENTER,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (window), wrap);

  box = g_object_new (GTK_TYPE_BOX,
                      "spacing", 20,
                      "margin-start", 6,
                      "margin-end", 6,
                      "margin-top", 6,
                      "margin-bottom", 6,
                      "halign", GTK_ALIGN_CENTER,
                      "valign", GTK_ALIGN_CENTER,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (wrap), box);

  info = g_desktop_app_info_new ("org.gtk.Demo4.desktop");
  btn = g_object_new (PHOSH_TYPE_APP_GRID_BUTTON,
                      "app-info", info,
                      "mode", PHOSH_APP_GRID_BUTTON_FAVORITES,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (box), btn);

  info = g_desktop_app_info_new ("org.gtk.IconBrowser4.desktop");
  btn = g_object_new (PHOSH_TYPE_APP_GRID_BUTTON,
                      "app-info", info,
                      "mode", PHOSH_APP_GRID_BUTTON_FAVORITES,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (box), btn);

  box = g_object_new (GTK_TYPE_BOX,
                      "spacing", 20,
                      "margin-start", 6,
                      "margin-end", 6,
                      "margin-top", 6,
                      "margin-bottom", 6,
                      "halign", GTK_ALIGN_CENTER,
                      "valign", GTK_ALIGN_CENTER,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (wrap), box);

  info = g_desktop_app_info_new ("org.gtk.Demo4.desktop");
  btn = g_object_new (PHOSH_TYPE_APP_GRID_BUTTON,
                      "app-info", info,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (box), btn);

  info = g_desktop_app_info_new ("org.gtk.IconBrowser4.desktop");
  btn = g_object_new (PHOSH_TYPE_APP_GRID_BUTTON,
                      "app-info", info,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (box), btn);

  gtk_main ();

  return 0;
}