Compare commits

..

2 Commits

Author SHA1 Message Date
Siegfried-Angel Gevatter Pujals
fe47a3d86e Use const enum ...' instead of const gchar' for the type parameter. 2011-12-29 16:56:47 +01:00
Siegfried-Angel Gevatter Pujals
66ff8f8785 Start working on GtkRecentManagerAndZeitgeist. 2011-12-27 20:54:23 +01:00
312 changed files with 24770 additions and 41530 deletions

View File

@@ -63,6 +63,10 @@ gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc gdk-broadway-3.0.pc gdk-waylan
rm -f $@ && \
cp gdk-3.0.pc $@
gtk+-*-3.0-uninstalled.pc: gtk+-3.0-uninstalled.pc
rm -f $@ && \
cp gtk+-3.0-uninstalled.pc $@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gdk-3.0.pc gtk+-3.0.pc gail-3.0.pc
@@ -80,6 +84,8 @@ DISTCLEANFILES = \
gdk-3.0.pc \
gdk-x11-3.0.pc \
gail-3.0.pc \
gtk+-3.0-uninstalled.pc \
gail-3.0-uninstalled.pc \
config.lt
distclean-local:

95
NEWS
View File

@@ -1,98 +1,3 @@
Overview of Changes in GTK+ 3.3.8
=================================
* GtkApplication:
- Supports logout notification and inhibiting
- Buttons, toolbuttons and switches can now be connected
to GActions
* GtkSpinButton no longer allows to change the value
when not editable
* GtkLabel link support has been rewritten to be be
more robust
* GtkBuilder:
- Supports the 'id' in GtkComboBoxText
- Can parse GVariant-valued properties
- Support loading from a GResource
* GtkImage:
- Support loading from a GResource
* GtkUIManager:
- Support loading from a GResource
* Accessibility:
- key snooping support has been removed
* Wayland backend:
- Cursor handling updates
- Look for cursors in the 'weston' directory
- Make resize grips work
- Implement device grabs
- Implement window geometry hints
- Set surface type based on window type hint
- Add basic clipboard and selection implementations
- Implement client-side keyboard repeat
- Update GdkWindow focus state to match reality
* Theming:
- Improved CSS compliance for selector matching
- Improved CSS compliance for value resolution,
including full support for 'inherit', 'initial',
'currentColor', 'none'
- Support border-style properties
- 'window-unfocused' has been renamed to 'backdrop'
* New deprecations:
- GdkColor
- GtkButton::inner-border
* Miscellaneous:
- Turn default theme css files and dnd cursors into
GResources
* Bugs fixed:
543520 Cups custom options are not sent properly
612396 ...default of entry-text-column for GtkComboBoxText
613728 Rationalize GtkTreeView focus
620240 GNOME Drag & Drop broken for remote X sessions
629878 Missing "Back" and "Forward" icons for Firefox
631414 Add symbolic constants for event emission control
639875 crashes when unparenting a tab from a window...
657367 GtkAction: Hold a reference to proxy widgets
659516 gtk_css_provider_to_string lacks "since" tag
660139 GtkGrid gives Gtk-Warnings about negative sizes when empty
660309 check x11 backend when create xim module
663479 "Finishing" ("Completion") and "Advanced" tabs are empty
665015 "Widget (%s) has more than one label" unwanted warnings
666103 Should be able to match the parent where a dropdown menu...
666600 allocate the CSS border and deprecate GtkButton-inner-border
666685 SIGSEGV in _gtk_tree_selection_internal_select_node
666710 Fix compose sequences disabling other sequences
666842 [patch] "sticky" window state reported wrongly on X11
667018 Fix compilation on Windows
667229 gtkspinbutton: Respect value of inherited 'editable' property
667394 Gtk(Tool)Button: add an 'action-name' property
667473 gdk_rgba_free (NULL)
667485 gdk_rgba_parse error checking
667534 Non-XInput2 build fix
667546 GApplication doc mentions g_application_set_app_menu
667628 GtkWindow:application property should have G_PARAM_CONSTRUCT
667695 GAction leaked in examples/plugman.c
667705 fix up GtkApplication on OS X
666921 Fix the _NET_SUPPORTING_WM_CHECK window fetch to be spec...
* Translation updates:
Arabic
Bulgarian
Finnish
Hebrew
Norwegian bokmål
Spanish
Overview of Changes in GTK+ 3.3.6
=================================

View File

@@ -27,11 +27,6 @@ Installation
See the file 'INSTALL'
Release notes for 3.4
=====================
* The -uninstalled variants of the pkg-config files have been dropped.
Release notes for 3.2
=====================

View File

@@ -565,9 +565,7 @@ mkdir $(CopyDir)\share\glib-2.0\schemas
copy ..\..\..\gtk\org.gtk.Settings.FileChooser.gschema.xml $(CopyDir)\share\glib-2.0\schemas
copy ..\..\..\gtk\org.gtk.WindowState.gschema.xml $(CopyDir)\share\glib-2.0\schemas
echo "Compiling gsettings XML Files..."
echo "Compiling gsettings XML File(s)..."
$(CopyDir)\bin\glib-compile-schemas.exe $(CopyDir)\share\glib-2.0\schemas

View File

@@ -69,7 +69,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\gdk;..\..\..\gdk\win32;..\..\..\gtk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\gdk;..\..\..\gtk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;G_ENABLE_DEBUG;$(GtkDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -91,7 +91,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\gdk;..\..\..\gdk\win32;..\..\..\gtk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\gdk;..\..\..\gdk\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>$(GtkDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
@@ -114,7 +114,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\gdk;..\..\..\gdk\win32;..\..\..\gtk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\gdk;..\..\..\gdk\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;G_ENABLE_DEBUG;$(GtkDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -136,7 +136,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\gdk;..\..\..\gdk\win32;..\..\..\gtk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\gdk;..\..\..\gdk\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>$(GtkDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>

View File

@@ -202,7 +202,6 @@
<ClCompile Include="..\..\..\demos\gtk-demo\textscroll.c" />
<ClCompile Include="..\..\..\demos\gtk-demo\textview.c" />
<ClCompile Include="..\..\..\demos\gtk-demo\toolpalette.c" />
<ClCompile Include="..\..\..\demos\gtk-demo\transparent.c" />
<ClCompile Include="..\..\..\demos\gtk-demo\tree_store.c" />
<ClCompile Include="..\..\..\demos\gtk-demo\ui_manager.c" />
</ItemGroup>

View File

@@ -125,9 +125,6 @@
<ClCompile Include="..\..\..\demos\gtk-demo\toolpalette.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\demos\gtk-demo\transparent.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\demos\gtk-demo\tree_store.c">
<Filter>Source Files</Filter>
</ClCompile>

View File

@@ -339,8 +339,7 @@ copy $(ConfigurationName)\$(PlatformName)\bin\gailutil.lib $(OutDir)\lib&#x0D;&#
mkdir $(OutDir)\share\glib-2.0\schemas&#x0D;&#x0A;
copy ..\..\..\gtk\org.gtk.Settings.FileChooser.gschema.xml $(OutDir)\share\glib-2.0\schemas&#x0D;&#x0A;
copy ..\..\..\gtk\org.gtk.WindowState.gschema.xml $(OutDir)\share\glib-2.0\schemas&#x0D;&#x0A;
echo &quot;Compiling gsettings XML Files...&quot;&#x0D;&#x0A;
echo &quot;Compiling gsettings XML File(s)...&quot;&#x0D;&#x0A;
$(OutDir)\bin\glib-compile-schemas.exe $(OutDir)\share\glib-2.0\schemas&#x0D;&#x0A;
"
/>

View File

@@ -31,7 +31,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\gdk;..\..\..\gdk\win32;..\..\..\gtk"
AdditionalIncludeDirectories="..\..\..\gdk;..\..\..\gtk"
PreprocessorDefinitions="_DEBUG;G_ENABLE_DEBUG;$(GtkDefines)"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -63,7 +63,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\gdk;..\..\..\gdk\win32;..\..\..\gtk"
AdditionalIncludeDirectories="..\..\..\gdk;..\..\..\gdk\win32"
PreprocessorDefinitions="$(GtkDefines)"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
@@ -96,7 +96,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\gdk;..\..\..\gdk\win32;..\..\..\gtk"
AdditionalIncludeDirectories="..\..\..\gdk;..\..\..\gdk\win32"
PreprocessorDefinitions="_DEBUG;G_ENABLE_DEBUG;$(GtkDefines)"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -128,7 +128,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\gdk;..\..\..\gdk\win32;..\..\..\gtk"
AdditionalIncludeDirectories="..\..\..\gdk;..\..\..\gdk\win32"
PreprocessorDefinitions="$(GtkDefines)"
RuntimeLibrary="2"
UsePrecompiledHeader="0"

View File

@@ -198,7 +198,6 @@
<File RelativePath="..\..\..\demos\gtk-demo\textscroll.c" />
<File RelativePath="..\..\..\demos\gtk-demo\textview.c" />
<File RelativePath="..\..\..\demos\gtk-demo\toolpalette.c" />
<File RelativePath="..\..\..\demos\gtk-demo\transparent.c" />
<File RelativePath="..\..\..\demos\gtk-demo\tree_store.c" />
<File RelativePath="..\..\..\demos\gtk-demo\ui_manager.c" />
</Filter>

View File

@@ -10,7 +10,7 @@
m4_define([gtk_major_version], [3])
m4_define([gtk_minor_version], [3])
m4_define([gtk_micro_version], [8])
m4_define([gtk_micro_version], [7])
m4_define([gtk_interface_age], [0])
m4_define([gtk_binary_age],
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
@@ -39,7 +39,7 @@ AC_CONFIG_AUX_DIR([build-aux])
m4_define([gtk_binary_version], [3.0.0])
# required versions of other packages
m4_define([glib_required_version], [2.31.10])
m4_define([glib_required_version], [2.31.6])
m4_define([pango_required_version], [1.29.0])
m4_define([atk_required_version], [2.1.5])
m4_define([cairo_required_version], [1.10.0])
@@ -1529,13 +1529,6 @@ fi
GLIB_GSETTINGS
#############
# Resources #
#############
GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
AC_SUBST(GLIB_COMPILE_RESOURCES)
##################################################
# GObject introspection
##################################################
@@ -1741,6 +1734,8 @@ gdk-3.0.pc
gtk+-3.0.pc
gtk+-unix-print-3.0.pc
gail-3.0.pc
gtk+-3.0-uninstalled.pc
gail-3.0-uninstalled.pc
m4macros/Makefile
po/Makefile.in
po-properties/Makefile.in
@@ -1754,7 +1749,6 @@ tests/a11y/Makefile
tests/css/Makefile
tests/css/parser/Makefile
tests/reftests/Makefile
tests/visuals/Makefile
docs/Makefile
docs/reference/Makefile
docs/reference/gdk/Makefile

18
debian/README.debian vendored Normal file
View File

@@ -0,0 +1,18 @@
libgtk1 for Debian
----------------------
The GIMP Tool Kit (gtk) is a set of widgets to help you program
programs for the X Windowing System easily and powerfully.
gtk is the moving force behind The GNU Image Manipulation Program (The
GIMP) -- the number one freely-available image editing and creation
program available.
gtk is rapidly under development, and the source tree has officially
been separated from The GIMP now, as other teams of programmers
are beginning to write software using its great widget set -- like
GNOME, a desktop interface for X, and gzilla, a freely available
web browser for X.
Ben Gertzfield <che@debian.org>, Mon, 29 Sep 1997 13:11:45 -0700

62
debian/build vendored Executable file
View File

@@ -0,0 +1,62 @@
#!/usr/bin/perl -w
# Adjust debian/changelog and build a new
# Debian package of a CVS archive.
# Written 17 November 1998 by Ben Gertzfield
# <che@debian.org>
# This work is released under the GNU
# General Public License, version 2 or
# later.
use strict;
use diagnostics;
use File::Copy;
my $maintainer = 'Ben Gertzfield <che@debian.org>';
my @date = localtime;
my $datestr = sprintf("%d%.2d%.2d", $date[5] + 1900, $date[4] + 1, $date[3]);
my $revision = '01';
open (CHANGELOG, 'debian/changelog') or die "Couldn't open debian/changelog: $!\n";
$_ = <CHANGELOG>;
chomp;
close CHANGELOG;
my ($package, $last_date, $last_revision) = /^(.*?) \((.*?)\.(.*)?\)/;
if ($last_date eq $datestr) {
$revision = sprintf("%.2d", $last_revision + 1);
}
my $new_version = "$datestr.$revision";
copy('debian/changelog', 'debian/changelog.old') or die "Couldn't copy debian/changelog to debian/changelog.old: $!\n";
open(NEWCHANGELOG, ">debian/changelog") or die "Couldn't open debian/changelog for writing: $!\n";
print NEWCHANGELOG "$package ($new_version) unstable; urgency=low\n\n * CVS snapshot build at " . scalar localtime() . "\n\n -- $maintainer " . `date -R` . "\n";
open(OLDCHANGELOG, "debian/changelog.old") or die "Couldn't open debian/changelog.old: $!\n";
while (<OLDCHANGELOG>) {
print NEWCHANGELOG;
}
close OLDCHANGELOG;
close NEWCHANGELOG;
unlink('debian/changelog.old') or die "Couldn't unlink debian/changelog.old: $!\n";
open(NEWVERSION, '>debian/version') or die "Couldn't open debian/version for writing: $!\n";
print NEWVERSION "$new_version\n";
close NEWVERSION;
system('dpkg-buildpackage -b -rfakeroot -us -uc');
unlink 'debian/version' or die "Couldn't unlink debian/version: $!\n";

10
debian/changelog vendored Normal file
View File

@@ -0,0 +1,10 @@
gtk+-cvs (19981116.01) unstable; urgency=low
* First test build from CVS
-- Ben Gertzfield <che@debian.org> Tue, 17 Nov 1998 12:02:13 -0800
Local variables:
mode: debian-changelog
add-log-mailing-address: "che@debian.org"
End:

81
debian/control vendored Normal file
View File

@@ -0,0 +1,81 @@
Source: gtk+-cvs
Priority: extra
Section: libs
Maintainer: Ben Gertzfield <che@debian.org>
Standards-Version: 2.4.0.0
Package: libgtk-cvs-1.1
Architecture: any
Section: libs
Depends: ${shlibs:Depends}
Conflicts: libgtk-dev (<< 1:1.0.2), libgtk1.1
Description: CVS build of the GIMP Toolkit set of widgets for X
**THIS IS NOT AN OFFICIAL DEBIAN PACKAGE! THIS IS AN AUTOMATED CVS
BUILD OF THE GTK+ LIBRARIES! BEWARE! IT MAY NOT WORK!**
.
The GIMP Toolkit is a freely available set of widgets for X.
GTK is easy to use, and has been implemented in such projects as
The GNU Image Manipulation Program (The GIMP), GNOME, a GNU
desktop set of utilities for X, and gzilla, a GNU web-browser.
.
This is the unstable 1.1 branch of GTK. It is not intended for use
with stable projects!
Package: libgtk-cvs-dev
Architecture: any
Section: devel
Depends: libgtk-cvs-1.1 (=${Source-Version}), libglib-cvs-dev
Suggests: libgtk-cvs-doc
Provides: libgtk1.1-dev
Replaces: libgtk1.1-dev
Conflicts: libgtk-dev, libgtk1 (<< 1:1.0.4), libgtk1.1-dev
Description: CVS build of development files for the GIMP Toolkit
**THIS IS NOT AN OFFICIAL DEBIAN PACKAGE! THIS IS AN AUTOMATED CVS
BUILD OF THE GTK+ LIBRARIES! BEWARE! IT MAY NOT WORK!**
.
This package contains the header files and static libraries for the
GIMP Toolkit set of widgets for X.
.
This is the unstable, 1.1 branch of GTK+. This is not intended for
use with stable releases of programs!
.
Install this package if you wish to develop your own X programs using
the GIMP Toolkit 1.1, or if you wish to compile your own plug-ins for
The GIMP.
Package: libgtk-cvs-doc
Architecture: all
Section: doc
Conflicts: libgtk-dev (<< 1:0.99.4), libgtk-doc, libgtk1.1-doc
Description: CVS build of documentation for the GIMP Toolkit
**THIS IS NOT AN OFFICIAL DEBIAN PACKAGE! THIS IS AN AUTOMATED CVS
BUILD OF THE GTK+ LIBRARIES! BEWARE! IT MAY NOT WORK!**
.
This package contains lots of info-files, HTML docs, FAQs, and
other handy documentation about the GIMP Toolkit set of widgets
for X.
.
This package documents the unstable 1.1 release of the GIMP Toolkit.
.
Install this package if you want to have lots of info about the
GIMP toolkit when you're programming.
Package: libgtk-cvs-dbg
Architecture: any
Section: devel
Depends: libgtk-cvs-1.1 (= ${Source-Version}), libgtk-cvs-dev (= ${Source-Version})
Suggests: libgtk-cvs-doc
Conflicts: libgtk1.1-dbg
Description: CVS build of debugging files for the GIMP Toolkit
**THIS IS NOT AN OFFICIAL DEBIAN PACKAGE! THIS IS AN AUTOMATED CVS
BUILD OF THE GTK+ LIBRARIES! BEWARE! IT MAY NOT WORK!**
.
This package contains the debugging static libraries for the
GIMP Toolkit set of widgets for X.
.
This is the unstable, 1.1 branch of GTK+. This is not intended for
use with stable releases of programs!
.
Install this package if you wish to debug your own X programs using
the GIMP Toolkit 1.1, or if you wish to debug your own plug-ins for
The GIMP.

8
debian/copyright vendored Normal file
View File

@@ -0,0 +1,8 @@
This package was debianized by Ben Gertzfield <che@debian.org> on
Tue, 17 Nov 1998 12:07:17 -0800
It was produced from the CVS repository at cvs.gimp.org.
It may be redistributed under the terms of the GNU LGPL, Version 2 or
later, found on Debian systems in the file /usr/doc/copyright/LGPL.

9
debian/libgtk-cvs-dev.files vendored Normal file
View File

@@ -0,0 +1,9 @@
usr/lib/libgdk.so
usr/lib/libgdk.a
usr/lib/libgtk.so
usr/lib/libgtk.a
usr/include/gdk/
usr/include/gtk/
usr/bin/gtk-config
usr/man/man1/gtk-config.1
usr/share/aclocal/gtk.m4

5
debian/libgtk-cvs-dev.postinst vendored Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
set -e
#DEBHELPER#

6
debian/libgtk-cvs-dev.prerm vendored Normal file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
set -e
install-info --quiet --remove gtk
#DEBHELPER#

8
debian/libgtk-cvs-doc.files vendored Normal file
View File

@@ -0,0 +1,8 @@
usr/info/gdk.info
usr/info/gtk.info
usr/info/gtk.info-1
usr/info/gtk.info-2
usr/info/gtk.info-3
usr/info/gtk.info-4
usr/info/gtk.info-5

11
debian/libgtk-cvs-doc.postinst vendored Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
set -e
install-info --quiet --description="The GIMP Toolkit." \
--section "The GIMP" "The GIMP" /usr/info/gtk.info.gz
install-info --quiet --description="The GIMP Drawing Kit." \
--section "The GIMP" "The GIMP" /usr/info/gdk.info.gz
#DEBHELPER#

7
debian/libgtk-cvs-doc.prerm vendored Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
set -e
install-info --quiet --remove gtk
install-info --quiet --remove gdk
#DEBHELPER#

7
debian/postinst vendored Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
set -e
ldconfig
#DEBHELPER#

160
debian/rules vendored Executable file
View File

@@ -0,0 +1,160 @@
#!/usr/bin/make -f
# debian/rules file for gtk+ Debian package
# written April 1998 by Ben Gertzfield <che@debian.org
build: build-stamp
build-stamp:
dh_testdir
./autogen.sh --prefix=/usr --with-xinput=xfree
$(MAKE)
cd docs && make distdocs
cd ..
touch build-stamp
build-dbg: build-dbg-stamp
build-dbg-stamp:
dh_testdir
./configure --prefix=/usr --with-xinput=xfree --enable-debug=yes
$(MAKE)
touch build-dbg-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp build-dbg-stamp install-stamp install-dbg-stamp
# Add here commands to clean up after the build process.
-$(MAKE) clean
cd docs
-$(MAKE) maintainer-clean
cd ..
-$(MAKE) distclean
find . -name '*.o' -o -name '_libs' -o -name '*.lo' -o -name '*.a' -o -name '.deps' | xargs rm -rf
dh_clean
clean-dbg:
dh_testdir
dh_testroot
rm -f build-stamp build-dbg-stamp install-stamp install-dbg-stamp
# Add here commands to clean up after the build process.
-$(MAKE) clean
cd docs
-$(MAKE) maintainer-clean
cd ..
-$(MAKE) distclean
find . -name '*.o' -o -name '_libs' -o -name '*.lo' -o -name '*.a' -o -name '.deps' | xargs rm -rf
dh_clean -k
install: install-stamp
install-stamp: build
dh_testdir
dh_testroot
dh_clean
$(MAKE) prefix=`pwd`/debian/tmp/usr install
touch install-stamp
install-dbg: install-dbg-stamp
install-dbg-stamp: build-dbg
dh_testdir
dh_testroot
dh_clean -k
$(MAKE) prefix=`pwd`/debian/libgtk-cvs-dbg/usr install
touch install-dbg-stamp
# Build architecture-independent files here.
binary-indep: build install libgtk-cvs-doc
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install libgtk-cvs-dev libgtk-cvs-1.1 libgtk-cvs-dbg
libgtk-cvs-1.1: build
dh_testdir -plibgtk-cvs-1.1
dh_testroot -plibgtk-cvs-1.1
dh_installdirs -plibgtk-cvs-1.1
# Add here commands to install the files into debian/tmp
rm -rf debian/tmp/usr/bin debian/tmp/usr/include debian/tmp/usr/info debian/tmp/usr/lib/glib debian/tmp/usr/share/aclocal debian/tmp/usr/man debian/tmp/usr/lib/*.la
dh_installdocs -plibgtk-cvs-1.1
dh_installchangelogs -plibgtk-cvs-1.1
dh_strip -plibgtk-cvs-1.1
dh_compress -plibgtk-cvs-1.1
dh_fixperms -plibgtk-cvs-1.1
dh_installdeb -plibgtk-cvs-1.1
dh_shlibdeps -plibgtk-cvs-1.1
dh_gencontrol -plibgtk-cvs-1.1
dh_makeshlibs -plibgtk-cvs-1.1 -V 'libgtk-cvs-1.1 (='`cat debian/version`')'
dh_md5sums -plibgtk-cvs-1.1
dh_builddeb -plibgtk-cvs-1.1
libgtk-cvs-dev: build
dh_testdir -plibgtk-cvs-dev
dh_testroot -plibgtk-cvs-dev
dh_clean -plibgtk-cvs-dev -k
dh_installdirs -plibgtk-cvs-dev
# Add here commands to install the files into debian/tmp
dh_movefiles -plibgtk-cvs-dev
cp gtk-config debian/tmp/usr/bin
dh_installdocs -plibgtk-cvs-dev
dh_installchangelogs -plibgtk-cvs-dev
dh_strip -plibgtk-cvs-dev
dh_compress -plibgtk-cvs-dev
dh_fixperms -plibgtk-cvs-dev
dh_installdeb -plibgtk-cvs-dev
dh_shlibdeps -plibgtk-cvs-dev
dh_gencontrol -plibgtk-cvs-dev
dh_md5sums -plibgtk-cvs-dev
dh_builddeb -plibgtk-cvs-dev
libgtk-cvs-doc:
dh_testdir -plibgtk-cvs-doc
dh_testroot -plibgtk-cvs-doc
dh_clean -plibgtk-cvs-doc -k
dh_installdirs -plibgtk-cvs-doc usr/doc/libgtk-cvs-doc/faq-html \
usr/doc/libgtk-cvs-doc/tutorial-html usr/doc/libgtk-cvs-doc/italian-tutorial-html usr/doc/libgtk-cvs-doc/french-tutorial-html usr/doc/libgtk-cvs-doc/gdk-html
dh_movefiles -plibgtk-cvs-doc
cp docs/html/gtkfaq*.html debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/faq-html
cp docs/html/gtk_tut-*.html debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/tutorial-html
cp docs/html/*.gif debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/tutorial-html
cp docs/html/gtk_tut.html debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/tutorial-html
cp docs/html/gtk_tut_it*.html debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/italian-tutorial-html
cp docs/html/*.gif debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/italian-tutorial-html
cp docs/html/gtk_tut_fr*.html debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/french-tutorial-html
cp docs/html/*.gif debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/french-tutorial-html
cp docs/html/gdk* debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/gdk-html
cp docs/text/*.txt debian/libgtk-cvs-doc/usr/doc/libgtk-cvs-doc/
dh_installdocs -plibgtk-cvs-doc docs/{debugging,developers,styles,text_widget,widget_system,gtk-config,refcounting}.txt TODO NEWS
dh_installchangelogs -plibgtk-cvs-doc
dh_strip -plibgtk-cvs-doc
dh_compress -plibgtk-cvs-doc
dh_fixperms -plibgtk-cvs-doc
dh_installdeb -plibgtk-cvs-doc
dh_shlibdeps -plibgtk-cvs-doc
dh_gencontrol -plibgtk-cvs-doc
dh_md5sums -plibgtk-cvs-doc
dh_builddeb -plibgtk-cvs-doc
libgtk-cvs-dbg: clean-dbg install-dbg
dh_testdir -plibgtk-cvs-dbg
dh_testroot -plibgtk-cvs-dbg
dh_installdirs -plibgtk-cvs-dbg
# Add here commands to install the files into debian/libgtk-cvs-dbg
rm -rf debian/libgtk-cvs-dbg/usr/bin debian/libgtk-cvs-dbg/usr/include debian/libgtk-cvs-dbg/usr/info debian/libgtk-cvs-dbg/usr/lib/glib debian/libgtk-cvs-dbg/usr/man debian/libgtk-cvs-dbg/usr/share debian/libgtk-cvs-dbg/usr/lib/*.{la,so*}
for file in `find debian/libgtk-cvs-dbg/usr/lib -name '*.a'` ; do \
mv $$file debian/libgtk-cvs-dbg/usr/lib/`basename $$file .a`_g.a; \
done
dh_installdocs -plibgtk-cvs-dbg
dh_installchangelogs -plibgtk-cvs-dbg
dh_compress -plibgtk-cvs-dbg
dh_fixperms -plibgtk-cvs-dbg
dh_installdeb -plibgtk-cvs-dbg
dh_shlibdeps -plibgtk-cvs-dbg
dh_gencontrol -plibgtk-cvs-dbg
dh_md5sums -plibgtk-cvs-dbg
dh_builddeb -plibgtk-cvs-dbg
source diff:
@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary

View File

@@ -6,7 +6,6 @@ democodedir=$(datadir)/gtk-$(GTK_API_VERSION)/demo
## These should be in the order you want them to appear in the
## demo app, which means alphabetized by demo title, not filename
demos = \
application.c \
appwindow.c \
assistant.c \
builder.c \
@@ -66,18 +65,13 @@ LDADDS = \
$(GTK_DEP_LIBS) \
-lm
bin_PROGRAMS = gtk3-demo gtk3-demo-application
bin_PROGRAMS = gtk3-demo
BUILT_SOURCES = demos.h application_resources.c
BUILT_SOURCES = demos.h
EXTRA_DIST += \
$(IMAGEFILES) \
demo.ui \
application.gresource.xml \
application.ui \
menus.ui \
gtk-logo-24.png \
gtk-logo-48.png
EXTRA_DIST += \
$(IMAGEFILES) \
demo.ui
demos.h: @REBUILD@ $(demos) geninclude.pl
$(AM_V_GEN) (here=`pwd` ; cd $(srcdir) && $(PERL) $$here/geninclude.pl $(demos)) > demos.h
@@ -92,17 +86,8 @@ gtk3_demo_DEPENDENCIES = $(DEPS)
gtk3_demo_LDADD = $(LDADDS)
gtk3_demo_LDFLAGS = -export-dynamic
gtk3_demo_application_SOURCES = \
application-standalone.c \
application_resources.c
gtk3_demo_application_LDADD = $(LDADDS)
application_resources.c: application.gresource.xml gtk-logo-24.png gtk-logo-48.png application.ui menus.ui
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $(srcdir)/application.gresource.xml
IMAGEFILES= alphatest.png \
apple-red.png \
apple-red.png \
background.jpg \
floppybuddy.gif \
gnome-applets.png \

View File

@@ -1,3 +0,0 @@
#define STANDALONE
#include "application.c"

View File

@@ -1,471 +0,0 @@
/* Application class
*
* Demonstrates a simple application.
*
* This examples uses GtkApplication, GtkApplicationWindow, GtkBuilder
* as well as GMenu and GResource. Due to the way GtkApplication is structured,
* it is run as a separate process.
*/
#include "config.h"
#include <gtk/gtk.h>
#ifdef STANDALONE
static void
show_action_dialog (GSimpleAction *action)
{
const gchar *name;
GtkWidget *dialog;
name = g_action_get_name (G_ACTION (action));
dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
"You activated action: \"%s\"",
name);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
}
static void
show_action_infobar (GSimpleAction *action,
GVariant *parameter,
gpointer window)
{
GtkWidget *infobar;
GtkWidget *message;
gchar *text;
const gchar *name;
const gchar *value;
name = g_action_get_name (G_ACTION (action));
value = g_variant_get_string (parameter, NULL);
message = g_object_get_data (G_OBJECT (window), "message");
infobar = g_object_get_data (G_OBJECT (window), "infobar");
text = g_strdup_printf ("You activated radio action: \"%s\".\n"
"Current value: %s", name, value);
gtk_label_set_text (GTK_LABEL (message), text);
gtk_widget_show (infobar);
g_free (text);
}
static void
activate_action (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
show_action_dialog (action);
}
static void
activate_toggle (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GVariant *state;
show_action_dialog (action);
state = g_action_get_state (G_ACTION (action));
g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state)));
g_variant_unref (state);
}
static void
activate_radio (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
show_action_infobar (action, parameter, user_data);
g_action_change_state (G_ACTION (action), parameter);
}
static void
activate_about (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkWidget *window = user_data;
GdkPixbuf *pixbuf;
GInputStream *stream;
const gchar *authors[] = {
"Peter Mattis",
"Spencer Kimball",
"Josh MacDonald",
"and many more...",
NULL
};
const gchar *documentors[] = {
"Owen Taylor",
"Tony Gale",
"Matthias Clasen <mclasen@redhat.com>",
"and many more...",
NULL
};
stream = g_resources_open_stream ("/logos/gtk-logo-48.png", 0, NULL);
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
g_object_unref (stream);
gtk_show_about_dialog (GTK_WINDOW (window),
"program-name", "GTK+ Code Demos",
"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 ()),
"copyright", "(C) 1997-2009 The GTK+ Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK+ functions.",
"authors", authors,
"documenters", documentors,
"logo", pixbuf,
"title", "About GTK+ Code Demos",
NULL);
g_object_unref (pixbuf);
}
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;
gtk_widget_destroy (GTK_WIDGET (win));
list = next;
}
}
static void
register_stock_icons (void)
{
static gboolean registered = FALSE;
if (!registered)
{
GdkPixbuf *pixbuf;
GtkIconFactory *factory;
GtkIconSet *icon_set;
GInputStream *stream;
static GtkStockItem items[] = {
{ "demo-gtk-logo", "_GTK!", 0, 0, NULL }
};
registered = TRUE;
gtk_stock_add (items, G_N_ELEMENTS (items));
factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (factory);
stream = g_resources_open_stream ("/logos/gtk-logo-24.png", 0, NULL);
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
g_object_unref (stream);
icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
gtk_icon_factory_add (factory, "demo-gtk-logo", icon_set);
gtk_icon_set_unref (icon_set);
g_object_unref (pixbuf);
/* Drop our reference to the factory, GTK will hold a reference. */
g_object_unref (factory);
}
}
static void
update_statusbar (GtkTextBuffer *buffer,
GtkStatusbar *statusbar)
{
gchar *msg;
gint row, col;
gint count;
GtkTextIter iter;
/* clear any previous message, underflow is allowed */
gtk_statusbar_pop (statusbar, 0);
count = gtk_text_buffer_get_char_count (buffer);
gtk_text_buffer_get_iter_at_mark (buffer,
&iter,
gtk_text_buffer_get_insert (buffer));
row = gtk_text_iter_get_line (&iter);
col = gtk_text_iter_get_line_offset (&iter);
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
row, col, count);
gtk_statusbar_push (statusbar, 0, msg);
g_free (msg);
}
static void
mark_set_callback (GtkTextBuffer *buffer,
const GtkTextIter *new_location,
GtkTextMark *mark,
gpointer data)
{
update_statusbar (buffer, GTK_STATUSBAR (data));
}
static void
change_theme_state (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GtkSettings *settings = gtk_settings_get_default ();
g_object_set (G_OBJECT (settings),
"gtk-application-prefer-dark-theme",
g_variant_get_boolean (state),
NULL);
g_simple_action_set_state (action, state);
}
static void
change_titlebar_state (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GtkWindow *window = user_data;
gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (window),
g_variant_get_boolean (state));
g_simple_action_set_state (action, state);
}
static void
change_radio_state (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
g_simple_action_set_state (action, state);
}
static GActionEntry app_entries[] = {
{ "new", activate_action, NULL, NULL, NULL },
{ "open", activate_action, NULL, NULL, NULL },
{ "save", activate_action, NULL, NULL, NULL },
{ "save-as", activate_action, NULL, NULL, NULL },
{ "quit", activate_quit, NULL, NULL, NULL },
{ "dark", activate_toggle, NULL, "false", change_theme_state }
};
static GActionEntry win_entries[] = {
{ "titlebar", activate_toggle, NULL, "false", change_titlebar_state },
{ "color", activate_radio, "s", "'red'", change_radio_state },
{ "shape", activate_radio, "s", "'oval'", change_radio_state },
{ "bold", activate_toggle, NULL, "false", NULL },
{ "about", activate_about, NULL, NULL, NULL },
{ "logo", activate_action, NULL, NULL, NULL }
};
static void
clicked_cb (GtkWidget *widget, GtkWidget *info)
{
gtk_widget_hide (info);
}
static void
startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *appmenu;
GMenuModel *menubar;
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/ui/menus.ui", NULL);
appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
menubar = (GMenuModel *)gtk_builder_get_object (builder, "menubar");
gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
g_object_unref (builder);
}
static void
activate (GApplication *app)
{
GtkBuilder *builder;
GtkWidget *window;
GtkWidget *grid;
GtkWidget *contents;
GtkWidget *status;
GtkWidget *message;
GtkWidget *button;
GtkWidget *infobar;
GtkTextBuffer *buffer;
window = gtk_application_window_new (GTK_APPLICATION (app));
gtk_window_set_title (GTK_WINDOW (window), "Application Class");
gtk_window_set_icon_name (GTK_WINDOW (window), "document-open");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
g_action_map_add_action_entries (G_ACTION_MAP (window),
win_entries, G_N_ELEMENTS (win_entries),
window);
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/ui/application.ui", NULL);
grid = (GtkWidget *)gtk_builder_get_object (builder, "grid");
contents = (GtkWidget *)gtk_builder_get_object (builder, "contents");
status = (GtkWidget *)gtk_builder_get_object (builder, "status");
message = (GtkWidget *)gtk_builder_get_object (builder, "message");
button = (GtkWidget *)gtk_builder_get_object (builder, "button");
infobar = (GtkWidget *)gtk_builder_get_object (builder, "infobar");
g_object_set_data (G_OBJECT (window), "message", message);
g_object_set_data (G_OBJECT (window), "infobar", infobar);
gtk_container_add (GTK_CONTAINER (window), grid);
gtk_widget_grab_focus (contents);
g_signal_connect (button, "clicked", G_CALLBACK (clicked_cb), infobar);
/* Show text widget info in the statusbar */
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
g_signal_connect_object (buffer, "changed",
G_CALLBACK (update_statusbar), status, 0);
g_signal_connect_object (buffer, "mark-set",
G_CALLBACK (mark_set_callback), status, 0);
update_statusbar (buffer, GTK_STATUSBAR (status));
gtk_widget_show_all (window);
g_object_unref (builder);
}
int
main (int argc, char *argv[])
{
GtkApplication *app;
gtk_init (NULL, NULL);
register_stock_icons ();
app = gtk_application_new ("org.gtk.Demo", 0);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_application_run (G_APPLICATION (app), 0, NULL);
return 0;
}
#else /* !STANDALONE */
static gboolean name_seen;
static GtkWidget *placeholder;
static void
on_name_appeared (GDBusConnection *connection,
const gchar *name,
const gchar *name_owner,
gpointer user_data)
{
name_seen = TRUE;
}
static void
on_name_vanished (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
if (!name_seen)
return;
if (placeholder)
{
gtk_widget_destroy (placeholder);
g_object_unref (placeholder);
placeholder = NULL;
}
}
GtkWidget *
do_application (GtkWidget *toplevel)
{
static guint watch = 0;
if (watch == 0)
watch = g_bus_watch_name (G_BUS_TYPE_SESSION,
"org.gtk.Demo",
0,
on_name_appeared,
on_name_vanished,
NULL, NULL);
if (placeholder == NULL)
{
const gchar *command;
GError *error = NULL;
if (g_file_test ("./gtk3-demo-application", G_FILE_TEST_IS_EXECUTABLE))
command = "./gtk3-demo-application";
else
command = "gtk3-demo-application";
if (!g_spawn_command_line_async (command, &error))
{
g_warning ("%s", error->message);
g_error_free (error);
}
placeholder = gtk_label_new ("");
g_object_ref_sink (placeholder);
}
else
{
g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL),
"org.gtk.Demo",
"/org/gtk/Demo",
"org.gtk.Actions",
"Activate",
g_variant_new ("(sava{sv})", "quit", NULL, NULL),
NULL,
0,
G_MAXINT,
NULL, NULL);
}
return placeholder;
}
#endif

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/logos">
<file>gtk-logo-24.png</file>
<file>gtk-logo-48.png</file>
</gresource>
<gresource prefix="/ui">
<file>application.ui</file>
<file>menus.ui</file>
</gresource>
</gresources>

