Gnome2-GConf-1.044/0000755000175000017500000000000010677450301013624 5ustar torstentorstenGnome2-GConf-1.044/gconfperl.h0000644000175000017500000000407710364007442015761 0ustar torstentorsten/* * Copyright (c) 2003-2005 by Emmanuele Bassi (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library 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. */ #ifndef _GNOME_GCONF_PERL_H_ # define _GNOME_GCONF_PERL_H_ # include "gperl.h" /* basic include files */ # include # include # include # include # include # include # include # include # include #ifndef GCONFPERL_TYPE_GCONF_ERROR # define GCONFPERL_TYPE_GCONF_ERROR (gconfperl_gconf_error_get_type ()) GType gconfperl_gconf_error_get_type (void) G_GNUC_CONST; #endif /* !GCONFPERL_TYPE_ENGINE */ #ifndef GCONF_TYPE_ENGINE # define GCONF_TYPE_ENGINE (gconfperl_gconf_engine_get_type ()) # define GCONFPERL_TYPE_ENGINE 1 GType gconfperl_gconf_engine_get_type (void) G_GNUC_CONST; #endif /* !GCONF_TYPE_ENGINE */ /* forward declaration for opaque containers converters */ SV * newSVGConfEntry (GConfEntry *); SV * newSVGConfValue (GConfValue *); SV * newSVGConfSchema (GConfSchema *); SV * newSVGConfChangeSet (GConfChangeSet *); GConfEntry * SvGConfEntry (SV *); GConfValue * SvGConfValue (SV *); GConfSchema * SvGConfSchema (SV *); GConfChangeSet * SvGConfChangeSet (SV *); # include "gconfperl-autogen.h" # include "gconfperl-version.h" #endif /* _GNOME_GCONF_PERL_H_ */ Gnome2-GConf-1.044/examples/0000755000175000017500000000000010677450301015442 5ustar torstentorstenGnome2-GConf-1.044/examples/simple-view.pl0000644000175000017500000000204707756251401020247 0ustar torstentorsten#!/usr/bin/perl # Copyright (C) 1999, 2000 Red Hat Inc. # Copyright (C) 2003 Emmanuele Bassi # A very simple program that monitors a single key for changes. use strict; use warnings; use Gtk2; use Gnome2::GConf; Gtk2->init; my $client = Gnome2::GConf::Client->get_default; my $window = Gtk2::Window->new('toplevel'); $window->signal_connect(delete_event => sub { $_[0]->destroy; }); $window->signal_connect(destroy => sub { Gtk2->main_quit; }); my $str = $client->get_string("/extra/test/directory/key"); my $label = Gtk2::Label->new($str ? $str : ""); $window->add($label); $client->add_dir("/extra/test/directory", 'preload-none'); $client->notify_add("/extra/test/directory/key", sub { my ($client, $cnxn_id, $entry, $label) = @_; if (not ($entry->{value})) { $label->set_text(''); } elsif ($entry->{value}->{type} eq 'string') { $label->set_text($entry->{value}->{value}); } else { $label->set_text(''); } }, $label); $window->show_all; Gtk2->main; 0; Gnome2-GConf-1.044/examples/simple-controller.pl0000644000175000017500000000164207756251400021457 0ustar torstentorsten#!/usr/bin/perl # Copyright (C) 1999, 2000 Red Hat Inc. # Copyright (C) 2003 Emmanuele Bassi # A very simple program that sets a single key value when you type # it in an entry and press return use strict; use warnings; use Gtk2; use Gnome2::GConf; Gtk2->init; my $window = Gtk2::Window->new('toplevel'); $window->signal_connect(delete_event => sub { $_[0]->destroy; }); $window->signal_connect(destroy => sub { Gtk2->main_quit; }); my $entry = Gtk2::Entry->new; $window->add($entry); my $client = Gnome2::GConf::Client->get_default; $client->add_dir("/extra/test/directory", 'preload-none'); $entry->signal_connect(activate => sub { my ($entry, $client) = @_; my $str = $entry->get_chars(0, -1); $client->set_string("/extra/test/directory/key", $str); }, $client); $entry->set_sensitive($client->key_is_writable("/extra/test/directory/key")); $window->show_all; Gtk2->main; 0; Gnome2-GConf-1.044/examples/error.pl0000644000175000017500000000201010020061567017113 0ustar torstentorsten#!/usr/bin/perl # GConf Error test using Glib::Error. # Copyright 2004 Emmanuele Bassi # Released under the terms of the GNU General Public License. use strict; use warnings; use Gnome2::GConf; our $client = Gnome2::GConf::Client->get_default; # try: eval { # if you ran the basic/complex gconf apps inside the examples/ directory, # this call should not fail. print $client->get_string('/apps/basic-gconf-app/foo') . "\n"; # this call, on the other hand, will always fail. print $client->get_string('/apps/basic-gconf-app/') . "\n"; 1; }; # catch: if ($@) { use Data::Dumper; use Glib; # catch Gnome2::GConf::Error if ($@->isa('Gnome2::GConf::Error')) { print "Catching a Gnome2::GConf::Error exception...\n"; if (Glib::Error::matches($@, 'Gnome2::GConf::Error', 'bad-key')) { # print message... print "*** Our catched error:\n" . $@->message . "\n"; # ...and recover from the 'bad-key' error. } } # this is always valid print "*** GConf error:\n$@\n"; print Dumper($@) . "\n"; } 0; Gnome2-GConf-1.044/examples/basic-gconf-app.pl0000644000175000017500000002306710363474035020742 0ustar torstentorsten#!/usr/bin/perl # This program demonstrates how to use GConf. The key thing is that # the main window and the prefs dialog have NO KNOWLEDGE of one # another as far as configuration values are concerned; they don't # even have to be in the same process. That is, the GConfClient acts # as the data "model" for configuration information; the main # application is a "view" of the model; and the prefs dialog is a # "controller." # # You can tell if your application has done this correctly by # using "gconftool" instead of your preferences dialog to set # preferences. For example: # # gconftool --type=string --set /apps/basic-gconf-app/foo "My string" # # If that doesn't work every bit as well as setting the value # via the prefs dialog, then you aren't doing things right. ;-) # # # If you really want to be mean to your app, make it survive # this: # # gconftool --break-key /apps/basic-gconf-app/foo # # Remember, the GConf database is just like an external file or # the network - it may have bogus values in it. GConf admin # tools will let people put in whatever they can think of. # # GConf does guarantee that string values will be valid UTF-8, for # convenience. # # Throughout, this program is letting GConfClient use its default # error handlers rather than checking for errors or attaching custom # handlers to the "unreturned_error" signal. Thus the last arg to # GConfClient functions is None. # # Special mention of an idiom often used in GTK+ apps that does # not work right with GConf but may appear to at first: # # i_am_changing_value = gtk.TRUE # change_value (value) # i_am_changing_value = gtk.FALSE # # This breaks for several reasons: notification of changes # may be asynchronous, you may get notifications that are not # caused by change_value () while change_value () is running, # since GConf will enter the main loop, and also if you need # this code to work you are probably going to have issues # when someone other than yourself sets the value. # # A robust solution in this case is often to compare the old # and new values to see if they've really changed, thus avoiding # whatever loop you were trying to avoid. # # The code is a direct mapping (with some perlisms) of the C # code; where the code diverge, I placed a comment. (ebassi) use strict; use warnings; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use Gnome2::GConf; our $client = Gnome2::GConf::Client->get_default; # Tell GConfClient that we're interested in the given directory. # This means GConfClient will receive notification of changes # to this directory, and cache keys under this directory. # So _don't_ add "/" or something silly like that or you'll end # up with a copy of the whole GConf database. ;-) # # We use 'preload_none' to avoid loading all config keys on # startup. If your app pretty much reads all config keys # on startup, then preloading the cache may make sense. $client->add_dir ("/apps/basic-gconf-app", 'preload-none'); our $main_window = create_main_window ($client); $main_window->show_all; Gtk2->main; # Remove any notification on the directory $client->remove_dir ("/apps/basic-gconf-app"); 0; sub create_main_window { my $client = shift; my $w = Gtk2::Window->new('toplevel'); $w->set_title('basic-gconf-app Main Window'); my $vbox = Gtk2::VBox->new(FALSE, 12); $vbox->set_border_width(12); $w->add($vbox); my $config; # Create labels that we can "configure" $config = create_configurable_widget ($client, "/apps/basic-gconf-app/foo"); $vbox->pack_start($config, TRUE, TRUE, 0); $config = create_configurable_widget ($client, "/apps/basic-gconf-app/bar"); $vbox->pack_start($config, TRUE, TRUE, 0); $config = create_configurable_widget ($client, "/apps/basic-gconf-app/baz"); $vbox->pack_start($config, TRUE, TRUE, 0); $config = create_configurable_widget ($client, "/apps/basic-gconf-app/blah"); $vbox->pack_start($config, TRUE, TRUE, 0); $w->signal_connect(destroy => sub { Gtk2->main_quit }); $w->{client} = $client; my $prefs = Gtk2::Button->new("Prefs"); $vbox->pack_end($prefs, FALSE, FALSE, 0); $prefs->signal_connect(clicked => sub { my $button = shift; my $main_window = shift; my $prefs_dialog = $main_window->{prefs}; if (not $prefs_dialog) { my $client = $main_window->{client}; $prefs_dialog = create_prefs_dialog ($main_window, $client); $main_window->{prefs} = $prefs_dialog; $prefs_dialog->signal_connect( destroy => \&prefs_dialog_destroyed, $main_window); $prefs_dialog->show_all; } else { # show existing dialog $prefs_dialog->present; } }, $w); return $w; } # Create a GtkLabel inside a frame, that we can "configure" # (the label displays the value of the config key). sub create_configurable_widget { my $client = shift; my $config_key = shift; my $frame = Gtk2::Frame->new($config_key); my $label = Gtk2::Label->new; $frame->add($label); my $s = $client->get_string($config_key); $label->set_text("Value: $s") if $s; my $notify_id = $client->notify_add($config_key, sub { # Notification callback for our label widgets that # monitor the current value of a gconf key. i.e. # we are conceptually "configuring" the label widgets my ($client, $cnxn_id, $entry, $label) = @_; return unless $entry; # Note that value can be undef (unset) or it can have # the wrong type! Need to check that to survive # gconftool --break-key unless ($entry->{value}) { $label->set_text(''); } elsif ($entry->{value}->{type} eq 'string') { warn(sprintf("got: %s\n", $entry->{value})); $label->set_text("Value: " . $entry->{value}->{value}); } else { $label->set_text('!type error!'); } }, $label); # Note that notify_id will be 0 if there was an error, # so we handle that in our destroy callback. $label->{notify_id} = $notify_id; $label->{client} = $client; $label->signal_connect(destroy => sub { # Remove the notification callback when the widget # monitoring notifications is destroyed my $client = $_[0]->{client}; my $notify_id = $_[0]->{notify_id}; $client->notify_remove($notify_id) if $notify_id; }); return $frame; } # # Preferences dialog code. NOTE that the prefs dialog knows NOTHING # about the existence of the main window; it is purely a way to fool # with the GConf database. It never does something like change # the main window directly; it ONLY changes GConf keys via # GConfClient. This is _important_, because people may configure # your app without using your preferences dialog. # # This is an instant-apply prefs dialog. For a complicated # apply/revert/cancel dialog as in GNOME 1, see the # complex-gconf-app.c example. But don't actually copy that example # in GNOME 2, thanks. ;-) complex-gconf-app.c does show how # to use GConfChangeSet. # sub prefs_dialog_destroyed { my $dialog = shift; my $main_window = shift; $main_window->{prefs} = undef; } sub config_entry_commit { my $entry = shift; my $client = $entry->{client}; my $key = $entry->{key}; my $text = $entry->get_chars(0, -1); # Unset if the string is zero-length, otherwise set if ($text) { # show how to use the generic 'set' method, instead of # get_string. (ebassi) $client->set($key, { type => 'string', value => $text }); } else { $client->unset($key); } # since we connect the "focus_out_event" to this callback, # this return is needed. (ebassi) return FALSE; } sub create_config_entry { my $prefs_dialog = shift; my $client = shift; my $config_key = shift; my $has_focus = shift || FALSE; my $hbox = Gtk2::HBox->new(FALSE, 6); my $label = Gtk2::Label->new("$config_key ="); my $entry = Gtk2::Entry->new; $hbox->pack_start($label, FALSE, FALSE, 0); $hbox->pack_end($entry, FALSE, FALSE, 0); # this will print an error via default error handler # if the key isn't set to a string my $s = $client->get_string($config_key); $entry->set_text($s) if $s; $entry->{client} = $client; $entry->{key} = $config_key; # Commit changes if the user focuses out, or hits enter; we # don't do this on "changed" since it'd probably be a bit too # slow to round-trip to the server on every "changed" signal. $entry->signal_connect(activate => \&config_entry_commit); $entry->signal_connect(focus_out_event => \&config_entry_commit); # Set the entry insensitive if the key it edits isn't writable. # Technically, we should update this sensitivity if the key # gets a change notify, but that's probably overkill. $entry->set_sensitive($client->key_is_writable($config_key)); $entry->grab_focus if $has_focus; return $hbox; } sub create_prefs_dialog { my $parent = shift; my $client = shift; my $dialog = Gtk2::Dialog->new("basic-gconf-app Preferences", $parent, [ qw/destroy-with-parent/ ], 'gtk-close', 'accept'); # destroy dialog on button press $dialog->signal_connect(response => sub { $_[0]->destroy }); $dialog->set_default_response('accept'); # resizing doesn't grow the entries anyhow $dialog->set_resizable(FALSE); my $vbox = Gtk2::VBox->new(FALSE, 12); $vbox->set_border_width(12); $dialog->vbox->pack_start($vbox, FALSE, FALSE, 0); my $entry; $entry = create_config_entry ($dialog, $client, "/apps/basic-gconf-app/foo", TRUE); $vbox->pack_start($entry, FALSE, FALSE, 0); $entry = create_config_entry ($dialog, $client, "/apps/basic-gconf-app/bar"); $vbox->pack_start($entry, FALSE, FALSE, 0); $entry = create_config_entry ($dialog, $client, "/apps/basic-gconf-app/baz"); $vbox->pack_start($entry, FALSE, FALSE, 0); $entry = create_config_entry ($dialog, $client, "/apps/basic-gconf-app/blah"); $vbox->pack_start($entry, FALSE, FALSE, 0); return $dialog; } Gnome2-GConf-1.044/examples/complex-gconf-app.pl0000644000175000017500000002172707756515053021341 0ustar torstentorsten#!/usr/bin/perl # This is a reworked version of basic-gconf-app.pl that uses GConfChangeSet for # storing the preferences with an 'explicit-apply' dialog. (ebassi) use strict; use warnings; use constant TRUE => 1; use constant FALSE => 0; use constant FOO_KEY => '/apps/basic-gconf-app/foo'; use constant BAR_KEY => '/apps/basic-gconf-app/bar'; use constant BAZ_KEY => '/apps/basic-gconf-app/baz'; use constant BLAH_KEY => '/apps/basic-gconf-app/blah'; use Gtk2; use Gnome2::GConf; Gtk2->init; our $client = Gnome2::GConf::Client->get_default; # Tell GConfClient that we're interested in the given directory. # This means GConfClient will receive notification of changes # to this directory, and cache keys under this directory. # So _don't_ add "/" or something silly like that or you'll end # up with a copy of the whole GConf database. ;-) # # We use 'preload_none' to avoid loading all config keys on # startup. If your app pretty much reads all config keys # on startup, then preloading the cache may make sense. $client->add_dir ("/apps/basic-gconf-app", 'preload-none'); our $main_window = create_main_window ($client); $main_window->show_all; Gtk2->main; $client->remove_dir ("/apps/basic-gconf-app"); 0; sub create_main_window { my $client = shift; my $w = Gtk2::Window->new('toplevel'); $w->set_title('complex-gconf-app Main Window'); my $vbox = Gtk2::VBox->new(FALSE, 5); $vbox->set_border_width(5); $w->add($vbox); my $config; # Create labels that we can "configure" $config = create_configurable_widget ($client, FOO_KEY); $vbox->pack_start($config, TRUE, TRUE, 0); $config = create_configurable_widget ($client, BAR_KEY); $vbox->pack_start($config, TRUE, TRUE, 0); $config = create_configurable_widget ($client, BAZ_KEY); $vbox->pack_start($config, TRUE, TRUE, 0); $config = create_configurable_widget ($client, BLAH_KEY); $vbox->pack_start($config, TRUE, TRUE, 0); $w->signal_connect(delete_event => sub { $_[0]->destroy }); $w->signal_connect(destroy => sub { Gtk2->main_quit }); $w->{client} = $client; my $prefs = Gtk2::Button->new("Prefs"); $vbox->pack_end($prefs, FALSE, FALSE, 0); $prefs->signal_connect(clicked => sub { my $button = shift; my $main_window = shift; my $prefs_dialog = $main_window->{prefs}; if (not $prefs_dialog) { my $client = $main_window->{client}; $prefs_dialog = create_prefs_dialog ($main_window, $client); $main_window->{prefs} = $prefs_dialog; $prefs_dialog->signal_connect( destroy => \&prefs_dialog_destroyed, $main_window); $prefs_dialog->show_all; } else { # show existing dialog $prefs_dialog->present; } }, $w); return $w; } # Create a GtkLabel inside a frame, that we can "configure" # (the label displays the value of the config key). sub create_configurable_widget { my $client = shift; my $config_key = shift; my $frame = Gtk2::Frame->new($config_key); my $label = Gtk2::Label->new; $frame->add($label); my $s = $client->get_string($config_key); $label->set_text($s) if $s; my $notify_id = $client->notify_add($config_key, sub { # Notification callback for our label widgets that # monitor the current value of a gconf key. i.e. # we are conceptually "configuring" the label widgets my ($client, $cnxn_id, $entry, $label) = @_; return unless $entry; # Note that value can be undef (unset) or it can have # the wrong type! Need to check that to survive # gconftool --break-key unless ($entry->{value}) { $label->set_text(''); } elsif ($entry->{value}->{type} eq 'string') { $label->set_text($entry->{value}->{value}); } else { $label->set_text('!type error!'); } }, $label); # Note that notify_id will be 0 if there was an error, # so we handle that in our destroy callback. $label->{notify_id} = $notify_id; $label->{client} = $client; $label->signal_connect(destroy => sub { # Remove the notification callback when the widget monitoring # notifications is destroyed my $client = $_[0]->{client}; my $notify_id = $_[0]->{notify_id}; $client->notify_remove($notify_id) if $notify_id; }); return $frame; } # Preferences dialog code. NOTE that the prefs dialog knows NOTHING # about the existence of the main window; it is purely a way to fool # with the GConf database. It never does something like change # the main window directly; it ONLY changes GConf keys via # GConfClient. This is _important_, because people may configure # your app without using your preferences dialog. # # This is an explicit-apply prefs dialog that uses GConfChangeSets. This kind # of dialog is disencouraged inside the GNOME Human Interface Guidelines, # since it's anti-intuitive; nevertheless, sometimes it is the only # acceptable solution (e.g.: when preferences might take more than a short # period of time to apply). (ebassi) sub prefs_dialog_destroyed { my $dialog = shift; my $main_window = shift; $main_window->{prefs} = undef; } sub on_prefs_response { use Data::Dumper; my $dialog = shift; my $response = shift; my $client = shift; my $changeset = $dialog->{changeset}; # see the state of the change set before committing it #print Dumper($changeset); if ('apply' eq $response) { # apply changeset but remain open. we should disable the 'apply' # button until a change is made, but this is left as an exercise # to the reader. $client->commit_change_set($changeset, FALSE); } elsif ('ok' eq $response) { # apply changeset and close. $client->commit_change_set($changeset, FALSE); $dialog->destroy; } else { $dialog->destroy; } } # this sub will handle the changes inside the preferences. It's important to # note that every change is made inside the changeset; the client is not used # inside this callback. sub config_entry_commit { my $entry = shift; my $changeset = $entry->{changeset}; my $key = $entry->{key}; my $text = $entry->get_chars(0, -1); # Unset if the string is zero-length, otherwise set if ($text) { # change the value inside the changeset $changeset->{$key} = { type => 'string', value => $text }; } else { # unset the key inside the changeset $changeset->{$key} = { type => 'string', value => undef }; } # since we also connect the "focus_out_event" to this callback, this return # is needed. (ebassi) FALSE; } sub create_config_entry { my $prefs_dialog = shift; my $changeset = shift; my $config_key = shift; my $has_focus = shift || FALSE; my $hbox = Gtk2::HBox->new(FALSE, 5); my $label = Gtk2::Label->new($config_key); my $entry = Gtk2::Entry->new; $hbox->pack_start($label, FALSE, FALSE, 0); $hbox->pack_end($entry, FALSE, FALSE, 0); # get the key's value from the changeset. it's important to note that a # changeset is a collection of gconfvalues, so we must access the 'value' # field of that data structure. my $s = $changeset->{$config_key}->{'value'}; $entry->set_text($s) if $s; $entry->{changeset} = $changeset; $entry->{key} = $config_key; # Commit changes if the user focuses out, or hits enter; we don't # do this on "changed" since it'd probably be a bit too slow to # round-trip to the server on every "changed" signal. $entry->signal_connect(activate => \&config_entry_commit); $entry->signal_connect(focus_out_event => \&config_entry_commit); # Set the entry insensitive if the key it edits isn't writable. # Technically, we should update this sensitivity if the key gets # a change notify, but that's probably overkill. $entry->set_sensitive($client->key_is_writable($config_key)); $entry->grab_focus if $has_focus; return $hbox; } sub create_prefs_dialog { use Data::Dumper; my $parent = shift; my $client = shift; my $dialog = Gtk2::Dialog->new("basic-gconf-app Preferences", $parent, [ qw/destroy-with-parent/ ], 'gtk-cancel', 'cancel', 'gtk-apply', 'apply', 'gtk-ok', 'ok'); # commit on button press $dialog->signal_connect(response => \&on_prefs_response, $client); $dialog->set_default_response('ok'); # resizing doesn't grow the entries anyhow $dialog->set_resizable(FALSE); my $vbox = Gtk2::VBox->new(FALSE, 5); $vbox->set_border_width(5); $dialog->vbox->pack_start($vbox, FALSE, FALSE, 0); # create the changeset from the current key state; the changeset will be # our "interface" to the gconf client, and we will operate any change in # the key state on it. my $cs = $client->change_set_from_current( FOO_KEY, BAR_KEY, BAZ_KEY, BLAH_KEY ); # see the state of the changeset #print Dumper($cs); my $entry; $entry = create_config_entry ($dialog, $cs, FOO_KEY, TRUE); $vbox->pack_start($entry, FALSE, FALSE, 0); $entry = create_config_entry ($dialog, $cs, BAR_KEY); $vbox->pack_start($entry, FALSE, FALSE, 0); $entry = create_config_entry ($dialog, $cs, BAZ_KEY); $vbox->pack_start($entry, FALSE, FALSE, 0); $entry = create_config_entry ($dialog, $cs, BLAH_KEY); $vbox->pack_start($entry, FALSE, FALSE, 0); $dialog->{changeset} = $cs; # hold a reference return $dialog; } Gnome2-GConf-1.044/maps0000644000175000017500000000072310513234233014502 0ustar torstentorstenGCONF_TYPE_ENGINE GConfEngine GBoxed Gnome2::GConf::Engine GCONF_TYPE_CLIENT GConfClient GObject Gnome2::GConf::Client GCONF_TYPE_VALUE_TYPE GConfValueType GEnum Gnome2::GConf::ValueType GCONF_TYPE_UNSET_FLAGS GConfUnsetFlags GFlags Gnome2::GConf::UnsetFlags GCONF_TYPE_CLIENT_PRELOAD_TYPE GConfClientPreloadType GEnum Gnome2::GConf::ClientPreloadType GCONF_TYPE_CLIENT_ERROR_HANDLING_MODE GConfClientErrorHandlingMode GEnum Gnome2::GConf::ClientErrorHandlingMode Gnome2-GConf-1.044/xs/0000755000175000017500000000000010677450301014256 5ustar torstentorstenGnome2-GConf-1.044/xs/GConfClient.xs0000644000175000017500000006750410513234233016772 0ustar torstentorsten/* * Copyright (c) 2003, 2004 by Emmanuele Bassi (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library 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. */ #include "gconfperl.h" #include /* Here's some magic. In C, the notify function has the following parameters: * the GConfClient that is monitoring the keys, the connection id for notifier * handler and a GConfEntry, which is an opaque container for the key which is * being monitored and its value, stored as a GConfValue dynamic type (similar * to GValue). Both GConfEntry and GConfValue should not be accessed directly * from the programmer (except for the "type" field of GConfValue, which is * used for type detection); so, these two objects do not have a type inside * Glib. In order to expose the data contained inside those two objects, we * create an hashref and fill it with the key and the value; then, we pass it * to the notify marshaller. */ static GPerlCallback * gconfperl_notify_func_create (SV * func, SV * data) { GType param_types [] = { GCONF_TYPE_CLIENT, G_TYPE_INT, GPERL_TYPE_SV, }; return gperl_callback_new (func, data, G_N_ELEMENTS (param_types), param_types, 0); } static void gconfperl_notify_func (GConfClient * client, guint cnxn_id, GConfEntry * entry, gpointer data) { gperl_callback_invoke ((GPerlCallback*)data, NULL, client, cnxn_id, newSVGConfEntry (entry)); } /* the "error" and "unreturned_error" signals pass a GError to the callbacks * attached to them. GError is an opaque struct which contains the error * message string. Since GError is not a Glib type, we pass to the Perl * marshallers directly the message string. */ static void gconfperl_client_error_marshal (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) { GError *err; dGPERL_CLOSURE_MARSHAL_ARGS; GPERL_CLOSURE_MARSHAL_INIT (closure, marshal_data); PERL_UNUSED_VAR (return_value); PERL_UNUSED_VAR (n_param_values); PERL_UNUSED_VAR (invocation_hint); ENTER; SAVETMPS; PUSHMARK (SP); GPERL_CLOSURE_MARSHAL_PUSH_INSTANCE (param_values); err = (GError *) g_value_get_pointer (param_values + 1); XPUSHs (sv_2mortal (gperl_sv_from_gerror (err))); GPERL_CLOSURE_MARSHAL_PUSH_DATA; PUTBACK; GPERL_CLOSURE_MARSHAL_CALL (G_DISCARD); FREETMPS; LEAVE; } MODULE = Gnome2::GConf::Client PACKAGE = Gnome2::GConf::Client PREFIX = gconf_client_ BOOT: gperl_signal_set_marshaller_for (GCONF_TYPE_CLIENT, "unreturned_error", gconfperl_client_error_marshal); gperl_signal_set_marshaller_for (GCONF_TYPE_CLIENT, "error", gconfperl_client_error_marshal); =for position DESCRIPTION =head1 DESCRIPTION Gnome2::GConf::Client is a commodity class based on C used to access the default C provided by the GConf daemon. It has a cache, finer-grained notification of changes and a default error handling mechanism. =head1 ERROR HANDLING In C, each fallible function has a C optional argument: by setting it to a valid C structure, the function will fill it in case of error; by passing a NULL value, the function will silently fail. In Perl, each fallible method has a boolean C argument; by setting this argument to C, the method will croak con failure, otherwise it will silently fail. B: To retain backward compatibility, the default behaviour is to check each error; that is, the C argument silently is set to TRUE. In order to catch an error, you might use eval as a try...catch equivalent: eval { $s = $client->get_string($some_key); 1; }; if (Glib::Error::matches($@, 'Gnome2::GConf::Error', 'bad-key')) { # recover from a bad-key error. } On failure, if the error is unchecked, the C signal will be fired by the Gnome2::GConf::Client object; the C signal will B be fired, whether the error is checked or not. If you want to let the global error handler function catch just the unchecked error, use the C method, and attach a callback to the C signal: $client->set_error_handling('handle-unreturned'); $client->signal_connect(unreturned_error => sub { my ($client, $error) = @_; warn $error; # is a Glib::Error }); =cut GConfClient_noinc * gconf_client_get_default (class) C_ARGS: /* void */ GConfClient_noinc * gconf_client_get_for_engine (class, engine) GConfEngine * engine C_ARGS: engine =for enum GConfClientPreloadType =cut void gconf_client_add_dir (client, dir, preload, check_error=TRUE) GConfClient * client const gchar * dir GConfClientPreloadType preload gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { gconf_client_add_dir (client, dir, preload, &err); if (err) gperl_croak_gerror (NULL, err); } else gconf_client_add_dir (client, dir, preload, NULL); void gconf_client_remove_dir (client, dir, check_error=TRUE) GConfClient * client const gchar * dir gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { gconf_client_remove_dir (client, dir, &err); if (err) gperl_croak_gerror (NULL, err); } else gconf_client_remove_dir (client, dir, NULL); guint gconf_client_notify_add (client, namespace_section, func, data=NULL, check_error=TRUE) GConfClient * client const gchar * namespace_section SV * func SV * data gboolean check_error PREINIT: GPerlCallback * callback; GError * err = NULL; guint cnxn_id = 0; CODE: callback = gconfperl_notify_func_create (func, data); if (TRUE == check_error) { cnxn_id = gconf_client_notify_add (client, namespace_section, gconfperl_notify_func, callback, (GFreeFunc) gperl_callback_destroy, &err); if (err) gperl_croak_gerror (NULL, err); } else { cnxn_id = gconf_client_notify_add (client, namespace_section, gconfperl_notify_func, callback, (GFreeFunc) gperl_callback_destroy, NULL); } RETVAL = cnxn_id; OUTPUT: RETVAL void gconf_client_notify_remove (GConfClient * client, guint cnxn_id) =for enum GConfClientErrorHandlingMode =cut void gconf_client_set_error_handling (client, mode) GConfClient * client GConfClientErrorHandlingMode mode ##void gconf_client_set_global_default_error_handler (GConfClientErrorHandlerFunc func); void gconf_client_clear_cache (GConfClient * client) void gconf_client_preload (client, dirname, type, check_error=TRUE) GConfClient * client const gchar * dirname GConfClientPreloadType type gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { gconf_client_preload (client, dirname, type, &err); if (err) gperl_croak_gerror (NULL, err); } else { gconf_client_preload (client, dirname, type, NULL); } ### Get/Set methods ##void gconf_client_set (GConfClient *client, const gchar *key, const GConfValue *val, GError **err); =for apidoc Set the C I<$val> bound to the given I<$key>. =cut void gconf_client_set (client, key, value, check_error=TRUE) GConfClient * client const gchar * key GConfValue * value gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { gconf_client_set (client, key, value, &err); } else { gconf_client_set (client, key, value, NULL); } gconf_value_free (value); /* leaks otherwise */ if (err) gperl_croak_gerror (NULL, err); ##GConfValue* gconf_client_get (GConfClient *client, const gchar *key, GError **err); =for apidoc Fetch the C bound to the give I<$key>. =cut GConfValue * gconf_client_get (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_get (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_get (client, key, NULL); } OUTPUT: RETVAL ##GConfValue* gconf_client_get_without_default (GConfClient *client, const gchar *key, GError **err); GConfValue * gconf_client_get_without_default (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_get_without_default (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_get_without_default (client, key, NULL); } OUTPUT: RETVAL ##GConfEntry* gconf_client_get_entry (GConfClient *client, const gchar *key, const gchar *locale, gboolean use_schema_default, GError **err); GConfEntry * gconf_client_get_entry (client, key, locale, use_schema_default, check_error=TRUE) GConfClient * client const gchar * key const gchar * locale gboolean use_schema_default gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_get_entry (client, key, locale, use_schema_default, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_get_entry (client, key, locale, use_schema_default, NULL); } OUTPUT: RETVAL ##GConfValue* gconf_client_get_default_from_schema (GConfClient *client, const gchar *key, GError **err); GConfValue * gconf_client_get_default_from_schema (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_get_default_from_schema (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_get_default_from_schema (client, key, NULL); } OUTPUT: RETVAL ##gboolean gconf_client_unset (GConfClient* client, const gchar* key, GError** err); gboolean gconf_client_unset (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_unset (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_unset (client, key, NULL); } OUTPUT: RETVAL #if GCONF_CHECK_VERSION (2, 3, 3) gboolean gconf_client_recursive_unset (client, key, flags=0, check_error=TRUE) GConfClient * client const gchar * key GConfUnsetFlags flags gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_recursive_unset (client, key, flags, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_recursive_unset (client, key, flags, NULL); } OUTPUT: RETVAL #endif /* GCONF_CHECK_VERSION (2, 3, 3) */ ##GSList* gconf_client_all_entries (GConfClient *client, const gchar *dir, GError **err); =for apidoc =for signature list = $client->all_entries($dir, $check_error=TRUE) This method returns an array containing all the entries (as L) of a given directory. =cut void gconf_client_all_entries (client, dir, check_error=TRUE) GConfClient * client const gchar * dir gboolean check_error PREINIT: GError * err = NULL; GSList * l, * tmp; PPCODE: if (TRUE == check_error) { l = gconf_client_all_entries (client, dir, &err); if (err) gperl_croak_gerror (NULL, err); } else { l = gconf_client_all_entries (client, dir, NULL); } for (tmp = l; tmp != NULL; tmp = tmp->next) { GConfEntry *entry = (GConfEntry *) tmp->data; XPUSHs (sv_2mortal (newSVGConfEntry (entry))); } g_slist_free (l); ##GSList* gconf_client_all_dirs (GConfClient *client, const gchar *dir, GError **err); =for apidoc =for signature list = $client->all_dirs($dir, $check_error=TRUE) This method returns an array containing all the directories in a given directory. =cut void gconf_client_all_dirs (client, dir, check_error=TRUE) GConfClient * client const gchar * dir gboolean check_error PREINIT: GError * err = NULL; GSList * l, * tmp; PPCODE: if (TRUE == check_error) { l = gconf_client_all_dirs (client, dir, &err); if (err) gperl_croak_gerror (NULL, err); } else { l = gconf_client_all_dirs (client, dir, NULL); } for (tmp = l; tmp != NULL; tmp = tmp->next) XPUSHs (sv_2mortal (newSVGChar (tmp->data))); g_slist_free (l); ##void gconf_client_suggest_sync (GConfClient* client, GError** err); void gconf_client_suggest_sync (client, check_error=TRUE) GConfClient * client gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { gconf_client_suggest_sync (client, &err); if (err) gperl_croak_gerror (NULL, err); } else { gconf_client_suggest_sync (client, NULL); } ##gboolean gconf_client_dir_exists (GConfClient* client, const gchar* dir, GError** err); gboolean gconf_client_dir_exists (client, dir, check_error=TRUE) GConfClient * client const gchar * dir gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_dir_exists (client, dir, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_dir_exists (client, dir, NULL); } OUTPUT: RETVAL ##gboolean gconf_client_key_is_writable (GConfClient* client, const gchar* key, GError** err); gboolean gconf_client_key_is_writable (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_key_is_writable (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_key_is_writable (client, key, NULL); } OUTPUT: RETVAL ##gdouble gconf_client_get_float (GConfClient* client, const gchar* key, GError** err); gdouble gconf_client_get_float (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_get_float (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_get_float (client, key, NULL); } OUTPUT: RETVAL ##gint gconf_client_get_int (GConfClient* client, const gchar* key, GError** err); gint gconf_client_get_int (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_get_int (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_get_int (client, key, NULL); } OUTPUT: RETVAL ##/* free the retval, if non-NULL */ ##gchar* gconf_client_get_string(GConfClient* client, const gchar* key, GError** err); gchar_own * gconf_client_get_string (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_get_string (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_get_string (client, key, NULL); } OUTPUT: RETVAL ##gboolean gconf_client_get_bool (GConfClient* client, const gchar* key, GError** err); gboolean gconf_client_get_bool (client, key, check_error=TRUE) GConfClient * client const gchar * key gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_get_bool (client, key, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_get_bool (client, key, NULL); } OUTPUT: RETVAL ##GConfSchema* gconf_client_get_schema (GConfClient* client, ## const gchar* key, GError** err); GConfSchema * gconf_client_get_schema (client, key) GConfClient * client const gchar * key PREINIT: GError * err = NULL; CODE: RETVAL = gconf_client_get_schema (client, key, &err); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL CLEANUP: gconf_schema_free (RETVAL); ### These methods are implemented in perl, but we still need documentation on ### them, so we cheat with this evil trick. ##GSList* gconf_client_get_list (GConfClient* client, const gchar* key, ## GConfValueType list_type, GError** err); ##gboolean gconf_client_get_pair (GConfClient* client, const gchar* key, ## GConfValueType car_type, GConfValueType cdr_type, ## gpointer car_retloc, gpointer cdr_retloc, ## GError** err); #if 0 =for apidoc =for signature list = $client->get_list($key, $check_error=TRUE) =cut void gconf_client_get_list (GConfClient * client, const gchar * key, gboolean check_error=TRUE) =for apidoc =for signature (car, cdr) = $client->get_pair($key, $check_error=TRUE) =cut void gconf_client_get_pair (GConfClient * client, const gchar * key, gboolean check_error=TRUE) #endif ## gboolean gconf_client_set_float (GConfClient* client, const gchar* key, gdouble val, GError** err); =for apidoc Returns FALSE on failure. =cut gboolean gconf_client_set_float (client, key, val, check_error=TRUE) GConfClient * client const gchar * key gdouble val gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_set_float (client, key, val, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_set_float (client, key, val, NULL); } OUTPUT: RETVAL ## gboolean gconf_client_set_int (GConfClient* client, const gchar* key, gint val, GError** err); =for apidoc Returns FALSE on failure. =cut gboolean gconf_client_set_int (client, key, val, check_error=TRUE) GConfClient * client const gchar * key gint val gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_set_int (client, key, val, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_set_int (client, key, val, NULL); } OUTPUT: RETVAL ## gboolean gconf_client_set_string (GConfClient* client, const gchar* key, const gchar* val, GError** err); =for apidoc Returns FALSE on failure =cut gboolean gconf_client_set_string (client, key, val, check_error=TRUE) GConfClient * client const gchar * key const gchar * val gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_set_string (client, key, val, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_set_string (client, key, val, NULL); } OUTPUT: RETVAL ## gboolean gconf_client_set_bool (GConfClient* client, const gchar* key, gboolean val, GError** err); =for apidoc Returns FALSE on failure. =cut gboolean gconf_client_set_bool (client, key, val, check_error=TRUE) GConfClient * client const gchar * key gboolean val gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_set_bool (client, key, val, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_set_bool (client, key, val, NULL); } OUTPUT: RETVAL ##gboolean gconf_client_set_schema (GConfClient* client, const gchar* key, ## const GConfSchema* val, GError** err); gboolean gconf_client_set_schema (client, key, schema, check_error=TRUE) GConfClient * client const gchar * key GConfSchema * schema gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_set_schema (client, key, schema, &err); gconf_schema_free (schema); /* leaks otherwise */ if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_set_schema (client, key, schema, NULL); gconf_schema_free (schema); } OUTPUT: RETVAL ### These methods are implemented in perl, but we still need documentation on ### them, so we cheat with this evil trick. ##/* List should be the same as the one gconf_client_get_list() would return */ ##gboolean gconf_client_set_list (GConfClient* client, const gchar* key, ## GConfValueType list_type, ## GSList* list, ## GError** err); ##gboolean gconf_client_set_pair (GConfClient* client, const gchar* key, ## GConfValueType car_type, GConfValueType cdr_type, ## gconstpointer address_of_car, ## gconstpointer address_of_cdr, ## GError** err); #if 0 gboolean gconf_client_set_list (client, key, list_type, list, check_error=TRUE) GConfClient * client const gchar * key const gchar * list_type SV * list gboolean check_error gboolean gconf_client_set_pair (client, key, car, cdr, check_error=TRUE) GConfClient * client const gchar * key GConfValue * car GConfValue * cdr gboolean check_error #endif ##/* Functions to emit signals */ ##void gconf_client_error (GConfClient* client, GError* error); =for apidoc =for arg error a L You should not use this method. This method emits the "error" signal. =cut void gconf_client_error (client, error) GConfClient * client SV * error PREINIT: GError * err = NULL; PPCODE: gperl_gerror_from_sv (error, &err); gconf_client_error (client, err); /* free err, otherwise we'd leak it. */ g_error_free (err); ##void gconf_client_unreturned_error (GConfClient* client, GError* error); =for apidoc =for arg error a L You should not use this method. This method emits the "unreturned-error" signal. =cut void gconf_client_unreturned_error (client, error) GConfClient * client SV * error PREINIT: GError * err = NULL; PPCODE: gperl_gerror_from_sv (error, &err); gconf_client_unreturned_error (client, err); /* free err, otherwise we'd leak it. */ g_error_free (err); ##void gconf_client_value_changed (GConfClient* client, ## const gchar* key, ## GConfValue* value); =for apidoc You should not use this method. This method emits the "value-changed" signal. =cut void gconf_client_value_changed (client, key, value) GConfClient * client const gchar * key GConfValue * value PPCODE: gconf_client_value_changed (client, key, value); gconf_value_free (value); /* leaks otherwise */ ##/* ## * Change set stuff ## */ ## ##gboolean gconf_client_commit_change_set (GConfClient* client, ## GConfChangeSet* cs, ## /* remove all ## successfully ## committed changes ## from the set */ ## gboolean remove_committed, ## GError** err); =for apidoc =for signature boolean = $client->commit_change_set ($cs, $remove_committed, $check_error=TRUE) =for signature (boolean, changeset) = $client->commit_change_set ($cs, $remove_committed, $check_error=TRUE) Commit a given L. In scalar context, or if I<$remove_committed> is FALSE, return a boolean value; otherwise, return the boolean value and the L I<$cs>, pruned of the successfully committed changes. =cut void gconf_client_commit_change_set (client, cs, remove_committed, check_error=TRUE) GConfClient * client GConfChangeSet * cs gboolean remove_committed gboolean check_error PREINIT: GError * err = NULL; gboolean res; PPCODE: if (TRUE == check_error) { res = gconf_client_commit_change_set (client, cs, remove_committed, &err); if (err) gperl_croak_gerror (NULL, err); } else { res = gconf_client_commit_change_set (client, cs, remove_committed, NULL); } if ((GIMME_V != G_ARRAY) || (! remove_committed)) { /* push on the stack the returned boolean value if the user * wants only that, or if the user does not want to remove * the successfully committed keys. */ XPUSHs (sv_2mortal (newSViv (res))); gconf_change_set_unref (cs); } else { /* push on the stack the returned value AND the reduced set. */ XPUSHs (sv_2mortal (newSViv (res))); XPUSHs (sv_2mortal (newSVGConfChangeSet (cs))); } ##/* Create a change set that would revert the given change set for the given GConfClient */ ##GConfChangeSet* gconf_client_reverse_change_set (GConfClient* client, ## GConfChangeSet* cs, ## GError** err); =for apidoc Reverse the given L. =cut GConfChangeSet * gconf_client_reverse_change_set (client, cs, check_error=TRUE) GConfClient * client GConfChangeSet * cs gboolean check_error PREINIT: GError * err = NULL; CODE: if (TRUE == check_error) { RETVAL = gconf_client_reverse_change_set (client, cs, &err); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_reverse_change_set (client, cs, NULL); } OUTPUT: RETVAL ### Gnome2::GConf::Client::change_set_from_current is really ### change_set_from_currentv for implementation ease, but the calling signature ### is the same of change_set_from_current, so here it goes. ##GConfChangeSet* gconf_client_change_set_from_currentv (GConfClient* client, ## const gchar** keys, ## GError** err); ##GConfChangeSet* gconf_client_change_set_from_current (GConfClient* client, ## GError** err, ## const gchar* first_key, ## ...); =for apidoc =for arg key (__hide__) =for arg ... list of keys to add to the changeset Create a L from a list of keys inside the GConf database. =cut GConfChangeSet * gconf_client_change_set_from_current (client, check_error=TRUE, key, ...) GConfClient * client gboolean check_error PREINIT: char ** keys; int i; GError * err = NULL; CODE: keys = g_new0 (char *, items - 1); for (i = 2; i < items; i++) keys[i-1] = SvPV_nolen (ST (i)); if (TRUE == check_error) { RETVAL = gconf_client_change_set_from_currentv (client, (const gchar **) keys, &err); g_free (keys); if (err) gperl_croak_gerror (NULL, err); } else { RETVAL = gconf_client_change_set_from_currentv (client, (const gchar **) keys, NULL); g_free (keys); } OUTPUT: RETVAL Gnome2-GConf-1.044/xs/GConfSchema.xs0000644000175000017500000001411410513234233016741 0ustar torstentorsten/* * Copyright (c) 2003 by Emmanuele Bassi (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library 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. */ #include "gconfperl.h" /* See GConfEntry and GConfValue. GConfSchema is (yet another) hollow boxed * type, which describes a key/value pair; it provides a short description of * the key, a longer one, the locale to which both descriptions applies to, the * application that handles this pair, and a default value for the key. Since * there's no registered type for this container, we use a Perl hashref, and an * interface to all the accessor methods. */ SV * newSVGConfSchema (GConfSchema * s) { HV * h; SV * r; GConfValueType t; if (! s) return newSVsv(&PL_sv_undef); h = newHV (); r = newRV_noinc ((SV *) h); /* safe */ /* we begin storing the default type. * originally, GConfSchema also offers the type of the list or the type * of the pair; since that is really a job for GConfValue, we simply * let that handle the 'list'/'pair' case; the programmer will simply * do: * * # pair * if ($schema->{type} eq 'pair') { * $car_type = $schema->{default}->{car}->{type}; * $cdr_type = $schema->{default}->{cdr}->{type}; * } * * # list * elsif ($schema->{type} eq 'list') { * $list_type = $schema->{default}->{type}; * } * * which is a little more perlish. */ t = gconf_schema_get_type (s); hv_store (h, "type", 4, gperl_convert_back_enum (GCONF_TYPE_VALUE_TYPE, t), 0); /* all the strings are constant, so we use copies */ hv_store (h, "locale", 6, newSVGChar (gconf_schema_get_locale (s)), 0); hv_store (h, "short_desc", 10, newSVGChar (gconf_schema_get_short_desc (s)), 0); hv_store (h, "long_desc", 9, newSVGChar (gconf_schema_get_long_desc (s)), 0); hv_store (h, "owner", 5, newSVGChar (gconf_schema_get_owner (s)), 0); /* default value: we convert it from a GConfValue */ hv_store (h, "default_value", 13, newSVGConfValue (gconf_schema_get_default_value (s)), 0); return r; } GConfSchema * SvGConfSchema (SV * data) { HV * h; SV ** s; GConfSchema * schema; GConfValueType t; int n; if ((!data) || (!SvOK(data)) || (!SvRV(data)) || (SvTYPE(SvRV(data)) != SVt_PVHV)) croak ("SvGConfSchema: value must be an hashref"); h = (HV *) SvRV (data); schema = gconf_schema_new (); /* every key inside the hashref is optional */ if ((s = hv_fetch (h, "type", 4, 0)) && SvOK (*s)) { /* if it is an integer, just assign it... */ if (looks_like_number (*s)) t = SvIV (*s); else { /* otherwise, try to convert it from the enum */ if (!gperl_try_convert_enum (GCONF_TYPE_VALUE_TYPE, *s, &n)) croak ("SvGConfSchema: 'type' should be either " "a GConfValueType or an integer"); t = (GConfValueType) n; } gconf_schema_set_type (schema, t); } if ((s = hv_fetch (h, "default_value", 13, 0)) && SvOK (*s)) { gconf_schema_set_default_value (schema, SvGConfValue (*s)); } if ((s = hv_fetch (h, "owner", 5, 0)) && SvOK (*s)) { gconf_schema_set_owner (schema, SvGChar (*s)); } if ((s = hv_fetch (h, "short_desc", 10, 0)) && SvOK (*s)) { gconf_schema_set_short_desc (schema, SvGChar (*s)); } if ((s = hv_fetch (h, "long_desc", 9, 0)) && SvOK (*s)) { gconf_schema_set_long_desc (schema, SvGChar (*s)); } if ((s = hv_fetch (h, "locale", 6, 0)) && SvOK (*s)) { gconf_schema_set_locale (schema, SvGChar (*s)); } return schema; } MODULE = Gnome2::GConf::Schema PACKAGE = Gnome2::GConf::Schema PREFIX = gconf_schema =for object Gnome2::GConf::Schema Schema Objects for key description =cut =for position SYNOPSIS =head1 SYNOPSIS $client->set_schema($key, { owner => 'some_program', short_desc => 'Some key.', long_desc => 'A key that does something to some_program.', locale => 'C', type => 'int', default_value => { type => 'int', value => 42 } }); $description{'short'} = $client->get_schema($key)->{short_desc}; =cut =for position DESCRIPTION =head1 DESCRIPTION In C, C is an opaque type for a "schema", that is a collection of useful informations about a key/value pair. It may contain a description of the key, a default value, the program which owns the key, etc. In perl, it is represented using an hashref containing any of these keys: =over 4 =item B The type of the value the key points to. It's similar to the corresponding 'type' key of C, but it explicitly tags lists and pairs using the 'list' and 'pair' types (the 'type' key is just an indication of what should be expected inside the C field). =item B The default value of the key. In C, this should be a C, so, in perl, it becomes an hashref (see L) =item B A string containing a short description (a phrase, no more) of the key. =item B A string containing a longer description (a paragraph or more) of the key. =item B A string containing the name of the program which uses ('owns') the key to which the schema is bound. =item B The locale for the three strings above (above strings are UTF-8, and the locale is needed for translations purposes). =back =cut =for see_also =head1 SEE ALSO L(3pm), L(3pm). =cut ## we need an explicit DESTROY because GConfSchema objects are ## dynamically allocated and thus must be freed by us. void DESTROY (schema) SV * schema CODE: gconf_schema_free (SvGConfSchema (schema)); Gnome2-GConf-1.044/xs/GConfEngine.xs0000644000175000017500000003007210417400152016745 0ustar torstentorsten/* * Copyright (c) 2005 by Emmanuele Bassi (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library 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. */ #include "gconfperl.h" #ifdef GCONFPERL_TYPE_ENGINE GType gconfperl_gconf_engine_get_type (void) { static GType t = 0; if (! t) { t = g_boxed_type_register_static ("GConfEngine", (GBoxedCopyFunc) gconf_engine_ref, (GBoxedFreeFunc) gconf_engine_unref); } return t; } #endif /* GCONFPERL_TYPE_ENGINE */ static GPerlCallback * gconfperl_engine_notify_func_create (SV * func, SV * data) { GType param_types [] = { GCONF_TYPE_ENGINE, G_TYPE_INT, GPERL_TYPE_SV, }; return gperl_callback_new (func, data, G_N_ELEMENTS (param_types), param_types, 0); } static void gconfperl_engine_notify_func (GConfEngine *engine, guint cnxn_id, GConfEntry *entry, gpointer data) { gperl_callback_invoke ((GPerlCallback*)data, NULL, engine, cnxn_id, newSVGConfEntry (entry)); } MODULE = Gnome2::GConf::Engine PACKAGE = Gnome2::GConf::Engine PREFIX = gconf_engine_ =for object Gnome2::GConf::Engine A Configuration Engine =cut =for position SYNOPSIS =head1 SYNOPSIS =cut =for position DESCRIPTION =head1 DESCRIPTION Gnome2::GConf::Engine is the Perl binding for the C object. A GConfEngine is a configuration engine, that is a stack of config sources. Normally, there's just one of these on the system. Gnome2::GConf::Engine provides a low-level interface for accessing GConf data; you should normally use a Gnome2::GConf::Client inside your code. =for see_also =head1 SEE ALSO L(3pm), L(3pm), L(3pm). =cut ## gconf-engine.h =for apidoc Get the default Gnome2::GConf::Engine. =cut GConfEngine * gconf_engine_get_default (class) C_ARGS: /* void */ =for apidoc Create a Gnome2::GConf::Engine for the given address. =cut GConfEngine_ornull * gconf_engine_get_for_address (class, address) const gchar * address C_ARGS: address PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_get_for_address (address, &err); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL #if GCONF_CHECK_VERSION (2, 7, 1) =for apidoc Create a Gnome2::GConf::Engine for the given addresses. =cut GConfEngine_ornull * gconf_engine_get_for_addresses (class, ...) PREINIT: GSList *addresses = NULL; int i; GError *err = NULL; CODE: for (i = 1; i < items; i++) addresses = g_slist_append (addresses, SvPV_nolen (ST (i))); RETVAL = gconf_engine_get_for_addresses (addresses, &err); g_slist_free (addresses); /* the contents are handled by Perl */ if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL #endif /* GCONF_CHECK_VERSION (2, 7, 1) */ # these should never be needed ## void gconf_engine_ref (GConfEngine *engine) ## void gconf_engine_unref (GConfEngine *engine) # these cannot hold more than an integer, so we do not need those too. ## void gconf_engine_set_user_data (GConfEngine *engine, gpointer user_data, GDestroyNotify dnotify) ## gpointer gconf_engine_get_user_data (GConfEngine *engine) ## gconf.h #/* Low-level interfaces */ =for apidoc Fetch and return the Gnome2::GConf::Value bound to the given $key. This overrides Glib::Object's C, so you'll want to use C<< $object->get_property >> to get object's properties. =cut GConfValue * gconf_engine_get (engine, key) GConfEngine * engine const gchar * key PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_get (engine, key, &err); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL =for apidoc Fetch the Gnome2::GConf::Value bound to the given key, without returning the default value (specified inside the schema) if the key is unset. =cut GConfValue * gconf_engine_get_without_default (engine, key) GConfEngine * engine const gchar * key PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_get_without_default (engine, key, &err); if (err) gperl_croak_gerror (NULL, err); =for apidoc Fetch and return the Gnome2::GConf::Value bound to the given $key, for a specific $locale. Locale only matters if you are expecting to get a schema, or if you don't know what you are expecting and it might be a schema. Note that Gnome2::GConf::Engine::get automatically uses the current locale, which is normally what you want. =cut GConfValue * gconf_engine_get_with_locale (engine, key, locale) GConfEngine * engine const gchar * key const gchar * locale PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_get_with_locale (engine, key, locale, &err); if (err) gperl_croak_gerror (NULL, err); =for apidoc Set the Gnome2::GConf::Value bound to the given key. =cut gboolean gconf_engine_set (engine, key, value) GConfEngine * engine const gchar * key GConfValue * value PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_set (engine, key, value, &err); gconf_value_free (value); /* leaks otherwise */ if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL =for apidoc Unset the given key. =cut gboolean gconf_engine_unset (engine, key) GConfEngine * engine const gchar * key PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_unset (engine, key, &err); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL =for apidoc Associate a schema to a key. $schema_key should have a schema (if $key stores a value) or a dir full of schemas (if $key stores a directory name) =cut gboolean gconf_engine_associate_schema (engine, key, schema_key) GConfEngine * engine const gchar * key const gchar * schema_key PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_associate_schema (engine, key, schema_key, &err); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL =for apidoc This method returns an array containing all the entries of a given directory. =cut void gconf_engine_all_entries (engine, dir) GConfEngine * engine const gchar * dir PREINIT: GError * err = NULL; GSList * l, * tmp; PPCODE: l = gconf_engine_all_entries (engine, dir, &err); if (err) gperl_croak_gerror (NULL, err); for (tmp = l; tmp != NULL; tmp = tmp->next) XPUSHs (sv_2mortal (newSVGChar (gconf_entry_get_key(tmp->data)))); g_slist_free (l); =for apidoc This method returns an array containing all the directories in a given directory. =cut void gconf_engine_all_dirs (engine, dir) GConfEngine * engine const gchar * dir PREINIT: GError * err = NULL; GSList * l, * tmp; PPCODE: l = gconf_engine_all_dirs (engine, dir, &err); if (err) gperl_croak_gerror (NULL, err); for (tmp = l; tmp != NULL; tmp = tmp->next) XPUSHs (sv_2mortal (newSVGChar (tmp->data))); g_slist_free (l); ##void gconf_engine_suggest_sync (GConfEngine *conf, ## GError **err); void gconf_engine_suggest_sync (engine) GConfEngine * engine PREINIT: GError *err = NULL; CODE: gconf_engine_suggest_sync (engine, &err); if (err) gperl_croak_gerror (NULL, err); ##gboolean gconf_engine_dir_exists (GConfEngine *conf, ## const gchar *dir, ## GError **err); gboolean gconf_engine_dir_exists (engine, dir) GConfEngine * engine const gchar * dir PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_dir_exists (engine, dir, &err); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL ##void gconf_engine_remove_dir (GConfEngine* conf, ## const gchar* dir, ## GError** err); ## void gconf_engine_remove_dir (engine, dir) GConfEngine * engine const gchar * dir PREINIT: GError *err = NULL; CODE: gconf_engine_remove_dir (engine, dir, &err); if (err) gperl_croak_gerror (NULL, err); ##gboolean gconf_engine_key_is_writable (GConfEngine *conf, ## const gchar *key, ## GError **err); gboolean gconf_engine_key_is_writable (engine, key) GConfEngine * engine const gchar * key PREINIT: GError *err = NULL; CODE: RETVAL = gconf_engine_key_is_writable (engine, key, &err); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL guint gconf_engine_notify_add (engine, namespace_section, func, data=NULL) GConfEngine * engine const gchar * namespace_section SV * func SV * data PREINIT: GPerlCallback * callback; GError * err = NULL; guint cnxn_id = 0; CODE: callback = gconfperl_engine_notify_func_create (func, data); cnxn_id = gconf_engine_notify_add (engine, namespace_section, gconfperl_engine_notify_func, callback, &err); if (err) gperl_croak_gerror (NULL, err); RETVAL = cnxn_id; OUTPUT: RETVAL void gconf_engine_notify_remove (GConfEngine * engine, guint cnxn_id) ##/* ## * Higher-level stuff ## */ ## gconf-changeset.h =for apidoc =for signature boolean = $engine->commit_change_set ($cs, $remove_committed) =for signature (boolean, changeset) = $engine->commit_change_set ($cs, $remove_committed) Commit a given L. In scalar context, or if I<$remove_committed> is FALSE, return a boolean value; otherwise, return the boolean value and the L I<$cs>, pruned of the successfully committed changes. =cut void gconf_engine_commit_change_set (engine, cs, remove_committed) GConfEngine * engine GConfChangeSet * cs gboolean remove_committed PREINIT: GError * err = NULL; gboolean res; PPCODE: res = gconf_engine_commit_change_set (engine, cs, remove_committed, &err); if (err) { gperl_croak_gerror (NULL, err); } if ((GIMME_V != G_ARRAY) || (! remove_committed)) { /* push on the stack the returned boolean value if the user * wants only that, or if the user does not want to remove * the successfully committed keys. */ XPUSHs (sv_2mortal (newSViv (res))); gconf_change_set_unref (cs); } else { /* push on the stack the returned value AND the reduced set. */ XPUSHs (sv_2mortal (newSViv (res))); XPUSHs (sv_2mortal (newSVGConfChangeSet (cs))); } =for apidoc Create a change set that would revert the given change set for the given L. =cut GConfChangeSet * gconf_engine_reverse_change_set (engine, cs) GConfEngine * engine GConfChangeSet * cs PREINIT: GError * err = NULL; CODE: RETVAL = gconf_engine_reverse_change_set (engine, cs, &err); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL ### Gnome2::GConf::Engine::change_set_from_current is really ### change_set_from_currentv for implementation ease, but the calling signature ### is the same of change_set_from_current, so here it goes. =for apidoc =for arg key (__hide__) =for arg ... list of keys to add to the changeset Create a L from a list of keys inside the GConf database. =cut GConfChangeSet * gconf_engine_change_set_from_current (engine, key, ...) GConfEngine * engine PREINIT: char ** keys; int i; GError * err = NULL; CODE: keys = g_new0 (char *, items - 1); for (i = 1; i < items; i++) keys[i-1] = SvPV_nolen (ST (i)); RETVAL = gconf_engine_change_set_from_currentv (engine, (const gchar **) keys, &err); g_free(keys); if (err) gperl_croak_gerror (NULL, err); OUTPUT: RETVAL Gnome2-GConf-1.044/xs/GConfChangeSet.xs0000644000175000017500000000600010021363334017374 0ustar torstentorsten/* * Copyright (c) 2003 by Emmanuele Bassi (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library 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. */ #include "gconfperl.h" /* this function will fill up the perl hashref */ static void fill_hash (GConfChangeSet *cs, const gchar *key, GConfValue *value, gpointer user_data) { HV * hash = (HV *) user_data; hv_store (hash, key, (U32) strlen(key), newSVGConfValue(value), 0); } SV * newSVGConfChangeSet (GConfChangeSet * cs) { SV * r; HV * h; h = newHV (); r = newRV_noinc ((SV *) h); gconf_change_set_foreach (cs, fill_hash, h); return r; } GConfChangeSet * SvGConfChangeSet (SV * data) { HV * h; HE * entry; GConfChangeSet * cs; if ((!data) || (!SvOK(data)) || (!SvRV(data)) || (SvTYPE(SvRV(data)) != SVt_PVHV)) croak ("data must be an hashref"); h = (HV *) SvRV (data); cs = gconf_change_set_new (); hv_iterinit(h); while (NULL != (entry = hv_iternext(h))) { SV * v; char * key; GConfValue * value; I32 len; /* force exit from the traversing if the key is unset */ key = hv_iterkey(entry, &len); if (! key) break; /* the key could be unset */ v = hv_iterval(h, entry); value = SvGConfValue (v); gconf_change_set_set (cs, key, value); } return cs; } MODULE = Gnome2::GConf::ChangeSet PACKAGE = Gnome2::GConf::ChangeSet PREFIX = gconf_change_set_ =for object Gnome2::GConf::ChangeSet A set of configuration changes to be made =cut =for position SYNOPSIS =head1 SYNOPSIS $cs = { '/apps/someapp/some_int_key' => { type => 'int', value => 42 }, '/apps/someapp/some_string_key' => { type => 'string', value => 'hi' }, }; $reverse_cs = $client->reverse_change_set($cs); $client->commit_change_set($cs, FALSE); =cut =for position DESCRIPTION =head1 DESCRIPTION A C allows you to collect a set of changes to configuration keys (set/unset operations). You can then commit all the changes at once. In C, C is an hash containing keys and Cs to be committed in a single pass (though not yet with an atomic operation). Since perl has hashes as a built-in type, C is threated as an hash with the GConf keys as keys, and their relative L as payload. =cut =for see_also =head1 SEE ALSO L(3pm), L(3pm). =cut Gnome2-GConf-1.044/xs/GConfEntry.xs0000644000175000017500000001120510364010073016636 0ustar torstentorsten/* * Copyright (c) 2003 by Emmanuele Bassi (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library 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. */ #include "gconfperl.h" /* Since GConfEntry and GConfValue are not registered types, we create a * hashref containing their data, in order to mask them from the Perl * developer. (eb) */ SV * newSVGConfEntry (GConfEntry * e) { HV * h; SV * sv; GConfValue * value; HV * stash; if (! e) return newSVsv(&PL_sv_undef); h = newHV (); sv = newRV_noinc ((SV *) h); /* safe */ /* store the key */ hv_store (h, "key", 3, newSVGChar (gconf_entry_get_key (e)), 0); /* this GConfValue is not a copy, and it should not be modified nor * freed, according to GConf documentation. If value is NULL, the * GConf key is "unset" - and we make it undefined. */ value = gconf_entry_get_value (e); if (value) hv_store (h, "value", 5, newSVGConfValue (value), 0); /* the "is_default", "is_writable" and "schema_name" fields are * accessible only by using their relative accessor functions; * since we "mask" a GConfEntry as a blessed reference, we also * provide these three fields as hash keys. */ hv_store (h, "is_default", 10, newSViv (gconf_entry_get_is_default (e)), 0); hv_store (h, "is_writable", 11, newSViv (gconf_entry_get_is_writable (e)), 0); hv_store (h, "schema_name", 11, newSVGChar (gconf_entry_get_schema_name (e)), 0); /* bless this stuff */ stash = gv_stashpv ("Gnome2::GConf::Entry", TRUE); sv_bless (sv, stash); return sv; } GConfEntry * SvGConfEntry (SV * data) { HV * h; SV ** s; GConfValue * v; GConfEntry * e; if ((!data) || (!SvOK(data)) || (!SvRV(data)) || (SvTYPE(SvRV(data)) != SVt_PVHV)) croak ("SvGConfEntry: value must be an hashref"); h = (HV *) SvRV (data); /* we require the 'value' key */ if (! ((s = hv_fetch (h, "value", 5, 0)) && SvOK (*s))) croak ("SvGConfEntry: 'value' key needed"); v = SvGConfValue (*s); if (! ((s = hv_fetch (h, "key", 3, 0)) && SvOK (*s))) croak ("SvGConfEntry: 'key' key needed"); e = gconf_entry_new (SvGChar (*s), v); if ((s = hv_fetch (h, "is_default", 10, 0)) && SvOK (*s)) gconf_entry_set_is_default (e, TRUE); if ((s = hv_fetch (h, "is_writable", 11, 0)) && SvOK (*s)) gconf_entry_set_is_writable (e, TRUE); if ((s = hv_fetch (h, "schema_name", 11, 0)) && SvOK (*s)) gconf_entry_set_schema_name (e, SvGChar (*s)); gconf_value_free (v); return e; } MODULE = Gnome2::GConf::Entry PACKAGE = Gnome2::GConf::Entry PREFIX = gconf_entry_ =for object Gnome2::GConf::Entry Container Objects for key/value pairs =cut =for position SYNOPSIS =head1 SYNOPSIS $client = Gnome2::GConf::Client->get_default; $client->notify_add($config_key, sub { my ($client, $cnxn_id, $entry) = @_; return unless $entry; unless ($entry->{value}) { $label->set_text(''); } elsif ($entry->{value}->{type} eq 'string') { $label->set_text($entry->{value}->{value}); } else { $label->set_text('!type error!'); } }); =cut =for position DESCRIPTION =head1 DESCRIPTION In C, C is a opaque container for the key string and for the C bound to that key. In perl, it's a blessed reference to L, holding these keys: =over =item B The key that is being monitored. =item B An hashref, representing a C (see L), which contains the type and the value of the key; it may be undef if the key has been unset. Every method of the C API is replaced by standard perl functions that operate on hashrefs. =item B Whether the L held by this entry is the default value provided by the schema attached to the key. =item B Whether the key is stored in a writable source inside the GConf database. =item B The name of the schema key bound to this key. =back =cut =for see_also =head1 SEE ALSO L(3pm), L(3pm). =cut Gnome2-GConf-1.044/xs/GConfValue.xs0000644000175000017500000002720010513234233016615 0ustar torstentorsten/* * Copyright (c) 2003 by Emmanuele Bassi (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library 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. */ #include "gconfperl.h" /* * GConfValue is a dynamic type container used by GConf, in many ways similar * to GValue. It should be accessed only via methods, so GConf doesn't export * it as a registered type. Hence, I decided to translate it into a Perl data * structure completely transparent to the programmer; GConfValues are used * only internally: what a programmer will always see or use will be an hashref * containing the "type" field, which is used to store the symbolic type of the * key which GConfValue is bound to, and the payload, that is the value bound * to the key. Fundamental types will have the "value" field filled with the * corresponding perl scalar; lists of fundamental types will have the "value" * field filled with an arrayref of scalars; pairs of fundamental types will * have two fields, "car" (for the first value of the pair) and "cdr" (for the * second value of the pair), each one containing an hashref corresponding to a * GConfValue of their fundamental types. This may seems a little obfuscated, * but, since we're not providing any accessor methods to gather the data * inside GConfValue, I've decided to keep the semantics as much as similar to * the corresponding C one. (ebassi) * */ /* gconfperl_sv_from_value returns the correct SV for the fundamental types * stored inside a GConfValue. gconfperl_value_from_sv is used the other way * around, to fill an already initialized GConfValue from a SV. */ static SV * gconfperl_sv_from_value (GConfValue * v) { SV * sv; switch (v->type) { case GCONF_VALUE_BOOL: sv = newSViv (gconf_value_get_bool (v)); break; case GCONF_VALUE_FLOAT: sv = newSVnv (gconf_value_get_float (v)); break; case GCONF_VALUE_INT: sv = newSViv (gconf_value_get_int (v)); break; case GCONF_VALUE_STRING: sv = newSVGChar (gconf_value_get_string (v)); break; case GCONF_VALUE_SCHEMA: sv = newSVGConfSchema (gconf_value_get_schema (v)); break; case GCONF_VALUE_INVALID: default: sv = NULL; break; } return sv; } static void gconfperl_value_from_sv (SV * sv, GConfValue * v) { switch (v->type) { case GCONF_VALUE_BOOL: gconf_value_set_bool (v, SvIV (sv)); break; case GCONF_VALUE_FLOAT: gconf_value_set_float (v, SvNV (sv)); break; case GCONF_VALUE_INT: gconf_value_set_int (v, SvIV (sv)); break; case GCONF_VALUE_STRING: gconf_value_set_string (v, SvGChar (sv)); break; case GCONF_VALUE_SCHEMA: gconf_value_set_schema (v, SvGConfSchema (sv)); break; case GCONF_VALUE_INVALID: default: break; } } /* * Create a SV from a GConfValue. * The hash has this form: * * fundamentals = { 'int' | 'bool' | 'float' | 'string' | 'schema' } * * iff := * { type => , value => { | } } * * iff := 'pair' * { * type => 'pair', * car => { type => , value => }, * cdr => { type => , value => } * } * * a schema is a fundamental type because we have a type for it, like * we do have types for integer, boolean, floating and string values. */ SV * newSVGConfValue (GConfValue * v) { HV * h; SV * sv; HV * stash; if (! v) return newSVsv(&PL_sv_undef); h = newHV (); sv = newRV_noinc ((SV *) h); /* safe */ switch (v->type) { case GCONF_VALUE_STRING: case GCONF_VALUE_INT: case GCONF_VALUE_FLOAT: case GCONF_VALUE_BOOL: case GCONF_VALUE_SCHEMA: /* these are fundamental types, so store type and value * directly inside the hashref; for the type, use the * 'stringyfied' version. */ hv_store (h, "type", 4, gperl_convert_back_enum (GCONF_TYPE_VALUE_TYPE, v->type), 0); hv_store (h, "value", 5, gconfperl_sv_from_value (v), 0); break; case GCONF_VALUE_PAIR: /* a pair consists of two fundamental types, stored as * car and cdr (damned LISP lovers). We do not supply * accessor methods for GConfValue, so we try to * reflect the storage as much as we can; thus, we * create two keys, 'car' and 'cdr', instead of the * usual 'value' one. The programmer must be warned, * so we leave type as 'pair' (also because car and cdr * may be of two different types, so we need a marker * for this situation). */ { SV * car, * cdr; hv_store (h, "type", 4, gperl_convert_back_enum (GCONF_TYPE_VALUE_TYPE, v->type), 0); car = newSVGConfValue (gconf_value_get_car (v)); cdr = newSVGConfValue (gconf_value_get_cdr (v)); hv_store (h, "car", 3, newSVsv (car), 0); hv_store (h, "cdr", 3, newSVsv (cdr), 0); } break; case GCONF_VALUE_LIST: /* lists are handled like arrayrefs; the type is the * list type, in order to mask the special 'list' type * from the programmer. */ { AV * a; SV * r; GSList * l, * tmp; GConfValueType t = gconf_value_get_list_type (v); a = newAV (); r = newRV_noinc ((SV *) a); /* safe */ l = gconf_value_get_list (v); for (tmp = l; tmp != NULL; tmp = tmp->next) av_push (a, gconfperl_sv_from_value ((GConfValue *) tmp->data)); hv_store (h, "type", 4, gperl_convert_back_enum (GCONF_TYPE_VALUE_TYPE, t), 0); hv_store (h, "value", 5, newSVsv (r), 0); } break; case GCONF_VALUE_INVALID: /* this is used only for error handling */ default: croak ("newSVGConfValue: invalid type found"); break; } stash = gv_stashpv ("Gnome2::GConf::Value", TRUE); sv_bless (sv, stash); return sv; } /* Create a GConfValue from a SV. */ GConfValue * SvGConfValue (SV * data) { HV * h; SV ** s; GConfValue * v; GConfValueType t; int n; if ((!data) || (!SvOK(data)) || (!SvRV(data)) || (SvTYPE(SvRV(data)) != SVt_PVHV)) croak ("SvGConfValue: value must be an hashref"); h = (HV *) SvRV (data); /* retrieve the type */ if (! ((s = hv_fetch (h, "type", 4, 0)) && SvOK (*s))) croak ("SvGConfValue: 'type' key is needed"); /* if it is an integer, just assign it... */ if (looks_like_number (*s)) t = SvIV (*s); /* otherwise, try to convert it from the enum */ if (!gperl_try_convert_enum (GCONF_TYPE_VALUE_TYPE, *s, &n)) croak ("SvGConfValue: 'type' should be either a GConfValueType or an integer"); t = (GConfValueType) n; /* set GConfValue using the right setter method */ switch (t) { case GCONF_VALUE_STRING: case GCONF_VALUE_INT: case GCONF_VALUE_FLOAT: case GCONF_VALUE_BOOL: case GCONF_VALUE_SCHEMA: if (! ((s = hv_fetch (h, "value", 5, 0)) && SvOK (*s))) croak ("SvGConfValue: fundamental types require a value key"); /* the argument is not a reference, so convert it */ if (!SvROK (*s)) { v = gconf_value_new (t); gconfperl_value_from_sv (*s, v); } else if (SvROK (*s) || SvTYPE (SvRV (*s)) == SVt_PVAV) { /* the argument is an array, so fill the list */ AV * av = (AV*) SvRV (*s); GSList * list = NULL; int i; v = gconf_value_new (GCONF_VALUE_LIST); gconf_value_set_list_type (v, t); for (i = av_len (av) ; i >= 0 ; i--) { GConfValue * v = gconf_value_new (t); gconfperl_value_from_sv (*av_fetch (av, i, FALSE), v); list = g_slist_prepend (list, v); } gconf_value_set_list_nocopy (v, list); } else croak ("SvGConfValue: value must be either a " "scalar or an array reference"); break; case GCONF_VALUE_PAIR: { GConfValue * car, * cdr; v = gconf_value_new (GCONF_VALUE_PAIR); /* build up the first value of the pair */ if (! ((s = hv_fetch (h, "car", 3, 0)) && SvOK (*s))) croak ("SvGConfValue: 'pair' type requires a 'car' key"); car = SvGConfValue (*s); gconf_value_set_car_nocopy (v, car); /* and then the second value */ if (! ((s = hv_fetch (h, "cdr", 3, 0)) && SvOK (*s))) croak ("SvGConfValue: 'pair' type requires a 'cdr' key"); cdr = SvGConfValue (*s); gconf_value_set_cdr_nocopy (v, cdr); } break; case GCONF_VALUE_LIST: /* handled above, this should never be passed */ case GCONF_VALUE_INVALID: /* used for error situations */ default: croak ("SvGConfValue: invalid type found."); } return v; } MODULE = Gnome2::GConf::Value PACKAGE = Gnome2::GConf::Value =for object Gnome2::GConf::Value Opaque datatype for generic values =cut =for position SYNOPSIS =head1 SYNOPSIS $client = Gnome2::GConf::Client->get_default; $client->set($config_key, { type => 'string', value => 'Hello, World', }); print "The Meaning of Life." if ($client->get($another_key)->{value} == 42); =cut =for position DESCRIPTION =head1 DESCRIPTION C is a dynamic type similar to C, and represents a value that can be obtained from or stored in the configuration database; it contains the value bound to a key, and its type. In perl, it's an hashref containing these keys: =over =item B The type of the data. Fundamental types are 'string', 'int', 'float' and 'bool'. Lists are handled by passing an arrayref as the payload of the C key: $client->set($key, { type => 'string', value => 'some string' }); $client->set($key, { type => 'float', value => 0.5 }); $client->set($key, { type => 'bool', value => FALSE }); $client->set($key, { type => 'int', value => [0..15] }); Pairs are handled by using the special type 'pair', and passing, in place of the C key, the C and the C keys, each containing an hashref representing a GConfValue: $client->set($key, { type => 'pair', car => { type => 'string', value => 'some string' }, cdr => { type => 'int', value => 42 }, }); This is needed since pairs might have different types; lists, instead, are of the same type. =item B The payload, containing the value of type C. It is used only for fundamental types (scalars or lists). =item B, B Special keys, that must be used only when working with the 'pair' type. =back =cut =for see_also =head1 SEE ALSO L(3pm), L(3pm), L(3pm), L(3pm). =cut ##/* we need to provide a real DESTROY function because GConfValue ## * objects are dynamically allocated ## */ void DESTROY (value) SV * value CODE: gconf_value_free (SvGConfValue (value)); #if GCONF_CHECK_VERSION (2, 13, 1) gint compare (value_a, value_b) GConfValue * value_a GConfValue * value_b CODE: RETVAL = gconf_value_compare (value_a, value_b); OUTPUT: RETVAL #endif /* GCONF_CHECK_VERSION (2, 13, 1) */ gchar_own * to_string (value) GConfValue * value CODE: RETVAL = gconf_value_to_string (value); OUTPUT: RETVAL Gnome2-GConf-1.044/xs/GConf2.xs0000644000175000017500000001111610176301276015710 0ustar torstentorsten/* * Copyright (c) 2003, 2004 by Emmanuele Bassi (see the file AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library 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. */ #include "gconfperl.h" #ifdef GCONFPERL_TYPE_GCONF_ERROR /* error codes taken from gconf-error.h */ static const GEnumValue _gconfperl_gconf_error_values[] = { { GCONF_ERROR_SUCCESS, "GCONF_ERROR_SUCCESS", "success" }, { GCONF_ERROR_FAILED, "GCONF_ERROR_FAILED", "failed" }, { GCONF_ERROR_NO_SERVER, "GCONF_ERROR_NO_SERVER", "no-server" }, { GCONF_ERROR_NO_PERMISSION, "GCONF_ERROR_NO_PERMISSION", "no-permission" }, { GCONF_ERROR_BAD_ADDRESS, "GCONF_ERROR_BAD_ADDRESS", "bad-address" }, { GCONF_ERROR_BAD_KEY, "GCONF_ERROR_BAD_KEY", "bad-key" }, { GCONF_ERROR_PARSE_ERROR, "GCONF_ERROR_PARSE_ERROR", "parse-error" }, { GCONF_ERROR_CORRUPT, "GCONF_ERROR_CORRUPT", "corrupt" }, { GCONF_ERROR_TYPE_MISMATCH, "GCONF_ERROR_TYPE_MISMATCH", "type-mismatch" }, { GCONF_ERROR_IS_DIR, "GCONF_ERROR_IS_DIR", "is-dir" }, { GCONF_ERROR_IS_KEY, "GCONF_ERROR_IS_KEY", "is-key" }, { GCONF_ERROR_OVERRIDDEN, "GCONF_ERROR_OVERRIDDEN", "overridden" }, { GCONF_ERROR_OAF_ERROR, "GCONF_ERROR_OAF_ERROR", "oaf-error" }, { GCONF_ERROR_LOCAL_ENGINE, "GCONF_ERROR_LOCAL_ENGINE", "local-engine" }, { GCONF_ERROR_LOCK_FAILED, "GCONF_ERROR_LOCK_FAILED", "lock-failed" }, { GCONF_ERROR_NO_WRITABLE_DATABASE, "GCONF_ERROR_NO_WRITABLE_DATABASE", "no-writable-database" }, { GCONF_ERROR_IN_SHUTDOWN, "GCONF_ERROR_IN_SHUTDOWN", "in-shutdown" }, { 0, NULL, NULL }, }; GType gconfperl_gconf_error_get_type (void) { static GType type = 0; if (! type) type = g_enum_register_static ("GConfPerlError", _gconfperl_gconf_error_values); return type; } #endif MODULE = Gnome2::GConf PACKAGE = Gnome2::GConf PREFIX = gconf_ =for object Gnome2::GConf::version =cut BOOT: #include "register.xsh" #include "boot.xsh" gperl_register_error_domain (GCONF_ERROR, GCONFPERL_TYPE_GCONF_ERROR, "Gnome2::GConf::Error"); =for apidoc =for signature (MAJOR, MINOR, MICRO) = Gnome2::GConf->GET_VERSION_INFO Fetch as a list the version of libgconf for which Gnome2::GConf was built. =cut void GET_VERSION_INFO (class) PPCODE: EXTEND (SP, 3); PUSHs (sv_2mortal (newSViv (GCONF_MAJOR_VERSION))); PUSHs (sv_2mortal (newSViv (GCONF_MINOR_VERSION))); PUSHs (sv_2mortal (newSViv (GCONF_MICRO_VERSION))); PERL_UNUSED_VAR (ax); gboolean CHECK_VERSION (class, major, minor, micro) int major int minor int micro CODE: RETVAL = GCONF_CHECK_VERSION (major, minor, micro); OUTPUT: RETVAL ## gconf.h =for object Gnome2::GConf::main =cut =for apidoc =for signature boolean = Gnome2::GConf->valid_key ($key) =for signature (boolean, string) = Gnome2::GConf->valid_key ($key) In scalar context, it returns a boolean value. In array context, it returns a boolean value and a string containing a user-readable explanation of the problem. =cut void gconf_valid_key (class, key) const gchar * key C_ARGS: key PREINIT: gchar *why_invalid = NULL; gboolean is_valid; PPCODE: is_valid = gconf_valid_key (key, &why_invalid); if (GIMME_V == G_ARRAY) { EXTEND (SP, 2); PUSHs (sv_2mortal (newSViv (is_valid))); PUSHs (sv_2mortal (newSVpv (why_invalid, 0))); g_free (why_invalid); /* leaks otherwise */ } else { XPUSHs (sv_2mortal (newSViv (is_valid))); } =for apidoc Return TRUE if the path $below would be somewhere below the directory $above. =cut gboolean gconf_key_is_below (class, above, below) const gchar * above const gchar * below C_ARGS: above, below =for apidoc Returns a concatenation of $dir and $key. =cut gchar* gconf_concat_dir_and_key (class, dir, key) const gchar * dir const gchar * key C_ARGS: dir, key =for apidoc Returns a different string every time (at least, the chances of getting a duplicate are like one in a zillion). The key is a legal gconf key name (a single element of one). =cut gchar* gconf_unique_key (class) C_ARGS: /* void */ Gnome2-GConf-1.044/MANIFEST0000644000175000017500000000073610354335444014765 0ustar torstentorstenAUTHOR ChangeLog copyright.pod doctypes examples/basic-gconf-app.pl examples/complex-gconf-app.pl examples/error.pl examples/simple-controller.pl examples/simple-view.pl GConf.pm gconf.typemap gconfperl.h genmaps.pl Makefile.PL MANIFEST MANIFEST.SKIP maps META.yml Module meta-data (added by MakeMaker) NEWS perl-Gnome2-GConf.spec.in README t/00.GConf.t xs/GConf2.xs xs/GConfChangeSet.xs xs/GConfClient.xs xs/GConfEngine.xs xs/GConfEntry.xs xs/GConfSchema.xs xs/GConfValue.xs Gnome2-GConf-1.044/GConf.pm0000644000175000017500000001621510677450273015173 0ustar torstentorsten# # Copyright (c) 2003-2006 by Emmanuele Bassi (see the file AUTHORS) # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 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 # Library General Public License for more details. # # You should have received a copy of the GNU Library 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. package Gnome2::GConf; use 5.008; use strict; use warnings; use Glib; require DynaLoader; our @ISA = qw(DynaLoader); our $VERSION = '1.044'; sub dl_load_flags { $^O eq 'darwin' ? 0x00 : 0x01 } Gnome2::GConf->bootstrap ($VERSION); # Preloaded methods go here package Gnome2::GConf::Value; use overload '==' => sub { Gnome2::GConf::Value::compare($_[0], $_[1]) }, fallback => 1; use overload '""' => sub { Gnome2::GConf::Value::to_string($_[0]) }, fallback => 1; package Gnome2::GConf::Client; use Carp; sub get_list { my $self = shift; # the object my $key = shift; my $check_error = shift || 1; my $val = $self->get($key, $check_error); return $val->{value}; } sub get_pair { my $self = shift; # the object my $key = shift; my $check_error = shift || 1; my $val = $self->get($key, $check_error); carp "$key is not bound to a pair" if not $val->{type} eq 'pair'; return ($val->{car}, $val->{cdr}); } sub set_list { my $self = shift; # the object my $key = shift; my $type = shift; my $list = shift; my $check_error = shift || 1; $self->set($key, { type => $type, value => $list }, $check_error); } sub set_pair { my $self = shift; # the object my $key = shift; my $car = shift; my $cdr = shift; my $check_error = shift || 1; $self->set($key, { type => 'pair', car => $car, cdr => $cdr, }, $check_error); } package Gnome2::GConf; 1; __END__ =head1 NAME Gnome2::GConf - Perl wrappers for the GConf configuration engine. =head1 SYNOPSIS use Gnome2::GConf; my $client = Gnome2::GConf::Client->get_default; my $app_key = "/apps/myapp/mykey"; $client->add_dir($app_key, 'preload-none'); # add a notify for the key my $notify_id = $client->notify_add($app_key, sub { my ($client, $cnxn_id, $entry) = @_; return unless $entry->{value}; if ($entry->{value}->{type} eq 'string') { printf "key '%s' changed to '%s'\n", $entry->{key}, $entry->{value}->{value}; } }); my $string = $client->get_string($app_key); $string = 'some string' unless $string; $client->set($app_key, { type => 'string', data => $string }); # set a schema for the key $client->set_schema ($app_key, { type => 'string', locale => 'C', short_desc => 'Some key.', long_desc => 'This key does something.', owner => 'some_program' }); # remove the notification callback $client->notify_remove($notify_id); =head1 ABSTRACT Perl bindings to the 2.2 series of the GConf configuration engine libraries, for use with gtk2-perl. =head1 DESCRIPTION This module allows you to use the GConf configuration system in order to store/retrieve the configuration of an application. The GConf system is a powerful configuration manager based on a user daemon that handles a set of key and value pairs, and notifies any changes of the value to every program that monitors those keys. GConf is used by GNOME 2.x. To discuss gtk2-perl, ask questions and flame/praise the authors, join gtk-perl-list@gnome.org at lists.gnome.org. Find out more about Gnome at http://www.gnome.org. =head1 DIFFERENT DATA TYPES Some opaque data types in GConf are not registered inside the Glib type system. Thus, they have been implemented in a more perlish way, when possible, for the sake of coherency and following the principle of least surprise for the perl developer. These changes try to preserve semantics, to add syntactic sugar and to remove the need for accessor methods. =over =item GConfEntry See L =item GConfValue See L =item GConfChangeSet See L =item GConfSchema See L =back =head1 DIFFERENT CALL SIGNATURES Reflecting the changes operated for the data types, some methods that use those type have had the call signature modified. =over =item GConfNotifyFunc In C, the function passed to C must have the following signature: void (GConfNotifyFunc *) (GConfClient * client, guint cnxn_id, GConfEntry * entry); Where C is a container for the key/value pair. Since in perl there's no C (see above), the C parameter is an hashref. =item GConfClient::get =item GConfClient::set In C, these accessor methods return/use a C. In perl, they return/use an hashref. See L =item GConfClient::get_list =item GConfClient::set_list These accessor methods use a string for setting the type of the lists (lists may have values of only B type), and an arrayref containing the values. =item GConfClient::get_pair =item GConfClient::set_pair These accessor methods use two hashref (representing Cs) for the C and the C parameters. =item GConfClient::get_schema =item GConfClient::set_schema Similarly to the get/set pair above, these two methods return/use an hashref. See L. =item GConfClient::commit_change_set In C, this method return a boolean value (TRUE on success, FALSE on failure). On user request (using the boolean parameter C), it also returns the C, pruned of the successfully committed keys. In perl, this method returns a boolean value both in scalar context or if the user sets to FALSE the C parameter; in array context or if the user requests the uncommitted keys, returns both the return value and the pruned C. =back =head1 SEE ALSO L(1), L(3pm). =head1 AUTHOR Emmanuele Bassi Eebassi@gmail.comE gtk2-perl created by the gtk2-perl team: http://gtk2-perl.sf.net =head1 COPYRIGHT AND LICENSE Copyright 2003-2006 by Emmanuele Bassi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library 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. =cut Gnome2-GConf-1.044/MANIFEST.SKIP0000644000175000017500000000015110136752627015525 0ustar torstentorsten~$ \.bak$ blib \.bs$ build \.c$ CVS \.cvsignore$ Makefile$ Makefile\.old$ \.o$ \.spec$ \.sw.$ \.tar\.gz$ Gnome2-GConf-1.044/genmaps.pl0000644000175000017500000000401607756246315015630 0ustar torstentorsten=out gconf2 =cut @dirs = ( '/usr/include/gconf/2/gconf/', ); foreach $dir (@dirs) { @lines = `grep _TYPE_ $dir/*.h | grep get_type`; foreach (@lines) { chomp; s/^.*\s([A-Z][A-Z0-9_]*_TYPE_[A-Z0-9_]*)\s.*$/$1/; #print "$1\n"; push @types, $_; } } open FOO, "> foo.c"; select FOO; print '#include #include #include #include #include #include #include #include #include #include const char * find_base (GType gtype) { if (g_type_is_a (gtype, GTK_TYPE_OBJECT)) return "GtkObject"; if (g_type_is_a (gtype, G_TYPE_OBJECT)) return "GObject"; if (g_type_is_a (gtype, G_TYPE_BOXED)) return "GBoxed"; if (g_type_is_a (gtype, G_TYPE_FLAGS)) return "GFlags"; if (g_type_is_a (gtype, G_TYPE_ENUM)) return "GEnum"; if (g_type_is_a (gtype, G_TYPE_INTERFACE)) return "GInterface"; if (g_type_is_a (gtype, G_TYPE_STRING)) return "GString"; { GType parent = gtype; while (parent != 0) { gtype = parent; parent = g_type_parent (gtype); } return g_type_name (gtype); } return "-"; } int main (int argc, char * argv []) { g_type_init (); '; foreach (@types) { print '#ifdef '.$_.' { GType gtype = '.$_.'; printf ("%s\t%s\t%s\n", "'.$_.'", g_type_name (gtype), find_base (gtype)); } #endif /* '.$_.' */ '; } print ' return 0; } '; close FOO; select STDOUT; system 'gcc -DGTK_DISABLE_DEPRECATED -Wall -o foo foo.c `pkg-config gtk+-2.0 gconf-2.0 --cflags --libs`' and die "couldn't compile helper program"; @packagemap = ( [ GConf => 'Gnome2::GConf' ], # fallback ); foreach (`./foo`) { chomp; my @p = split; my $pkg = 'Gnome2'; my $prefix = 'GConf'; foreach $f (@packagemap) { my $t = $f->[0]; if ($p[1] =~ /^$t/) { $prefix = $f->[0]; $pkg = $f->[1]; last; } } (my $fullname = $p[1]) =~ s/^$prefix/$pkg\::/; print join("\t", @p, $fullname), "\n"; } Gnome2-GConf-1.044/gconf.typemap0000644000175000017500000000050410016067661016320 0ustar torstentorstenTYPEMAP GConfValue * T_GPERL_GENERIC_WRAPPER GConfEntry * T_GPERL_GENERIC_WRAPPER GConfSchema * T_GPERL_GENERIC_WRAPPER GConfChangeSet * T_GPERL_GENERIC_WRAPPER TYPEMAP GConfValue * T_GPERL_GENERIC_WRAPPER GConfEntry * T_GPERL_GENERIC_WRAPPER GConfSchema * T_GPERL_GENERIC_WRAPPER GConfChangeSet * T_GPERL_GENERIC_WRAPPER Gnome2-GConf-1.044/META.yml0000644000175000017500000000055310677450301015100 0ustar torstentorsten--- #YAML:1.0 name: Gnome2-GConf version: 1.044 abstract: Perl wrappers for the GConf configuration engine. license: ~ generated_by: ExtUtils::MakeMaker version 6.36 distribution_type: module requires: meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.2.html version: 1.2 Gnome2-GConf-1.044/AUTHOR0000644000175000017500000000031110513234233014535 0ustar torstentorstenModule author: Emmanuele Bassi Patches contributed by: * Torsten Schoenfeld * muppet * Laurent Simonneau See ChangeLog for a complete list of contributors. Gnome2-GConf-1.044/perl-Gnome2-GConf.spec.in0000644000175000017500000000401510446020072020156 0ustar torstentorstenSummary: Gnome2 Perl module Name: perl-Gnome2-GConf Version: @VERSION@ Release: 1 Packager: gtk-perl-list@gnome.org License: GPL Group: Development/Libraries URL: http://search.cpan.org/dist/Gnome2-GConf/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: perl >= 2:5.8.0 BuildRequires: GConf2-devel >= @GCONF@ BuildRequires: perl-ExtUtils-Depends >= @PERL_EXTUTILS_DEPENDS@ BuildRequires: perl-ExtUtils-PkgConfig >= @PERL_EXTUTILS_PKGCONFIG@ BuildRequires: perl-Glib >= @PERL_GLIB@ Requires: GConf2 >= %(pkg-config --modversion gconf-2.0) Requires: perl-Glib >= @PERL_GLIB@ Requires: %(perl -MConfig -le 'if (defined $Config{useithreads}) { print "perl(:WITH_ITHREADS)" } else { print "perl(:WITHOUT_ITHREADS)" }') Requires: %(perl -MConfig -le 'if (defined $Config{usethreads}) { print "perl(:WITH_THREADS)" } else { print "perl(:WITHOUT_THREADS)" }') Requires: %(perl -MConfig -le 'if (defined $Config{uselargefiles}) { print "perl(:WITH_LARGEFILES)" } else { print "perl(:WITHOUT_LARGEFILES)" }') Source0: @SOURCE@ %description Perl bindings to the 2.x series of the Gnome widget set. This module allows you to write graphical user interfaces in a perlish and object-oriented way, freeing you from the casting and memory management in C, yet remaining very close in spirit to original API. %prep %setup -q -n Gnome2-GConf-%{version} %build CFLAGS="$RPM_OPT_FLAGS" perl Makefile.PL PREFIX=$RPM_BUILD_ROOT%{_prefix} make OPTIMIZE="$RPM_OPT_FLAGS" make test %install %makeinstall [ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress find $RPM_BUILD_ROOT \( -name perllocal.pod -o -name .packlist \) -exec rm -v {} \; find $RPM_BUILD_ROOT/usr -type f -print | \ sed "s@^$RPM_BUILD_ROOT@@g" | \ grep -v perllocal.pod | \ grep -v "\.packlist" > %{name}-%{version}-filelist if [ "$(cat %{name}-%{version}-filelist)X" = "X" ] ; then exit -1 fi %clean rm -rf $RPM_BUILD_ROOT %files -f %{name}-%{version}-filelist %defattr(-,root,root) %changelog * @DATE@ gtk-perl-list@gnome.org - @VERSION@ - Specfile autogenerated Gnome2-GConf-1.044/copyright.pod0000644000175000017500000000020310364010073016322 0ustar torstentorstenCopyright (C) 2003-2006 by the gtk2-perl team. This software is licensed under the LGPL. See L for a full notice. Gnome2-GConf-1.044/t/0000755000175000017500000000000010677450301014067 5ustar torstentorstenGnome2-GConf-1.044/t/00.GConf.t0000644000175000017500000000317510177606267015505 0ustar torstentorsten######################### # Gnome2::GConf Tests # - ebb ######################### ######################### use strict; use Gnome2::GConf; use constant SKIP_1 => 7; use constant SKIP_2 => 1; use Test::More tests => SKIP_1 + SKIP_2 + 3; my @version = Gnome2::GConf->GET_VERSION_INFO; is( @version, 3, 'version is three items long' ); our $app_dir = '/apps/basic-gconf-app'; our $key_foo = 'foo'; my $foo_path = Gnome2::GConf->concat_dir_and_key($app_dir, $key_foo); is( $foo_path, '/apps/basic-gconf-app/foo', 'valid foo key'); my $is_valid = Gnome2::GConf->valid_key($foo_path); ok( $is_valid ); my $c = Gnome2::GConf::Client->get_default; SKIP: { skip("Couldn't connect to the GConf default client.", SKIP_1) unless ($c); skip("basic-gconf-app directory not found in GConf.", SKIP_1) unless ($c->dir_exists('/apps/basic-gconf-app')); our $client = Gnome2::GConf::Client->get_default; isa_ok( $client, 'Gnome2::GConf::Client' ); $client->add_dir($app_dir, 'preload-recursive'); ok( 1 ); is( $client->get($foo_path)->{'type'}, 'string' ); ok( $client->get_string($foo_path) ); our $id = $client->notify_add($foo_path, sub { warn @_; }); ok( $id ); ok( $client->set_string($foo_path, 'test') ); $client->notify_remove($id); ok( 1 ); } my $e = Gnome2::GConf::Engine->get_default; SKIP: { skip("Couldn't connect to the GConf default engine.", SKIP_2) unless ($e); # we can not use an engine with a client attached - so we just test the # ::get_default method. our $engine = Gnome2::GConf::Engine->get_default; isa_ok( $engine, 'Gnome2::GConf::Engine' ); } ######################### Gnome2-GConf-1.044/ChangeLog0000644000175000017500000004447710677450273015426 0ustar torstentorsten2007-09-29 Torsten Schoenfeld * README: * NEWS: Release 1.044. 2007-09-29 Torsten Schoenfeld * GConf.pm: Use DynaLoader instead of XSLoader for bootstrapping to make sure our symbols are exported properly. Also remove the unused Exporter stuff. * Makefile.PL: Install our doctypes file so other bindings get to use it as well. 2006-10-10 Emmanuele Bassi * AUTHORS: Update * GConf.pm: Post release bump to 1.044 2006-10-10 Emmanuele Bassi * README: * NEWS: Release 1.043 2006-10-10 Emmanuele Bassi * xs/GConfValue.xs: Treat GConfSchema objects like fundamental types; this should fix the croak() emitted when getting a value of type 'schema'. (#361103, Laurent Simonneau) * xs/GConfSchema.xs: Provide an explicit DESTROY for GConfSchema objects, otherwise we'll leak them all over the floor. 2006-10-10 Emmanuele Bassi * GConf.pm: Post release bump to 1.043 2006-10-10 Emmanuele Bassi * GConf.pm: * README: * NEWS: Release 1.042 * xs/GConfClient.xs: Implement gconf_client_recursive_unset(), which appeared in GConf >= 2.3.3. (#361094, based on a patch by Laurent Simonneau) (gconf_client_unset): reverse the check_error default argument. 2006-09-29 Emmanuele Bassi * README: * NEWS: Release 1.041. 2006-09-29 Emmanuele Bassi * GConf.pm: Bump to 1.041. * xs/GConfValue.xs: Add a DESTROY function for removing the GConfValue structure, as it's not a GType, so we don't have all the convenient memory handling provided by the gperl bindings. (#358294, Santeri Paavolainen) 2006-09-04 Emmanuele Bassi * README: * GConf.pm: Release 1.040. 2006-07-25 Emmanuele Bassi * GConf.pm: Update the dl_load_flags() sub to work on Darwin (reported by Daniel Macks). 2006-06-20 Emmanuele Bassi * GConf.pm: Post-release bump to 1.032 2006-06-20 Emmanuele Bassi * README: * perl-Gnome2-GConf.spec.in: * Makefile.PL: Drop Gtk2 and just require Glib, now that we have Glib::CodeGen (Laurent Simonneau, #338313) * GConf.pm: bump to 1.031. 2006-04-13 Emmanuele Bassi * Makefile.PL: Require the new stable releases for Glib and Gtk2. * README: ditto. * GConf.pm: Bump to 1.030. 2006-04-13 Emmanuele Bassi * xs/GConfEngine.xs (gconf_engine_get_for_addresses): Fix the wrapper making it return RETVAL (Laurent Simonneau, #338311) 2006-01-19 23:17 (+0100) ebassi * xs/GConfEntry.xs: add the "schema_name" key to the apidoc. * copyright.pod: update copyright notice. 2006-01-19 23:13 (+0100) ebassi * gconfperl.h: I should double check my commits. 2006-01-18 17:59 (+0100) ebassi * xs/GConfEntry.xs: fix coding style and add the "schema_name" hash key for binding the gconf_entry_get_schema_name function; also, add the "is_default", "is_writable" and "schema_name" keys recognition to the SvGConfEntry constructor. * examples/basic-gconf-app.pl: fix some coding style and whitespace issues. 2006-01-18 17:50 (+0100) ebassi * xs/GConfEntry.xs: the names of the functions are: gconf_entry_get_is_default gconf_entry_get_is_writable you dolt! 2006-01-18 17:44 (+0100) ebassi * xs/GConfEngine.xs: fix apidoc; make our type registration function for GConfEngine really unused if ever the GConf people decide to register the type themselves. * ChangeLog: fix version number. 2006-01-18 15:35 (+0100) ebassi * GConf.pm: post release bump to 1.022. * xs/GConfEntry: add the "is_writable" and "is_default" keys to the Gnome2::GConf::Entry object, to wrap the gconf_entry_is_default and gconf_entry_is_writable C functions. 2005-12-27 23:30 (+0100) ebassi * GConf.pm: update my email address. 2005-12-27 23:23 (+0100) ebassi * examples/basic-gconf-app.pl: remove our TRUE/FALSE constants and use Glib ones instead; use the compact init for Gtk2; show the new overloaded stringification thingie. * GConf.pm: overload the == and "" operatores using Gnome2::GConf::Value::compare and Gnome2::GConf::Value::to_string. * xs/GConfValue.xs: implement to_string and compare class methods; bless the hash representing a GConfValue as Gnome2::GConf::Value. * xs/GConfEntry.xs: bless the hash representing a GConfEntry as Gnome2::GConf::Entry. 2005-12-27 22:12 (+0100) ebassi D TODO * README, GConf.pm: post release version bump. * TODO: remove the TODO file, since every item has been implemented (yay!). === Gnome2::GConf 1.021 === 2005-12-26 22:09 (+0100) ebassi * AUTHOR: change email address * README, NEWS, GConf.pm: bump to version 1.021 * xs/GConfEngine.xs: wrap: gconf_engine_get_for_addresses() under version check for GConf >= 2.7.1. 2005-09-05 22:15 (+0200) ebassi * README, NEWS, GConf.pm: bump to version 1.020. * Makefile.PL: require Glib >= 1.100 and Gtk2 >= 1.100, and remove the unstable warning. Also, use Glib::CodeGen instead of Gtk2::CodeGen. 2005/03/07 00:47 (+0100) ebassi * xs/GConfEngine.xs: remove g_boxed_copy from our get_type function. 2005/02/11 12:30 (+0100) ebassi * GConf.pm: remove the ERROR HANDLING section from the perldoc. * xs/GConfClient.xs: the "error" and "unreturned_error" signals now pass a Glib::Error to the callbacks, instead of the error message. see Glib::Error for details on the perl object. * xs/GConfClient.xs: implement the new error handling system; each fallible method will have a check_error argument (default to TRUE, to retain backward compatibility): if it is set to TRUE, the method will croak on error, otherwise it will silently fail. The new error handling system is documented inside the Gnome2::GConf::Client perldoc page. * xs/GConfClient.xs: bind gconf_client_set_error_handling * xs/GConfClient.xs: apidoc fixes * xs/GConfClient.xs: finally change the semantics of ::all_entries; instead of an array of strings for the keys, now we return an array of Gnome2::GConf::Entry objects, since this is the same thing that the C library does, and we have had bindings for GConfEntry opaque containers for a while, now. * GConf.pm: bump to 1.013. 2005/01/31 23:58 (-0500) muppetman * t/00.GConf.t: fix skip count 2005/01/28 01:18 (+0100) ebassi * GConf.pm, META.yml, NEWS, README: release 1.012. 2005/01/28 01:15 (+0100) ebassi * t/00.GConf.t: *really* fix test suite. 2005/01/28 01:05 (+0100) ebassi * xs/GConfEngine.xs: wrap gconf_engine_associate_schema gconf_engine_all_entries gconf_engine_all_dirs * xs/GConfEngine.xs: fix "cut'n'paste" bugs (Torsten Schoenfeld) * t/00.GConf.t: fix test suite (Torsten Schoenfeld) 2005/01/24 10:30 (+0100) ebassi * Makefile.PL: require GConf 2.0.0; there is no point in keeping the old 1.2.0 requirement. * META.yml, NEWS, GConf.pm: release 1.011 2005/01/23 23:47 (+0100) ebassi * xs/GConf2.xs: fix a bug in valid_key. * t/00.GConf.t: update test suite. 2005/01/23 23:35 (+0100) ebassi * Makefile.PL: add the "unstable release" warning. 2005/01/23 23:26 (+0100) ebassi * GConf.pm: bumped revision to 1.010. 2005/01/23 22:45 (+0100) ebassi * xs/GConf2.xs: wrap utilty functions: gconf_valid_key gconf_concat_dir_and_key gconf_unique_key as class methods. 2005/01/23 22:41 (+0100) ebassi * copyright.pod: update copyright notice * Makefile.PL: require Glib >= 1.070 (this is a development cycle, afterall) and Gtk2 >= 1.070. * doctpes: remove links, and beautify apidoc. * xs/GConfClient.xs: beatify apidoc. 2005/01/23 22:37 (+0100) ebassi A xs/GConfEngine.xs M gconfperl.h M maps M MANIFEST M t/00.GConf.t * xs/GConfEngine.xs, gconfperl.h, maps, MANIFEST, t/00.GConf.t: initial import of the GConfEngine bindings. 2005/01/23 22:34 (+0100) ebassi * xs/GConfEntry.xs: removed unnecessary variable declaration. 2004/10/24 11:55 (-0400) rwmcfa1 * MANIFEST.SKIP: updates * perl-Gnome2-Gconf.spec.in: new scheme that addresses x86_64 problems found by Carl Nygard 2004/06/02 18:23 (+0200) ebassi * GConf.pm: Verified the code inside the SYNOPSIS section of the POD. 2004/04/09 03:56 (+0200) kaffeetisch * Makefile.PL: Actually test for the correct versions of EU::Depends and EU::PkgConfig. 2004/03/24 15:26 (+0100) ebassi * README, NEWS, GConf.pm: version 1.000. * Makefile.PL: require the new stable Glib 1.040. 2004/03/17 23:37 (+0100) ebassi * xs/GConf2.xs: flesh out the pod for GET_VERSION_INFO, and move version information methods in the ::version pod. 2004/03/16 22:52 (+0100) ebassi * t/00.GConf.t: fix number of skippable tests 2004/03/15 00:16 (+0100) ebassi * xs/GConf2.xs, t/00.GConf.t: Adapt to the new version information implementation policy. 2004/03/14 08:38 (+0100) ebassi * GConf.pm: unindent ABSTRACT text. 2004/03/14 08:35 (+0100) ebassi * t/00.GConf.t: move skip() inside the SKIP block (patch by Torsten Schoenfeld). 2004/03/12 10:17 (+0100) ebassi * GConf.pm: updated documentation 2004/03/12 10:12 (+0100) ebassi * t/00.GConf.t: conditional tests: if the gconf directory '/apps/basic-gconf-app' (created by the basic-gconf-app example in the examples dir) exists, do some testing. 2004/03/07 13:54 (+0100) ebassi * GConf.pm, NEWS, README: version 0.94 * xs/GConfValue.xs: fixed a stupid bug that prevented the retrieval of lists. 2004/03/06 14:54 (+0100) ebassi * xs/GConfClient.xs: update documentation. * xs/GConfClient.xs: document [sg]et_pair with apidoc. 2004/03/03 15:33 (+0100) ebassi * GConf.pm, README, NEWS: version 0.93 - API freeze state. * Makefile.PL: require Glib 1.038. 2004/03/02 19:28 (+0100) ebassi A copyright.pod * doctypes: add man page references * Makefile.PL: append copyright notice to auto-generated man pages. * GConf.pm: updated the "Different Data Types" section of the documentation. * xs/GConfChangeSet.xs, xs/GConfEntry.xs, xs/GConfSchema.xs, xs/GConfValue.xs: add apidoc for these perl types. 2004/02/28 12:09 (+0100) ebassi * GConf.pm, README, NEWS, META.yml: released version 0.92. 2004/02/28 12:07 (+0100) ebassi * xs/GConfClient.xs: added the apidoc generation of the preload type enumeration (GConfClientPreloadType). 2004/02/28 10:05 (+0100) ebassi A examples/error.pl * GConf.pm: updated the Error Handling section. * gconfperl.h, xs/GConf2.xs: use the new Glib::Error exception handling system. * maps: remove GConfError from the typemap, since it's never used; the package Gnome2::GConf::Error shall be used for subclassing Glib::Error. * xs/GConfClient.xs: remove the first (unused) argument when calling gperl_croak_gerror(). * Makefile.PL, README: update requirement versions: Glib >= 1.037 (for the new Glib::Error exception handling) and Gtk2 >= 1.037 (comes with Glib 1.037). 2004/02/26 17:44 (+0100) ebassi * xs/GConfClient.xs: remove our custom SV->GError translation function, and use gperl_gerror_from_sv which is kindly provided by the Glib::Error package. 2004/02/22 10:11 (+0100) ebassi * README: update version requirements. 2004/02/21 00:30 (-0500) muppetman A doctypes A NEWS A gconf.typemap M MANIFEST add new files. * Makefile.PL: add the new typemap; use postamble_docs_full() so we can supply doctypes and give decent names to the unregistered structures in the bindings. this requires an update to ExtUtils::Depends 0.2 and bleeding edge Glib. * xs/GConfClient.xs: use the new typemaps instead of hand-coded PPCODE sections; this eliminates the need for several =for signature directives in pod. 2004/02/20 14:15 (+0100) ebassi * GConf,pm, README: version 0.91 - final beta cycle before API freeze for the GNOME Platform Bindings. 2004/02/20 13:48 (+0100) ebassi * GConf.pm, README, perl-Gnome2-GConf.spec.in: remove runtime dependency on Gtk2. It is used only for Gtk2::CodeGen at compile time. (by muppet) * Makefile.PL: various bits of cleanup and modernization: update requirement versions: ExtUtils::PkgConfig 1.03 (for the write_version_macros() helper), Glib 1.020 (first stable version with Glib::MakeHelper), and Gtk2 1.020 (accompanies Glib 1.020). Use write_version_macros() to replace hand-coded stuff. Remove Gtk2 from the ExtUtils::Depends module, since we don't actually need its headers, typemaps, or anything. Remove -I. from set_inc(), it's provided by Glib. (-I./build should be, too, but that doesn't appear to work.) Remove call to add_headers(), which is a no-op. Don't canonicalize typemap filenames, it's not necessary (may be necessary for older ExtUtils::Depends, but i don't think it was). Remove override for const_cccmd(), Glib::MakeHelper provides that for us. (by muppet) 2004/02/13 12:18 (+0100) ebassi * GConf.pm: updated documentation. 2004/01/29 13:27 (+0100) ebassi * xs/GConfClient.xs: implemented gconf_client_error gconf_client_unreturned_error gconf_client_value_changed these methods emit their relative signal, and should not be used, but could be needed for testing. I've translated the GError parameter of the C functions with an hashref containing the error id and message. 2004/01/27 04:14 (+0100) ebassi * GConf.pm, META.yml: version 0.46 2004/01/27 04:01 (+0100) ebassi * GConf.pm: bound set_/get_list and set_/get_pair; I've implemented them in Perl, since writing them in XS would have been overkill. 2004/01/24 21:44 (-0500) rwmcfa1 * Makefile.PL: removed runtime_reqs stuff, replaced by the pkg-config trick * perl-Gnome2-GConf.spec.in: use pkg-config for Requires version 2004/01/08 22:00 (+0100) ebassi * GConf.pm: version 0.45 2004/01/08 21:55 (+0100) ebassi * xs/GConfClient.xs: better apidoc for change_set methods. * xs/GConfSchema.xs, xs/GConfEntry.xs: added function name to the croak() calls. 2003/12/31 02:19 (-0500) muppetman * xs/GConf2.xs: mark ax unused in functions which don't touch the input stack, to hush compiler warnings 2003/12/29 16:32 (-0500) rwmcfa1 * perl-Gnome2-GConf.spec.in: use the new DATE replacement in conjunction with VERSION to create the changlog on the fly, which is better. 2003/12/22 23:51 (-0500) muppetman * xs/GConfClient.xs: remove the type specifiers on the class parameters, to keep xsubpp from creating a value that will be unused and therefore cause unused variable warnings. 2003/11/29 17:46 (-0500) rwmcfa1 * xs/GConfClient.xs: dGPERL_CLOSURE_MARSHAL_ARGS has to be the last dec b/c it doesn't always seem to be only decs. 2003/11/29 09:15 (-0500) muppetman * xs/GConfEntry.xs, xs/GConfSchema.xs: remove unused variables to hush compiler warnings. 2003/11/28 23:34 (+0100) ebassi * Makefile.PL: added auto-generation of API reference man page. * Makefile.PL, xs/GConf2.xs: added methods for retrieving/checking libgconf version symbols (thanks to Torsten Schoenfeld). * GConf.pm: added documentation for the gconf_client_commit_change_set method. 2003/11/25 17:22 (-0500) rwmcfa1 * GConf.pm: removed use Gnome2 which falsly made Gnome2 a dep, kaffee found it. 2003/11/24 22:55 (-0500) rwmcfa1 * Makefile.PL: fixes to rpm gen stuff * perl-Gnome2-GConf.spec.in: intial import * MANIFEST: updates 2003/11/21 12:27 (+0100) ebassi * Makefile.PL, README: change minimum required versions for Glib and Gtk modules (1.012), since it's release time. 2003/11/18 23:20 (+0100) ebassi * README: changed version and minimum required version of Glib and Gtk modules. * Makefile.PL: new required versions for Glib and Gtk modules (1.011). 2003/11/18 18:37 (+0100) ebassi * GConf.pm: bumped to version 0.42. * examples/comples-gconf-app.pl: better code and comments. * GConf.pm: added "ERROR HANDLING" section inside the documentation. * Makefile.PL: new required versions for Glib and Gtk modules (1.02); needed for the marshalling helper macros. * xs/GConfClient.xs: make use of the new marshalling helper macros inside the custom marshallers for "error" and "unreturned_error" signals (muppet). * xs/*.xs: less criptic croak messages. * xs/*.xs: remove header dependency on gnome2perl.h - gconfperl.h is enough (muppet). * gconfperl.h: removed header dependency on gnome2perl.h - using gperl.h instead (muppet). 2003/11/18 00:07 (+0100) ebassi * examples/complex-gconf-app.pl: added this example application that uses GConfChangeSets and GConfSchemas. 2003/11/17 21:12 (+0100) ebassi * debian/*, MANIFEST: removed debian packaging info before committing the package. * *: committed to CVS. 2003/11/17 20:53 (+0100) ebassi * xs/GConfChangeSet.xs: implemented GConfChangeSet as an hashref with GConf keys as hash keys and hashrefs in place of GConfValues; see documentation for more details. * xs/GConfClient.xs: implemented gconf_client_commit_change_set gconf_client_reverse_change_set gconf_client_change_set_from_current * GConf.pm: updated the documentation and bumped to version 0.41 * TODO: updated to do list. 2003/10/17 13:25 (+0200) ebassi * xs/GConfClient.xs: created custom marshaller for "error" and "unreturned_error" signals; these signal pass a GError in C, and since in gtk2-perl that's not a GType, we swap it inside the Perl marshaller with the string which contains the error message. 2003/10/12 13:26 (+0200) ebassi * xs/GConfSchema.xs: implemented GConfSchema container as GConfEntry and GConfValue - using an hashref. * xs/GConfClient.xs: implemented gconf_client_get_schema gconf_client_set_schema * debian/*: debianized package. * examples/basic-gconf-app.pl: placed some comments. 2003/09/21 23:45 (+0200) ebassi * xs/GConfClient.xs: implemented gconf_client_all_entries (patch by Luis Lopez Lopez). 2003/09/19 12:44 (+0200) ebassi * xs/GConfEntry.xs: added the reverse converter for GConfEntry (it creates a GConfEntry from an hashref). * xs/GConfClient.xs: implemented gconf_client_all_dirs gconf_client_get_entry gconf_client_get_without_default gconf_client_get_default_from_schema 2003/09/19 12:17 (+0200) ebassi * examples/basic-gconf-app,pl: connected the 'focus_out_event' signal. * Makefile.PL: changed minimum required version for GConf to 1.2.0, in order to cover GNOME 2.0 (thanks to muppet); fixed a cut&paste typo. * xs/GConfValue.xs: croak if an invalid hashref is passed to SvGConfValue, instead of silently discarding it. 2003/09/19 01:56 (+0200) ebassi * examples/simple-controller.pl, examples/simple-view.pl: added these two examples, ported directly from GConf sources. 2003/09/18 17:18 (+0200) ebassi * *: initial ChangeLog entry. Gnome2-GConf-1.044/NEWS0000644000175000017500000000602310677447726014345 0ustar torstentorstenOverview of changes since 1.043 =============================== * Make it possible for other bindings to use symbols from Gnome2::GConf's API. Overview of changes since 1.042 =============================== * Treat Gnome2::GConf::Schema objects as fundamental types in Gnome2::GConf::Value. * Fix usage of Gnome2::GConf::Client getters for keys of type 'schema' (#361103, Laurent Simonneau) * Fix a leak inside Gnome2::GConf::Schema. Overview of changes since 1.041 =============================== * Implement GConf::Client::recursive_unset() to recursively unset a directory in the database. (#361094, based on a patch by Laurent Simonneau) Overview of changes since 1.040 =============================== * Fix a leak in GConfValue. (#358294, Santeri Paavolainen) Overview of changes since 1.031 =============================== * Fix loaded flags on Darwin. [Daniel Macks] Overview of changes since 1.020 =============================== * The "An Address Indicates Where It Is" release. * Wrap Gnome2::GConf::Engine::get_for_addresses. [Emmanuele] Overview of changes since 1.013 =============================== * The "Differential Engine" release * Fix Gnome2::GConf::Engine reference mechanism. [Emmanuele] * Use Glib::CodeGen from the stable Glib release. [Emmanuele] Overview of changes since 1.012 =============================== * The "Breaking up is hard to do" release. * Implemented the new error handling system. [Emmanuele] * Changed Gnome2::GConf::Client::all_entries semantics. [Emmanuele] * Documentation fixes. [Emmanuele] Overview of changes since 1.011 =============================== * Finished the GConfEngine bindings. [Emmanuele] Overview of changes since 1.010 =============================== * Require GConf 2.0.0. [Emmanuele] Overview of changes since 1.000 =============================== * Wrapped GConfEngine. [Emmanuele] * Documentation fixes. [Emmanuele] * Require Glib 1.070. [Emmanuele] Overview of changes since 0.94 ============================== * New test suite for GConfClient. [Emmanuele] * Adapted version information methods to the current policy. [Toersten] * Updated documentation. [Emmanuele] * Require Glib 1.040. [Emmanuele] Overview of changes since 0.93 ============================== * Fixed a stupid bug in GConfValue [Emmanuele] Overview of changes since 0.92 * Split-up API documentation for GConfValue, GConfEntry, GConfChangeSet and GConfSchema. [Emmanuele] * API frozen [Emmanuele] * Require Glib 1.038 (for API freeze state) [Emmanuele] Overview of changes since 0.91 ============================== * Require Glib 1.037 [Emmanuele] * Use the new Glib::Error exception handling. [Emmanuele] * Updated documentation. [muppet] Overview of changes since 0.46 ============================== * Require ExtUtils::PkgConfig 1.03 * Require Glib 1.020 * Remove runtime dependency on Gtk2; Gtk2's Gtk2::CodeGen is a build-only requirement. [muppet] * Build system updates. [muppet] * Updated documentation. [Emmanuele] * Added some test methods that apps should not use. [Emmanuele] [started NEWS] Gnome2-GConf-1.044/doctypes0000644000175000017500000000014110175014615015372 0ustar torstentorstenGConfValue value GConfEntry entry GConfSchema schema GConfChangeSet changeset GConfEngine engine Gnome2-GConf-1.044/README0000644000175000017500000000435710677446617014534 0ustar torstentorstenGnome2::GConf version 1.044 =========================== This module allows you to use the GConf configuration system in order to store/retrieve the configuration of an application. GConf is a powerful configuration manager based on a user daemon that handles a set of key and value pairs, and notifies any changes of the value to every program that monitors those keys. GConf is used by GNOME 2.x. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install To avoid installing to a system directory, since this is a beta release, you can change the installation prefix at Makefile.PL time with perl Makefile.PL PREFIX=/some/other/place This will install the module to the subdirectory lib/perl5 under the given prefix. If this is not already in perl's include path, you'll need to tell perl how to get to this library directory so you can use it; there are three ways: in your environment (the easiest): PERL5LIB=/some/other/place/lib/perl5/site_perl:$PERL5LIB on the perl command line: perl -I /some/other/place/lib/perl5/site_perl yourscript in the code of your perl script: use lib '/some/other/place/lib/perl5/site_perl'; DEPENDENCIES This module requires these other modules and libraries: perl >= 5.8.0 Glib >= 1.120 (perl module and requisite C libraries) libgconf2 >= 2.0.0 (C library) To build from source, you also need: ExtUtils::Depends >= 0.2 ExtUtils::PkgConfig >= 1.03 COPYRIGHT AND LICENSE Copyright (C) 2003-2006 by Emmanuele Bassi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library 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. Gnome2-GConf-1.044/Makefile.PL0000644000175000017500000000743310677447206015617 0ustar torstentorsten# # $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gnome2-GConf/Makefile.PL,v 1.20 2007/09/29 13:09:26 kaffeetisch Exp $ # use 5.008; use strict; use warnings; use Cwd; use File::Spec; use ExtUtils::MakeMaker; # minimum required version of dependancies we need to build our %build_reqs = ( 'perl-ExtUtils-Depends' => '0.2', 'perl-ExtUtils-PkgConfig' => '1.03', 'perl-Glib' => '1.120', # for Glib::MakeHelper 'GConf' => '2.0.0', ); # Writing a fake Makefile ensures that CPAN will pick up the correct # dependencies and install them. unless (eval "use ExtUtils::Depends '$build_reqs{'perl-ExtUtils-Depends'}';" . "use ExtUtils::PkgConfig '$build_reqs{'perl-ExtUtils-PkgConfig'}';" . "use Glib::CodeGen;" # just seeing if Glib is available isn't enough, make sure # it's recent enough, too . "use Glib '$build_reqs{'perl-Glib'}';" . "use Glib::MakeHelper;" . "1") { warn "$@\n"; WriteMakefile( PREREQ_FATAL => 1, PREREQ_PM => { 'Glib' => $build_reqs{'perl-Glib'}, 'ExtUtils::Depends' => $build_reqs{'perl-ExtUtils-Depends'}, 'ExtUtils::PkgConfig' => $build_reqs{'perl-ExtUtils-PkgConfig'}, }, ); exit 1; # not reached } mkdir 'build', 0777; our %pkgcfg = ExtUtils::PkgConfig->find ('gconf-2.0 >= '.$build_reqs{GConf}); our @xs_files = ; our %pm_files = ( 'GConf.pm' => '$(INST_LIBDIR)/GConf.pm', ); our %pod_files = ( 'GConf.pm' => '$(INST_MAN3DIR)/Gnome2::GConf.$(MAN3EXT)', Glib::MakeHelper->do_pod_files (@xs_files), ); ExtUtils::PkgConfig->write_version_macros ("build/gconfperl-version.h", 'gconf-2.0' => 'GCONF'); # # autogeneration # Glib::CodeGen->parse_maps ('gconfperl'); Glib::CodeGen->write_boot (ignore => '^Gnome2::GConf$'); # now we're ready to start creating the makefile. # we need to use ExtUtils::Depends to get relevant information out of # the Glib extension, and to save config information for other modules which # will chain from this one. our $gconf = ExtUtils::Depends->new ('Gnome2::GConf', 'Glib'); $gconf->set_inc ($pkgcfg{cflags} . ' -I./build '); $gconf->set_libs ($pkgcfg{libs}); $gconf->add_xs (@xs_files); $gconf->add_pm (%pm_files); my $cwd = cwd(); $gconf->add_typemaps (map { File::Spec->catfile($cwd, $_) } 'build/gconfperl.typemap', 'gconf.typemap'); $gconf->install (qw(gconfperl.h build/gconfperl-autogen.h build/gconfperl-version.h doctypes)); $gconf->save_config ('build/IFiles.pm'); WriteMakefile( NAME => 'Gnome2::GConf', VERSION_FROM => 'GConf.pm', # finds $VERSION PREREQ_PM => {}, # e.g., Module::Name => 1.1 ABSTRACT_FROM => 'GConf.pm', # retrieve abstract from module XSPROTOARG => '-noprototypes', MAN3PODS => \%pod_files, $gconf->get_makefile_vars, ); #print " #WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING # #This is an unstable development release of Gnome2::GConf. The API is #not frozen and things are subject to change at any time. Report any #bugs to gtk-perl-list AT gnome DOT org as soon as possible. #Please use the stable 1.020 version for important work. # #WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING # #"; sub MY::postamble { return Glib::MakeHelper->postamble_clean () . Glib::MakeHelper->postamble_docs_full ( DEPENDS => $gconf, DOCTYPES => 'doctypes', COPYRIGHT_FROM => 'copyright.pod', ) . Glib::MakeHelper->postamble_rpms ( 'GCONF' => $build_reqs{'GConf'}, 'PERL_EXTUTILS_DEPENDS' => $build_reqs{'perl-ExtUtils-Depends'}, 'PERL_EXTUTILS_PKGCONFIG' => $build_reqs{'perl-ExtUtils-PkgConfig'}, 'PERL_GLIB' => $build_reqs{'perl-Glib'}, ); }