view release on metacpan or search on metacpan
misc/t-symlist-menu.pl
misc/t-symlist-model.pl
misc/t-symlist-tree.pl
misc/t-symlist.pl
misc/t-textbuffer.pl
misc/t-tge.pl
misc/t-ticker.pl
misc/t-tie-hash-union.pl
misc/t-tie-weaken.pl
misc/t-timebase.pl
misc/t-timer-object.pl
misc/t-tsp.pl
misc/t-useragent.pl
misc/t-variable-magic.pl
misc/t-viewstyle.pl
misc/t-volume-series.pl
misc/t-watchlist-model.pl
misc/t-widget-disc.pl
misc/t-widget-tracker.pl
misc/t-widget.pl
misc/t-write-only.pl
SHA256 dde37fbb4334fffdb0e54b48b71484c324f453ecf3341a6380a2ee84619dce5e misc/t-symlist-menu.pl
SHA256 c429117bfc542298d5ac3fd72f96d422eee234d00eccfb3988cf62079bdb214b misc/t-symlist-model.pl
SHA256 7b5fe4d726a897b67ec9c349557e1beb4423d09701a6672b84e90432bb9b4b4d misc/t-symlist-tree.pl
SHA256 8cbd395d5847716e606dd6becacb5831e5c3bf8257b5309c8fdde6013840beb2 misc/t-symlist.pl
SHA256 9c3740a52f3cdab7326e6ee5dc3ea6e74fda6197573877caa599ddba3816fb0e misc/t-textbuffer.pl
SHA256 79907d407d2c82a5ad137a9995a552863272d1e8d11f948dcafb3f366c88a535 misc/t-tge.pl
SHA256 23a7d8d04feedacd646bb5550862095c1d1868215d46c34586aec21c50d6cdfe misc/t-ticker.pl
SHA256 0710b0dfdfb9f96b5d4ea89e282bb6257f877c9ab14789cc51628f567441c93a misc/t-tie-hash-union.pl
SHA256 57b64e926f5c88e0a0a3c7b8b52452f7b2a3b83f05cecf95b9011839b8a86657 misc/t-tie-weaken.pl
SHA256 34e686f52a48605d1324b4e193cc31beef654e52bde7ef581e44e605ef5994f3 misc/t-timebase.pl
SHA256 1db1ab8b2b535f9ab672b2490c06d1116993a25e36c9219a7c6326040452bdbb misc/t-timer-object.pl
SHA256 24f511d67820204708ac297429be7ef33f58a63db06de5e7b849dba4b1473ac6 misc/t-tsp.pl
SHA256 3fbacdc88daad94c39c4ee8f2c1211c4f7021ab02b8a3a82913f36f43cf4f974 misc/t-useragent.pl
SHA256 16b64ff65593bbed47c7507127a39991758e2a552a9bfd53334acc015a66404b misc/t-variable-magic.pl
SHA256 963d16c4a00447b9778a3f63e8c44b6b2d365765d29dcb3987d89bc4552cb877 misc/t-viewstyle.pl
SHA256 a60c8ee45be71ed326a16c216e41705d187c0c9a121050e89e39de21e7624fee misc/t-volume-series.pl
SHA256 06438e1c71cec92c9527ccd850c45800e4364b4c23d4a43e6f52cf5ef8437840 misc/t-watchlist-model.pl
SHA256 fa4261f92dddb973db6eecfbba682ba2932fab7a3ea6cd5a19e14c516599550b misc/t-widget-disc.pl
SHA256 ed2bc868cb58120bd77e037d21c49cb41a020c481a4a0b0c155af999f36b81cf misc/t-widget-tracker.pl
SHA256 ac394cb13221ceaa01bdbd928b81336eb6218a4fba96c944aca5f065b44111a8 misc/t-widget.pl
SHA256 8859c1258371b8dfebc21fbddf0588ef11b67791309f5447c1d3dc0192f90739 misc/t-write-only.pl
emacs/chartprog.el view on Meta::CPAN
;; along with Chart. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; See section "Emacs" in the Chart manual for usage.
;;; Code:
(require 'timer) ;; for xemacs21
(eval-when-compile ;; for macros in emacs20
(unless (and (fboundp 'declare)
(fboundp 'dolist)
(fboundp 'push))
(require 'cl)))
(defvar bookmark-make-record-function) ;; in bookmark.el
emacs/chartprog.el view on Meta::CPAN
;; subprocess
(defconst chartprog-protocol-version 102
"An internal part of chartprog.el.
This must be the same as the number in App::Chart::EmacsMain, to
ensure cooperation with the sub-process.")
(defvar chartprog-process nil
"An internal part of chartprog.el.
The running chart subprocess, or nil if not running.")
(defvar chartprog-process-timer nil
"An internal part of chartprog.el.
Idle timer to kill chart subprocess when it's unused for a while.")
;; forward references
(defvar chartprog-completion-symbols-alist)
(defvar chartprog-latest-cache)
(defvar chartprog-symlist-alist)
(defvar chartprog-watchlist-map)
(defvar chartprog-watchlist-menu)
(defvar chartprog-quote-symbol)
(defvar chartprog-quote-changed)
emacs/chartprog.el view on Meta::CPAN
(buffer-disable-undo (process-buffer chartprog-process)))
;; send this command
(let ((str (concat (prin1-to-string
(chartprog-copy-tree-no-properties (cons proc args)))
"\n")))
(chartprog-debug-message "\noutgoing " str)
(process-send-string chartprog-process str))
;; start or restart idle timer
(when chartprog-process-timer
(cancel-timer chartprog-process-timer))
(setq chartprog-process-timer (run-at-time "5 min" nil 'chartprog-process-kill)))
(defun chartprog-incoming-init (codeset protocol-version)
"An internal part of chartprog.el.
Handle chart subprocess init message.
CODESET is always \"UTF-8\".
PROTOCOL-VERSION is the protocol number the subprocess is speaking, to be
matched against `chartprog-protocol-version'."
(unless (= protocol-version chartprog-protocol-version)
(when (get-buffer "*chartprog-watchlist*") ;; ignore if gone
emacs/chartprog.el view on Meta::CPAN
(when form
(delete-region (point-min) (point))
(chartprog-debug-message "incoming " form)
(apply (intern (concat "chartprog-incoming-"
(symbol-name (car form))))
(cdr form)))
;; no more processing after `synchronous', let the result get
;; back to the caller before further asynch stuff is
;; processed (that further stuff deferred under a timer)
(when (eq (car form) 'synchronous)
(run-at-time 0.0000001 nil
(lambda ()
(chartprog-process-filter chartprog-process "")))
(setq form nil))
;; process another form, perhaps
form)))))
(defun chartprog-process-sentinel (proc event)
"An internal part of chartprog.el.
The sentinel for the chart subprocess per `set-process-sentinel'.
The subprocess should stay alive forever, until we ask it to stop
by the `chartprog-process-timer, so any termination is
unexpected."
(when (get-buffer "*chartprog-watchlist*")
(with-current-buffer "*chartprog-watchlist*"
(let ((inhibit-read-only t))
(save-excursion
(goto-char (point-min))
(when (looking-at "\\s-*Starting")
(erase-buffer))
(insert (format "\nSubprocess died: %s\n\n" event))))))
(chartprog-process-kill)
(message "Chart subprocess died: %s" event))
(defun chartprog-process-kill ()
"An internal part of chartprog.el.
Kill chart subprocess."
(when chartprog-process-timer
(cancel-timer chartprog-process-timer)
(setq chartprog-process-timer nil))
(when chartprog-process
;; clear chartprog-process variable immediately, xemacs recurses to here
(let ((p chartprog-process))
(setq chartprog-process nil)
(set-process-sentinel p nil)
(set-process-filter p nil)
(delete-process p)
(kill-buffer (process-buffer p)))
;; go back to uninitialized to force a re-read on the contents if the
;; subprocess is restarted, that way any additions while we were away
lib/App/Chart/Gtk2/Subprocess.pm view on Meta::CPAN
### Subprocess FINALIZE_INSTANCE()
$self->stop;
}
sub SET_PROPERTY {
my ($self, $pspec, $newval) = @_;
my $pname = $pspec->get_name;
$self->{$pname} = $newval; # per default GET_PROPERTY
if ($pname eq 'job') {
_update_idle_timer ($self);
}
}
# 'notify' signal class closure
sub _do_notify {
my ($self, $pspec) = @_;
### Subprocess notify: $pspec->get_name
$self->signal_chain_from_overridden ($pspec);
# emit 'status-changed' under notify so it's held up by freeze_notify
lib/App/Chart/Gtk2/Subprocess.pm view on Meta::CPAN
App::Chart::Gtk2::JobQueue->consider_run;
} else {
if (my $job = $self->{'job'}) {
$job->set (status => $status);
}
}
}
return Glib::SOURCE_CONTINUE;
}
sub _update_idle_timer {
my ($self) = @_;
my $want_timer = ($self->pid && ! $self->{'job'});
if ($want_timer) {
$self->{'timer_ids'} ||= Glib::Ex::SourceIds->new
(Glib::Timeout->add (IDLE_TIMEOUT_SECONDS * 1000,
\&_do_idle_timeout,
App::Chart::Glib::Ex::MoreUtils::ref_weak($self)));
} else {
$self->{'timer_ids'} = undef;
}
}
sub _do_idle_timeout {
my ($ref_weak_self) = @_;
my $self = $$ref_weak_self || return Glib::SOURCE_REMOVE;
$self->stop;
Gtk2::Ex::TreeModelBits::remove_matching_rows
($store, sub { my ($store, $iter) = @_;
$store->get_value($iter,0) == $self });
$self->{'timer_ids'} = undef;
return Glib::SOURCE_REMOVE;
}
# send out a 'row-changed' on the global $store for subprocesses $self
sub _emit_row_changed {
my ($self) = @_;
$store->foreach (sub {
my ($store, $path, $iter) = @_;
my $this = $store->get_value ($iter, 0);
if ($this && $this == $self) {
maybe/TimerObject.pm view on Meta::CPAN
# Glib timer as an object, and weak reference to its data.
# Copyright 2007, 2008, 2010, 2011 Kevin Ryde
# This file is part of Chart.
#
# Chart is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
maybe/TimerObject.pm view on Meta::CPAN
package Gtk2::Ex::TimerObject;
use strict;
use warnings;
use Carp;
use Glib;
use Scalar::Util;
use base 'Gtk2::Ex::SourceObject';
#------------------------------------------------------------------------------
# timer object
sub _establish {
my ($self) = @_;
if (my $id = delete $self->{'source_id'}) {
Glib::Source->remove ($id);
}
if (my $period = $self->{'period'}) {
my $weak_self = $self;
Scalar::Util::weaken ($weak_self);
$self->{'source_id'} = Glib::Timeout->add
($period,
\&Gtk2::Ex::SourceObject::_source_callback, \$weak_self,
$self->{'priority'} || Glib::G_PRIORITY_DEFAULT);
### timer id: "$self $self->{'source_id'}"
}
}
sub set_period {
my ($self, $period) = @_;
my $old_period = $self->{'period'};
$self->{'period'} = $period;
if (($period||0) != ($old_period||0)) { _establish ($self); }
}
maybe/TimerObject.pm view on Meta::CPAN
my $self = $class->SUPER::new (@_);
_establish ($self);
return $self;
}
1;
__END__
=head1 NAME
Gtk2::Ex::TimerObject -- oop Glib timer
=head1 SYNOPSIS
use Gtk2::Ex::TimerObject;
my $timer = Gtk2::Ex::TimerObject->new
(period => 1000, # milliseconds
callback => \&my_func,
userdata => 'some value');
# or weak reference to a widget
my $timer = Gtk2::Ex::TimerObject->new
(period => 500,
run => 0, # start off stopped too
callback => \&my_update_func,
userdata => $widget,
weak_userdata => 1);
$timer->set_period (100);
$timer->start;
$timer->stop;
=head1 DESCRIPTION
C<Gtk2::Ex::TimerObject> is an object-oriented wrapper around the
C<< Glib::Timeout->add >> timer mechanism. A timer object can be stopped
and later restarted, and is automatically stopped if the object is destroyed
(when all references to it are dropped).
The "C<weak>" option allows only a weak reference to be kept to the userdata
passed to the callback function. If the userdata object or widget is
destroyed then the timer stops. This is good if the timer is part of a
widget implementation (the weakening avoid a circular reference).
=head1 FUNCTIONS
=over 4
=item C<< Gtk2::Ex::TimerObject->new (key=>value, ...) >>
Create and return a new timer object. Parameters are taken as key/value
pairs. The following keys are supported
period time in milliseconds, or undef
callback function to call
userdata parameter to each callback call
weak if true then weaken userdata (default false)
priority Glib main loop level (default G_PRIORITY_DEFAULT)
When the timer is running the given C<callback> function is called every
C<period> milliseconds,
$callback->($timerobj, $userdata);
Any return value from it is ignored, but it can change the period or stop
the timer within that callback, if desired.
If C<period> is C<undef> it means the timer should not run, and no calls to
the C<callback> function are made. This can be good for an initialization
function where a timer should be created, but it shouldn't run until some
later setups.
If the C<weak> option is true then the C<userdata> value is kept only as a
weak reference (if it is in fact a reference). If that value is garbage
collected (because nothing else is using it) then the timer stops.
The C<priority> parameter controls the priority of the timer within the Glib
main loop. The default is C<Glib::G_PRIORITY_DEFAULT>, which is 0.
Positive values are lower priority, negative values higher.
=item C<< $timer->set_period ($milliseconds) >>
Set the period of C<$timer> to C<$milliseconds>, or stop it if
C<$milliseconds> is C<undef>.
In the current implementation, if the timer is running and the period is
changed then it starts counting down again from a whole new C<$milliseconds>
period. Perhaps in the future it'll be possible to take into account how
long since the last firing, to keep it running smoothly if merely making
small adjustments to the period, but current Glib (version 2.14) doesn't
allow that (not with the basic C<< Glib::Timeout->add >>).
=item C<< $timer->stop >>
Stop C<$timer>, so no further calls to its C<$callback> are made. This is
the same as a C<< $timer->set_period(undef) >>. The timer can be restarted
later by a new C<set_period>, if desired.
=back
=head1 OTHER NOTES
C<TimerObject> is currently implemented as a Perl object holding a timer ID
from C<< Glib::Timeout->add >>. If C<GSource> was available at the Perl
level in the future then perhaps C<TimerObject> could become a subclass of
that.
=head1 SEE ALSO
L<Glib::MainLoop>, L<Gtk2::Ex::IdleObject>, L<Glib::Ex::SignalObject>
=cut
maybe/TimerObject.t view on Meta::CPAN
my $id = Glib::Timeout->add (1, \&attempts);
alarm(5);
Gtk2->main;
alarm(0);
($main_where) = 'nowhere';
Glib::Source->remove ($id);
}
skip ($if_no_display, sub {
my $timer = Gtk2::Ex::TimerObject->new (1000, \&noop);
Scalar::Util::weaken ($timer);
return defined $timer ? 'defined' : 'not defined';
},
'not defined', 'should be garbage collected when weakened');
# skip ($if_no_display, sub {
# my $userdata = [ 'foo' ];
# my $timer = Gtk2::Ex::TimerObject->new_weak (1, \&noop, $userdata);
# Scalar::Util::weaken ($userdata);
# main ('new_weak');
# return $timer->is_running ? 'running' : 'not running';
# },
# 'not running', 'should stop on weakened userdata');
exit 0;
misc/t-timer-object.pl view on Meta::CPAN
# with Chart. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Data::Dumper;
use Glib;
use Scalar::Util;
use Gtk2 '-init';
use Gtk2::Ex::TimerObject;
sub timer {
my @args = @_;
print "timer ", Dumper (\@args);
}
{
my $timer;
{
my $widget = Gtk2::Label->new;
$widget->signal_connect (destroy => sub { print "widget destroy\n"; });
$timer = $widget->{'timer'} = Gtk2::Ex::TimerObject->new
(period => 1000,
callback => \&timer,
userdata => $widget,
weak => 1);
}
Gtk2->main;
exit 0;
}
{
my $widget = Gtk2::Label->new;
my $weak_widget = $widget;
Scalar::Util::weaken ($weak_widget);
my $id = Glib::Timeout->add (1000, \&timer, $weak_widget);
Gtk2->main;
exit 0;
}
__END__
{
{
my $widget = Gtk2::Label->new;
$widget->signal_connect (destroy => sub { print "label destroy\n"; });
my $id = Gtk2::Ex::TimerObject::timeout_add_weak (1000, \&timer, $widget);
}
Gtk2->main;
exit 0;
}
#------------------------------------------------------------------------------
# generic weakened callback
sub _weak_callback {
misc/t-timer-object.pl view on Meta::CPAN
my ($period, $callback, $userdata, @optional_priority) = @_;
if (ref $userdata) {
my @wdata = ($callback, $userdata);
Scalar::Util::weaken ($wdata[1]);
return (\&_weak_callback, \@wdata);
} else {
return ($callback, $userdata);
}
}
# $self->{'timer_id'} = Glib::Timeout->add
# ($period, weak_callback(\&_timer_object_callback,$self), @optional_priority);
#------------------------------------------------------------------------------
# integer ID, with weak reference to userdata
sub timeout_add_weak {
my ($period, $callback, $userdata, @optional_priority) = @_;
if (ref $userdata) {
misc/ticker.el view on Meta::CPAN
(defvar ticker-mode-map
(let ((m (make-sparse-keymap)))
(define-key m "q" 'ticker-quit)
m)
"Keymap for `ticker-mode' display buffer.")
(defun ticker-quit ()
(interactive)
(delete-window))
(defun ticker-timer-scroll (buffer)
(dolist (window (get-buffer-window-list buffer))
(with-selected-window window
(let ((offset (- (point) (window-hscroll)))
(new-hscroll (if (> (+ (window-hscroll) (window-width)) (point-max))
(point-min)
(1+ (window-hscroll)))))
(goto-char (+ new-hscroll offset))
(set-window-hscroll window new-hscroll)))))
(defvar ticker-timer nil)
(make-local-variable 'ticker-timer)
(defun ticker-stop-timer ()
(when ticker-timer
(cancel-timer ticker-timer)
(setq ticker-timer nil)))
(defun ticker-mode ()
"Show a scrolling ticker.
"
(kill-all-local-variables)
(setq major-mode 'ticker-mode
mode-name "Ticker"
truncate-lines t)
(use-local-map ticker-mode-map)
(setq buffer-read-only t)
(setq ticker-timer (run-at-time 0 1 'ticker-timer-scroll (current-buffer)))
(add-hook 'kill-buffer-hook 'ticker-stop-timer t t)
(run-hooks 'ticker-mode-hook))
(progn
(if (get-buffer "x")
(kill-buffer "x"))
(let ((window-min-height 1))
(split-window nil 2))
(switch-to-buffer "x")
(insert "fjksdj fksd jfksd fksd jfksd jfk sjdfk jsdkf sjdkf jsdkf jsdk fjsdk fjksd fjksd fjksd fjksd fjk sdjfksd fjkj kj kj k jk jk jk k ")
(ticker-mode))
;; (cancel-timer (car timer-list))
t/MyTestHelpers.pm view on Meta::CPAN
my ($widget, $signame) = @_;
if (DEBUG) { MyTestHelpers::diag ("wait_for_event() $signame on ",$widget); }
my $done = 0;
my $got_event = 0;
my $sig_id = $widget->signal_connect
($signame => sub {
if (DEBUG) { MyTestHelpers::diag ("wait_for_event() $signame received"); }
$done = 1;
return 0; # Gtk2::EVENT_PROPAGATE (new in Gtk2 1.220)
});
my $timer_id = Glib::Timeout->add
(30_000, # 30 seconds
sub {
$done = 1;
MyTestHelpers::diag ("wait_for_event() oops, timeout waiting for $signame on ",$widget);
return 1; # Glib::SOURCE_CONTINUE (new in Glib 1.220)
});
if ($widget->can('get_display')) {
# display new in Gtk 2.2
$widget->get_display->sync;
} else {
t/MyTestHelpers.pm view on Meta::CPAN
my $count = 0;
while (! $done) {
if (DEBUG >= 2) { MyTestHelpers::diag ("wait_for_event() iteration $count"); }
Gtk2->main_iteration;
$count++;
}
MyTestHelpers::diag ("wait_for_event(): '$signame' ran $count events/iterations\n");
$widget->signal_handler_disconnect ($sig_id);
Glib::Source->remove ($timer_id);
}
#-----------------------------------------------------------------------------
# X11::Protocol helpers
sub X11_chosen_screen_number {
my ($X) = @_;
my $i;
foreach $i (0 .. $#{$X->{'screens'}}) {