View File

@@ -1,109 +0,0 @@
<?xml version="1.0"?>
<interface>
<object class="GtkGrid" id="grid">
<child>
<object class="GtkToolbar" id="toolbar">
<property name="orientation">horizontal</property>
<property name="halign">fill</property>
<property name="hexpand">True</property>
<child>
<object class="GtkMenuToolButton" id="menu">
<property name="stock-id">gtk-open</property>
<child type="menu">
<object class="GtkMenu" id="m">
<child>
<object class="GtkMenuItem" id="file">
<property name="visible">True</property>
<property name="label">File1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToolButton" id="quit">
<property name="stock-id">gtk-quit</property>
<property name="action-name">app.quit</property>
</object>
</child>
<child>
<object class="GtkSeparatorToolItem" id="sep">
</object>
</child>
<child>
<object class="GtkToolButton" id="logo">
<property name="stock-id">demo-gtk-logo</property>
<property name="action-name">win.logo</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="no-show-all">True</property>
<property name="halign">fill</property>
<property name="hexpand">True</property>
<child internal-child="content_area">
<object class="GtkBox" id="content_area">
<child>
<object class="GtkLabel" id="message">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="halign">fill</property>
</object>
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkBox" id="action_area">
<child>
<object class="GtkButton" id="button">
<property name="visible">True</property>
<property name="valign">center</property>
<property name="label">gtk-ok</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="sw">
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="contents">
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkStatusbar" id="status">
<property name="halign">fill</property>
<property name="hexpand">True</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
</object>
</interface>

View File

@@ -1,8 +1,6 @@
/* Application window
/* Application main window
*
* Demonstrates a typical application window with menubar, toolbar, statusbar.
*
* This example uses GtkUIManager and GtkActionGroup.
*/
#include <gtk/gtk.h>

View File

@@ -116,7 +116,7 @@ if (defined @child_arrays) {
}
# toplevel
print "\nDemo gtk_demos[] = {\n";
print "\nDemo testgtk_demos[] = {\n";
$first = 1;
foreach $href (@demos) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -63,13 +63,7 @@ do_links (GtkWidget *do_widget)
label = gtk_label_new ("Some <a href=\"http://en.wikipedia.org/wiki/Text\""
"title=\"plain text\">text</a> may be marked up\n"
"as hyperlinks, which can be clicked\n"
"or activated via <a href=\"keynav\">keynav</a>\n"
"and they work fine with other markup, like when\n"
"searching on <a href=\"http://www.google.com/\">"
"<span color=\"#0266C8\">G</span><span color=\"#F90101\">o</span>"
"<span color=\"#F2B50F\">o</span><span color=\"#0266C8\">g</span>"
"<span color=\"#00933B\">l</span><span color=\"#F90101\">e</span>"
"</a>.");
"or activated via <a href=\"keynav\">keynav</a>");
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
g_signal_connect (label, "activate-link", G_CALLBACK (activate_link), NULL);
gtk_container_add (GTK_CONTAINER (window), label);

View File

@@ -782,7 +782,7 @@ create_tree (void)
GtkTreeIter iter;
GtkWidget *box, *label, *scrolled_window;
Demo *d = gtk_demos;
Demo *d = testgtk_demos;
model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INT);
tree_view = gtk_tree_view_new ();
@@ -936,8 +936,10 @@ main (int argc, char **argv)
* these few lines, which are just a hack so gtk-demo will work
* in the GTK tree without installing it.
*/
if (g_file_test ("../../modules/input/immodules.cache", G_FILE_TEST_EXISTS))
if (g_file_test ("../../gdk-pixbuf/libpixbufloader-pnm.la",
G_FILE_TEST_EXISTS))
{
g_setenv ("GDK_PIXBUF_MODULE_FILE", "../../gdk-pixbuf/loaders.cache", TRUE);
g_setenv ("GTK_IM_MODULE_FILE", "../../modules/input/immodules.cache", TRUE);
}
/* -- End of hack -- */
@@ -1000,7 +1002,7 @@ main (int argc, char **argv)
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_widget_show_all (window);
load_file (gtk_demos[0].filename);
load_file (testgtk_demos[0].filename);
gtk_main ();

View File

@@ -1,40 +0,0 @@
<?xml version="1.0"?>
<interface>
<menu id="appmenu">
<section>
<item label="_New" action="app.new" accel="&lt;Primary&gt;n"/>
<item label="_Open" action="app.open"/>
<item label="_Save" action="app.save" accel="&lt;Primary&gt;s"/>
<item label="Save _As..." action="app.save-as" accel="&lt;Primary&gt;s"/>
</section>
<section>
<item label="_Quit" action="app.quit" accel="&lt;Primary&gt;q"/>
</section>
</menu>
<menu id="menubar">
<submenu label="_Preferences">
<section>
<item label="_Prefer Dark Theme" action="app.dark"/>
<item label="_Hide Titlebar when maximized" action="win.titlebar"/>
<submenu label="_Color">
<section>
<item label="_Red" action="win.color" target="red" accel="&lt;Primary&gt;r"/>
<item label="_Green" action="win.color" target="green" accel="&lt;Primary&gt;g"/>
<item label="_Blue" action="win.color" target="blue" accel="&lt;Primary&gt;b"/>
</section>
</submenu>
<submenu label="_Shape">
<section>
<item label="_Square" action="win.shape" target="square" accel="&lt;Primary&gt;s"/>
<item label="_Rectangle" action="win.shape" target="rectangle" accel="&lt;Primary&gt;r"/>
<item label="_Oval" action="win.shape" target="oval" accel="&lt;Primary&gt;o"/>
</section>
</submenu>
<item label="_Bold" action="win.bold" accel="&lt;Primary&gt;b"/>
</section>
</submenu>
<submenu label="_Help">
<item label="_About" action="win.about" accel="&lt;Primary&gt;a"/>
</submenu>
</menu>
</interface>

View File

@@ -757,8 +757,6 @@ GdkEventMask
GDK_CURRENT_TIME
GDK_PRIORITY_EVENTS
GDK_PRIORITY_REDRAW
GDK_EVENT_PROPAGATE
GDK_EVENT_STOP
<SUBSECTION>
gdk_events_pending

View File

@@ -123,8 +123,7 @@ content_files = \
glossary.xml \
migrating-2to3.xml \
migrating-checklist.sgml \
migrating-unique-GtkApplication.xml \
migrating-smclient-GtkApplication.xml \
migrating-GtkApplication.xml \
migrating-GtkGrid.xml \
migrating-GtkStyleContext.xml \
objects_grouped.sgml \
@@ -147,8 +146,7 @@ expand_content_files = \
glossary.xml \
migrating-2to3.xml \
migrating-checklist.sgml \
migrating-unique-GtkApplication.xml \
migrating-smclient-GtkApplication.xml \
migrating-GtkApplication.xml \
migrating-GtkGrid.xml \
migrating-GtkStyleContext.xml \
question_index.sgml \

View File

@@ -339,7 +339,6 @@
<title>Application support</title>
<xi:include href="xml/gtkapplication.xml" />
<xi:include href="xml/gtkapplicationwindow.xml" />
<xi:include href="xml/gtkactionable.xml" />
</chapter>
</part>
@@ -356,12 +355,11 @@
</para>
</partintro>
<xi:include href="xml/migrating-checklist.sgml" />
<xi:include href="xml/migrating-2to3.xml" />
<xi:include href="xml/migrating-GtkStyleContext.xml" />
<xi:include href="xml/migrating-unique-GtkApplication.xml" />
<xi:include href="xml/migrating-smclient-GtkApplication.xml" />
<xi:include href="xml/migrating-GtkApplication.xml" />
<xi:include href="xml/migrating-GtkGrid.xml" />
<xi:include href="xml/migrating-checklist.sgml" />
</part>
<part>

View File

@@ -5294,7 +5294,6 @@ gtk_window_set_gravity
gtk_window_get_gravity
gtk_window_set_position
gtk_window_set_transient_for
gtk_window_set_attached_to
gtk_window_set_destroy_with_parent
gtk_window_set_hide_titlebar_when_maximized
gtk_window_set_screen
@@ -5353,7 +5352,6 @@ gtk_window_get_role
gtk_window_get_size
gtk_window_get_title
gtk_window_get_transient_for
gtk_window_get_attached_to
gtk_window_get_type_hint
gtk_window_get_skip_taskbar_hint
gtk_window_get_skip_pager_hint
@@ -5682,7 +5680,6 @@ gtk_style_context_add_provider_for_screen
gtk_style_context_get
gtk_style_context_get_direction
gtk_style_context_get_junction_sides
gtk_style_context_set_parent
gtk_style_context_get_path
gtk_style_context_get_property
gtk_style_context_get_screen
@@ -5691,7 +5688,6 @@ gtk_style_context_get_style
gtk_style_context_get_style_property
gtk_style_context_get_style_valist
gtk_style_context_get_valist
gtk_style_context_get_section
gtk_style_context_get_color
gtk_style_context_get_background_color
gtk_style_context_get_border_color
@@ -5716,7 +5712,6 @@ gtk_style_context_restore
gtk_style_context_save
gtk_style_context_set_direction
gtk_style_context_set_junction_sides
gtk_style_context_set_parent
gtk_style_context_set_path
gtk_style_context_add_class
gtk_style_context_remove_class
@@ -7011,14 +7006,6 @@ gtk_application_add_window
gtk_application_remove_window
gtk_application_get_windows
<SUBSECTION>
GtkApplicationInhibitFlags
gtk_application_inhibit
gtk_application_uninhibit
gtk_application_is_inhibited
GtkApplicationEndSessionStyle
gtk_application_end_session
<SUBSECTION>
gtk_application_get_app_menu
gtk_application_set_app_menu
@@ -7060,32 +7047,6 @@ gtk_application_window_get_type
GtkApplicationWindowPrivate
</SECTION>
<SECTION>
<FILE>gtkactionable</FILE>
<TITLE>GtkActionable</TITLE>
GtkActionable
GtkActionableInterface
<SUBSECTION>
gtk_actionable_get_action_name
gtk_actionable_set_action_name
<SUBSECTION>
gtk_actionable_get_action_target_value
gtk_actionable_set_action_target_value
gtk_actionable_set_action_target
<SUBSECTION>
gtk_actionable_set_detailed_action_name
<SUBSECTION Standard>
gtk_actionable_get_type
GTK_ACTIONABLE
GTK_ACTIONABLE_GET_IFACE
GTK_IS_ACTIONABLE
GTK_TYPE_ACTIONABLE
</SECTION>
<SECTION>
<FILE>gtkgrid</FILE>
<TITLE>GtkGrid</TITLE>

View File

@@ -6,7 +6,6 @@ gtk_accel_group_get_type
gtk_accel_label_get_type
gtk_accel_map_get_type
gtk_accessible_get_type
gtk_actionable_get_type
gtk_action_get_type
gtk_action_group_get_type
gtk_activatable_get_type

View File

@@ -2,7 +2,7 @@
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<chapter id="gtk-migrating-unique-GtkApplication">
<chapter id="gtk-migrating-GtkApplication">
<title>Migrating from libunique to GApplication or GtkApplication</title>
@@ -20,7 +20,7 @@
<example><title>A unique application</title>
<para>Here is a simple application using libunique:
<informalexample><programlisting>
<programlisting>
int
main (int argc, char *argv[])
{
@@ -53,9 +53,9 @@ main (int argc, char *argv[])
return 0;
}
</programlisting></informalexample>
</programlisting>
The same application using GtkApplication:
<informalexample><programlisting>
<programlisting>
static void
activate (GtkApplication *app)
{
@@ -85,13 +85,13 @@ main (int argc, char *argv[])
app = gtk_application_new ("org.gtk.TestApplication", 0);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
status = g_application_run (app);
g_object_unref (app);
return status;
}
</programlisting></informalexample>
</programlisting>
</para>
</example>
<section><title>Uniqueness</title>

View File

@@ -3,10 +3,10 @@
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<chapter id="gtk-migrating-checklist">
<title>Migration Details Checklist</title>
<title>Migration Checklist</title>
<para>
This chapter includes a checklist of smaller things you need to do to
This chapter includes a checklist of things you need to do to
ensure that your programs are good citizens in the GTK+ world. By
paying attention to the points in the checklist, you ensure that
many automatic features of GTK+ will work correctly in your

View File

@@ -1,48 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<chapter id="gtk-migrating-smclient-GtkApplication">
<title>Migrating from EggSMClient to GtkApplication</title>
<para>
EggSMClient provides 'session management' support for applications.
This means a number of things:
<itemizedlist>
<listitem>logout notification and negotiation</listitem>
<listitem>application state saving</listitem>
<listitem>restarting of applications with saved state</listitem>
</itemizedlist>
EggSMClient supports this functionality to varying degrees on
Windows and OS X, as well as with XSMP and D-Bus based session
managers in X11.
</para>
<para>
Starting with GTK+ 3.4, #GtkApplication supports logout notification
and negotiation similar to EggSMClient.
</para>
<table>
<tgroup cols="2">
<title>EggSMClient to GtkApplication</title>
<thead>
<row><entry>EggSMClient</entry><entry>GtkApplication</entry></row>
</thead>
<tbody>
<row><entry>EggSMClient::quit-requested</entry><entry>instead of calling will_quit (FALSE,...) in response to this signal, install an inhibitor</entry></row>
<row><entry>EggSMClient::quit</entry><entry>the #GtkApplication::quit signal</entry></row>
<row><entry>EggSMClient::quit-cancelled</entry><entry></entry></row>
<row><entry>egg_sm_client_will_quit</entry><entry>instead of calling will_quit (FALSE,...), install an inhibitor</entry></row>
<row><entry>egg_sm_client_end_session</entry><entry>gtk_application_end_session()</entry></row>
</tbody>
</tgroup>
</table>
<para>
At this point, GtkApplication has no special support for state saving.
Applications can use GSettings or GKeyFile and save as much state as
they see fit in response to #GtkApplication::quit or whenever they
consider appropriate.
</para>
</chapter>

View File

@@ -13,14 +13,6 @@ activate_toggle (GSimpleAction *action,
g_variant_unref (state);
}
static void
activate_radio (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
g_action_change_state (G_ACTION (action), parameter);
}
static void
change_fullscreen_state (GSimpleAction *action,
GVariant *state,
@@ -34,29 +26,6 @@ change_fullscreen_state (GSimpleAction *action,
g_simple_action_set_state (action, state);
}
static void
change_justify_state (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GtkTextView *text = g_object_get_data (user_data, "bloatpad-text");
const gchar *str;
str = g_variant_get_string (state, NULL);
if (g_str_equal (str, "left"))
gtk_text_view_set_justification (text, GTK_JUSTIFY_LEFT);
else if (g_str_equal (str, "center"))
gtk_text_view_set_justification (text, GTK_JUSTIFY_CENTER);
else if (g_str_equal (str, "right"))
gtk_text_view_set_justification (text, GTK_JUSTIFY_RIGHT);
else
/* ignore this attempted change */
return;
g_simple_action_set_state (action, state);
}
static GtkClipboard *
get_clipboard (GtkWidget *widget)
{
@@ -93,8 +62,7 @@ window_paste (GSimpleAction *action,
static GActionEntry win_entries[] = {
{ "copy", window_copy, NULL, NULL, NULL },
{ "paste", window_paste, NULL, NULL, NULL },
{ "fullscreen", activate_toggle, NULL, "false", change_fullscreen_state },
{ "justify", activate_radio, "s", "'left'", change_justify_state }
{ "fullscreen", activate_toggle, NULL, "false", change_fullscreen_state }
};
static void
@@ -102,9 +70,6 @@ new_window (GApplication *app,
GFile *file)
{
GtkWidget *window, *grid, *scrolled, *view;
GtkWidget *toolbar;
GtkToolItem *button;
GtkWidget *sw, *box, *label;
window = gtk_application_window_new (GTK_APPLICATION (app));
gtk_window_set_default_size ((GtkWindow*)window, 640, 480);
@@ -114,36 +79,6 @@ new_window (GApplication *app,
grid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (window), grid);
toolbar = gtk_toolbar_new ();
button = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_LEFT);
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button), "win.justify::left");
gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));
button = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_CENTER);
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button), "win.justify::center");
gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));
button = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT);
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button), "win.justify::right");
gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));
button = gtk_separator_tool_item_new ();
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (button), FALSE);
gtk_tool_item_set_expand (GTK_TOOL_ITEM (button), TRUE);
gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));
button = gtk_tool_item_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_add (GTK_CONTAINER (button), box);
label = gtk_label_new ("Fullscreen:");
gtk_container_add (GTK_CONTAINER (box), label);
sw = gtk_switch_new ();
gtk_actionable_set_action_name (GTK_ACTIONABLE (sw), "win.fullscreen");
gtk_container_add (GTK_CONTAINER (box), sw);
gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));
gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 1, 1);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
@@ -153,7 +88,7 @@ new_window (GApplication *app,
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_grid_attach (GTK_GRID (grid), scrolled, 0, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid), scrolled, 0, 0, 1, 1);
if (file != NULL)
{
@@ -207,15 +142,13 @@ new_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GApplication *app = user_data;
g_application_activate (app);
g_application_activate (user_data);
}
static void
about_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
show_about (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gtk_show_about_dialog (NULL,
"program-name", "Bloatpad",
@@ -225,14 +158,16 @@ about_activated (GSimpleAction *action,
}
static void
quit_app (GtkApplication *app)
quit_app (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GList *list, *next;
GtkWindow *win;
g_print ("Going down...\n");
list = gtk_application_get_windows (app);
list = gtk_application_get_windows (GTK_APPLICATION (g_application_get_default ()));
while (list)
{
win = list->data;
@@ -244,20 +179,10 @@ quit_app (GtkApplication *app)
}
}
static void
quit_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkApplication *app = user_data;
quit_app (app);
}
static GActionEntry app_entries[] = {
{ "new", new_activated, NULL, NULL, NULL },
{ "about", about_activated, NULL, NULL, NULL },
{ "quit", quit_activated, NULL, NULL, NULL },
{ "about", show_about, NULL, NULL, NULL },
{ "quit", quit_app, NULL, NULL, NULL },
};
static void
@@ -322,31 +247,15 @@ bloat_pad_class_init (BloatPadClass *class)
}
static void
quit_cb (GtkApplication *app)
{
g_print ("Session manager to us to quit\n");
quit_app (app);
}
BloatPad *
bloat_pad_new (void)
{
GtkApplication *bloat_pad;
g_type_init ();
bloat_pad = g_object_new (bloat_pad_get_type (),
"application-id", "org.gtk.Test.bloatpad",
"flags", G_APPLICATION_HANDLES_OPEN,
"inactivity-timeout", 30000,
"register-session", TRUE,
NULL);
g_signal_connect (bloat_pad, "quit", G_CALLBACK (quit_cb), NULL);
return bloat_pad;
return g_object_new (bloat_pad_get_type (),
"application-id", "org.gtk.Test.bloatpad",
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
}
int

View File

@@ -223,7 +223,6 @@ enable_plugin (const gchar *name)
g_signal_connect (action, "activate", G_CALLBACK (plugin_action), (gpointer)name);
g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()), action);
g_print ("Actions of '%s' plugin added\n", name);
g_object_unref (action);
plugin_menu = find_plugin_menu ();
if (plugin_menu)
@@ -231,14 +230,14 @@ enable_plugin (const gchar *name)
GMenu *section;
GMenuItem *item;
gchar *label;
gchar *action_name;
gchar *action;
section = g_menu_new ();
label = g_strdup_printf ("Turn text %s", name);
action_name = g_strconcat ("app.", name, NULL);
g_menu_insert (section, 0, label, action_name);
action = g_strconcat ("app.", name, NULL);
g_menu_insert (section, 0, label, action);
g_free (label);
g_free (action_name);
g_free (action);
item = g_menu_item_new_section (NULL, (GMenuModel*)section);
g_menu_item_set_attribute (item, "id", "s", name);
g_menu_append_item (G_MENU (plugin_menu), item);

