p-hatan/ mirror

pub repository

mirror.p-hatan.ir

gtk

2.1.0

GTK+ utilities for Flutter Linux applications.

Download archive

Readme

GTK+ utilities for Flutter Linux applications

license: MPL CI codecov

GtkSettings

GtkSettings provide a mechanism to share global settings between applications on Linux.

screenshot

GtkApplication

GtkApplication allows the primary Flutter GTK application instance to listen to remote application instances' command-line arguments and file open requests.

NOTE: linux/my_application.cc must be modified for this package to be able to function. See "Getting Started" below for details.

gtk-application.webm

Getting Started

Apply the following changes to linux/my_application.cc:

diff --git a/example/linux/my_application.cc b/example/linux/my_application.cc
index 5cd43c6..94e7215 100644
--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -20,6 +20,12 @@ static void my_application_activate(GApplication* application) {
   GtkWindow* window =
       GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
 
+  GList* windows = gtk_application_get_windows(GTK_APPLICATION(application));
+  if (windows) {
+    gtk_window_present(GTK_WINDOW(windows->data));
+    return;
+  }
+
   // Use a header bar when running in GNOME as this is the common style used
   // by applications and is the setup most users will be using (e.g. Ubuntu
   // desktop).
--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -81,7 +81,7 @@ static gboolean my_application_local_command_line(GApplication* application,
   g_application_activate(application);
   *exit_status = 0;
 
-  return TRUE;
+  return FALSE;
 }
 
 // Implements GObject::dispose.

--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -101,7 +101,8 @@ static void my_application_class_init(MyApplicationClass* klass) {
 static void my_application_init(MyApplication* self) {}
 
 MyApplication* my_application_new() {
-  return MY_APPLICATION(g_object_new(my_application_get_type(),
-                                     "application-id", APPLICATION_ID, "flags",
-                                     G_APPLICATION_NON_UNIQUE, nullptr));
+  return MY_APPLICATION(g_object_new(
+      my_application_get_type(), "application-id", APPLICATION_ID, "flags",
+      G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN,
+      nullptr));
 }

Examples

The GtkApplication widget allows listening to remote application instances' command-line arguments and file open requests from within the widget tree.

import 'package:flutter/material.dart';
import 'package:gtk_application/gtk_application.dart';

void main() {
  runApp(
    MaterialApp(
      home: GtkApplication(
        onCommandLine: (args) => print('command-line: $args'),
        onOpen: (files, hint) => print('open ($hint): $files'),
        child: // ...
      ),
    ),
  );
}

The GtkApplicationNotifier object allows listening to remote application instances' command-line arguments and file open requests outside the widget tree.

import 'package:flutter/widgets.dart';
import 'package:gtk_application/gtk_application.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  final notifier = GtkApplicationNotifier();
  notifier.addCommandLineListener((args) {
    print('command-line: $args');
  });
  notifier.addOpenListener((files, hint) {
    print('open ($hint): $files');
  });

  // ...
  // notifier.dispose();
}
Changelog

2.1.0

  • Migrate to Flutter 3.10 and Dart 3.0

2.0.0

  • GSettings: adjust naming to closer follow GTK
  • GSettings: replace setXxxValue() with setValue()

2.0.0-beta.1

  • Made GtkSettings mockable.

2.0.0-beta.0

  • Re-purpose this package to be a collection of non-visual GTK+ utilities for Flutter applications.
  • Add GtkApplication handling remote command-line arguments and file open requests.
  • Add GtkSettings for accessing desktop and application settings.

1.0.0-rc.9

  • Change adwaitaLight and adwaitaDark type to getters instead of Function

1.0.0-rc.8

  • Fix canvasColor not working

1.0.0-rc.7

  • Add documentation for colors in libadwaita_theme
  • Add adwaitaLight and adwaitaDark for LibAdwaita Theme

1.0.0-rc.6

  • GnomeTheme is now deprecated, use Theme.of(context).[color] to get whatever color you want.

1.0.0-rc.5

  • Get native window button placement by using gsetting schema

1.0.0-rc.4

  • Made width nullable and fix defaults for GtkContainer
  • Update Screenshot

1.0.0-rc.3

  • Fix ViewSwitcher color
  • Add GtkContainer custom widget
  • Add new example app
  • Fix gtk sidebar item bg color

1.0.0-rc.2

  • Fix error when no leading icon was provided for the sidebar
  • Rename gtk_colors.dart to gtk_theme.dart and moved it to the widgets directory
  • Fix imports in the files

1.0.0-rc.1

  • Remove gnomeTheme parameter requirement for gtk_sidebar
  • Add details about paramters of GnomeTheme.of(context)

1.0.0-rc.0

  • Use color schemes from libadwaita

0.9.8+1

  • Remove dead code

0.9.8

  • Add riverpod example
  • Fix selected and unselected color for gtk sidebar
  • Fix initial color parsing

0.9.5

  • Fix instructions on how to use window decoration
  • Update README and screenshot

0.9.0

  • Update gsettings to latest version
  • Fix native theme picker by @MalcolmMielle
  • Made Window Decorations a seperate package to keep this package lightweight

0.8.5

  • Use NavigationToolbar instead of Stack to center widget.

0.8.0

  • Update example
  • Add expanded and height property to GtkViewSwitcher

0.7.0+1

  • Fix Padding of Icons with Gtk header button
  • Update titlebarSpace and padding for GtkHeaderBar

0.7.0

  • Add GtkViewSwitcher from flutter_gtk package
  • Fix Double tap on header buttons doesn't work.
  • Change default padding for header

0.6.0

  • Remove adwaita_icons from dependency of example
  • Revamp code for GtkSidebar.

0.5.5

  • Remove adwaita_icons from dependency
  • Add default values for onClose, onMinimize and onMaximize for GtkHeaderBar.bitsdojo and .nativeshell.
  • Add titlebarSpace property to adjust the space b/w titlebar and trailing items.

0.5.0+1

  • Rename beignDrag to performDrag for nativeshell Gtk Header.

0.5.0

  • Add onDoubleTap and onHeaderDrag method for GtkHeaderBar
  • Add padding and height parameter to GtkHeaderBar
  • Add GtkHeaderBar.bitsdojo and GtkHeaderBar.nativeshell to integerate well with these plugins

0.4.0+1

  • Update Screenshot

0.4.0

  • Add auto detect gtk theme using GtkColorType.system by @MalcolmMielle
  • Update Window Decorations plugin
  • Add isActive parameter to Gtk popup button

0.2.3

  • Change children to body for GtkPopupMenu
  • Update Documentation and comments
  • Update get Gtk color logic
  • Update example by adding bitsdojo_window
  • Update Screenshot

0.2.0+2

  • Fix typo in README
  • Add Screenshot in README

0.2.0+1

  • Update github homepage

0.2.0

  • Remove bitsdojo_window dependency

0.1.0+1

  • Fix Readme

0.1.0

  • initial release.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add gtk
pubspec.yaml
name: gtk
description: GTK+ utilities for Flutter Linux applications.
homepage: https://github.com/ubuntu-flutter-community/gtk.dart
repository: https://github.com/ubuntu-flutter-community/gtk.dart
issue_tracker: https://github.com/ubuntu-flutter-community/gtk.dart/issues
version: 2.1.0

environment:
  sdk: '>=3.0.0 <4.0.0'
  flutter: ">=3.10.0"

dependencies:
  ffi: ^2.0.1
  flutter:
    sdk: flutter
  meta: ^1.8.0

dev_dependencies:
  ffigen: 8.0.2
  flutter_lints: ^2.0.0
  flutter_test:
    sdk: flutter
  mockito: ^5.3.2

flutter:
  plugin:
    platforms:
      linux:
        pluginClass: GtkPlugin

Version history

VersionPublishedArchiveSHA-256
0.1.02021-08-16T17:40:15.636034ZDownloadef9b882fbe22b739e45c4ccfaa010629828a6ec52675e360560f5f1e841b26b5
0.1.0+12021-08-16T17:45:13.189764ZDownloadca70f6c3e2e3610e4caa57abd697a14b52541e55faf8b648713a8f5ba2d794a3
0.2.02021-08-17T16:49:32.619016ZDownload8045cff826236dee6cd29bfea969bee83cb8126496a7cfe90e931dd6497ff973
0.2.0+12021-08-17T17:38:21.237781ZDownloadb38fde1bcac044e310f39f9d2954f6000dfb6d58418712acc40ab544d572f4d7
0.2.0+22021-08-17T17:50:37.175664ZDownload9a333a93c36fea9261be36c6ec73aae1fdf6742745518f1c135f7fa008de735c
0.2.32021-08-18T08:45:00.361662ZDownload79a5c345e250653557072a76ea746b9434eed0fab91b8068a82b5429a2eb6800
0.4.02021-08-21T12:36:41.818539ZDownload396a38f098f32e75d922b33b20cd7a00552f73bca6e8fb6811014ed91003acbd
0.4.0+12021-08-21T13:02:39.123757ZDownload5b4921bb7785e0f14b8087fc9a58ea06ca4bfd91cdebf8cd28bab7162ff62e08
0.5.02021-08-22T16:37:42.182315ZDownloadf1de0c93b1b7b18d77df29b2246b0c39fc881ed71795a8da1ae064caec5c7475
0.5.0+12021-08-22T17:01:09.139984ZDownload5a6b4cf33fc79ab6583baba579747eee5d2721a064bcda9f5f1fa5015ac39329
0.5.52021-08-23T10:25:47.196650ZDownload3f7ae581d126a23f8a3c4e3ca343a479a7103988c0da41233b02813c3114d771
0.6.02021-08-24T15:49:28.004035ZDownload03bf578585c5ad41ad76abf92b0fa59a75ba70e70ab0be6c53ea1bd3e14792b5
0.7.02021-08-26T08:40:04.366584ZDownload32b68ce03236950cf399ac23968669a82a85929f6f81937687784891785c69c8
0.7.0+12021-08-26T10:54:36.173471ZDownload17067a52d467a878238d63bbda87b29a579692d355d021e4274226e15862d9b2
0.8.02021-09-05T19:38:07.269694ZDownload3b802bc66a15dd64711881b6fb0df94fad4428fe6681792bd92b326d1cf6581d
0.8.52021-09-05T20:44:49.804204ZDownload201e532391a3ae5f6868179794acf5c4ceb41eb10f9c73a7405af0e2b38af9a4
0.9.02021-09-28T19:52:58.693537ZDownloadc50ba54729f4a406aad22bf6f7c104c5317ba603f09b10be5354680097857b5d
0.9.52021-09-29T06:49:57.859775ZDownload4e386c43dd9179b48614a8479779d913f2c09efd5cc57d3dc091edcb76a7555b
0.9.82021-09-29T10:19:48.572582ZDownloadd66096f716e0261deb26fd261242979885a18fac9e0fb1b177b655bfb75a58eb
0.9.8+12021-09-29T10:33:54.058484ZDownload4d1be5637635416b41ab55f8cfa22ffe4879de31b0c80698a560b4ea027e6288
1.0.0-rc.02021-10-11T10:38:32.256504ZDownload8771c670eec719910226a65806c1c75bc763fa929bccbe0f3b8a01d50dbb2b81
1.0.0-rc.12021-10-11T15:18:38.390673ZDownloada88f7144a82afcb784a14d0c0b3d5876fabb904946209c013fc8052f001e5a5d
1.0.0-rc.22021-10-12T09:38:11.252371ZDownloadb8c40027cf134a8cdddbd6390db8dad1e8ee30aa97ae9342d308ad3b506f6189
1.0.0-rc.32021-10-15T05:04:26.978783ZDownload5b240b0784f06372516bb03c6abbe2e805c7e8dac45e4cd7ed7aa89c9e6435ce
1.0.0-rc.42021-10-15T06:04:05.751658ZDownload4ce226e7aa8c89de73c0e66aa9be46d65ba06bda1f83db18e4e9a7822e3b905c
1.0.0-rc.52021-10-24T17:59:03.807674ZDownloadb2c42722909798e65e852973eb80a955328118a43d491ee4bdc82c352e92e88c
1.0.0-rc.62021-11-12T09:59:53.609054ZDownloaddec60264b804e1ef765427e7c40a5ac8fc5e016a47292f2fab1dcb8ef5d57f6c
1.0.0-rc.72021-11-12T11:03:55.892032ZDownload6b85ca1cf20e45397c2095de887ff98e5157870d70ca35fdd80bf5dfbbb14540
1.0.0-rc.82021-11-12T11:38:48.884088ZDownloadb59709223a0e3ea55316f4b53545acb855ae46d2223344fa9227d7e8f33db33b
1.0.0-rc.92021-11-12T11:50:34.288790ZDownloadef4792e1056ff16e022916a1ab636409a8530685532465c15548db403b213551
1.0.02021-11-17T08:39:51.593900ZDownload53def55487dd7207a6a597df83120a96a219bc143e1001e974a16e273a859450
2.0.0-beta.02023-01-23T21:00:50.170743ZDownload56607b30b99ce8f8cc9ec9f8ab6f6674d907d4051928f94075e2294a095badcb
2.0.0-beta.12023-01-23T22:05:36.372733ZDownload47f7871264089bf10c09bd5f045e02250c10fe5fb31f54d00f0eaa7d918fad91
2.0.02023-01-25T11:03:13.994480ZDownload517560d6ec625c114cbdcde9223e5ee6418d30860377347ee1b0513399e7a3f5
2.1.02023-05-15T17:45:50.850520ZDownloade8ce9ca4b1df106e4d72dad201d345ea1a036cc12c360f1a7d5a758f78ffa42c
2.2.02026-05-04T15:05:00.061999ZDownload4ff85b2a16724029dd9e5bbb5a94b6918f9973f74ba571c949d2002801879cf5

Dependencies

ffi "^2.0.1"

flutter { "sdk": "flutter" }

meta "^1.8.0"