View File

@@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: Gail
Description: GNOME Accessibility Implementation Library
Version: @VERSION@
Requires: atk gtk+-3.0
Libs: ${pc_top_builddir}/${pcfiledir}/modules/other/gail/libgail.la ${pc_top_builddir}/${pcfiledir}/modules/other/gail/libgail-util/libgailutil.la
Cflags: -I${pc_top_builddir}/${pcfiledir}/modules/other/gail

View File

@@ -1213,7 +1213,8 @@ gdk_broadway_display_finalize (GObject *object)
_gdk_broadway_cursor_display_finalize (GDK_DISPLAY_OBJECT(broadway_display));
/* input GdkDevice list */
g_list_free_full (broadway_display->input_devices, g_object_unref);
g_list_foreach (broadway_display->input_devices, (GFunc) g_object_unref, NULL);
g_list_free (broadway_display->input_devices);
/* Free all GdkScreens */
g_object_unref (broadway_display->screens[0]);
g_free (broadway_display->screens);

View File

@@ -14,19 +14,6 @@
G_BEGIN_DECLS
/* These macros are used to mark deprecated functions in GDK and
* GTK+ headers, and thus have to be exposed in installed headers.
* But please do *not* use them in other projects. Instead, use
* G_DEPRECATED or define your own wrappers around it.
*/
#ifdef GDK_DISABLE_DEPRECATION_WARNINGS
#define GDK_DEPRECATED
#define GDK_DEPRECATED_FOR(f)
#else
#define GDK_DEPRECATED G_DEPRECATED
#define GDK_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f)
#endif
#define GDK_WINDOWING_WIN32

View File

@@ -154,7 +154,8 @@ free_device_grabs_foreach (gpointer key,
{
GList *list = value;
g_list_free_full (list, (GDestroyNotify) free_device_grab);
g_list_foreach (list, (GFunc) free_device_grab, NULL);
g_list_free (list);
return TRUE;
}
@@ -210,7 +211,8 @@ gdk_display_dispose (GObject *object)
device_manager = gdk_display_get_device_manager (GDK_DISPLAY (object));
g_list_free_full (display->queued_events, (GDestroyNotify) gdk_event_free);
g_list_foreach (display->queued_events, (GFunc)gdk_event_free, NULL);
g_list_free (display->queued_events);
display->queued_events = NULL;
display->queued_tail = NULL;

View File

@@ -74,25 +74,6 @@ G_BEGIN_DECLS
*/
#define GDK_PRIORITY_REDRAW (G_PRIORITY_HIGH_IDLE + 20)
/**
* GDK_EVENT_PROPAGATE:
*
* Use this macro as the return value for continuing the propagation of
* an event handler.
*
* Since: 3.4
*/
#define GDK_EVENT_PROPAGATE (FALSE)
/**
* GDK_EVENT_STOP:
*
* Use this macro as the return value for stopping the propagation of
* an event handler.
*
* Since: 3.4
*/
#define GDK_EVENT_STOP (TRUE)
typedef struct _GdkEventAny GdkEventAny;
typedef struct _GdkEventExpose GdkEventExpose;

View File

@@ -27,8 +27,6 @@
#include "config.h"
#include "gdkrgba.h"
#include <string.h>
#include <errno.h>
#include <math.h>
/**
* SECTION:rgba_colors
@@ -73,7 +71,15 @@ G_DEFINE_BOXED_TYPE (GdkRGBA, gdk_rgba,
GdkRGBA *
gdk_rgba_copy (const GdkRGBA *rgba)
{
return g_slice_dup (GdkRGBA, rgba);
GdkRGBA *copy;
copy = g_slice_new (GdkRGBA);
copy->red = rgba->red;
copy->green = rgba->green;
copy->blue = rgba->blue;
copy->alpha = rgba->alpha;
return copy;
}
/**
@@ -103,17 +109,14 @@ gdk_rgba_free (GdkRGBA *rgba)
* - We accept mixed percentages and non-percentages in a single
* rgb() or rgba() specification.
*/
static gboolean
parse_rgb_value (const gchar *str,
gchar **endp,
gdouble *number)
static double
parse_rgb_value (const char *str,
char **endp)
{
double number;
const char *p;
*number = g_ascii_strtod (str, endp);
if (errno == ERANGE || *endp == str ||
isinf (*number) || isnan (*number))
return FALSE;
number = g_ascii_strtod (str, endp);
p = *endp;
@@ -122,14 +125,12 @@ parse_rgb_value (const gchar *str,
if (*p == '%')
{
*endp = (char *)(p + 1);
*number = CLAMP(*number / 100., 0., 1.);
return CLAMP(number / 100., 0., 1.);
}
else
{
*number = CLAMP(*number / 255., 0., 1.);
return CLAMP(number / 255., 0., 1.);
}
return TRUE;
}
/**
@@ -175,7 +176,6 @@ gdk_rgba_parse (GdkRGBA *rgba,
gboolean has_alpha;
gdouble r, g, b, a;
gchar *str = (gchar *) spec;
gchar *p;
if (strncmp (str, "rgba", 4) == 0)
{
@@ -220,8 +220,7 @@ gdk_rgba_parse (GdkRGBA *rgba,
/* Parse red */
SKIP_WHITESPACES (str);
if (!parse_rgb_value (str, &str, &r))
return FALSE;
r = parse_rgb_value (str, &str);
SKIP_WHITESPACES (str);
if (*str != ',')
@@ -231,8 +230,7 @@ gdk_rgba_parse (GdkRGBA *rgba,
/* Parse green */
SKIP_WHITESPACES (str);
if (!parse_rgb_value (str, &str, &g))
return FALSE;
g = parse_rgb_value (str, &str);
SKIP_WHITESPACES (str);
if (*str != ',')
@@ -242,8 +240,7 @@ gdk_rgba_parse (GdkRGBA *rgba,
/* Parse blue */
SKIP_WHITESPACES (str);
if (!parse_rgb_value (str, &str, &b))
return FALSE;
b = parse_rgb_value (str, &str);
SKIP_WHITESPACES (str);
if (has_alpha)
@@ -254,24 +251,13 @@ gdk_rgba_parse (GdkRGBA *rgba,
str++;
SKIP_WHITESPACES (str);
a = g_ascii_strtod (str, &p);
if (errno == ERANGE || p == str ||
isinf (a) || isnan (a))
return FALSE;
str = p;
a = g_ascii_strtod (str, &str);
SKIP_WHITESPACES (str);
}
if (*str != ')')
return FALSE;
str++;
SKIP_WHITESPACES (str);
if (*str != '\0')
return FALSE;
if (rgba)
{
rgba->red = CLAMP (r, 0, 1);

View File

@@ -2065,8 +2065,12 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
window->clip_region_with_children = NULL;
}
g_list_free_full (window->outstanding_moves, (GDestroyNotify) gdk_window_region_move_free);
window->outstanding_moves = NULL;
if (window->outstanding_moves)
{
g_list_foreach (window->outstanding_moves, (GFunc)gdk_window_region_move_free, NULL);
g_list_free (window->outstanding_moves);
window->outstanding_moves = NULL;
}
}
break;
}
@@ -3941,7 +3945,8 @@ _gdk_window_process_updates_recurse (GdkWindow *window,
}
}
g_list_free_full (children, g_object_unref);
g_list_foreach (children, (GFunc)g_object_unref, NULL);
g_list_free (children);
}

View File

@@ -308,7 +308,8 @@ gdk_quartz_display_finalize (GObject *object)
{
GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (object);
g_list_free_full (display_quartz->input_devices, g_object_unref);
g_list_foreach (display_quartz->input_devices, (GFunc) g_object_unref, NULL);
g_list_free (display_quartz->input_devices);
G_OBJECT_CLASS (gdk_quartz_display_parent_class)->finalize (object);
}

View File

@@ -19,9 +19,9 @@ progs_ldadd = \
#check_gdk_cairo_SOURCES = check-gdk-cairo.c
#check_gdk_cairo_LDADD = $(progs_ldadd)
TEST_PROGS += rgba
rgba_SOURCES = rgba.c
rgba_LDADD = $(progs_ldadd)
TEST_PROGS += gdk-color
gdk_color_SOURCES = gdk-color.c
gdk_color_LDADD = $(progs_ldadd)
TEST_PROGS += encoding
encoding_SOURCES = encoding.c

View File

@@ -49,14 +49,6 @@ test_color_parse (void)
res = gdk_rgba_parse (&color, "#0080ff");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
expected.red = 0.0;
expected.green = 0.0;
expected.blue = 0.0;
expected.alpha = 1.0;
res = gdk_rgba_parse (&color, "rgb(0,0,0)");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
}
static void
@@ -98,67 +90,13 @@ test_color_to_string (void)
g_free (orig);
}
static void
test_color_copy (void)
{
GdkRGBA rgba;
GdkRGBA *out;
rgba.red = 0.0;
rgba.green = 0.1;
rgba.blue = 0.6;
rgba.alpha = 0.9;
out = gdk_rgba_copy (&rgba);
g_assert (gdk_rgba_equal (&rgba, out));
gdk_rgba_free (out);
}
static void
test_color_parse_nonsense (void)
{
GdkRGBA color;
gboolean res;
g_test_bug ("667485");
res = gdk_rgba_parse (&color, "rgb(,,)");
g_assert (!res);
res = gdk_rgba_parse (&color, "rgb(%,%,%)");
g_assert (!res);
res = gdk_rgba_parse (&color, "rgb(nan,nan,nan)");
g_assert (!res);
res = gdk_rgba_parse (&color, "rgb(inf,inf,inf)");
g_assert (!res);
res = gdk_rgba_parse (&color, "rgb(1p12,0,0)");
g_assert (!res);
res = gdk_rgba_parse (&color, "rgb(5d1%,1,1)");
g_assert (!res);
res = gdk_rgba_parse (&color, "rgb(0,0,0)moo");
g_assert (!res);
res = gdk_rgba_parse (&color, "rgb(0,0,0) moo");
g_assert (!res);
}
int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org");
g_test_add_func ("/rgba/parse", test_color_parse);
g_test_add_func ("/rgba/parse/nonsense", test_color_parse_nonsense);
g_test_add_func ("/rgba/to-string", test_color_to_string);
g_test_add_func ("/rgba/copy", test_color_copy);
g_test_add_func ("/color/parse", test_color_parse);
g_test_add_func ("/color/to-string", test_color_to_string);
return g_test_run ();
}

View File

@@ -227,7 +227,7 @@ create_cursor(GdkDisplayWayland *display, GdkPixbuf *pixbuf, int x, int y)
fd,
cursor->width,
cursor->height,
stride, WL_SHM_FORMAT_ARGB8888);
stride, WL_SHM_FORMAT_ARGB32);
close(fd);
@@ -293,7 +293,7 @@ _gdk_wayland_display_get_cursor_for_type (GdkDisplay *display,
{
gchar *filename;
filename = g_build_filename (directories[j],
"weston",
"wayland",
cursor_definitions[i].filename,
NULL);
if (g_file_test (filename, G_FILE_TEST_EXISTS))

View File

@@ -17,11 +17,6 @@
* Boston, MA 02111-1307, USA.
*/
#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "config.h"
#include <string.h>
@@ -37,8 +32,6 @@
#include <X11/extensions/XKBcommon.h>
#include <X11/keysym.h>
#include <sys/time.h>
#define GDK_TYPE_DEVICE_CORE (gdk_device_core_get_type ())
#define GDK_DEVICE_CORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_CORE, GdkDeviceCore))
#define GDK_DEVICE_CORE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE_CORE, GdkDeviceCoreClass))
@@ -52,8 +45,6 @@ typedef struct _GdkWaylandDevice GdkWaylandDevice;
typedef struct _DataOffer DataOffer;
typedef struct _GdkWaylandSelectionOffer GdkWaylandSelectionOffer;
struct _GdkWaylandDevice
{
GdkDisplay *display;
@@ -66,16 +57,9 @@ struct _GdkWaylandDevice
struct wl_data_device *data_device;
int32_t x, y, surface_x, surface_y;
uint32_t time;
GdkWindow *pointer_grab_window;
uint32_t pointer_grab_time;
guint32 repeat_timer;
guint32 repeat_key;
guint32 repeat_count;
DataOffer *drag_offer;
DataOffer *selection_offer;
GdkWaylandSelectionOffer *selection_offer_out;
};
struct _GdkDeviceCore
@@ -155,20 +139,14 @@ gdk_device_core_set_window_cursor (GdkDevice *device,
int x, y;
if (cursor)
g_object_ref (cursor);
/* Setting the cursor to NULL means that we should use the default cursor */
if (!cursor)
{
/* FIXME: Is this the best sensible default ? */
cursor = _gdk_wayland_display_get_cursor_for_type (device->display,
GDK_LEFT_PTR);
buffer = _gdk_wayland_cursor_get_buffer(cursor, &x, &y);
wl_input_device_attach(wd->device, wd->time, buffer, x, y);
}
else
{
wl_input_device_attach(wd->device, wd->time, NULL, 0, 0);
}
buffer = _gdk_wayland_cursor_get_buffer(cursor, &x, &y);
wl_input_device_attach(wd->device, wd->time, buffer, x, y);
g_object_unref (cursor);
}
static void
@@ -223,30 +201,6 @@ gdk_device_core_grab (GdkDevice *device,
GdkCursor *cursor,
guint32 time_)
{
GdkWaylandDevice *wayland_device = GDK_DEVICE_CORE (device)->device;
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
/* Device is a keyboard */
return GDK_GRAB_SUCCESS;
}
else
{
/* Device is a pointer */
if (wayland_device->pointer_grab_window != NULL &&
time_ != 0 && wayland_device->pointer_grab_time > time_)
{
return GDK_GRAB_ALREADY_GRABBED;
}
if (time_ == 0)
time_ = wayland_device->time;
wayland_device->pointer_grab_window = window;
wayland_device->pointer_grab_time = time_;
}
return GDK_GRAB_SUCCESS;
}
@@ -254,23 +208,6 @@ static void
gdk_device_core_ungrab (GdkDevice *device,
guint32 time_)
{
GdkDisplay *display;
GdkDeviceGrabInfo *grab;
display = gdk_device_get_display (device);
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
/* Device is a keyboard */
}
else
{
/* Device is a pointer */
grab = _gdk_display_get_last_device_grab (display, device);
if (grab)
grab->serial_end = grab->serial_start;
}
}
static GdkWindow *
@@ -471,13 +408,11 @@ translate_keyboard_string (GdkEventKey *event)
}
}
static gboolean
keyboard_repeat (gpointer data);
static gboolean
deliver_key_event(GdkWaylandDevice *device,
uint32_t time, uint32_t key, uint32_t state)
static void
input_handle_key(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t key, uint32_t state)
{
GdkWaylandDevice *device = data;
GdkEvent *event;
uint32_t code, modifier, level;
struct xkb_desc *xkb;
@@ -520,60 +455,6 @@ deliver_key_event(GdkWaylandDevice *device,
"string %s, mods 0x%x",
code, event->key.keyval,
event->key.string, event->key.state));
device->repeat_count++;
device->repeat_key = key;
if (state == 0)
{
if (device->repeat_timer)
{
g_source_remove (device->repeat_timer);
device->repeat_timer = 0;
}
return FALSE;
}
else if (modifier)
{
return FALSE;
}
else switch (device->repeat_count)
{
case 1:
if (device->repeat_timer)
{
g_source_remove (device->repeat_timer);
device->repeat_timer = 0;
}
device->repeat_timer =
gdk_threads_add_timeout (400, keyboard_repeat, device);
return TRUE;
case 2:
device->repeat_timer =
gdk_threads_add_timeout (80, keyboard_repeat, device);
return FALSE;
default:
return TRUE;
}
}
static gboolean
keyboard_repeat (gpointer data)
{
GdkWaylandDevice *device = data;
return deliver_key_event (device, device->time, device->repeat_key, 1);
}
static void
input_handle_key(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t key, uint32_t state)
{
GdkWaylandDevice *device = data;
device->repeat_count = 0;
deliver_key_event (data, time, key, state);
}
static void
@@ -675,7 +556,6 @@ input_handle_keyboard_focus(void *data,
device->time = time;
if (device->keyboard_focus)
{
_gdk_wayland_window_remove_focus (device->keyboard_focus);
event = gdk_event_new (GDK_FOCUS_CHANGE);
event->focus_change.window = g_object_ref (device->keyboard_focus);
event->focus_change.send_event = FALSE;
@@ -710,8 +590,6 @@ input_handle_keyboard_focus(void *data,
device, device->keyboard_focus));
_gdk_wayland_display_deliver_event (device->display, event);
_gdk_wayland_window_add_focus (device->keyboard_focus);
}
}
@@ -845,21 +723,14 @@ data_device_selection (void *data,
struct wl_data_offer *offer)
{
GdkWaylandDevice *device = (GdkWaylandDevice *)data;
GdkDeviceManager *device_manager =
gdk_display_get_device_manager (device->display);
GdkDeviceManagerCore *device_manager_core =
GDK_DEVICE_MANAGER_CORE (device_manager);
g_debug (G_STRLOC ": %s wl_data_device = %p wl_data_offer = %p",
G_STRFUNC, wl_data_device, offer);
if (!offer)
{
if (device->selection_offer)
{
data_offer_unref (device->selection_offer);
device->selection_offer = NULL;
}
return;
}
if (device->selection_offer)
{
data_offer_unref (device->selection_offer);
@@ -940,7 +811,7 @@ _gdk_wayland_device_manager_add_device (GdkDeviceManager *device_manager,
}
static void
free_device (gpointer data)
free_device (void *data, void *user_data)
{
g_object_unref (data);
}
@@ -952,7 +823,8 @@ gdk_device_manager_core_finalize (GObject *object)
device_manager_core = GDK_DEVICE_MANAGER_CORE (object);
g_list_free_full (device_manager_core->devices, free_device);
g_list_foreach (device_manager_core->devices, free_device, NULL);
g_list_free (device_manager_core->devices);
G_OBJECT_CLASS (gdk_device_manager_core_parent_class)->finalize (object);
}
@@ -1005,290 +877,3 @@ _gdk_wayland_device_manager_new (GdkDisplay *display)
"display", display,
NULL);
}
gint
gdk_wayland_device_get_selection_type_atoms (GdkDevice *gdk_device,
GdkAtom **atoms_out)
{
gint i;
GdkAtom *atoms;
GdkWaylandDevice *device;
g_return_val_if_fail (GDK_IS_DEVICE_CORE (gdk_device), 0);
g_return_val_if_fail (atoms_out != NULL, 0);
device = GDK_DEVICE_CORE (gdk_device)->device;
if (device->selection_offer->types->len == 0)
{
*atoms_out = NULL;
return 0;
}
atoms = g_new0 (GdkAtom, device->selection_offer->types->len);
/* Convert list of targets to atoms */
for (i = 0; i < device->selection_offer->types->len; i++)
{
atoms[i] = gdk_atom_intern (device->selection_offer->types->pdata[i],
FALSE);
GDK_NOTE (MISC,
g_message (G_STRLOC ": Adding atom for %s",
(char *)device->selection_offer->types->pdata[i]));
}
*atoms_out = atoms;
return device->selection_offer->types->len;
}
typedef struct
{
GdkWaylandDevice *device;
DataOffer *offer;
GIOChannel *channel;
GdkDeviceWaylandRequestContentCallback cb;
gpointer userdata;
} RequestContentClosure;
static gboolean
_request_content_io_func (GIOChannel *channel,
GIOCondition condition,
gpointer userdata)
{
RequestContentClosure *closure = (RequestContentClosure *)userdata;
gchar *data = NULL;
gsize len = 0;
GError *error = NULL;
/* FIXME: We probably want to do something better than this to avoid
* blocking on the transfer of large pieces of data: call the callback
* multiple times I should think.
*/
if (g_io_channel_read_to_end (channel,
&data,
&len,
&error) != G_IO_STATUS_NORMAL)
{
g_warning (G_STRLOC ": Error reading content from pipe: %s", error->message);
g_clear_error (&error);
}
/* Since we use _read_to_end we've got a guaranteed EOF and thus can go
* ahead and close the fd
*/
g_io_channel_shutdown (channel, TRUE, NULL);
closure->cb (closure->device->pointer, data, len, closure->userdata);
g_free (data);
data_offer_unref (closure->offer);
g_io_channel_unref (channel);
g_free (closure);
return FALSE;
}
gboolean
gdk_wayland_device_request_selection_content (GdkDevice *gdk_device,
const gchar *requested_mime_type,
GdkDeviceWaylandRequestContentCallback cb,
gpointer userdata)
{
int pipe_fd[2];
RequestContentClosure *closure;
GdkWaylandDevice *device;
GError *error = NULL;
g_return_val_if_fail (GDK_IS_DEVICE_CORE (gdk_device), FALSE);
g_return_val_if_fail (requested_mime_type != NULL, FALSE);
g_return_val_if_fail (cb != NULL, FALSE);
device = GDK_DEVICE_CORE (gdk_device)->device;
if (!device->selection_offer)
return FALSE;
/* TODO: Check mimetypes */
closure = g_new0 (RequestContentClosure, 1);
device->selection_offer->ref_count++;
pipe2 (pipe_fd, O_CLOEXEC);
wl_data_offer_receive (device->selection_offer->offer,
requested_mime_type,
pipe_fd[1]);
close (pipe_fd[1]);
closure->device = device;
closure->offer = device->selection_offer;
closure->channel = g_io_channel_unix_new (pipe_fd[0]);
closure->cb = cb;
closure->userdata = userdata;
if (!g_io_channel_set_encoding (closure->channel, NULL, &error))
{
g_warning (G_STRLOC ": Error setting encoding on channel: %s",
error->message);
g_clear_error (&error);
goto error;
}
g_io_add_watch (closure->channel,
G_IO_IN,
_request_content_io_func,
closure);
return TRUE;
error:
data_offer_unref (closure->offer);
g_io_channel_unref (closure->channel);
close (pipe_fd[1]);
g_free (closure);
return FALSE;
}
struct _GdkWaylandSelectionOffer {
GdkDeviceWaylandOfferContentCallback cb;
gpointer userdata;
struct wl_data_source *source;
GdkWaylandDevice *device;
};
static void
data_source_target (void *data,
struct wl_data_source *source,
const char *mime_type)
{
g_debug (G_STRLOC ": %s source = %p, mime_type = %s",
G_STRFUNC, source, mime_type);
}
static void
data_source_send (void *data,
struct wl_data_source *source,
const char *mime_type,
int32_t fd)
{
GdkWaylandSelectionOffer *offer = (GdkWaylandSelectionOffer *)data;;
gchar *buf;
gssize len, bytes_written = 0;
g_debug (G_STRLOC ": %s source = %p, mime_type = %s fd = %d",
G_STRFUNC, source, mime_type, fd);
buf = offer->cb (offer->device->pointer, mime_type, &len, offer->userdata);
while (len > 0)
{
bytes_written += write (fd, buf + bytes_written, len);
if (bytes_written == -1)
goto error;
len -= bytes_written;
}
close (fd);
g_free (buf);
return;
error:
g_warning (G_STRLOC ": Error writing data to client: %s",
g_strerror (errno));
close (fd);
g_free (buf);
}
static void
data_source_cancelled (void *data,
struct wl_data_source *source)
{
g_debug (G_STRLOC ": %s source = %p",
G_STRFUNC, source);
}
static const struct wl_data_source_listener data_source_listener = {
data_source_target,
data_source_send,
data_source_cancelled
};
static guint32
_wl_time_now (void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
gboolean
gdk_wayland_device_offer_selection_content (GdkDevice *gdk_device,
const gchar **mime_types,
gint nr_mime_types,
GdkDeviceWaylandOfferContentCallback cb,
gpointer userdata)
{
GdkDisplay *display;
GdkDisplayWayland *display_wayland;
GdkWaylandSelectionOffer *offer;
GdkWaylandDevice *device;
gint i;
g_return_val_if_fail (GDK_IS_DEVICE_CORE (gdk_device), 0);
device = GDK_DEVICE_CORE (gdk_device)->device;
display = device->display;
display_wayland = GDK_DISPLAY_WAYLAND (display);
offer = g_new0 (GdkWaylandSelectionOffer, 1);
offer->cb = cb;
offer->userdata = userdata;
offer->source =
wl_data_device_manager_create_data_source (display_wayland->data_device_manager);
offer->device = device;
for (i = 0; i < nr_mime_types; i++)
{
wl_data_source_offer (offer->source,
mime_types[i]);
}
wl_data_source_add_listener (offer->source,
&data_source_listener,
offer);
wl_data_device_set_selection (device->data_device,
offer->source,
_wl_time_now ());
device->selection_offer_out = offer;
return TRUE;
}
gboolean
gdk_wayland_device_clear_selection_content (GdkDevice *gdk_device)
{
GdkWaylandDevice *device;
g_return_val_if_fail (GDK_IS_DEVICE_CORE (gdk_device), 0);
device = GDK_DEVICE_CORE (gdk_device)->device;
if (!device->selection_offer_out)
return FALSE;
wl_data_device_set_selection (device->data_device,
NULL,
_wl_time_now ());
wl_data_source_destroy (device->selection_offer_out->source);
g_free (device->selection_offer_out);
device->selection_offer_out = NULL;
return TRUE;
}

View File

@@ -274,7 +274,8 @@ gdk_wayland_display_finalize (GObject *object)
g_object_unref (display_wayland->keymap);
/* input GdkDevice list */
g_list_free_full (display_wayland->input_devices, g_object_unref);
g_list_foreach (display_wayland->input_devices, (GFunc) g_object_unref, NULL);
g_list_free (display_wayland->input_devices);
g_object_unref (display_wayland->screen);
@@ -425,8 +426,7 @@ gdk_wayland_display_after_process_all_updates (GdkDisplay *display)
static gulong
gdk_wayland_display_get_next_serial (GdkDisplay *display)
{
static gulong serial = 0;
return ++serial;
return 0;
}
void

View File

@@ -135,8 +135,8 @@ gdk_wayland_display_manager_get_atom_name (GdkDisplayManager *manager_in,
while (g_hash_table_iter_next (&iter, &key, &value))
{
if (GDK_POINTER_TO_ATOM (value) == atom)
return g_strdup (key);
if (GDK_POINTER_TO_ATOM (key) == atom)
return g_strdup (value);
}
return NULL;

View File

@@ -113,10 +113,10 @@ void
_gdk_wayland_display_deliver_event (GdkDisplay *display, GdkEvent *event)
{
GList *node;
static int serial;
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event,
_gdk_display_get_next_serial (display));
_gdk_windowing_got_event (display, node, event, serial++);
}
GSource *

View File

@@ -49,8 +49,6 @@ void _gdk_wayland_window_update_size (GdkWindow *window,
int32_t width,
int32_t height,
uint32_t edges);
void _gdk_wayland_window_add_focus (GdkWindow *window);
void _gdk_wayland_window_remove_focus (GdkWindow *window);
GdkKeymap *_gdk_wayland_keymap_new (GdkDisplay *display);
struct xkb_desc *_gdk_wayland_keymap_get_xkb_desc (GdkKeymap *keymap);

View File

@@ -33,36 +33,6 @@ G_BEGIN_DECLS
GType gdk_wayland_display_manager_get_type (void);
#if defined (GTK_COMPILATION) || defined (GDK_COMPILATION)
#define gdk_wayland_device_get_selection_type_atoms gdk_wayland_device_get_selection_type_atoms_libgtk_only
int
gdk_wayland_device_get_selection_type_atoms (GdkDevice *device,
GdkAtom **atoms_out);
typedef void (*GdkDeviceWaylandRequestContentCallback) (GdkDevice *device, const gchar *data, gsize len, gpointer userdata);
#define gdk_wayland_device_request_selection_content gdk_wayland_device_request_selection_content_libgtk_only
gboolean
gdk_wayland_device_request_selection_content (GdkDevice *device,
const gchar *requested_mime_type,
GdkDeviceWaylandRequestContentCallback cb,
gpointer userdata);
typedef gchar *(*GdkDeviceWaylandOfferContentCallback) (GdkDevice *device, const gchar *mime_type, gssize *len, gpointer userdata);
#define gdk_wayland_device_offer_selection_content gdk_wayland_device_offer_selection_content_libgtk_only
gboolean
gdk_wayland_device_offer_selection_content (GdkDevice *gdk_device,
const gchar **mime_types,
gint nr_mime_types,
GdkDeviceWaylandOfferContentCallback cb,
gpointer userdata);
#define gdk_wayland_device_clear_selection_content gdk_wayland_device_clear_selection_content_libgtk_only
gboolean
gdk_wayland_device_clear_selection_content (GdkDevice *gdk_device);
#endif
G_END_DECLS
#endif /* __GDK_WAYLAND_H__ */

View File

@@ -102,14 +102,42 @@ struct _GdkWindowImplWayland
struct wl_shell_surface *shell_surface;
unsigned int mapped : 1;
GdkWindow *transient_for;
GdkWindowTypeHint hint;
cairo_surface_t *cairo_surface;
cairo_surface_t *server_surface;
GLuint texture;
uint32_t resize_edges;
int focus_count;
/* Set if the window, or any descendent of it, is the server's focus window
*/
guint has_focus_window : 1;
/* Set if window->has_focus_window and the focus isn't grabbed elsewhere.
*/
guint has_focus : 1;
/* Set if the pointer is inside this window. (This is needed for
* for focus tracking)
*/
guint has_pointer : 1;
/* Set if the window is a descendent of the focus window and the pointer is
* inside it. (This is the case where the window will receive keystroke
* events even window->has_focus_window is FALSE)
*/
guint has_pointer_focus : 1;
/* Set if we are requesting these hints */
guint skip_taskbar_hint : 1;
guint skip_pager_hint : 1;
guint urgency_hint : 1;
guint on_all_desktops : 1; /* _NET_WM_STICKY == 0xFFFFFFFF */
guint have_sticky : 1; /* _NET_WM_STATE_STICKY */
guint have_maxvert : 1; /* _NET_WM_STATE_MAXIMIZED_VERT */
guint have_maxhorz : 1; /* _NET_WM_STATE_MAXIMIZED_HORZ */
guint have_fullscreen : 1; /* _NET_WM_STATE_FULLSCREEN */
gulong map_serial; /* Serial of last transition from unmapped */
@@ -118,9 +146,6 @@ struct _GdkWindowImplWayland
/* Time of most recent user interaction. */
gulong user_time;
GdkGeometry geometry_hints;
GdkWindowHints geometry_mask;
};
struct _GdkWindowImplWaylandClass
@@ -136,26 +161,6 @@ _gdk_window_impl_wayland_init (GdkWindowImplWayland *impl)
impl->toplevel_window_type = -1;
}
void
_gdk_wayland_window_add_focus (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->focus_count++;
if (impl->focus_count == 1)
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
}
void
_gdk_wayland_window_remove_focus (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->focus_count--;
if (impl->focus_count == 0)
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
}
/**
* _gdk_wayland_window_update_size:
* @drawable: a #GdkDrawableImplWayland.
@@ -476,22 +481,11 @@ shell_surface_handle_configure(void *data,
int32_t height)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkDisplay *display;
GdkEvent *event;
display = gdk_window_get_display (window);
gdk_window_constrain_size (&impl->geometry_hints,
impl->geometry_mask,
width,
height,
&width,
&height);
/* TODO: Only generate a configure event if width or height have actually
* changed?
*/
event = gdk_event_new (GDK_CONFIGURE);
event->configure.window = window;
event->configure.send_event = FALSE;
@@ -534,8 +528,6 @@ gdk_wayland_window_show (GdkWindow *window, gboolean already_mapped)
wl_shell_surface_add_listener(impl->shell_surface,
&shell_surface_listener, window);
gdk_window_set_type_hint (window, impl->hint);
_gdk_make_event (window, GDK_MAP, NULL, FALSE);
event = _gdk_make_event (window, GDK_VISIBILITY_NOTIFY, NULL, FALSE);
event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
@@ -846,20 +838,16 @@ static void
gdk_wayland_window_set_type_hint (GdkWindow *window,
GdkWindowTypeHint hint)
{
GdkWindowImplWayland *impl;
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (GDK_WINDOW_DESTROYED (window))
return;
impl->hint = hint;
switch (hint)
{
case GDK_WINDOW_TYPE_HINT_DIALOG:
case GDK_WINDOW_TYPE_HINT_MENU:
case GDK_WINDOW_TYPE_HINT_TOOLBAR:
case GDK_WINDOW_TYPE_HINT_UTILITY:
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
case GDK_WINDOW_TYPE_HINT_DOCK:
case GDK_WINDOW_TYPE_HINT_DESKTOP:
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
@@ -872,11 +860,7 @@ gdk_wayland_window_set_type_hint (GdkWindow *window,
default:
g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
/* Fall thru */
case GDK_WINDOW_TYPE_HINT_DIALOG:
case GDK_WINDOW_TYPE_HINT_NORMAL:
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
if (impl->shell_surface)
wl_shell_surface_set_toplevel (impl->shell_surface);
break;
}
}
@@ -916,17 +900,10 @@ gdk_wayland_window_set_geometry_hints (GdkWindow *window,
const GdkGeometry *geometry,
GdkWindowHints geom_mask)
{
GdkWindowImplWayland *impl;
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
return;
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->geometry_hints = *geometry;
impl->geometry_mask = geom_mask;
/*
* GDK_HINT_POS
* GDK_HINT_USER_POS
@@ -1217,14 +1194,9 @@ gdk_wayland_window_begin_resize_drag (GdkWindow *window,
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
wl_shell_surface_resize (impl->shell_surface,
_gdk_wayland_device_get_device (device),
timestamp, grab_type);
/* This is needed since Wayland will absorb all the pointer events after the
* above function - FIXME: Is this always safe..?
*/
gdk_device_ungrab (device, timestamp);
wl_shell_surface_resize(impl->shell_surface,
_gdk_wayland_device_get_device (device),
timestamp, grab_type);
}
static void
@@ -1235,6 +1207,7 @@ gdk_wayland_window_begin_move_drag (GdkWindow *window,
gint root_y,
guint32 timestamp)
{
GdkDisplay *display = gdk_window_get_display (window);
GdkWindowImplWayland *impl;
if (GDK_WINDOW_DESTROYED (window) ||
@@ -1243,13 +1216,8 @@ gdk_wayland_window_begin_move_drag (GdkWindow *window,
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
wl_shell_surface_move (impl->shell_surface,
_gdk_wayland_device_get_device (device), timestamp);
/* This is needed since Wayland will absorb all the pointer events after the
* above function - FIXME: Is this always safe..?
*/
gdk_device_ungrab (device, timestamp);
wl_shell_surface_move(impl->shell_surface,
_gdk_wayland_device_get_device (device), timestamp);
}
static void

View File

@@ -100,8 +100,6 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
*
* Returns: (transfer none): (allow-none): The #GdkDevice wrapping the device ID,
* or %NULL if the given ID doesn't currently represent a device.
*
* Since: 3.2
**/
GdkDevice *
gdk_x11_device_manager_lookup (GdkDeviceManager *device_manager,
@@ -147,8 +145,6 @@ gdk_x11_device_manager_lookup (GdkDeviceManager *device_manager,
* </note>
*
* Returns: the XInput2 device ID.
*
* Since: 3.2
**/
gint
gdk_x11_device_get_id (GdkDevice *device)

View File

@@ -308,8 +308,8 @@ gdk_x11_device_manager_xi_dispose (GObject *object)
GdkX11DeviceManagerXI *device_manager;
device_manager = GDK_X11_DEVICE_MANAGER_XI (object);
g_list_free_full (device_manager->devices, g_object_unref);
g_list_foreach (device_manager->devices, (GFunc) g_object_unref, NULL);
g_list_free (device_manager->devices);
device_manager->devices = NULL;
if (device_manager->id_table != NULL)

View File

@@ -203,7 +203,7 @@ do_net_wm_state_changes (GdkWindow *window)
}
else
{
if (toplevel->have_sticky && toplevel->on_all_desktops)
if (toplevel->have_sticky || toplevel->on_all_desktops)
gdk_synthesize_window_state (window,
0,
GDK_WINDOW_STATE_STICKY);
@@ -284,7 +284,7 @@ gdk_check_wm_desktop_changed (GdkWindow *window)
if (type != None)
{
desktop = (gulong *)data;
toplevel->on_all_desktops = ((*desktop & 0xFFFFFFFF) == 0xFFFFFFFF);
toplevel->on_all_desktops = (*desktop == 0xFFFFFFFF);
XFree (desktop);
}
else
@@ -1767,10 +1767,12 @@ gdk_x11_display_finalize (GObject *object)
g_slist_free (display_x11->event_types);
/* input GdkDevice list */
g_list_free_full (display_x11->input_devices, g_object_unref);
g_list_foreach (display_x11->input_devices, (GFunc) g_object_unref, NULL);
g_list_free (display_x11->input_devices);
/* input GdkWindow list */
g_list_free_full (display_x11->input_windows, g_free);
g_list_foreach (display_x11->input_windows, (GFunc) g_free, NULL);
g_list_free (display_x11->input_windows);
/* Free all GdkScreens */
for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)

View File

@@ -662,16 +662,11 @@ is_pointer_within_shape (GdkDisplay *display,
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
cairo_region_t *input_shape;
child->shape = NULL;
if (gdk_display_supports_shapes (display))
child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
child->xid, ShapeBounding);
child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
child->xid, ShapeBounding);
#ifdef ShapeInput
input_shape = NULL;
if (gdk_display_supports_input_shapes (display))
input_shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
child->xid, ShapeInput);
input_shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
child->xid, ShapeInput);
if (child->shape && input_shape)
{
cairo_region_intersect (child->shape, input_shape);

View File

@@ -1311,45 +1311,17 @@ cleanup_atoms(gpointer data)
g_free (supported_atoms);
}
static Window
get_net_supporting_wm_check (GdkX11Screen *screen,
Window window)
static void
fetch_net_wm_check_window (GdkScreen *screen)
{
GdkX11Screen *x11_screen;
GdkDisplay *display;
Atom type;
gint format;
gulong n_items;
gulong bytes_after;
guchar *data;
Window value;
display = screen->display;
type = None;
data = NULL;
value = None;
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (screen->xdisplay, window,
gdk_x11_get_xatom_by_name_for_display (display, "_NET_SUPPORTING_WM_CHECK"),
0, G_MAXLONG, False, XA_WINDOW, &type, &format,
&n_items, &bytes_after, &data);
gdk_x11_display_error_trap_pop_ignored (display);
if (type == XA_WINDOW)
value = *(Window *)data;
if (data)
XFree (data);
return value;
}
static void
fetch_net_wm_check_window (GdkScreen *screen)
{
GdkX11Screen *x11_screen;
GdkDisplay *display;
Window window;
Window *xwindow;
GTimeVal tv;
gint error;
@@ -1357,46 +1329,57 @@ fetch_net_wm_check_window (GdkScreen *screen)
display = x11_screen->display;
g_return_if_fail (GDK_X11_DISPLAY (display)->trusted_client);
if (x11_screen->wmspec_check_window != None)
return; /* already have it */
g_get_current_time (&tv);
if (ABS (tv.tv_sec - x11_screen->last_wmspec_check_time) < 15)
return; /* we've checked recently */
window = get_net_supporting_wm_check (x11_screen, x11_screen->xroot_window);
if (window == None)
return;
x11_screen->last_wmspec_check_time = tv.tv_sec;
if (window != get_net_supporting_wm_check (x11_screen, window))
return;
data = NULL;
XGetWindowProperty (x11_screen->xdisplay, x11_screen->xroot_window,
gdk_x11_get_xatom_by_name_for_display (display, "_NET_SUPPORTING_WM_CHECK"),
0, G_MAXLONG, False, XA_WINDOW, &type, &format,
&n_items, &bytes_after, &data);
if (type != XA_WINDOW)
{
if (data)
XFree (data);
return;
}
xwindow = (Window *)data;
if (x11_screen->wmspec_check_window == *xwindow)
{
XFree (xwindow);
return;
}
gdk_x11_display_error_trap_push (display);
/* Find out if this WM goes away, so we can reset everything. */
XSelectInput (x11_screen->xdisplay, window, StructureNotifyMask);
XSelectInput (x11_screen->xdisplay, *xwindow, StructureNotifyMask);
error = gdk_x11_display_error_trap_pop (display);
if (!error)
{
/* We check the window property again because after XGetWindowProperty()
* and before XSelectInput() the window may have been recycled in such a
* way that XSelectInput() doesn't fail but the window is no longer what
* we want.
*/
if (window != get_net_supporting_wm_check (x11_screen, window))
return;
x11_screen->wmspec_check_window = window;
x11_screen->last_wmspec_check_time = tv.tv_sec;
x11_screen->wmspec_check_window = *xwindow;
x11_screen->need_refetch_net_supported = TRUE;
x11_screen->need_refetch_wm_name = TRUE;
/* Careful, reentrancy */
_gdk_x11_screen_window_manager_changed (screen);
_gdk_x11_screen_window_manager_changed (GDK_SCREEN (x11_screen));
}
else if (error == BadWindow)
{
/* Leftover property, try again immediately, new wm may be starting up */
x11_screen->last_wmspec_check_time = 0;
}
XFree (xwindow);
}
/**

View File

@@ -1765,7 +1765,7 @@ move_to_current_desktop (GdkWindow *window)
xclient.format = 32;
xclient.data.l[0] = *current_desktop;
xclient.data.l[1] = 1; /* source indication */
xclient.data.l[1] = 0;
xclient.data.l[2] = 0;
xclient.data.l[3] = 0;
xclient.data.l[4] = 0;
@@ -1804,7 +1804,7 @@ gdk_x11_window_focus (GdkWindow *window,
xclient.type = ClientMessage;
xclient.window = GDK_WINDOW_XID (window);
xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,
"_NET_ACTIVE_WINDOW");
"_NET_ACTIVE_WINDOW");
xclient.format = 32;
xclient.data.l[0] = 1; /* requestor type; we're an app */
xclient.data.l[1] = timestamp;
@@ -1988,7 +1988,7 @@ gdk_wmspec_change_state (gboolean add,
xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
xclient.data.l[3] = 1; /* source indication */
xclient.data.l[3] = 0;
xclient.data.l[4] = 0;
XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
@@ -3095,8 +3095,6 @@ gdk_x11_window_set_user_time (GdkWindow *window,
* This function modifies or removes an arbitrary X11 window
* property of type UTF8_STRING. If the given @window is
* not a toplevel window, it is ignored.
*
* Since: 3.4
*/
void
gdk_x11_window_set_utf8_property (GdkWindow *window,
@@ -3892,24 +3890,17 @@ _gdk_x11_xwindow_get_shape (Display *xdisplay,
shape = NULL;
rn = 0;
/* Note that XShapeGetRectangles returns NULL in two situations:
* - the server doesn't support the SHAPE extension
* - the shape is empty
*
* Since we can't discriminate these here, we always return
* an empty shape. It is the callers responsibility to check
* whether the server supports the SHAPE extensions beforehand.
*/
xrl = XShapeGetRectangles (xdisplay, window, shape_type, &rn, &ord);
xrl = XShapeGetRectangles (xdisplay,
window,
shape_type, &rn, &ord);
if (rn == 0)
if (xrl == NULL || rn == 0)
return cairo_region_create (); /* Empty */
if (ord != YXBanded)
{
/* This really shouldn't happen with any xserver, as they
* generally convert regions to YXBanded internally
*/
generally convert regions to YXBanded internally */
g_warning ("non YXBanded shape masks not supported");
XFree (xrl);
return NULL;
@@ -3924,10 +3915,10 @@ _gdk_x11_xwindow_get_shape (Display *xdisplay,
rl[i].height = xrl[i].height;
}
XFree (xrl);
shape = cairo_region_create_rectangles (rl, rn);
g_free (rl);
return shape;
}
@@ -3949,7 +3940,7 @@ gdk_x11_window_get_input_shape (GdkWindow *window)
{
#if defined(ShapeInput)
if (!GDK_WINDOW_DESTROYED (window) &&
gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
ShapeInput);
@@ -4024,10 +4015,9 @@ static void
wmspec_moveresize (GdkWindow *window,
gint direction,
GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp)
guint32 timestamp)
{
GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
@@ -4045,9 +4035,9 @@ wmspec_moveresize (GdkWindow *window,
xclient.data.l[0] = root_x;
xclient.data.l[1] = root_y;
xclient.data.l[2] = direction;
xclient.data.l[3] = button;
xclient.data.l[4] = 1; /* source indication */
xclient.data.l[3] = 0;
xclient.data.l[4] = 0;
XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
SubstructureRedirectMask | SubstructureNotifyMask,
(XEvent *)&xclient);
@@ -4142,7 +4132,7 @@ wmspec_resize_drag (GdkWindow *window,
return;
}
wmspec_moveresize (window, direction, device, button, root_x, root_y, timestamp);
wmspec_moveresize (window, direction, device, root_x, root_y, timestamp);
}
static MoveResizeData *
@@ -4368,7 +4358,7 @@ _gdk_x11_moveresize_handle_event (XEvent *event)
finish_drag (mv_resize);
break;
#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
#ifdef HAVE_XGENERICEVENTS
case GenericEvent:
{
/* we just assume this is an XI2 event */
@@ -4627,8 +4617,8 @@ gdk_x11_window_begin_move_drag (GdkWindow *window,
if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE,
device, button, root_x, root_y, timestamp);
wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE, device, root_x, root_y,
timestamp);
else
emulate_move_drag (window, device, button, root_x, root_y, timestamp);
}

View File

@@ -0,0 +1,10 @@
targets=@GDK_BACKENDS@
gtk_binary_version=@GTK_BINARY_VERSION@
Name: GTK+ Uninstalled
Description: GTK+ Graphical UI Library (${target} target), Not Installed
Version: @VERSION@
Requires: gdk-@GTK_API_VERSION@-uninstalled @GTK_PACKAGES@
Libs: ${pc_top_builddir}/${pcfiledir}/gtk/libgtk-3.la @GTK_EXTRA_LIBS@
Cflags: -I${pc_top_builddir}/${pcfiledir}/@srcdir@ -I${pc_top_builddir}/${pcfiledir} @GTK_EXTRA_CFLAGS@

View File

@@ -172,7 +172,6 @@ gtk_public_h_sources = \
gtkaccellabel.h \
gtkaccelmap.h \
gtkaccessible.h \
gtkactionable.h \
gtkaction.h \
gtkactiongroup.h \
gtkactivatable.h \
@@ -393,7 +392,6 @@ gtk_private_type_h_sources = \
# GTK+ header files that don't get installed
gtk_private_h_sources = \
gactionmuxer.h \
gsimpleactionobserver.h \
gactionobserver.h \
gactionobservable.h \
gtkapplicationprivate.h \
@@ -404,28 +402,18 @@ gtk_private_h_sources = \
gtkappchoosermodule.h \
gtkappchooseronline.h \
gtkbindingsprivate.h \
gtkbitmaskprivate.h \
gtkborderimageprivate.h \
gtkboxprivate.h \
gtkbuilderprivate.h \
gtkbuttonprivate.h \
gtkcellareaboxcontextprivate.h \
gtkcontainerprivate.h \
gtkcsscomputedvaluesprivate.h \
gtkcsscustompropertyprivate.h \
gtkcssimagegradientprivate.h \
gtkcssimageprivate.h \
gtkcssimageurlprivate.h \
gtkcssimagewin32private.h \
gtkcsslookupprivate.h \
gtkcssparserprivate.h \
gtkcssproviderprivate.h \
gtkcsssectionprivate.h \
gtkcssselectorprivate.h \
gtkcssshorthandpropertyprivate.h \
gtkcssstylefuncsprivate.h \
gtkcssstylepropertyprivate.h \
gtkcustompaperunixdialog.h \
gtkdndcursors.h \
gtkentryprivate.h \
gtkfilechooserdefault.h \
gtkfilechooserembed.h \
@@ -465,7 +453,6 @@ gtk_private_h_sources = \
gtkrecentchooserdefault.h \
gtkrecentchooserprivate.h \
gtkrecentchooserutils.h \
gtkresources.h \
gtkroundedboxprivate.h \
gtkscaleprivate.h \
gtksearchengine.h \
@@ -478,8 +465,6 @@ gtk_private_h_sources = \
gtkstylecontextprivate.h \
gtkstylepropertiesprivate.h \
gtkstylepropertyprivate.h \
gtkstyleproviderprivate.h \
gtksymboliccolorprivate.h \
gtktextbtree.h \
gtktextbufferserialize.h \
gtktextchildprivate.h \
@@ -527,10 +512,8 @@ deprecated_c_sources = \
gtk_base_c_sources = \
$(deprecated_c_sources) \
gactionmuxer.c \
gsimpleactionobserver.c \
gactionobserver.c \
gactionobservable.c \
gtkactionable.c \
gtkquery.c \
gtksearchengine.c \
gtksearchenginesimple.c \
@@ -560,7 +543,6 @@ gtk_base_c_sources = \
gtkbbox.c \
gtkbin.c \
gtkbindings.c \
gtkbitmask.c \
gtkborder.c \
gtkborderimage.c \
gtkbox.c \
@@ -593,22 +575,10 @@ gtk_base_c_sources = \
gtkcombobox.c \
gtkcomboboxtext.c \
gtkcontainer.c \
gtkcsscomputedvalues.c \
gtkcsscustomproperty.c \
gtkcssimage.c \
gtkcssimagegradient.c \
gtkcssimageurl.c \
gtkcssimagewin32.c \
gtkcsslookup.c \
gtkcssparser.c \
gtkcssprovider.c \
gtkcsssection.c \
gtkcssselector.c \
gtkcssshorthandproperty.c \
gtkcssshorthandpropertyimpl.c \
gtkcssstylefuncs.c \
gtkcssstyleproperty.c \
gtkcssstylepropertyimpl.c \
gtkcsstypes.c \
gtkdialog.c \
gtkdrawingarea.c \
@@ -707,7 +677,6 @@ gtk_base_c_sources = \
gtkrecentchooser.c \
gtkrecentfilter.c \
gtkrecentmanager.c \
gtkresources.c \
gtkroundedbox.c \
gtkscale.c \
gtkscalebutton.c \
@@ -732,7 +701,6 @@ gtk_base_c_sources = \
gtkstyleproperties.c \
gtkstyleproperty.c \
gtkstyleprovider.c \
gtkstyleproviderprivate.c \
gtkswitch.c \
gtksymboliccolor.c \
gtktestutils.c \
@@ -876,15 +844,8 @@ gtk_clipboard_dnd_c_sources = \
gtkclipboard-quartz.c \
gtkdnd-quartz.c
else
if USE_WAYLAND
# No wayland gtkdnd-wayland.c yet
gtk_clipboard_dnd_c_sources = \
gtkclipboard-wayland.c \
gtkdnd.c
else
gtk_clipboard_dnd_c_sources = gtkclipboard.c gtkdnd.c
endif
endif
# we use our own built_sources variable rules to avoid automake's
# BUILT_SOURCES oddities
@@ -898,13 +859,12 @@ gtk_built_public_sources = \
# built headers that don't get installed
gtk_built_private_headers = \
gtkresources.h \
gtkmarshalers.h \
gtkbuiltincache.h \
gtkprivatetypebuiltins.h
gtkprivatetypebuiltins.h \
gtkwin32css.h
gtk_built_sources = \
gtkresources.c \
gtktypebuiltins.c \
gtktypefuncs.c \
gtkmarshalers.c \
@@ -916,6 +876,7 @@ stamp_files = \
stamp-gtkmarshalers.h \
stamp-gtktypebuiltins.h \
stamp-gtkprivatetypebuiltins.h \
stamp-gtkwin32css.h \
stamp-icons
# non-header sources (headers should be specified in the above variables)
@@ -946,13 +907,6 @@ EXTRA_DIST += $(gtk_private_h_sources) $(gtk_extra_sources)
EXTRA_DIST += $(gtk_built_sources)
EXTRA_DIST += $(STOCK_ICONS)
DND_CURSORS = \
cursor_dnd_ask.png \
cursor_dnd_copy.png \
cursor_dnd_link.png \
cursor_dnd_move.png \
cursor_dnd_none.png
#
# rules to generate built sources
#
@@ -980,6 +934,14 @@ gtkmarshalers.c: @REBUILD@ gtkmarshalers.list
&& cp xgen-gmlc gtkmarshalers.c \
&& rm -f xgen-gmlc
gtkwin32css.h: stamp-gtkwin32css.h
@true
stamp-gtkwin32css.h: @REBUILD@ gtk-win32.css
$(AWK) 'BEGIN { print "static const char *gtk_win32_default_css = " } { print " \"" $$0 "\\n\""} END { print ";" }' < $(srcdir)/gtk-win32.css >> xgen-gw3c\
&& (cmp -s xgen-gw3c gtkwin32css.h || cp xgen-gw3c gtkwin32css.h) \
&& rm -f xgen-gw3c \
&& echo timestamp > $(@F)
gtktypebuiltins.h: stamp-gtktypebuiltins.h
@true
stamp-gtktypebuiltins.h: @REBUILD@ $(gtk_public_h_sources) $(deprecated_h_sources) gtktypebuiltins.h.template
@@ -994,12 +956,6 @@ gtktypebuiltins.c: @REBUILD@ $(gtk_public_h_sources) $(deprecated_h_sources) gtk
&& cp xgen-gtbc gtktypebuiltins.c \
&& rm -f xgen-gtbc
gtkresources.h: gtk.gresource.xml
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) gtk.gresource.xml \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-header --manual-register
gtkresources.c: gtk.gresource.xml gtk-default.css gtk-win32.css $(DND_CURSORS)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) gtk.gresource.xml \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-source --manual-register
gtkprivatetypebuiltins.h: stamp-gtkprivatetypebuiltins.h
@true
@@ -1068,7 +1024,7 @@ endif
dist-hook: ../build/win32/vs9/gtk.vcproj ../build/win32/vs10/gtk.vcxproj ../build/win32/vs10/gtk.vcxproj.filters
../build/win32/vs9/gtk.vcproj: ../build/win32/vs9/gtk.vcprojin
for F in `echo $(gtk_base_c_sources) $(gtk_os_win32_c_sources) $(gtk_use_win32_c_sources) | tr '/' '\\'`; do \
for F in $(gtk_base_c_sources) $(gtk_os_win32_c_sources) $(gtk_use_win32_c_sources); do \
case $$F in \
*.c) echo ' <File RelativePath="..\..\..\gtk\'$$F'" />' \
;; \
@@ -1078,7 +1034,7 @@ dist-hook: ../build/win32/vs9/gtk.vcproj ../build/win32/vs10/gtk.vcxproj ../buil
rm libgtk.sourcefiles
../build/win32/vs10/gtk.vcxproj: ../build/win32/vs10/gtk.vcxprojin
for F in `echo $(gtk_base_c_sources) $(gtk_os_win32_c_sources) $(gtk_use_win32_c_sources) | tr '/' '\\'`; do \
for F in $(gtk_base_c_sources) $(gtk_os_win32_c_sources) $(gtk_use_win32_c_sources); do \
case $$F in \
*.c) echo ' <ClCompile Include="..\..\..\gtk\'$$F'" />' \
;; \
@@ -1088,7 +1044,7 @@ dist-hook: ../build/win32/vs9/gtk.vcproj ../build/win32/vs10/gtk.vcxproj ../buil
rm libgtk.vs10.sourcefiles
../build/win32/vs10/gtk.vcxproj.filters: ../build/win32/vs10/gtk.vcxproj.filtersin
for F in `echo $(gtk_base_c_sources) $(gtk_os_win32_c_sources) $(gtk_use_win32_c_sources) | tr '/' '\\'`; do \
for F in $(gtk_base_c_sources) $(gtk_os_win32_c_sources) $(gtk_use_win32_c_sources); do \
case $$F in \
*.c) echo ' <ClCompile Include="..\..\..\gtk\'$$F'"><Filter>Source Files</Filter></ClCompile>' \
;; \
@@ -1531,7 +1487,6 @@ endif
EXTRA_DIST += \
$(STOCK_ICONS) \
$(DND_CURSORS) \
$(GENERATED_ICONS) \
gtk.def \
gtk-win32.rc \
@@ -1543,8 +1498,6 @@ EXTRA_DIST += \
gtkprint-win32.c \
gtksearchenginequartz.h \
gtk.css.raleigh \
gtk.gresource.xml \
gtk-default.css \
gtk-keys.css.default \
gtk-keys.css.emacs \
gtk-keys.css.mac \

View File

@@ -29,6 +29,8 @@
static GHashTable *listener_list = NULL;
static gint listener_idx = 1;
static GSList *key_listener_list = NULL;
static guint key_snooper_id = 0;
typedef struct _GailUtilListenerInfo GailUtilListenerInfo;
typedef struct _GailKeyEventInfo GailKeyEventInfo;
@@ -318,6 +320,125 @@ gail_util_remove_global_event_listener (guint remove_listener)
}
}
static AtkKeyEventStruct *
atk_key_event_from_gdk_event_key (GdkEventKey *key)
{
AtkKeyEventStruct *event = g_new0 (AtkKeyEventStruct, 1);
switch (key->type)
{
case GDK_KEY_PRESS:
event->type = ATK_KEY_EVENT_PRESS;
break;
case GDK_KEY_RELEASE:
event->type = ATK_KEY_EVENT_RELEASE;
break;
default:
g_assert_not_reached ();
return NULL;
}
event->state = key->state;
event->keyval = key->keyval;
event->length = key->length;
if (key->string && key->string [0] &&
(key->state & GDK_CONTROL_MASK ||
g_unichar_isgraph (g_utf8_get_char (key->string))))
{
event->string = key->string;
}
else if (key->type == GDK_KEY_PRESS ||
key->type == GDK_KEY_RELEASE)
{
event->string = gdk_keyval_name (key->keyval);
}
event->keycode = key->hardware_keycode;
event->timestamp = key->time;
#ifdef GAIL_DEBUG
g_print ("GailKey:\tsym %u\n\tmods %x\n\tcode %u\n\ttime %lx\n",
(unsigned int) event->keyval,
(unsigned int) event->state,
(unsigned int) event->keycode,
(unsigned long int) event->timestamp);
#endif
return event;
}
typedef struct {
AtkKeySnoopFunc func;
gpointer data;
guint key;
} KeyEventListener;
static gint
gail_key_snooper (GtkWidget *the_widget,
GdkEventKey *event,
gpointer data)
{
GSList *l;
AtkKeyEventStruct *atk_event;
gboolean result;
atk_event = atk_key_event_from_gdk_event_key (event);
result = FALSE;
for (l = key_listener_list; l; l = l->next)
{
KeyEventListener *listener = l->data;
result |= listener->func (atk_event, listener->data);
}
g_free (atk_event);
return result;
}
static guint
gail_util_add_key_event_listener (AtkKeySnoopFunc listener_func,
gpointer listener_data)
{
static guint key = 0;
KeyEventListener *listener;
if (key_snooper_id == 0)
key_snooper_id = gtk_key_snooper_install (gail_key_snooper, NULL);
key++;
listener = g_slice_new0 (KeyEventListener);
listener->func = listener_func;
listener->data = listener_data;
listener->key = key;
key_listener_list = g_slist_append (key_listener_list, listener);
return key;
}
static void
gail_util_remove_key_event_listener (guint listener_key)
{
GSList *l;
for (l = key_listener_list; l; l = l->next)
{
KeyEventListener *listener = l->data;
if (listener->key == listener_key)
{
g_slice_free (KeyEventListener, listener);
key_listener_list = g_slist_delete_link (key_listener_list, l);
break;
}
}
if (key_listener_list == NULL)
{
gtk_key_snooper_remove (key_snooper_id);
key_snooper_id = 0;
}
}
static AtkObject *
gail_util_get_root (void)
{
@@ -351,6 +472,8 @@ _gail_util_install (void)
atk_class->add_global_event_listener = gail_util_add_global_event_listener;
atk_class->remove_global_event_listener = gail_util_remove_global_event_listener;
atk_class->add_key_event_listener = gail_util_add_key_event_listener;
atk_class->remove_key_event_listener = gail_util_remove_key_event_listener;
atk_class->get_root = gail_util_get_root;
atk_class->get_toolkit_name = gail_util_get_toolkit_name;
atk_class->get_toolkit_version = gail_util_get_toolkit_version;

View File

@@ -31,9 +31,9 @@
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include "gtktextviewaccessible.h"
#include "gtk/gtkwidgetprivate.h"
static void setup_buffer (GtkTextView *view,GtkTextViewAccessible *accessible);
static void insert_text_cb (GtkTextBuffer *buffer,
GtkTextIter *arg1,
gchar *arg2,
@@ -65,6 +65,8 @@ gtk_text_view_accessible_initialize (AtkObject *obj,
{
ATK_OBJECT_CLASS (_gtk_text_view_accessible_parent_class)->initialize (obj, data);
setup_buffer (GTK_TEXT_VIEW (data), GTK_TEXT_VIEW_ACCESSIBLE (obj));
obj->role = ATK_ROLE_TEXT;
}
@@ -83,6 +85,10 @@ gtk_text_view_accessible_notify_gtk (GObject *obj,
editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (obj));
atk_object_notify_state_change (atk_obj, ATK_STATE_EDITABLE, editable);
}
else if (!strcmp (pspec->name, "buffer"))
{
setup_buffer (GTK_TEXT_VIEW (obj), GTK_TEXT_VIEW_ACCESSIBLE (atk_obj));
}
else
GTK_WIDGET_ACCESSIBLE_CLASS (_gtk_text_view_accessible_parent_class)->notify_gtk (obj, pspec);
}
@@ -106,50 +112,12 @@ gtk_text_view_accessible_ref_state_set (AtkObject *accessible)
return state_set;
}
static void
gtk_text_view_accessible_change_buffer (GtkTextViewAccessible *accessible,
GtkTextBuffer *old_buffer,
GtkTextBuffer *new_buffer)
{
if (old_buffer)
{
g_signal_handlers_disconnect_matched (old_buffer, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, accessible);
}
if (new_buffer)
{
g_signal_connect_after (new_buffer, "insert-text", G_CALLBACK (insert_text_cb), accessible);
g_signal_connect (new_buffer, "delete-range", G_CALLBACK (delete_range_cb), accessible);
g_signal_connect_after (new_buffer, "mark-set", G_CALLBACK (mark_set_cb), accessible);
}
}
static void
gtk_text_view_accessible_widget_set (GtkAccessible *accessible)
{
gtk_text_view_accessible_change_buffer (GTK_TEXT_VIEW_ACCESSIBLE (accessible),
NULL,
gtk_text_view_get_buffer (GTK_TEXT_VIEW (gtk_accessible_get_widget (accessible))));
}
static void
gtk_text_view_accessible_widget_unset (GtkAccessible *accessible)
{
gtk_text_view_accessible_change_buffer (GTK_TEXT_VIEW_ACCESSIBLE (accessible),
gtk_text_view_get_buffer (GTK_TEXT_VIEW (gtk_accessible_get_widget (accessible))),
NULL);
}
static void
_gtk_text_view_accessible_class_init (GtkTextViewAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass);
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
accessible_class->widget_set = gtk_text_view_accessible_widget_set;
accessible_class->widget_unset = gtk_text_view_accessible_widget_unset;
class->ref_state_set = gtk_text_view_accessible_ref_state_set;
class->initialize = gtk_text_view_accessible_initialize;
@@ -161,6 +129,20 @@ _gtk_text_view_accessible_init (GtkTextViewAccessible *accessible)
{
}
static void
setup_buffer (GtkTextView *view,
GtkTextViewAccessible *accessible)
{
GtkTextBuffer *buffer;
buffer = gtk_text_view_get_buffer (view);
/* Set up signal callbacks */
g_signal_connect_after (buffer, "insert-text", G_CALLBACK (insert_text_cb), view);
g_signal_connect (buffer, "delete-range", G_CALLBACK (delete_range_cb), view);
g_signal_connect_after (buffer, "mark-set", G_CALLBACK (mark_set_cb), view);
}
static gchar *
gtk_text_view_accessible_get_text (AtkText *text,
gint start_offset,
@@ -1745,10 +1727,13 @@ insert_text_cb (GtkTextBuffer *buffer,
gint len,
gpointer data)
{
GtkTextViewAccessible *accessible = data;
GtkTextView *view = data;
GtkTextViewAccessible *accessible;
gint position;
gint length;
accessible = GTK_TEXT_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (view)));
position = gtk_text_iter_get_offset (iter);
length = g_utf8_strlen (text, len);
@@ -1763,9 +1748,12 @@ delete_range_cb (GtkTextBuffer *buffer,
GtkTextIter *end,
gpointer data)
{
GtkTextViewAccessible *accessible = data;
GtkTextView *view = data;
GtkTextViewAccessible *accessible;
gint offset, length;
accessible = GTK_TEXT_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (view)));
offset = gtk_text_iter_get_offset (start);
length = gtk_text_iter_get_offset (end) - offset;
@@ -1783,7 +1771,10 @@ mark_set_cb (GtkTextBuffer *buffer,
GtkTextMark *mark,
gpointer data)
{
GtkTextViewAccessible *accessible = data;
GtkTextView *text = data;
GtkTextViewAccessible *accessible;
accessible = GTK_TEXT_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (text)));
/*
* Only generate the signal for the "insert" mark, which
@@ -1938,22 +1929,3 @@ atk_streamable_content_interface_init (AtkStreamableContentIface *iface)
iface->get_mime_type = gail_streamable_content_get_mime_type;
iface->get_stream = gail_streamable_content_get_stream;
}
void
_gtk_text_view_accessible_set_buffer (GtkTextView *textview,
GtkTextBuffer *old_buffer)
{
GtkTextViewAccessible *accessible;
g_return_if_fail (GTK_IS_TEXT_VIEW (textview));
g_return_if_fail (old_buffer == NULL || GTK_IS_TEXT_BUFFER (old_buffer));
accessible = GTK_TEXT_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (textview)));
if (accessible == NULL)
return;
gtk_text_view_accessible_change_buffer (accessible,
old_buffer,
gtk_text_view_get_buffer (textview));
}

View File

@@ -47,11 +47,7 @@ struct _GtkTextViewAccessibleClass
GtkContainerAccessibleClass parent_class;
};
GType _gtk_text_view_accessible_get_type (void);
void _gtk_text_view_accessible_set_buffer (GtkTextView *textview,
GtkTextBuffer *old_buffer);
GType _gtk_text_view_accessible_get_type (void);
G_END_DECLS

View File

@@ -197,21 +197,20 @@ find_label (GtkWidget *widget)
GList *labels;
GtkWidget *label;
GtkWidget *temp_widget;
GList *ptr;
labels = gtk_widget_list_mnemonic_labels (widget);
label = NULL;
ptr = labels;
while (ptr)
if (labels)
{
if (ptr->data)
if (labels->data)
{
label = ptr->data;
break;
if (labels->next)
g_warning ("Widget (%s) has more than one label", G_OBJECT_TYPE_NAME (widget));
else
label = labels->data;
}
ptr = ptr->next;
g_list_free (labels);
}
g_list_free (labels);
/* Ignore a label within a button; bug #136602 */
if (label && GTK_IS_BUTTON (widget))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 B

View File

@@ -1,288 +0,0 @@
/*
* Copyright © 2012 Canonical Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* licence or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
* USA.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#include "config.h"
#include "gsimpleactionobserver.h"
#include "gactionobservable.h"
typedef GObjectClass GSimpleActionObserverClass;
struct _GSimpleActionObserver
{
GObject parent_instance;
GActionGroup *action_group;
gchar *action_name;
GVariant *target;
gboolean can_activate;
gboolean active;
gboolean enabled;
gint reporting;
};
static void g_simple_action_observer_init_iface (GActionObserverInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GSimpleActionObserver, g_simple_action_observer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_OBSERVER, g_simple_action_observer_init_iface));
enum
{
PROP_0,
PROP_ACTIVE,
PROP_ENABLED,
N_PROPS
};
static GParamSpec *g_simple_action_observer_pspecs[N_PROPS];
static void
g_simple_action_observer_action_added (GActionObserver *g_observer,
GActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state)
{
GSimpleActionObserver *observer = G_SIMPLE_ACTION_OBSERVER (g_observer);
gboolean active;
/* we can only activate if we have the correct type of parameter */
observer->can_activate = (observer->target == NULL && parameter_type == NULL) ||
(observer->target != NULL && parameter_type != NULL &&
g_variant_is_of_type (observer->target, parameter_type));
if (observer->can_activate)
{
if (observer->target != NULL && state != NULL)
active = g_variant_equal (state, observer->target);
else if (state != NULL && g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN))
active = g_variant_get_boolean (state);
else
active = FALSE;
if (active != observer->active)
{
observer->active = active;
observer->reporting++;
g_object_notify_by_pspec (G_OBJECT (observer), g_simple_action_observer_pspecs[PROP_ACTIVE]);
observer->reporting--;
}
if (enabled != observer->enabled)
{
observer->enabled = enabled;
g_object_notify_by_pspec (G_OBJECT (observer), g_simple_action_observer_pspecs[PROP_ENABLED]);
}
}
}
static void
g_simple_action_observer_action_enabled_changed (GActionObserver *g_observer,
GActionObservable *observable,
const gchar *action_name,
gboolean enabled)
{
GSimpleActionObserver *observer = G_SIMPLE_ACTION_OBSERVER (g_observer);
if (!observer->can_activate)
return;
if (enabled != observer->enabled)
{
observer->enabled = enabled;
g_object_notify_by_pspec (G_OBJECT (observer), g_simple_action_observer_pspecs[PROP_ENABLED]);
}
}
static void
g_simple_action_observer_action_state_changed (GActionObserver *g_observer,
GActionObservable *observable,
const gchar *action_name,
GVariant *state)
{
GSimpleActionObserver *observer = G_SIMPLE_ACTION_OBSERVER (g_observer);
gboolean active = FALSE;
if (!observer->can_activate)
return;
if (observer->target)
active = g_variant_equal (state, observer->target);
else if (g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN))
active = g_variant_get_boolean (state);
if (active != observer->active)
{
observer->active = active;
observer->reporting++;
g_object_notify_by_pspec (G_OBJECT (observer), g_simple_action_observer_pspecs[PROP_ACTIVE]);
observer->reporting--;
}
}
static void
g_simple_action_observer_action_removed (GActionObserver *g_observer,
GActionObservable *observable,
const gchar *action_name)
{
GSimpleActionObserver *observer = G_SIMPLE_ACTION_OBSERVER (g_observer);
if (!observer->can_activate)
return;
observer->can_activate = FALSE;
if (observer->active)
{
observer->active = FALSE;
observer->reporting++;
g_object_notify_by_pspec (G_OBJECT (observer), g_simple_action_observer_pspecs[PROP_ACTIVE]);
observer->reporting--;
}
if (observer->enabled)
{
observer->enabled = FALSE;
g_object_notify_by_pspec (G_OBJECT (observer), g_simple_action_observer_pspecs[PROP_ENABLED]);
}
}
static void
g_simple_action_observer_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
GSimpleActionObserver *observer = G_SIMPLE_ACTION_OBSERVER (object);
switch (prop_id)
{
case PROP_ACTIVE:
g_value_set_boolean (value, observer->active);
break;
case PROP_ENABLED:
g_value_set_boolean (value, observer->enabled);
break;
default:
g_assert_not_reached ();
}
}
static void
g_simple_action_observer_finalize (GObject *object)
{
GSimpleActionObserver *observer = G_SIMPLE_ACTION_OBSERVER (object);
g_object_unref (observer->action_group);
g_free (observer->action_name);
if (observer->target)
g_variant_unref (observer->target);
G_OBJECT_CLASS (g_simple_action_observer_parent_class)
->finalize (object);
}
static void
g_simple_action_observer_init (GSimpleActionObserver *observer)
{
}
static void
g_simple_action_observer_init_iface (GActionObserverInterface *iface)
{
iface->action_added = g_simple_action_observer_action_added;
iface->action_enabled_changed = g_simple_action_observer_action_enabled_changed;
iface->action_state_changed = g_simple_action_observer_action_state_changed;
iface->action_removed = g_simple_action_observer_action_removed;
}
static void
g_simple_action_observer_class_init (GObjectClass *class)
{
class->get_property = g_simple_action_observer_get_property;
class->finalize = g_simple_action_observer_finalize;
g_simple_action_observer_pspecs[PROP_ACTIVE] = g_param_spec_boolean ("active", "active", "active", FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_simple_action_observer_pspecs[PROP_ENABLED] = g_param_spec_boolean ("enabled", "enabled", "enabled", FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (class, N_PROPS, g_simple_action_observer_pspecs);
}
GSimpleActionObserver *
g_simple_action_observer_new (GActionObservable *observable,
const gchar *action_name,
GVariant *target)
{
GSimpleActionObserver *observer;
const GVariantType *type;
gboolean enabled;
GVariant *state;
observer = g_object_new (G_TYPE_SIMPLE_ACTION_OBSERVER, NULL);
observer->action_group = g_object_ref (observable);
observer->action_name = g_strdup (action_name);
if (target)
observer->target = g_variant_ref_sink (target);
g_action_observable_register_observer (observable, action_name, G_ACTION_OBSERVER (observer));
if (g_action_group_query_action (observer->action_group, action_name, &enabled, &type, NULL, NULL, &state))
{
g_simple_action_observer_action_added (G_ACTION_OBSERVER (observer), observable,
action_name, type, enabled, state);
if (state)
g_variant_unref (state);
}
return observer;
}
void
g_simple_action_observer_activate (GSimpleActionObserver *observer)
{
g_return_if_fail (G_IS_SIMPLE_ACTION_OBSERVER (observer));
if (observer->can_activate && !observer->reporting)
g_action_group_activate_action (G_ACTION_GROUP (observer->action_group),
observer->action_name, observer->target);
}
gboolean
g_simple_action_observer_get_active (GSimpleActionObserver *observer)
{
g_return_val_if_fail (G_IS_SIMPLE_ACTION_OBSERVER (observer), FALSE);
return observer->active;
}
gboolean
g_simple_action_observer_get_enabled (GSimpleActionObserver *observer)
{
g_return_val_if_fail (G_IS_SIMPLE_ACTION_OBSERVER (observer), FALSE);
return observer->enabled;
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright © 2012 Canonical Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* licence or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
* USA.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#ifndef __G_SIMPLE_ACTION_OBSERVER_H__
#define __G_SIMPLE_ACTION_OBSERVER_H__
#include "gactionobserver.h"
G_BEGIN_DECLS
#define G_TYPE_SIMPLE_ACTION_OBSERVER (g_simple_action_observer_get_type ())
#define G_SIMPLE_ACTION_OBSERVER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
G_TYPE_SIMPLE_ACTION_OBSERVER, \
GSimpleActionObserver))
#define G_IS_SIMPLE_ACTION_OBSERVER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
G_TYPE_SIMPLE_ACTION_OBSERVER))
typedef struct _GSimpleActionObserver GSimpleActionObserver;
G_GNUC_INTERNAL
GType g_simple_action_observer_get_type (void);
G_GNUC_INTERNAL
GSimpleActionObserver * g_simple_action_observer_new (GActionObservable *observable,
const gchar *action_name,
GVariant *target);
G_GNUC_INTERNAL
void g_simple_action_observer_activate (GSimpleActionObserver *observer);
G_GNUC_INTERNAL
gboolean g_simple_action_observer_get_active (GSimpleActionObserver *observer);
G_GNUC_INTERNAL
gboolean g_simple_action_observer_get_enabled (GSimpleActionObserver *observer);
G_END_DECLS
#endif /* __G_SIMPLE_ACTION_OBSERVER_H__ */

View File

@@ -1,363 +0,0 @@
@define-color fg_color #000;
@define-color bg_color #dcdad5;
@define-color text_color #000;
@define-color base_color #fff;
@define-color selected_bg_color #4b6983;
@define-color selected_fg_color #fff;
@define-color tooltip_bg_color #eee1b3;
@define-color tooltip_fg_color #000;
@define-color placeholder_text_color #808080;
@define-color info_fg_color rgb (181, 171, 156);
@define-color info_bg_color rgb (252, 252, 189);
@define-color warning_fg_color rgb (173, 120, 41);
@define-color warning_bg_color rgb (250, 173, 61);
@define-color question_fg_color rgb (97, 122, 214);
@define-color question_bg_color rgb (138, 173, 212);
@define-color error_fg_color rgb (166, 38, 38);
@define-color error_bg_color rgb (237, 54, 54);
* {
background-color: @bg_color;
color: @fg_color;
border-color: shade (@bg_color, 0.6);
padding: 2;
border-width: 0;
}
*:prelight {
background-color: shade (@bg_color, 1.05);
color: shade (@fg_color, 1.3);
}
*:selected {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
.expander, GtkTreeView.view.expander {
color: #fff;
}
.expander:prelight,
GtkTreeView.view.expander:selected:prelight {
color: @text_color;
}
.expander:active {
transition: 200ms linear;
}
*:insensitive {
border-color: shade (@bg_color, 0.7);
background-color: shade (@bg_color, 0.9);
color: shade (@bg_color, 0.7);
}
.view {
border-width: 0;
border-radius: 0;
background-color: @base_color;
color: @text_color;
}
.view:selected {
background-color: shade (@bg_color, 0.9);
color: @fg_color;
}
.view:selected:focused {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
.view column:sorted row,
.view column:sorted row:prelight {
background-color: shade (@bg_color, 0.85);
}
.view column:sorted row:nth-child(odd),
.view column:sorted row:nth-child(odd):prelight {
background-color: shade (@bg_color, 0.8);
}
.view row,
.view row:prelight {
background-color: @base_color;
color: @text_color;
}
.view row:nth-child(odd),
.view row:nth-child(odd):prelight {
background-color: shade (@base_color, 0.93);
}
.view row:selected:focused {
background-color: @selected_bg_color;
}
.view row:selected {
background-color: darker (@bg_color);
color: @selected_fg_color;
}
.view.cell.trough,
.view.cell.trough:hover,
.view.cell.trough:selected,
.view.cell.trough:selected:focused {
background-color: @bg_color;
color: @fg_color;
}
.view.cell.progressbar,
.view.cell.progressbar:hover,
.view.cell.progressbar:selected,
.view.cell.progressbar:selected:focused {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
.rubberband {
background-color: alpha (@fg_color, 0.25);
border-color: @fg_color;
border-style: solid;
border-width: 1;
}
.tooltip,
.tooltip * {
background-color: @tooltip_bg_color;
color: @tooltip_fg_color;
border-color: @tooltip_fg_color;
border-width: 1;
border-style: solid;
}
.button,
.slider {
border-style: outset;
border-width: 2;
}
.button:active {
background-color: shade (@bg_color, 0.7);
border-style: inset;
}
.button:prelight,
.slider:prelight {
background-color: @selected_bg_color;
color: @selected_fg_color;
border-color: shade (@selected_bg_color, 0.7);
}
.trough {
background-color: darker (@bg_color);
border-style: inset;
border-width: 1;
padding: 0;
}
.entry {
border-style: inset;
border-width: 2;
background-color: @base_color;
color: @text_color;
}
.entry:insensitive {
background-color: shade (@base_color, 0.9);
color: shade (@base_color, 0.7);
}
.entry:active {
background-color: #c4c2bd;
color: #000;
}
.progressbar,
.entry.progressbar,
.cell.progressbar {
background-color: @selected_bg_color;
border-color: shade (@selected_bg_color, 0.7);
color: @selected_fg_color;
border-style: outset;
border-width: 1;
}
GtkCheckButton:hover,
GtkCheckButton:selected,
GtkRadioButton:hover,
GtkRadioButton:selected {
background-color: shade (@bg_color, 1.05);
}
.check, .radio,
.cell.check, .cell.radio,
.cell.check:hover, .cell.radio:hover {
border-style: solid;
border-width: 1;
background-color: @base_color;
border-color: @fg_color;
}
.check:active, .radio:active,
.check:hover, .radio:hover {
background-color: @base_color;
border-color: @fg_color;
color: @text_color;
}
.check:selected, .radio:selected {
background-color: darker (@bg_color);
color: @selected_fg_color;
border-color: @selected_fg_color;
}
.check:selected:focused, .radio:selected:focused {
background-color: @selected_bg_color;
}
.menuitem.check, .menuitem.radio {
color: @fg_color;
border-style: none;
border-width: 0;
}
.popup {
border-style: outset;
border-width: 1;
}
.viewport {
border-style: inset;
border-width: 2;
}
.notebook {
border-style: outset;
border-width: 1;
}
.frame {
border-style: inset;
border-width: 1;
}
GtkScrolledWindow.frame {
padding: 0;
}
.menu,
.menubar,
.toolbar {
border-style: outset;
border-width: 1;
}
.menu:hover,
.menubar:hover,
.menuitem:hover,
.menuitem.check:hover,
.menuitem.radio:hover {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
GtkSpinButton.button {
border-width: 1;
}
.scale.slider:hover,
GtkSpinButton.button:hover {
background-color: shade (@bg_color, 1.05);
border-color: shade (@bg_color, 0.8);
}
GtkSwitch.trough:active {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
GtkToggleButton.button:inconsistent {
border-style: outset;
border-width: 1px;
background-color: shade (@bg_color, 0.9);
border-color: shade (@bg_color, 0.7);
}
GtkLabel:selected {
background-color: shade (@bg_color, 0.9);
}
GtkLabel:selected:focused {
background-color: @selected_bg_color;
}
.spinner:active {
transition: 750ms linear loop;
}
.info {
background-color: @info_bg_color;
color: @info_fg_color;
}
.warning {
background-color: @warning_bg_color;
color: @warning_fg_color;
}
.question {
background-color: @question_bg_color;
color: @question_fg_color;
}
.error {
background-color: @error_bg_color;
color: @error_fg_color;
}
.highlight {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
.light-area-focus {
color: #000;
}
.dark-area-focus {
color: #fff;
}
GtkCalendar.view {
border-width: 1;
border-style: inset;
padding: 1;
}
GtkCalendar.view:inconsistent {
color: darker (@bg_color);
}
GtkCalendar.header {
background-color: @bg_color;
border-style: outset;
border-width: 2;
}
GtkCalendar.highlight {
border-width: 0;
}
GtkCalendar.button {
background-color: @bg_color;
}
GtkCalendar.button:hover {
background-color: lighter (@bg_color);
color: @fg_color;
}
.menu * {
border-width: 0;
padding: 2;
}

View File

@@ -3,7 +3,7 @@
/* Buttons */
.button {
background-color: transparent;
background-color: none;
background-image: -gtk-win32-theme-part(button, 1 1);
border-width: 0;
-GtkWidget-focus-line-width: 1;
@@ -31,7 +31,7 @@
/* Check buttons */
.check {
background-color: transparent;
background-color: none;
background-image: -gtk-win32-theme-part(button, 3 1);
border-width: 0;
}
@@ -71,7 +71,7 @@
/* Radio buttons */
.radio {
background-color: transparent;
background-color: none;
background-image: -gtk-win32-theme-part(button, 2 1);
border-width: 0;
}
@@ -114,7 +114,7 @@
don't use this atm */
.scrollbar {
background-color: transparent;
background-color: none;
-GtkRange-trough-border: 0;
-GtkRange-arrow-scaling: 0.0;
-GtkRange-slider-width: -gtk-win32-size(scrollbar, 3);
@@ -239,7 +239,7 @@
.spinbutton.button,
.spinbutton.button:focused {
background-color: transparent;
background-color: none;
border-width: 1 1 0 0;
border-style: none;
background-image: -gtk-win32-theme-part(spin, 1 1);
@@ -294,7 +294,7 @@
trough */
.scale {
background-color: transparent;
background-color: none;
-GtkScale-value-spacing: 0;
-GtkScale-slider-length: 9;
-GtkRange-slider-width: 20;
@@ -312,7 +312,7 @@
}
.scale.slider {
background-color: transparent;
background-color: none;
border-width: 0;
color: rgba(0,0,0,0);
background-image: -gtk-win32-theme-part(trackbar, 3 1);
@@ -445,7 +445,7 @@
/* Progress bars */
GtkProgressBar {
background-color: transparent;
background-color: none;
padding: 0;
}
@@ -480,25 +480,25 @@ GtkProgressBar.trough.vertical {
/* Menus */
.menubar {
background-color: transparent;
background-color: none;
border-width: 0;
background-image: -gtk-win32-theme-part(menu, 7 1);
}
.menubar .menuitem {
background-color: transparent;
background-color: none;
border-width: 0;
background-image: -gtk-win32-theme-part(menu, 8 1);
}
.menubar .menuitem:prelight {
background-color: transparent;
background-color: none;
border-width: 0;
background-image: -gtk-win32-theme-part(menu, 8 3);
}
.menuitem:prelight {
background-color: transparent;
background-color: none;
background-image: -gtk-win32-theme-part(menu, 14 2);
}
@@ -506,7 +506,7 @@ GtkProgressBar.trough.vertical {
.menuitem.radio,
.menuitem.radio:prelight,
.menuitem.radio:insensitive {
background-color: transparent;
background-color: none;
background-image: none;
border-width: 0;
}
@@ -564,7 +564,7 @@ GtkProgressBar.trough.vertical {
GtkComboBox.combobox-entry .button {
background-color: transparent;
background-color: none;
border-width: 0;
background-image: -gtk-win32-theme-part(combobox, 1 1);
color: rgba(0, 0, 0, 0);
@@ -588,7 +588,7 @@ GtkComboBox.combobox-entry .button:insensitive {
/* Notebook */
.notebook {
background-color: transparent;
background-color: none;
border-width: 1 3 2 2;
border-style: solid;
background-origin: padding-box;
@@ -600,7 +600,7 @@ GtkComboBox.combobox-entry .button:insensitive {
}
.notebook tab {
background-color: transparent;
background-color: none;
border-width: 0;
background-image: -gtk-win32-theme-part(tab, 1 1);
}
@@ -625,14 +625,14 @@ GtkComboBox.combobox-entry .button:insensitive {
/* Toolbar */
.toolbar {
background-color: transparent;
background-color: none;
border-width: 0;
background-image: -gtk-win32-theme-part(rebar, 6 1);
}
.toolbar .button,
.toolbar .button:focused {
background-color: transparent;
background-color: none;
background-image: -gtk-win32-theme-part(toolbar, 1 1);
}
@@ -657,7 +657,7 @@ GtkComboBox.combobox-entry .button:insensitive {
column-header .button,
column-header .button:focus {
background-color: transparent;
background-color: none;
border-width: 0;
background-image: -gtk-win32-theme-part(header, 1 1);
}

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/libgtk">
<file>gtk-default.css</file>
<file>gtk-win32.css</file>
<file alias="cursor/dnd-ask.png">cursor_dnd_ask.png</file>
<file alias="cursor/dnd-link.png">cursor_dnd_link.png</file>
<file alias="cursor/dnd-none.png">cursor_dnd_none.png</file>
<file alias="cursor/dnd-move.png">cursor_dnd_move.png</file>
<file alias="cursor/dnd-copy.png">cursor_dnd_copy.png</file>
</gresource>
</gresources>

View File

@@ -36,7 +36,6 @@
#include <gtk/gtkaccelmap.h>
#include <gtk/gtkaccessible.h>
#include <gtk/gtkaction.h>
#include <gtk/gtkactionable.h>
#include <gtk/gtkactiongroup.h>
#include <gtk/gtkactivatable.h>
#include <gtk/gtkadjustment.h>

View File

@@ -85,13 +85,6 @@ gtk_accessible_connect_widget_destroyed
gtk_accessible_get_type
gtk_accessible_get_widget
gtk_accessible_set_widget
gtk_actionable_get_action_name
gtk_actionable_get_action_target_value
gtk_actionable_get_type
gtk_actionable_set_action_name
gtk_actionable_set_action_target
gtk_actionable_set_action_target_value
gtk_actionable_set_detailed_action_name
gtk_action_activate
gtk_action_block_activate
gtk_action_connect_accelerator
@@ -226,21 +219,15 @@ gtk_app_chooser_widget_set_show_other
gtk_app_chooser_widget_set_show_recommended
gtk_application_add_accelerator
gtk_application_add_window
gtk_application_end_session
gtk_application_end_session_style_get_type
gtk_application_get_app_menu
gtk_application_get_menubar
gtk_application_get_type
gtk_application_get_windows
gtk_application_inhibit
gtk_application_inhibit_flags_get_type
gtk_application_is_inhibited
gtk_application_new
gtk_application_remove_accelerator
gtk_application_remove_window
gtk_application_set_app_menu
gtk_application_set_menubar
gtk_application_uninhibit
gtk_application_window_get_show_menubar
gtk_application_window_get_type
gtk_application_window_new
@@ -324,10 +311,8 @@ gtk_buildable_parser_finished
gtk_buildable_set_buildable_property
gtk_buildable_set_name
gtk_builder_add_from_file
gtk_builder_add_from_resource
gtk_builder_add_from_string
gtk_builder_add_objects_from_file
gtk_builder_add_objects_from_resource
gtk_builder_add_objects_from_string
gtk_builder_connect_signals
gtk_builder_connect_signals_full
@@ -721,7 +706,6 @@ gtk_container_set_reallocate_redraws
gtk_container_set_resize_mode
gtk_container_unset_focus_chain
gtk_corner_type_get_type
gtk_css_image_get_parser_type
gtk_css_provider_error_get_type
gtk_css_provider_error_quark
gtk_css_provider_get_default
@@ -757,7 +741,6 @@ gtk_gradient_new_linear
gtk_gradient_new_radial
gtk_gradient_ref
gtk_gradient_resolve
gtk_gradient_resolve_for_context
gtk_gradient_to_string
gtk_gradient_unref
gtk_dialog_add_action_widget
@@ -1368,7 +1351,6 @@ gtk_image_new_from_gicon
gtk_image_new_from_icon_name
gtk_image_new_from_icon_set
gtk_image_new_from_pixbuf
gtk_image_new_from_resource
gtk_image_new_from_stock
gtk_image_set_from_animation
gtk_image_set_from_file
@@ -1376,7 +1358,6 @@ gtk_image_set_from_gicon
gtk_image_set_from_icon_name
gtk_image_set_from_icon_set
gtk_image_set_from_pixbuf
gtk_image_set_from_resource
gtk_image_set_from_stock
gtk_image_set_pixel_size
gtk_image_type_get_type
@@ -2551,11 +2532,9 @@ gtk_style_context_get_font
gtk_style_context_get_junction_sides
gtk_style_context_get_margin
gtk_style_context_get_padding
gtk_style_context_get_parent
gtk_style_context_get_path
gtk_style_context_get_property
gtk_style_context_get_screen
gtk_style_context_get_section
gtk_style_context_get_state
gtk_style_context_get_style
gtk_style_context_get_style_property
@@ -2584,7 +2563,6 @@ gtk_style_context_scroll_animations
gtk_style_context_set_background
gtk_style_context_set_direction
gtk_style_context_set_junction_sides
gtk_style_context_set_parent
gtk_style_context_set_path
gtk_style_context_set_screen
gtk_style_context_set_state
@@ -3486,7 +3464,6 @@ gtk_tree_view_unset_rows_drag_source
gtk_true
gtk_ui_manager_add_ui
gtk_ui_manager_add_ui_from_file
gtk_ui_manager_add_ui_from_resource
gtk_ui_manager_add_ui_from_string
gtk_ui_manager_ensure_update
gtk_ui_manager_get_accel_group
@@ -3825,7 +3802,6 @@ gtk_window_get_skip_pager_hint
gtk_window_get_skip_taskbar_hint
gtk_window_get_title
gtk_window_get_transient_for
gtk_window_get_attached_to
gtk_window_get_type
gtk_window_get_type_hint
gtk_window_get_urgency_hint
@@ -3897,7 +3873,6 @@ gtk_window_set_skip_taskbar_hint
gtk_window_set_startup_id
gtk_window_set_title
gtk_window_set_transient_for
gtk_window_set_attached_to
gtk_window_set_type_hint
gtk_window_set_urgency_hint
gtk_window_set_wmclass

View File

@@ -198,7 +198,7 @@ gtk_accessible_set_widget (GtkAccessible *accessible,
priv->widget = widget;
if (widget)
if (widget);
klass->widget_set (accessible);
g_object_notify (G_OBJECT (accessible), "widget");

View File

@@ -1,261 +0,0 @@
/*
* Copyright © 2012 Canonical Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* licence or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
* USA.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#include "config.h"
#include "gtkactionable.h"
#include "gtkwidget.h"
#include "gtkintl.h"
/**
* SECTION:gtkactionable
* @title: GtkActionable
* @short_description: an interface for widgets that can be associated
* with actions
*
* This interface provides a convenient way of associating widgets with
* actions on a #GtkApplicationWindow or #GtkApplication.
*
* It primarily consists of two properties: "action-name" and
* "action-target". There are also some convenience APIs for setting
* these properties.
*
* This interface is presently only meaningful if used on a widget that
* is (or will be) located inside of a #GtkApplicationWindow and can
* only be used to associate the widget with actions on that window, or
* its associated #GtkApplication.
*
* Since: 3.4
**/
/**
* GtkActionable:
*
* An opaque pointer type.
**/
/**
* GtkActionableInterface:
* @get_action_name: virtual pointer for gtk_actionable_get_action_name
* @set_action_name: virtual pointer for gtk_actionable_set_action_name
* @get_action_target_value: virtual pointer for gtk_actionable_get_action_target_value
* @set_action_target_value: virtual pointer for gtk_actionable_set_action_target_value
*
* The interface vtable for #GtkActionable.
**/
G_DEFINE_INTERFACE (GtkActionable, gtk_actionable, GTK_TYPE_WIDGET)
static void
gtk_actionable_default_init (GtkActionableInterface *iface)
{
g_object_interface_install_property (iface,
g_param_spec_string ("action-name", P_("action name"),
P_("The name of the associated action, like 'app.quit'"),
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_variant ("action-target", P_("action target value"),
P_("The parameter for action invocations"),
G_VARIANT_TYPE_ANY, NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
/**
* gtk_actionable_get_action_name:
* @actionable: a #GtkActionable widget
*
* Gets the action name for @actionable.
*
* See gtk_actionable_set_action_name() for more information.
*
* Returns: the action name, or %NULL if none is set
*
* Since: 3.4
**/
const gchar *
gtk_actionable_get_action_name (GtkActionable *actionable)
{
g_return_val_if_fail (GTK_IS_ACTIONABLE (actionable), NULL);
return GTK_ACTIONABLE_GET_IFACE (actionable)
->get_action_name (actionable);
}
/**
* gtk_actionable_set_action_name:
* @actionable: a #GtkActionable widget
* @action_name: an action name, or %NULL
*
* Specifies the name of the action with which this widget should be
* associated. If @action_name is %NULL then the widget will be
* unassociated from any previous action.
*
* Usually this function is used when the widget is located (or will be
* located) within the hierarchy of a #GtkApplicationWindow.
*
* Names are of the form "win.save" or "app.quit" for actions on the
* containing #GtkApplicationWindow or its associated #GtkApplication,
* respectively. This is the same form used for actions in the #GMenu
* associated with the window.
*
* Since: 3.4
**/
void
gtk_actionable_set_action_name (GtkActionable *actionable,
const gchar *action_name)
{
g_return_if_fail (GTK_IS_ACTIONABLE (actionable));
GTK_ACTIONABLE_GET_IFACE (actionable)
->set_action_name (actionable, action_name);
}
/**
* gtk_actionable_get_action_target_value:
* @actionable: a #GtkActionable widget
*
* Gets the current target value of @actionabe.
*
* See gtk_actionable_set_target_value() for more information.
*
* Returns: (transfer none): the current target value
*
* Since: 3.4
**/
GVariant *
gtk_actionable_get_action_target_value (GtkActionable *actionable)
{
g_return_val_if_fail (GTK_IS_ACTIONABLE (actionable), NULL);
return GTK_ACTIONABLE_GET_IFACE (actionable)
->get_action_target_value (actionable);
}
/**
* gtk_actionable_set_action_target_value:
* @actionable: a #GtkActionable widget
* @target_value: a #GVariant to set as the target value, or %NULL
*
* Sets the target value of an actionable widget.
*
* If @target_value is %NULL then the target value is unset.
*
* The target value has two purposes. First, it is used as the
* parameter to activation of the action associated with the
* #GtkActionable widget. Second, it is used to determine if the widget
* should be rendered as "active" -- the widget is active if the state
* is equal to the given target.
*
* Consider the example of associating a set of buttons with a #GAction
* with string state in a typical "radio button" situation. Each button
* will be associated with the same action, but with a different target
* value for that action. Clicking on a particular button will activate
* the action with the target of that button, which will typically cause
* the action's state to change to that value. Since the action's state
* is now equal to the target value of the button, the button will now
* be rendered as active (and the other buttons, with different targets,
* rendered inactive).
*
* Since: 3.4
**/
void
gtk_actionable_set_action_target_value (GtkActionable *actionable,
GVariant *target_value)
{
g_return_if_fail (GTK_IS_ACTIONABLE (actionable));
GTK_ACTIONABLE_GET_IFACE (actionable)
->set_action_target_value (actionable, target_value);
}
/**
* gtk_actionable_set_action_target:
* @actionable: a #GtkActionable widget
* @format_string: a GVariant format string
* @...: arguments appropriate for @format_string
*
* Sets the target of an actionable widget.
*
* This is a convenience function that calls g_variant_new() for
* @format_string and uses the result to call
* gtk_actionable_set_action_target_value().
*
* If you are setting a string-valued target and want to set the action
* name at the same time, you can use
* gtk_actionable_set_detailed_action_name ().
*
* Since: 3.4
**/
void
gtk_actionable_set_action_target (GtkActionable *actionable,
const gchar *format_string,
...)
{
va_list ap;
va_start (ap, format_string);
gtk_actionable_set_action_target_value (actionable, g_variant_new_va (format_string, NULL, &ap));
va_end (ap);
}
/**
* gtk_actionable_set_detailed_action_name:
* @actionable: a #GtkActionable widget
* @detailed_action_name: the detailed action name
*
* Sets the action-name and associated string target value of an
* actionable widget.
*
* This allows for the effect of both gtk_actionable_set_action_name()
* and gtk_actionable_set_target() in the common case that the target is
* string-valued.
*
* @detailed_action_name is a string of the form
* <literal>"action::target"</literal> where <literal>action</literal>
* is the action name and <literal>target</literal> is the string to use
* as the target.
*
* Since: 3.4
**/
void
gtk_actionable_set_detailed_action_name (GtkActionable *actionable,
const gchar *detailed_action_name)
{
gchar **parts;
g_return_if_fail (GTK_IS_ACTIONABLE (actionable));
if (detailed_action_name == NULL)
{
gtk_actionable_set_action_name (actionable, NULL);
gtk_actionable_set_action_target_value (actionable, NULL);
return;
}
parts = g_strsplit (detailed_action_name, "::", 2);
gtk_actionable_set_action_name (actionable, parts[0]);
if (parts[0] && parts[1])
gtk_actionable_set_action_target (actionable, "s", parts[1]);
else
gtk_actionable_set_action_target_value (actionable, NULL);
g_strfreev (parts);
}

View File

@@ -1,71 +0,0 @@
/*
* Copyright © 2012 Canonical Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* licence or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
* USA.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#ifndef __GTK_ACTIONABLE_H__
#define __GTK_ACTIONABLE_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define GTK_TYPE_ACTIONABLE (gtk_actionable_get_type ())
#define GTK_ACTIONABLE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
GTK_TYPE_ACTIONABLE, GtkActionable))
#define GTK_IS_ACTIONABLE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
GTK_TYPE_ACTIONABLE))
#define GTK_ACTIONABLE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
GTK_TYPE_ACTIONABLE, GtkActionableInterface))
typedef struct _GtkActionableInterface GtkActionableInterface;
typedef struct _GtkActionable GtkActionable;
struct _GtkActionableInterface
{
GTypeInterface g_iface;
const gchar * (* get_action_name) (GtkActionable *actionable);
void (* set_action_name) (GtkActionable *actionable,
const gchar *action_name);
GVariant * (* get_action_target_value) (GtkActionable *actionable);
void (* set_action_target_value) (GtkActionable *actionable,
GVariant *action_target_value);
};
GType gtk_actionable_get_type (void) G_GNUC_CONST;
const gchar * gtk_actionable_get_action_name (GtkActionable *actionable);
void gtk_actionable_set_action_name (GtkActionable *actionable,
const gchar *action_name);
GVariant * gtk_actionable_get_action_target_value (GtkActionable *actionable);
void gtk_actionable_set_action_target_value (GtkActionable *actionable,
GVariant *target_value);
void gtk_actionable_set_action_target (GtkActionable *actionable,
const gchar *format_string,
...);
void gtk_actionable_set_detailed_action_name (GtkActionable *actionable,
const gchar *detailed_action_name);
G_END_DECLS
#endif /* __GTK_ACTIONABLE_H__ */

View File

@@ -34,13 +34,10 @@
#include "gtkmain.h"
#include "gtkaccelmapprivate.h"
#include "gactionmuxer.h"
#include "gtkintl.h"
#ifdef GDK_WINDOWING_QUARTZ
#include "gtkquartz-menu.h"
#import <Cocoa/Cocoa.h>
#include <Carbon/Carbon.h>
#include "gtkmessagedialog.h"
#endif
#include <gdk/gdk.h>
@@ -58,10 +55,9 @@
* a one-size-fits-all application model.
*
* Currently, GtkApplication handles GTK+ initialization, application
* uniqueness, session management, provides some basic scriptability and
* desktop shell integration by exporting actions and menus and manages a
* list of toplevel windows whose life-cycle is automatically tied to the
* life-cycle of your application.
* uniqueness, provides some basic scriptability and desktop shell integration
* by exporting actions and menus and manages a list of toplevel windows whose
* life-cycle is automatically tied to the life-cycle of your application.
*
* While GtkApplication works fine with plain #GtkWindows, it is recommended
* to use it together with #GtkApplicationWindow.
@@ -76,10 +72,10 @@
* 'open' #GApplication methods.
*
* To set an application menu on a GtkApplication, use
* gtk_application_set_app_menu(). The #GMenuModel that this function
* g_application_set_app_menu(). The #GMenuModel that this function
* expects is usually constructed using #GtkBuilder, as seen in the
* following example. To set a menubar that will be automatically picked
* up by #GApplicationWindows, use gtk_application_set_menubar(). GTK+
* up by #GApplicationWindows, use g_application_set_menubar(). GTK+
* makes these menus appear as expected, depending on the platform
* the application is running on.
*
@@ -102,67 +98,31 @@
* </xi:include>
* </programlisting>
* </example>
*
* GtkApplication optionally registers with a session manager
* of the users session (if you set the #GtkApplication::register-session
* property) and offers various functionality related to the session
* life-cycle.
*
* An application can be informed when the session is about to end
* by connecting to the #GtkApplication::quit signal.
*
* An application can request the session to be ended by calling
* gtk_application_end_session().
*
* An application can block various ways to end the session with
* the gtk_application_inhibit() function. Typical use cases for
* this kind of inhibiting are long-running, uninterruptible operations,
* such as burning a CD or performing a disk backup. The session
* manager may not honor the inhibitor, but it can be expected to
* inform the user about the negative consequences of ending the
* session while inhibitors are present.
*/
enum {
WINDOW_ADDED,
WINDOW_REMOVED,
QUIT,
LAST_SIGNAL
};
static guint gtk_application_signals[LAST_SIGNAL];
enum {
PROP_ZERO,
PROP_REGISTER_SESSION
};
G_DEFINE_TYPE (GtkApplication, gtk_application, G_TYPE_APPLICATION)
struct _GtkApplicationPrivate
{
GList *windows;
gboolean register_session;
#ifdef GDK_WINDOWING_X11
GDBusConnection *session_bus;
GDBusConnection *session;
gchar *window_prefix;
guint next_id;
GDBusProxy *sm_proxy;
GDBusProxy *client_proxy;
gchar *app_id;
gchar *client_path;
#endif
#ifdef GDK_WINDOWING_QUARTZ
GActionMuxer *muxer;
GMenu *combined;
GSList *inhibitors;
gint quit_inhibit;
guint next_cookie;
#endif
};
@@ -171,7 +131,7 @@ static void
gtk_application_window_added_x11 (GtkApplication *application,
GtkWindow *window)
{
if (application->priv->session_bus == NULL)
if (application->priv->session == NULL)
return;
if (GTK_IS_APPLICATION_WINDOW (window))
@@ -191,7 +151,7 @@ gtk_application_window_added_x11 (GtkApplication *application,
window_id = application->priv->next_id++;
window_path = g_strdup_printf ("%s%d", application->priv->window_prefix, window_id);
success = gtk_application_window_publish (app_window, application->priv->session_bus, window_path);
success = gtk_application_window_publish (app_window, application->priv->session, window_path);
g_free (window_path);
}
while (!success);
@@ -202,7 +162,7 @@ static void
gtk_application_window_removed_x11 (GtkApplication *application,
GtkWindow *window)
{
if (application->priv->session_bus == NULL)
if (application->priv->session == NULL)
return;
if (GTK_IS_APPLICATION_WINDOW (window))
@@ -227,18 +187,14 @@ window_prefix_from_appid (const gchar *appid)
return appid_path;
}
static void gtk_application_startup_session_dbus (GtkApplication *app);
static void
gtk_application_startup_x11 (GtkApplication *application)
{
const gchar *application_id;
application_id = g_application_get_application_id (G_APPLICATION (application));
application->priv->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
application->priv->session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
application->priv->window_prefix = window_prefix_from_appid (application_id);
gtk_application_startup_session_dbus (GTK_APPLICATION (application));
}
static void
@@ -246,32 +202,15 @@ gtk_application_shutdown_x11 (GtkApplication *application)
{
g_free (application->priv->window_prefix);
application->priv->window_prefix = NULL;
g_clear_object (&application->priv->session_bus);
g_clear_object (&application->priv->sm_proxy);
g_clear_object (&application->priv->client_proxy);
g_free (application->priv->app_id);
g_free (application->priv->client_path);
if (application->priv->session)
{
g_object_unref (application->priv->session);
application->priv->session = NULL;
}
}
#endif
#ifdef GDK_WINDOWING_QUARTZ
typedef struct {
guint cookie;
GtkApplicationInhibitFlags flags;
char *reason;
GtkWindow *window;
} GtkApplicationQuartzInhibitor;
static void
gtk_application_quartz_inhibitor_free (GtkApplicationQuartzInhibitor *inhibitor)
{
g_free (inhibitor->reason);
g_clear_object (&inhibitor->window);
g_slice_free (GtkApplicationQuartzInhibitor, inhibitor);
}
static void
gtk_application_menu_changed_quartz (GObject *object,
GParamSpec *pspec,
@@ -281,14 +220,12 @@ gtk_application_menu_changed_quartz (GObject *object,
GMenu *combined;
combined = g_menu_new ();
g_menu_append_submenu (combined, "Application", gtk_application_get_app_menu (application));
g_menu_append_submenu (combined, "Application", g_application_get_app_menu (application));
g_menu_append_section (combined, NULL, gtk_application_get_menubar (application));
gtk_quartz_set_main_menu (G_MENU_MODEL (combined), G_ACTION_OBSERVABLE (application->priv->muxer));
}
static void gtk_application_startup_session_quartz (GtkApplication *app);
static void
gtk_application_startup_quartz (GtkApplication *application)
{
@@ -300,8 +237,6 @@ gtk_application_startup_quartz (GtkApplication *application)
g_signal_connect (application, "notify::app-menu", G_CALLBACK (gtk_application_menu_changed_quartz), NULL);
g_signal_connect (application, "notify::menubar", G_CALLBACK (gtk_application_menu_changed_quartz), NULL);
gtk_application_menu_changed_quartz (G_OBJECT (application), NULL, NULL);
gtk_application_startup_session_quartz (application);
}
static void
@@ -311,10 +246,6 @@ gtk_application_shutdown_quartz (GtkApplication *application)
g_object_unref (application->priv->muxer);
application->priv->muxer = NULL;
g_slist_free_full (application->priv->inhibitors,
(GDestroyNotify) gtk_application_quartz_inhibitor_free);
application->priv->inhibitors = NULL;
}
static void
@@ -554,61 +485,12 @@ gtk_application_notify (GObject *object,
G_OBJECT_CLASS (gtk_application_parent_class)->notify (object, pspec);
}
static void
gtk_application_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkApplication *application = GTK_APPLICATION (object);
switch (prop_id)
{
case PROP_REGISTER_SESSION:
g_value_set_boolean (value, application->priv->register_session);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_application_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkApplication *application = GTK_APPLICATION (object);
switch (prop_id)
{
case PROP_REGISTER_SESSION:
application->priv->register_session = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_application_quit (GtkApplication *app)
{
/* we are asked to quit, so don't linger */
g_application_set_inactivity_timeout (G_APPLICATION (app), 0);
}
static void
gtk_application_class_init (GtkApplicationClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GApplicationClass *application_class = G_APPLICATION_CLASS (class);
object_class->get_property = gtk_application_get_property;
object_class->set_property = gtk_application_set_property;
object_class->notify = gtk_application_notify;
application_class->add_platform_data = gtk_application_add_platform_data;
@@ -619,7 +501,6 @@ gtk_application_class_init (GtkApplicationClass *class)
class->window_added = gtk_application_window_added;
class->window_removed = gtk_application_window_removed;
class->quit = gtk_application_quit;
g_type_class_add_private (class, sizeof (GtkApplicationPrivate));
@@ -657,47 +538,6 @@ gtk_application_class_init (GtkApplicationClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GTK_TYPE_WINDOW);
/**
* GtkApplication::quit:
* @application: the #GtkApplication
*
* Emitted when the session manager wants the application to quit
* (generally because the user is logging out). The application
* should exit as soon as possible after receiving this signal; if
* it does not, the session manager may choose to forcibly kill it.
*
* Normally, an application would only be sent a ::quit if there
* are no inhibitors (see gtk_application_inhibit()).
* However, this is not guaranteed; in some situations the
* session manager may decide to end the session without giving
* applications a chance to object.
*
* To receive this signal, you need to set the
* #GtkApplication::register-session property
* when creating the application object.
*
* Since: 3.4
*/
gtk_application_signals[QUIT] =
g_signal_new ("quit", GTK_TYPE_APPLICATION, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkApplicationClass, quit),
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GtkApplication::register-session:
*
* Set this property to %TRUE to register with the session manager
* and receive the #GtkApplication::quit signal when the session
* is about to end.
*
* Since: 3.4
*/
g_object_class_install_property (object_class, PROP_REGISTER_SESSION,
g_param_spec_boolean ("register-session",
P_("Register session"),
P_("Register with the session manager"),
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
/**
@@ -721,8 +561,6 @@ gtk_application_class_init (GtkApplicationClass *class)
* The application id must be valid. See g_application_id_is_valid().
*
* Returns: a new #GtkApplication instance
*
* Since: 3.0
*/
GtkApplication *
gtk_application_new (const gchar *application_id,
@@ -842,8 +680,8 @@ gtk_application_get_windows (GtkApplication *application)
* with a "win." prefix.
*
* GtkApplication also extracts accelerators out of 'accel' attributes
* in the #GMenuModels passed to gtk_application_set_app_menu() and
* gtk_application_set_menubar(), which is usually more convenient
* in the #GMenuModels passed to g_application_set_app_menu() and
* g_application_set_menubar(), which is usually more convenient
* than calling this function for each accelerator.
*
* Since: 3.4
@@ -945,7 +783,7 @@ gtk_application_set_app_menu (GtkApplication *application,
* @application: a #GtkApplication
*
* Returns the menu model that has been set with
* gtk_application_set_app_menu().
* g_application_set_app_menu().
*
* Returns: (transfer none): the application menu of @application
*
@@ -995,7 +833,7 @@ gtk_application_set_menubar (GtkApplication *application,
* @application: a #GtkApplication
*
* Returns the menu model that has been set with
* gtk_application_set_menubar().
* g_application_set_menubar().
*
* Returns: (transfer none): the menubar for windows of @application
*
@@ -1013,617 +851,3 @@ gtk_application_get_menubar (GtkApplication *application)
return menubar;
}
#if defined(GDK_WINDOWING_X11)
/* D-Bus Session Management
*
* The protocol and the D-Bus API are described here:
* http://live.gnome.org/SessionManagement/GnomeSession
* http://people.gnome.org/~mccann/gnome-session/docs/gnome-session.html
*/
static void
unregister_client (GtkApplication *app)
{
GError *error = NULL;
g_debug ("Unregistering client");
g_dbus_proxy_call_sync (app->priv->sm_proxy,
"UnregisterClient",
g_variant_new ("(o)", app->priv->client_path),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&error);
if (error)
{
g_warning ("Failed to unregister client: %s", error->message);
g_error_free (error);
}
g_clear_object (&app->priv->client_proxy);
g_free (app->priv->client_path);
app->priv->client_path = NULL;
}
static void
gtk_application_quit_response (GtkApplication *application,
gboolean will_quit,
const gchar *reason)
{
g_debug ("Calling EndSessionResponse %d '%s'", will_quit, reason);
g_dbus_proxy_call (application->priv->client_proxy,
"EndSessionResponse",
g_variant_new ("(bs)", will_quit, reason ? reason : ""),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL, NULL, NULL);
}
static void
client_proxy_signal (GDBusProxy *proxy,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters,
GtkApplication *app)
{
if (strcmp (signal_name, "QueryEndSession") == 0)
{
g_debug ("Received QueryEndSession");
gtk_application_quit_response (app, TRUE, NULL);
}
else if (strcmp (signal_name, "CancelEndSession") == 0)
{
g_debug ("Received CancelEndSession");
}
else if (strcmp (signal_name, "EndSession") == 0)
{
g_debug ("Received EndSession");
gtk_application_quit_response (app, TRUE, NULL);
unregister_client (app);
g_signal_emit (app, gtk_application_signals[QUIT], 0);
}
else if (strcmp (signal_name, "Stop") == 0)
{
g_debug ("Received Stop");
unregister_client (app);
g_signal_emit (app, gtk_application_signals[QUIT], 0);
}
}
static void
gtk_application_startup_session_dbus (GtkApplication *app)
{
static gchar *client_id;
GError *error = NULL;
GVariant *res;
if (app->priv->session_bus == NULL)
return;
if (client_id == NULL)
{
const gchar *desktop_autostart_id;
desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
/* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to
* use the same client id.
*/
g_unsetenv ("DESKTOP_AUTOSTART_ID");
client_id = g_strdup (desktop_autostart_id ? desktop_autostart_id : "");
}
g_debug ("Connecting to session manager");
app->priv->sm_proxy = g_dbus_proxy_new_sync (app->priv->session_bus,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
"org.gnome.SessionManager",
NULL,
&error);
if (error)
{
g_warning ("Failed to get a session proxy: %s", error->message);
g_error_free (error);
return;
}
/* FIXME: should we reuse the D-Bus application id here ? */
app->priv->app_id = g_strdup (g_get_prgname ());
if (!app->priv->register_session)
return;
g_debug ("Registering client '%s' '%s'", app->priv->app_id, client_id);
res = g_dbus_proxy_call_sync (app->priv->sm_proxy,
"RegisterClient",
g_variant_new ("(ss)", app->priv->app_id, client_id),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&error);
if (error)
{
g_warning ("Failed to register client: %s", error->message);
g_error_free (error);
g_clear_object (&app->priv->sm_proxy);
return;
}
g_variant_get (res, "(o)", &app->priv->client_path);
g_variant_unref (res);
g_debug ("Registered client at '%s'", app->priv->client_path);
app->priv->client_proxy = g_dbus_proxy_new_sync (app->priv->session_bus, 0,
NULL,
"org.gnome.SessionManager",
app->priv->client_path,
"org.gnome.SessionManager.ClientPrivate",
NULL,
&error);
if (error)
{
g_warning ("Failed to get client proxy: %s", error->message);
g_error_free (error);
g_clear_object (&app->priv->sm_proxy);
g_free (app->priv->client_path);
app->priv->client_path = NULL;
return;
}
g_signal_connect (app->priv->client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), app);
}
/**
* GtkApplicationInhibitFlags:
* @GTK_APPLICATION_INHIBIT_LOGOUT: Inhibit ending the user session
* by logging out or by shutting down the computer
* @GTK_APPLICATION_INHIBIT_SWITCH: Inhibit user switching
* @GTK_APPLICATION_INHIBIT_SUSPEND: Inhibit suspending the
* session or computer
* @GTK_APPLICATION_INHIBIT_IDLE: Inhibit the session being
* marked as idle (and possibly locked)
*
* Types of user actions that may be blocked by gtk_application_inhibit().
*
* Since: 3.4
*/
/**
* gtk_application_inhibit:
* @application: the #GApplication
* @window: (allow-none): a #GtkWindow, or %NULL
* @flags: what types of actions should be inhibited
* @reason: (allow-none): a short, human-readable string that explains
* why these operations are inhibited
*
* Inform the session manager that certain types of actions should be
* inhibited. This is not guaranteed to work on all platforms and for
* all types of actions.
*
* Applications should invoke this method when they begin an operation
* that should not be interrupted, such as creating a CD or DVD. The
* types of actions that may be blocked are specified by the @flags
* parameter. When the application completes the operation it should
* call g_application_uninhibit() to remove the inhibitor. Note that
* an application can have multiple inhibitors, and all of the must
* be individually removed. Inhibitors are also cleared when the
* application exits.
*
* Applications should not expect that they will always be able to block
* the action. In most cases, users will be given the option to force
* the action to take place.
*
* Reasons should be short and to the point.
*
* If @window is given, the session manager may point the user to
* this window to find out more about why the action is inhibited.
*
* Returns: A non-zero cookie that is used to uniquely identify this
* request. It should be used as an argument to g_application_uninhibit()
* in order to remove the request. If the platform does not support
* inhibiting or the request failed for some reason, 0 is returned.
*
* Since: 3.4
*/
guint
gtk_application_inhibit (GtkApplication *application,
GtkWindow *window,
GtkApplicationInhibitFlags flags,
const gchar *reason)
{
GVariant *res;
GError *error = NULL;
guint cookie;
guint xid;
g_return_val_if_fail (GTK_IS_APPLICATION (application), 0);
g_return_val_if_fail (!g_application_get_is_remote (G_APPLICATION (application)), 0);
g_return_val_if_fail (application->priv->sm_proxy != NULL, 0);
if (window != NULL)
xid = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)));
else
xid = 0;
res = g_dbus_proxy_call_sync (application->priv->sm_proxy,
"Inhibit",
g_variant_new ("(susu)",
application->priv->app_id,
xid,
reason,
flags),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&error);
if (error)
{
g_warning ("Calling Inhibit failed: %s", error->message);
g_error_free (error);
return 0;
}
g_variant_get (res, "(u)", &cookie);
g_variant_unref (res);
return cookie;
}
/**
* gtk_application_uninhibit:
* @application: the #GApplication
* @cookie: a cookie that was returned by g_application_inhibit()
*
* Removes an inhibitor that has been established with g_application_inhibit().
* Inhibitors are also cleared when the application exits.
*
* Since: 3.4
*/
void
gtk_application_uninhibit (GtkApplication *application,
guint cookie)
{
g_return_if_fail (GTK_IS_APPLICATION (application));
g_return_if_fail (!g_application_get_is_remote (G_APPLICATION (application)));
g_return_if_fail (application->priv->sm_proxy != NULL);
g_dbus_proxy_call (application->priv->sm_proxy,
"Uninhibit",
g_variant_new ("(u)", cookie),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL, NULL, NULL);
}
/**
* gtk_application_is_inhibited:
* @application: the #GApplication
* @flags: what types of actions should be queried
*
* Determines if any of the actions specified in @flags are
* currently inhibited (possibly by another application).
*
* Returns: %TRUE if any of the actions specified in @flags are inhibited
*
* Since: 3.4
*/
gboolean
gtk_application_is_inhibited (GtkApplication *application,
GtkApplicationInhibitFlags flags)
{
GVariant *res;
GError *error = NULL;
gboolean inhibited;
g_return_val_if_fail (GTK_IS_APPLICATION (application), FALSE);
g_return_val_if_fail (!g_application_get_is_remote (G_APPLICATION (application)), FALSE);
g_return_val_if_fail (application->priv->sm_proxy != NULL, FALSE);
res = g_dbus_proxy_call_sync (application->priv->sm_proxy,
"IsInhibited",
g_variant_new ("(u)", flags),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&error);
if (error)
{
g_warning ("Calling IsInhibited failed: %s", error->message);
g_error_free (error);
return FALSE;
}
g_variant_get (res, "(b)", &inhibited);
g_variant_unref (res);
return inhibited;
}
/**
* GtkApplicationEndSessionStyle:
* @GTK_APPLICATION_LOGOUT: End the session by logging out
* @GTK_APPLICATION_REBOOT: Restart the computer
* @GTK_APPLICATION_SHUTDOWN: Shut the computer down
*
* Different ways to end a user session, for use with
* gtk_application_end_session().
*/
/**
* gtk_application_end_session:
* @application: the #GtkApplication
* @style: the desired kind of session end
* @request_confirmation: whether or not the user should get a chance
* to confirm the action
*
* Requests that the session manager end the current session.
* @style indicates how the session should be ended, and
* @request_confirmation indicates whether or not the user should be
* given a chance to confirm the action. Both of these parameters are
* merely hints though; the session manager may choose to ignore them.
*
* Return value: %TRUE if the request was sent; %FALSE if it could not
* be sent (eg, because it could not connect to the session manager)
*
* Since: 3.4
*/
gboolean
gtk_application_end_session (GtkApplication *application,
GtkApplicationEndSessionStyle style,
gboolean request_confirmation)
{
g_return_val_if_fail (GTK_IS_APPLICATION (application), FALSE);
g_return_val_if_fail (!g_application_get_is_remote (G_APPLICATION (application)), FALSE);
g_return_val_if_fail (application->priv->sm_proxy != NULL, FALSE);
switch (style)
{
case GTK_APPLICATION_LOGOUT:
g_dbus_proxy_call (application->priv->sm_proxy,
"Logout",
g_variant_new ("(u)", request_confirmation ? 0 : 1),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL, NULL, NULL);
break;
case GTK_APPLICATION_REBOOT:
case GTK_APPLICATION_SHUTDOWN:
g_dbus_proxy_call (application->priv->sm_proxy,
"Shutdown",
NULL,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL, NULL, NULL);
break;
}
return TRUE;
}
#elif defined(GDK_WINDOWING_QUARTZ)
/* OS X implementation copied from EggSMClient, but simplified since
* it doesn't need to interact with the user.
*/
static gboolean
idle_will_quit (gpointer data)
{
GtkApplication *app = data;
if (app->priv->quit_inhibit == 0)
g_signal_emit (app, gtk_application_signals[QUIT], 0);
else
{
GtkApplicationQuartzInhibitor *inhibitor;
GSList *iter;
GtkWidget *dialog;
for (iter = app->priv->inhibitors; iter; iter = iter->next)
{
inhibitor = iter->data;
if (inhibitor->flags & GTK_APPLICATION_INHIBIT_LOGOUT)
break;
}
g_assert (inhibitor != NULL);
dialog = gtk_message_dialog_new (inhibitor->window,
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("%s cannot quit at this time:\n\n%s"),
g_get_application_name (),
inhibitor->reason);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
return FALSE;
}
static pascal OSErr
quit_requested (const AppleEvent *aevt,
AppleEvent *reply,
long refcon)
{
GtkApplication *app = GSIZE_TO_POINTER ((gsize)refcon);
/* Don't emit the "quit" signal immediately, since we're
* called from a weird point in the guts of gdkeventloop-quartz.c
*/
g_idle_add_full (G_PRIORITY_DEFAULT, idle_will_quit, app, NULL);
return app->priv->quit_inhibit == 0 ? noErr : userCanceledErr;
}
static void
gtk_application_startup_session_quartz (GtkApplication *app)
{
if (app->priv->register_session)
AEInstallEventHandler (kCoreEventClass, kAEQuitApplication,
NewAEEventHandlerUPP (quit_requested),
(long)GPOINTER_TO_SIZE (app), false);
}
guint
gtk_application_inhibit (GtkApplication *application,
GtkWindow *window,
GtkApplicationInhibitFlags flags,
const gchar *reason)
{
GtkApplicationQuartzInhibitor *inhibitor;
g_return_val_if_fail (GTK_IS_APPLICATION (application), 0);
g_return_val_if_fail (flags != 0, 0);
inhibitor = g_slice_new (GtkApplicationQuartzInhibitor);
inhibitor->cookie = ++application->priv->next_cookie;
inhibitor->flags = flags;
inhibitor->reason = g_strdup (reason);
inhibitor->window = window ? g_object_ref (window) : NULL;
application->priv->inhibitors = g_slist_prepend (application->priv->inhibitors, inhibitor);
if (flags & GTK_APPLICATION_INHIBIT_LOGOUT)
application->priv->quit_inhibit++;
return inhibitor->cookie;
}
void
gtk_application_uninhibit (GtkApplication *application,
guint cookie)
{
GSList *iter;
for (iter = application->priv->inhibitors; iter; iter = iter->next)
{
GtkApplicationQuartzInhibitor *inhibitor = iter->data;
if (inhibitor->cookie == cookie)
{
if (inhibitor->flags & GTK_APPLICATION_INHIBIT_LOGOUT)
application->priv->quit_inhibit--;
gtk_application_quartz_inhibitor_free (inhibitor);
application->priv->inhibitors = g_slist_delete_link (application->priv->inhibitors, iter);
return;
}
}
g_warning ("Invalid inhibitor cookie");
}
gboolean
gtk_application_is_inhibited (GtkApplication *application,
GtkApplicationInhibitFlags flags)
{
if (flags & GTK_APPLICATION_INHIBIT_LOGOUT)
return application->priv->quit_inhibit > 0;
return FALSE;
}
gboolean
gtk_application_end_session (GtkApplication *application,
GtkApplicationEndSessionStyle style,
gboolean request_confirmation)
{
static const ProcessSerialNumber loginwindow_psn = { 0, kSystemProcess };
AppleEvent event = { typeNull, NULL };
AppleEvent reply = { typeNull, NULL };
AEAddressDesc target;
AEEventID id;
OSErr err;
switch (style)
{
case GTK_APPLICATION_LOGOUT:
id = request_confirmation ? kAELogOut : kAEReallyLogOut;
break;
case GTK_APPLICATION_REBOOT:
id = request_confirmation ? kAEShowRestartDialog : kAERestart;
break;
case GTK_APPLICATION_SHUTDOWN:
id = request_confirmation ? kAEShowShutdownDialog : kAEShutDown;
break;
}
err = AECreateDesc (typeProcessSerialNumber, &loginwindow_psn,
sizeof (loginwindow_psn), &target);
if (err != noErr)
{
g_warning ("Could not create descriptor for loginwindow: %d", err);
return FALSE;
}
err = AECreateAppleEvent (kCoreEventClass, id, &target,
kAutoGenerateReturnID, kAnyTransactionID,
&event);
AEDisposeDesc (&target);
if (err != noErr)
{
g_warning ("Could not create logout AppleEvent: %d", err);
return FALSE;
}
err = AESend (&event, &reply, kAENoReply, kAENormalPriority,
kAEDefaultTimeout, NULL, NULL);
AEDisposeDesc (&event);
if (err == noErr)
AEDisposeDesc (&reply);
return err == noErr;
}
#else
/* Trivial implementation.
*
* For the inhibit API on Windows, see
* http://msdn.microsoft.com/en-us/library/ms700677%28VS.85%29.aspx
*/
guint
gtk_application_inhibit (GtkApplication *application,
GtkWindow *window,
GtkApplicationInhibitFlags flags,
const gchar *reason)
{
return 0;
}
void
gtk_application_uninhibit (GtkApplication *application,
guint cookie)
{
}
gboolean
gtk_application_is_inhibited (GtkApplication *application,
GtkApplicationInhibitFlags flags)
{
return FALSE;
}
gboolean
gtk_application_end_session (GtkApplication *application,
GtkApplicationEndSessionStyle style,
gboolean request_confirmation)
{
return FALSE;
}
#endif

View File

@@ -59,10 +59,8 @@ struct _GtkApplicationClass
void (*window_removed) (GtkApplication *application,
GtkWindow *window);
void (*quit) (GtkApplication *application);
/*< private >*/
gpointer padding[11];
gpointer padding[14];
};
GType gtk_application_get_type (void) G_GNUC_CONST;
@@ -93,33 +91,6 @@ void gtk_application_remove_accelerator (GtkApplication *application
const gchar *action_name,
GVariant *parameter);
typedef enum
{
GTK_APPLICATION_INHIBIT_LOGOUT = (1 << 0),
GTK_APPLICATION_INHIBIT_SWITCH = (1 << 1),
GTK_APPLICATION_INHIBIT_SUSPEND = (1 << 2),
GTK_APPLICATION_INHIBIT_IDLE = (1 << 3)
} GtkApplicationInhibitFlags;
guint gtk_application_inhibit (GtkApplication *application,
GtkWindow *window,
GtkApplicationInhibitFlags flags,
const gchar *reason);
void gtk_application_uninhibit (GtkApplication *application,
guint cookie);
gboolean gtk_application_is_inhibited (GtkApplication *application,
GtkApplicationInhibitFlags flags);
typedef enum {
GTK_APPLICATION_LOGOUT,
GTK_APPLICATION_REBOOT,
GTK_APPLICATION_SHUTDOWN
} GtkApplicationEndSessionStyle;
gboolean gtk_application_end_session (GtkApplication *application,
GtkApplicationEndSessionStyle style,
gboolean request_confirmation);
G_END_DECLS
#endif /* __GTK_APPLICATION_H__ */

View File

@@ -23,7 +23,6 @@
#ifndef __GTK_APPLICATION_PRIVATE_H__
#define __GTK_APPLICATION_PRIVATE_H__
#include "gsimpleactionobserver.h"
#include "gtkapplicationwindow.h"
G_GNUC_INTERNAL
@@ -34,9 +33,4 @@ gboolean gtk_application_window_publish (GtkAppl
G_GNUC_INTERNAL
void gtk_application_window_unpublish (GtkApplicationWindow *window);
G_GNUC_INTERNAL
GSimpleActionObserver * gtk_application_window_create_observer (GtkApplicationWindow *window,
const gchar *action_name,
GVariant *target);
#endif /* __GTK_APPLICATION_PRIVATE_H__ */

View File

@@ -43,8 +43,8 @@
* GtkApplicationWindow is a #GtkWindow subclass that offers some
* extra functionality for better integration with #GtkApplication
* features. Notably, it can handle both the application menu as well
* as the menubar. See gtk_application_set_app_menu() and
* gtk_application_set_menubar().
* as the menubar. See g_application_set_app_menu() and
* g_application_set_menubar().
*
* This class implements the #GActionGroup and #GActionMap interfaces,
* to let you add window-specific actions that will be exported by the
@@ -88,8 +88,8 @@
* " </submenu>"
* " </menu>"
* "</interface>");
* gtk_application_set_menubar (G_APPLICATION (app),
* G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
* g_application_set_menubar (G_APPLICATION (app),
* G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
* g_object_unref (builder);
*
* ...
@@ -182,7 +182,6 @@ struct _GtkApplicationWindowPrivate
{
GSimpleActionGroup *actions;
GActionObservable *muxer;
gboolean muxer_initialised;
GtkWidget *menubar;
GtkAccelGroup *accels;
GSList *accel_closures;
@@ -603,21 +602,15 @@ gtk_application_window_real_get_preferred_width_for_height (GtkWidget *widget,
gint *natural_width)
{
GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
gint menubar_height;
if (window->priv->menubar != NULL)
gtk_widget_get_preferred_height (window->priv->menubar, &menubar_height, NULL);
else
menubar_height = 0;
GTK_WIDGET_CLASS (gtk_application_window_parent_class)
->get_preferred_width_for_height (widget, height - menubar_height, minimum_width, natural_width);
->get_preferred_width_for_height (widget, height, minimum_width, natural_width);
if (window->priv->menubar != NULL)
{
gint menubar_min_width, menubar_nat_width;
gtk_widget_get_preferred_width_for_height (window->priv->menubar, menubar_height, &menubar_min_width, &menubar_nat_width);
gtk_widget_get_preferred_width_for_height (window->priv->menubar, height, &menubar_min_width, &menubar_nat_width);
*minimum_width = MAX (*minimum_width, menubar_min_width);
*natural_width = MAX (*natural_width, menubar_nat_width);
}
@@ -632,14 +625,12 @@ gtk_application_window_real_size_allocate (GtkWidget *widget,
if (window->priv->menubar != NULL)
{
GtkAllocation menubar_allocation = *allocation;
gint menubar_height;
gint menubar_min_height, menubar_nat_height;
GtkWidget *child;
gtk_widget_set_allocation (widget, allocation);
gtk_widget_get_preferred_height_for_width (window->priv->menubar, allocation->width, &menubar_min_height, &menubar_nat_height);
gtk_widget_get_preferred_height_for_width (window->priv->menubar, allocation->width, &menubar_height, NULL);
menubar_allocation.height = menubar_height;
menubar_allocation.height = menubar_min_height;
gtk_widget_size_allocate (window->priv->menubar, &menubar_allocation);
child = gtk_bin_get_child (GTK_BIN (window));
@@ -648,14 +639,17 @@ gtk_application_window_real_size_allocate (GtkWidget *widget,
GtkAllocation child_allocation = *allocation;
gint border_width;
child_allocation.height = MAX (1, child_allocation.height - menubar_min_height);
border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
child_allocation.x += border_width;
child_allocation.y += border_width + menubar_height;
child_allocation.width = MAX (1, child_allocation.width - border_width * 2);
child_allocation.height = MAX (1, child_allocation.height - border_width * 2 - menubar_height);
child_allocation.y += border_width + menubar_min_height;
child_allocation.width -= border_width * 2;
child_allocation.height -= border_width * 2 - menubar_min_height;
gtk_widget_size_allocate (child, &child_allocation);
}
gtk_widget_set_allocation (widget, allocation);
}
else
GTK_WIDGET_CLASS (gtk_application_window_parent_class)
@@ -677,11 +671,14 @@ gtk_application_window_real_realize (GtkWidget *widget)
g_signal_connect (settings, "notify::gtk-shell-shows-menubar",
G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), window);
if (!window->priv->muxer_initialised)
if (window->priv->muxer == NULL)
{
g_action_muxer_insert (G_ACTION_MUXER (window->priv->muxer), "app", G_ACTION_GROUP (application));
g_action_muxer_insert (G_ACTION_MUXER (window->priv->muxer), "win", G_ACTION_GROUP (window));
window->priv->muxer_initialised = TRUE;
GActionMuxer *muxer;
muxer = g_action_muxer_new ();
g_action_muxer_insert (muxer, "app", G_ACTION_GROUP (application));
g_action_muxer_insert (muxer, "win", G_ACTION_GROUP (window));
window->priv->muxer = G_ACTION_OBSERVABLE (muxer);
}
gtk_application_window_update_shell_shows_app_menu (window, settings);
@@ -878,8 +875,6 @@ gtk_application_window_init (GtkApplicationWindow *window)
G_CALLBACK (g_action_group_action_state_changed), window);
g_signal_connect_swapped (window->priv->actions, "action-removed",
G_CALLBACK (g_action_group_action_removed), window);
window->priv->muxer = G_ACTION_OBSERVABLE (g_action_muxer_new ());
}
static void
@@ -907,8 +902,8 @@ gtk_application_window_class_init (GtkApplicationWindowClass *class)
*
* If this property is %TRUE, the window will display a menubar
* that includes the app menu and menubar, unless these are
* shown by the desktop shell. See gtk_application_set_app_menu()
* and gtk_application_set_menubar().
* shown by the desktop shell. See g_application_set_app_menu()
* and g_application_set_menubar().
*
* If %FALSE, the window will not display a menubar, regardless
* of whether the desktop shell is showing the menus or not.
@@ -987,13 +982,3 @@ gtk_application_window_set_show_menubar (GtkApplicationWindow *window,
g_object_notify_by_pspec (G_OBJECT (window), gtk_application_window_properties[PROP_SHOW_MENUBAR]);
}
}
GSimpleActionObserver *
gtk_application_window_create_observer (GtkApplicationWindow *window,
const gchar *action_name,
GVariant *target)
{
g_return_val_if_fail (GTK_IS_APPLICATION_WINDOW (window), NULL);
return g_simple_action_observer_new (window->priv->muxer, action_name, target);
}

View File

@@ -1,279 +0,0 @@
/*
* Copyright © 2011 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include <config.h>
#define GTK_INSIDE_BITMASK_C
#include "gtk/gtkbitmaskprivate.h"
#define VALUE_TYPE gsize
#define VALUE_SIZE_BITS (sizeof (VALUE_TYPE) * 8)
#define VALUE_BIT(idx) (((VALUE_TYPE) 1) << (idx))
GtkBitmask *
_gtk_bitmask_new (void)
{
return g_array_new (FALSE, TRUE, sizeof (VALUE_TYPE));
}
GtkBitmask *
_gtk_bitmask_copy (const GtkBitmask *mask)
{
GtkBitmask *copy;
g_return_val_if_fail (mask != NULL, NULL);
copy = _gtk_bitmask_new ();
_gtk_bitmask_union (copy, mask);
return copy;
}
void
_gtk_bitmask_free (GtkBitmask *mask)
{
g_return_if_fail (mask != NULL);
g_array_free (mask, TRUE);
}
void
_gtk_bitmask_print (const GtkBitmask *mask,
GString *string)
{
int i;
g_return_if_fail (mask != NULL);
g_return_if_fail (string != NULL);
for (i = mask->len * VALUE_SIZE_BITS - 1; i >= 0; i--)
{
if (_gtk_bitmask_get (mask, i))
break;
}
if (i < 0)
{
g_string_append_c (string, '0');
return;
}
for (; i >= 0; i--)
{
g_string_append_c (string, _gtk_bitmask_get (mask, i) ? '1' : '0');
}
}
char *
_gtk_bitmask_to_string (const GtkBitmask *mask)
{
GString *string;
string = g_string_new (NULL);
_gtk_bitmask_print (mask, string);
return g_string_free (string, FALSE);
}
/* NB: Call this function whenever the
* array might have become too large.
* _gtk_bitmask_is_empty() depends on this.
*/
static void
gtk_bitmask_shrink (GtkBitmask *mask)
{
guint i;
for (i = mask->len; i; i--)
{
if (g_array_index (mask, VALUE_TYPE, i - 1))
break;
}
g_array_set_size (mask, i);
}
void
_gtk_bitmask_intersect (GtkBitmask *mask,
const GtkBitmask *other)
{
guint i;
g_return_if_fail (mask != NULL);
g_return_if_fail (other != NULL);
g_array_set_size (mask, MIN (mask->len, other->len));
for (i = 0; i < mask->len; i++)
{
g_array_index (mask, VALUE_TYPE, i) &= g_array_index (other, VALUE_TYPE, i);
}
gtk_bitmask_shrink (mask);
}
void
_gtk_bitmask_union (GtkBitmask *mask,
const GtkBitmask *other)
{
guint i;
g_return_if_fail (mask != NULL);
g_return_if_fail (other != NULL);
g_array_set_size (mask, MAX (mask->len, other->len));
for (i = 0; i < other->len; i++)
{
g_array_index (mask, VALUE_TYPE, i) |= g_array_index (other, VALUE_TYPE, i);
}
}
void
_gtk_bitmask_subtract (GtkBitmask *mask,
const GtkBitmask *other)
{
guint i;
g_return_if_fail (mask != NULL);
g_return_if_fail (other != NULL);
for (i = 0; i < other->len; i++)
{
g_array_index (mask, VALUE_TYPE, i) &= ~g_array_index (other, VALUE_TYPE, i);
}
gtk_bitmask_shrink (mask);
}
static void
gtk_bitmask_indexes (guint index_,
guint *array_index,
guint *bit_index)
{
*array_index = index_ / VALUE_SIZE_BITS;
*bit_index = index_ % VALUE_SIZE_BITS;
}
gboolean
_gtk_bitmask_get (const GtkBitmask *mask,
guint index_)
{
guint array_index, bit_index;
g_return_val_if_fail (mask != NULL, FALSE);
gtk_bitmask_indexes (index_, &array_index, &bit_index);
if (array_index >= mask->len)
return FALSE;
return (g_array_index (mask, VALUE_TYPE, array_index) & VALUE_BIT (bit_index)) ? TRUE : FALSE;
}
void
_gtk_bitmask_set (GtkBitmask *mask,
guint index_,
gboolean value)
{
guint array_index, bit_index;
g_return_if_fail (mask != NULL);
gtk_bitmask_indexes (index_, &array_index, &bit_index);
if (value)
{
if (array_index >= mask->len)
g_array_set_size (mask, array_index + 1);
g_array_index (mask, VALUE_TYPE, array_index) |= VALUE_BIT (bit_index);
}
else
{
if (array_index < mask->len)
{
g_array_index (mask, VALUE_TYPE, array_index) &= ~ VALUE_BIT (bit_index);
gtk_bitmask_shrink (mask);
}
}
}
void
_gtk_bitmask_invert_range (GtkBitmask *mask,
guint start,
guint end)
{
guint i;
g_return_if_fail (mask != NULL);
g_return_if_fail (start < end);
/* I CAN HAS SPEEDUP? */
for (i = start; i < end; i++)
_gtk_bitmask_set (mask, i, !_gtk_bitmask_get (mask, i));
}
gboolean
_gtk_bitmask_is_empty (const GtkBitmask *mask)
{
g_return_val_if_fail (mask != NULL, FALSE);
return mask->len == 0;
}
gboolean
_gtk_bitmask_equals (const GtkBitmask *mask,
const GtkBitmask *other)
{
guint i;
g_return_val_if_fail (mask != NULL, FALSE);
g_return_val_if_fail (other != NULL, FALSE);
if (mask->len != other->len)
return FALSE;
for (i = 0; i < mask->len; i++)
{
if (g_array_index (mask, VALUE_TYPE, i) != g_array_index (other, VALUE_TYPE, i))
return FALSE;
}
return TRUE;
}
gboolean
_gtk_bitmask_intersects (const GtkBitmask *mask,
const GtkBitmask *other)
{
int i;
g_return_val_if_fail (mask != NULL, FALSE);
g_return_val_if_fail (other != NULL, FALSE);
for (i = MIN (mask->len, other->len) - 1; i >= 0; i--)
{
if (g_array_index (mask, VALUE_TYPE, i) & g_array_index (other, VALUE_TYPE, i))
return TRUE;
}
return FALSE;
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright © 2011 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_BITMASK_PRIVATE_H__
#define __GTK_BITMASK_PRIVATE_H__
#include <glib.h>
G_BEGIN_DECLS
#ifdef GTK_INSIDE_BITMASK_C
typedef GArray GtkBitmask;
#else
typedef struct _GtkBitmask GtkBitmask;
#endif
GtkBitmask * _gtk_bitmask_new (void);
GtkBitmask * _gtk_bitmask_copy (const GtkBitmask *mask);
void _gtk_bitmask_free (GtkBitmask *mask);
char * _gtk_bitmask_to_string (const GtkBitmask *mask);
void _gtk_bitmask_print (const GtkBitmask *mask,
GString *string);
void _gtk_bitmask_intersect (GtkBitmask *mask,
const GtkBitmask *other);
void _gtk_bitmask_union (GtkBitmask *mask,
const GtkBitmask *other);
void _gtk_bitmask_subtract (GtkBitmask *mask,
const GtkBitmask *other);
gboolean _gtk_bitmask_get (const GtkBitmask *mask,
guint index_);
void _gtk_bitmask_set (GtkBitmask *mask,
guint index_,
gboolean value);
void _gtk_bitmask_invert_range (GtkBitmask *mask,
guint start,
guint end);
gboolean _gtk_bitmask_is_empty (const GtkBitmask *mask);
gboolean _gtk_bitmask_equals (const GtkBitmask *mask,
const GtkBitmask *other);
gboolean _gtk_bitmask_intersects (const GtkBitmask *mask,
const GtkBitmask *other);
G_END_DECLS
#endif /* __GTK_BITMASK_PRIVATE_H__ */

View File

@@ -28,37 +28,208 @@
#include "gtkborderimageprivate.h"
#include "gtkstylepropertiesprivate.h"
#include "gtkthemingengineprivate.h"
/* this is in case round() is not provided by the compiler,
* such as in the case of C89 compilers, like MSVC
*/
#include "fallback-c89.c"
gboolean
_gtk_border_image_init (GtkBorderImage *image,
GtkThemingEngine *engine)
{
G_DEFINE_BOXED_TYPE (GtkBorderImage, _gtk_border_image,
_gtk_border_image_ref, _gtk_border_image_unref)
enum {
BORDER_LEFT,
BORDER_MIDDLE,
BORDER_RIGHT,
BORDER_LAST,
BORDER_TOP = BORDER_LEFT,
BORDER_BOTTOM = BORDER_RIGHT
};
enum {
SIDE_TOP,
SIDE_RIGHT,
SIDE_BOTTOM,
SIDE_LEFT
};
struct _GtkBorderImage {
cairo_pattern_t *source;
gpointer source_boxed;
GType boxed_type;
GtkBorder slice;
GtkBorder *width;
GtkCssBorderImageRepeat repeat;
image->source = g_value_get_object (_gtk_theming_engine_peek_property (engine, "border-image-source"));
if (image->source == NULL)
return FALSE;
gint ref_count;
};
image->slice = *(GtkBorder *) g_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-slice"));
width = g_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-width"));
if (width)
GtkBorderImage *
_gtk_border_image_new (cairo_pattern_t *pattern,
GtkBorder *slice,
GtkBorder *width,
GtkCssBorderImageRepeat *repeat)
{
GtkBorderImage *image;
image = g_slice_new0 (GtkBorderImage);
image->ref_count = 1;
if (pattern != NULL)
image->source = cairo_pattern_reference (pattern);
if (slice != NULL)
image->slice = *slice;
if (width != NULL)
image->width = gtk_border_copy (width);
if (repeat != NULL)
image->repeat = *repeat;
return image;
}
GtkBorderImage *
_gtk_border_image_new_for_boxed (GType boxed_type,
gpointer boxed,
GtkBorder *slice,
GtkBorder *width,
GtkCssBorderImageRepeat *repeat)
{
GtkBorderImage *image;
image = g_slice_new0 (GtkBorderImage);
image->ref_count = 1;
if (boxed != NULL)
image->source_boxed = g_boxed_copy (boxed_type, boxed);
image->boxed_type = boxed_type;
if (slice != NULL)
image->slice = *slice;
if (width != NULL)
image->width = gtk_border_copy (width);
if (repeat != NULL)
image->repeat = *repeat;
return image;
}
GtkBorderImage *
_gtk_border_image_ref (GtkBorderImage *image)
{
g_return_val_if_fail (image != NULL, NULL);
image->ref_count++;
return image;
}
void
_gtk_border_image_unref (GtkBorderImage *image)
{
g_return_if_fail (image != NULL);
image->ref_count--;
if (image->ref_count == 0)
{
image->width = *width;
image->has_width = TRUE;
if (image->source != NULL)
cairo_pattern_destroy (image->source);
if (image->source_boxed != NULL)
g_boxed_free (image->boxed_type, image->source_boxed);
if (image->width != NULL)
gtk_border_free (image->width);
g_slice_free (GtkBorderImage, image);
}
}
GParameter *
_gtk_border_image_unpack (const GValue *value,
guint *n_params)
{
GParameter *parameter = g_new0 (GParameter, 4);
GtkBorderImage *image = g_value_get_boxed (value);
parameter[0].name = "border-image-source";
if ((image != NULL) &&
(image->source_boxed != NULL))
g_value_init (&parameter[0].value, image->boxed_type);
else
g_value_init (&parameter[0].value, CAIRO_GOBJECT_TYPE_PATTERN);
parameter[1].name = "border-image-slice";
g_value_init (&parameter[1].value, GTK_TYPE_BORDER);
parameter[2].name = "border-image-repeat";
g_value_init (&parameter[2].value, GTK_TYPE_CSS_BORDER_IMAGE_REPEAT);
parameter[3].name = "border-image-width";
g_value_init (&parameter[3].value, GTK_TYPE_BORDER);
if (image != NULL)
{
if (image->source_boxed != NULL)
g_value_set_boxed (&parameter[0].value, image->source_boxed);
else
g_value_set_boxed (&parameter[0].value, image->source);
g_value_set_boxed (&parameter[1].value, &image->slice);
g_value_set_boxed (&parameter[2].value, &image->repeat);
g_value_set_boxed (&parameter[3].value, image->width);
}
*n_params = 4;
return parameter;
}
void
_gtk_border_image_pack (GValue *value,
GtkStyleProperties *props,
GtkStateFlags state,
GtkStylePropertyContext *context)
{
GtkBorderImage *image;
cairo_pattern_t *source;
GtkBorder *slice, *width;
GtkCssBorderImageRepeat *repeat;
_gtk_style_properties_get (props, state, context,
"border-image-source", &source,
"border-image-slice", &slice,
"border-image-repeat", &repeat,
"border-image-width", &width,
NULL);
if (source == NULL)
{
g_value_take_boxed (value, NULL);
}
else
image->has_width = FALSE;
{
image = _gtk_border_image_new (source, slice, width, repeat);
g_value_take_boxed (value, image);
image->repeat = *(GtkCssBorderImageRepeat *) g_value_get_boxed (
_gtk_theming_engine_peek_property (engine, "border-image-repeat"));
cairo_pattern_destroy (source);
}
return TRUE;
if (slice != NULL)
gtk_border_free (slice);
if (width != NULL)
gtk_border_free (width);
if (repeat != NULL)
g_free (repeat);
}
typedef struct _GtkBorderImageSliceSize GtkBorderImageSliceSize;
@@ -236,29 +407,45 @@ _gtk_border_image_render (GtkBorderImage *image,
cairo_surface_t *surface, *slice;
GtkBorderImageSliceSize vertical_slice[3], horizontal_slice[3];
GtkBorderImageSliceSize vertical_border[3], horizontal_border[3];
double source_width, source_height;
int surface_width, surface_height;
int h, v;
if (image->has_width)
border_width = &image->width;
if (image->width != NULL)
border_width = image->width;
_gtk_css_image_get_concrete_size (image->source,
0, 0,
width, height,
&source_width, &source_height);
if (cairo_pattern_get_type (image->source) != CAIRO_PATTERN_TYPE_SURFACE)
{
cairo_matrix_t matrix;
cairo_t *surface_cr;
/* XXX: Optimize for (source_width == width && source_height == height) */
surface_width = width;
surface_height = height;
surface = _gtk_css_image_get_surface (image->source,
cairo_get_target (cr),
source_width, source_height);
cairo_matrix_init_scale (&matrix, 1 / width, 1 / height);
cairo_pattern_set_matrix (image->source, &matrix);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
surface_cr = cairo_create (surface);
cairo_set_source (surface_cr, image->source);
cairo_paint (surface_cr);
cairo_destroy (surface_cr);
}
else
{
cairo_pattern_get_surface (image->source, &surface);
cairo_surface_reference (surface);
surface_width = cairo_image_surface_get_width (surface);
surface_height = cairo_image_surface_get_height (surface);
}
gtk_border_image_compute_slice_size (horizontal_slice,
source_width,
surface_width,
image->slice.left,
image->slice.right);
gtk_border_image_compute_slice_size (vertical_slice,
source_height,
surface_height,
image->slice.top,
image->slice.bottom);
gtk_border_image_compute_border_size (horizontal_border,

View File

@@ -25,25 +25,32 @@
#define __GTK_BORDER_IMAGE_H__
#include "gtkborder.h"
#include "gtkcssimageprivate.h"
#include "gtkgradient.h"
#include "gtkstyleproperties.h"
#include "gtkthemingengine.h"
#include "gtkcsstypesprivate.h"
#include "gtkstylecontextprivate.h"
G_BEGIN_DECLS
typedef struct _GtkBorderImage GtkBorderImage;
struct _GtkBorderImage {
GtkCssImage *source;
#define GTK_TYPE_BORDER_IMAGE (_gtk_border_image_get_type ())
GtkBorder slice;
gboolean has_width;
GtkBorder width;
GtkCssBorderImageRepeat repeat;
};
GType _gtk_border_image_get_type (void) G_GNUC_CONST;
gboolean _gtk_border_image_init (GtkBorderImage *image,
GtkThemingEngine *engine);
GtkBorderImage * _gtk_border_image_new (cairo_pattern_t *source,
GtkBorder *slice,
GtkBorder *width,
GtkCssBorderImageRepeat *repeat);
GtkBorderImage * _gtk_border_image_new_for_boxed (GType boxed_type,
gpointer boxed,
GtkBorder *slice,
GtkBorder *width,
GtkCssBorderImageRepeat *repeat);
GtkBorderImage * _gtk_border_image_ref (GtkBorderImage *image);
void _gtk_border_image_unref (GtkBorderImage *image);
void _gtk_border_image_render (GtkBorderImage *image,
GtkBorder *border_width,
@@ -53,6 +60,13 @@ void _gtk_border_image_render (GtkBorderImage *imag
gdouble width,
gdouble height);
GParameter * _gtk_border_image_unpack (const GValue *value,
guint *n_params);
void _gtk_border_image_pack (GValue *value,
GtkStyleProperties *props,
GtkStateFlags state,
GtkStylePropertyContext *context);
G_END_DECLS
#endif /* __GTK_BORDER_IMAGE_H__ */

View File

@@ -240,7 +240,7 @@
* <link linkend="GtkTextTagTable-BUILDER-UI">GtkTextTagTable</link>.
* </para>
* </refsect2>
* <refsect2>
* <refsect2 id="BUILDER-UI">
* <title>Embedding other XML</title>
* <para>
* Apart from the language for UI descriptions that has been explained
@@ -248,8 +248,6 @@
* of <link linkend="gio-GMenu-Markup">GMenu markup</link>. The resulting
* #GMenu object and its named submenus are available via
* gtk_builder_get_object() like other constructed objects.
* </para>
* </refsect2>
*/
#include "config.h"
@@ -296,7 +294,6 @@ struct _GtkBuilderPrivate
GSList *delayed_properties;
GSList *signals;
gchar *filename;
gchar *resource_prefix;
};
G_DEFINE_TYPE (GtkBuilder, gtk_builder, G_TYPE_OBJECT)
@@ -357,7 +354,6 @@ gtk_builder_finalize (GObject *object)
g_free (priv->domain);
g_free (priv->filename);
g_free (priv->resource_prefix);
g_hash_table_destroy (priv->objects);
@@ -915,9 +911,7 @@ gtk_builder_add_from_file (GtkBuilder *builder,
}
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (filename);
builder->priv->resource_prefix = NULL;
_gtk_builder_parser_parse_buffer (builder, filename,
buffer, length,
@@ -984,9 +978,7 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
}
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (filename);
builder->priv->resource_prefix = NULL;
_gtk_builder_parser_parse_buffer (builder, filename,
buffer, length,
@@ -1004,157 +996,6 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
return 1;
}
/**
* gtk_builder_add_from_resource:
* @builder: a #GtkBuilder
* @resource_path: the path of the resource file to parse
* @error: (allow-none): return location for an error, or %NULL
*
* Parses a resource file containing a <link linkend="BUILDER-UI">GtkBuilder
* UI definition</link> and merges it with the current contents of @builder.
*
* Upon errors 0 will be returned and @error will be assigned a
* #GError from the #GTK_BUILDER_ERROR, #G_MARKUP_ERROR or #G_RESOURCE_ERROR
* domain.
*
* Returns: A positive value on success, 0 if an error occurred
*
* Since: 3.4
**/
guint
gtk_builder_add_from_resource (GtkBuilder *builder,
const gchar *resource_path,
GError **error)
{
GError *tmp_error;
GBytes *data;
char *filename_for_errors;
char *slash;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (resource_path != NULL, 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
tmp_error = NULL;
data = g_resources_lookup_data (resource_path, 0, &tmp_error);
if (data == NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (".");
slash = strrchr (resource_path, '/');
if (slash != NULL)
builder->priv->resource_prefix =
g_strndup (resource_path, slash - resource_path + 1);
else
builder->priv->resource_prefix =
g_strdup ("/");
filename_for_errors = g_strconcat ("<resource>", resource_path, NULL);
_gtk_builder_parser_parse_buffer (builder, filename_for_errors,
g_bytes_get_data (data, NULL), g_bytes_get_size (data),
NULL,
&tmp_error);
g_free (filename_for_errors);
g_bytes_unref (data);
if (tmp_error != NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
return 1;
}
/**
* gtk_builder_add_objects_from_resource:
* @builder: a #GtkBuilder
* @resource_path: the path of the resource file to parse
* @object_ids: (array zero-terminated=1) (element-type utf8): nul-terminated array of objects to build
* @error: (allow-none): return location for an error, or %NULL
*
* Parses a resource file containing a <link linkend="BUILDER-UI">GtkBuilder
* UI definition</link> building only the requested objects and merges
* them with the current contents of @builder.
*
* Upon errors 0 will be returned and @error will be assigned a
* #GError from the #GTK_BUILDER_ERROR, #G_MARKUP_ERROR or #G_RESOURCE_ERROR
* domain.
*
* <note><para>
* If you are adding an object that depends on an object that is not
* its child (for instance a #GtkTreeView that depends on its
* #GtkTreeModel), you have to explicitely list all of them in @object_ids.
* </para></note>
*
* Returns: A positive value on success, 0 if an error occurred
*
* Since: 3.4
**/
guint
gtk_builder_add_objects_from_resource (GtkBuilder *builder,
const gchar *resource_path,
gchar **object_ids,
GError **error)
{
GError *tmp_error;
GBytes *data;
char *filename_for_errors;
char *slash;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (resource_path != NULL, 0);
g_return_val_if_fail (object_ids != NULL && object_ids[0] != NULL, 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
tmp_error = NULL;
data = g_resources_lookup_data (resource_path, 0, &tmp_error);
if (data == NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (".");
slash = strrchr (resource_path, '/');
if (slash != NULL)
builder->priv->resource_prefix =
g_strndup (resource_path, slash - resource_path + 1);
else
builder->priv->resource_prefix =
g_strdup ("/");
filename_for_errors = g_strconcat ("<resource>", resource_path, NULL);
_gtk_builder_parser_parse_buffer (builder, filename_for_errors,
g_bytes_get_data (data, NULL), g_bytes_get_size (data),
object_ids,
&tmp_error);
g_free (filename_for_errors);
g_bytes_unref (data);
if (tmp_error != NULL)
{
g_propagate_error (error, tmp_error);
return 0;
}
return 1;
}
/**
* gtk_builder_add_from_string:
* @builder: a #GtkBuilder
@@ -1187,9 +1028,7 @@ gtk_builder_add_from_string (GtkBuilder *builder,
tmp_error = NULL;
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (".");
builder->priv->resource_prefix = NULL;
_gtk_builder_parser_parse_buffer (builder, "<input>",
buffer, length,
@@ -1246,9 +1085,7 @@ gtk_builder_add_objects_from_string (GtkBuilder *builder,
tmp_error = NULL;
g_free (builder->priv->filename);
g_free (builder->priv->resource_prefix);
builder->priv->filename = g_strdup (".");
builder->priv->resource_prefix = NULL;
_gtk_builder_parser_parse_buffer (builder, "<input>",
buffer, length,
@@ -1572,31 +1409,6 @@ gtk_builder_value_from_string (GtkBuilder *builder,
return TRUE;
}
/*
* GParamSpecVariant can specify a GVariantType which can help with
* parsing, so we need to take care of that here.
*/
if (G_IS_PARAM_SPEC_VARIANT (pspec))
{
GParamSpecVariant *variant_pspec = G_PARAM_SPEC_VARIANT (pspec);
const GVariantType *type;
GVariant *variant;
g_value_init (value, G_TYPE_VARIANT);
/* The GVariant parser doesn't deal with indefinite types */
if (g_variant_type_is_definite (variant_pspec->type))
type = variant_pspec->type;
else
type = NULL;
variant = g_variant_parse (type, string, NULL, NULL, error);
if (variant == NULL)
return FALSE;
g_value_take_variant (value, variant);
return TRUE;
}
return gtk_builder_value_from_string_type (builder,
G_PARAM_SPEC_VALUE_TYPE (pspec),
string, value, error);
@@ -1752,17 +1564,6 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
case G_TYPE_STRING:
g_value_set_string (value, string);
break;
case G_TYPE_VARIANT:
{
GVariant *variant;
variant = g_variant_parse (NULL, string, NULL, NULL, error);
if (value != NULL)
g_value_take_variant (value, variant);
else
ret = FALSE;
}
break;
case G_TYPE_BOXED:
if (G_VALUE_HOLDS (value, GDK_TYPE_COLOR))
{
@@ -1816,7 +1617,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
{
gchar *filename;
GError *tmp_error = NULL;
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *pixbuf;
if (gtk_builder_get_object (builder, string))
{
@@ -1829,21 +1630,8 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
return FALSE;
}
filename = _gtk_builder_get_resource_path (builder, string);
if (filename != NULL)
{
GInputStream *stream = g_resources_open_stream (filename, 0, &tmp_error);
if (stream != NULL)
{
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, &tmp_error);
g_object_unref (stream);
}
}
else
{
filename = _gtk_builder_get_absolute_filename (builder, string);
pixbuf = gdk_pixbuf_new_from_file (filename, &tmp_error);
}
filename = _gtk_builder_get_absolute_filename (builder, string);
pixbuf = gdk_pixbuf_new_from_file (filename, &tmp_error);
if (pixbuf == NULL)
{
@@ -2072,19 +1860,6 @@ gtk_builder_error_quark (void)
return g_quark_from_static_string ("gtk-builder-error-quark");
}
gchar *
_gtk_builder_get_resource_path (GtkBuilder *builder, const gchar *string)
{
if (g_str_has_prefix (string, "resource:///"))
return g_uri_unescape_string (string + 11, "/");
if (g_path_is_absolute (string) ||
builder->priv->resource_prefix == NULL)
return NULL;
return g_build_path ("/", builder->priv->resource_prefix, string, NULL);
}
gchar *
_gtk_builder_get_absolute_filename (GtkBuilder *builder, const gchar *string)
{

Some files were not shown because too many files have changed in this diff Show More