help needed with Gtk3 accelerators ..
- From: perl <perlatwork gmail com>
- To: gtk-perl-list gnome org
- Subject: help needed with Gtk3 accelerators ..
- Date: Fri, 30 Dec 2011 21:10:12 +0530
Can one help me to configure the accelerators with gtk3
here is some code for gtk3
thanks you
kanishka
use strict;
use warnings;
use Gtk3 '-init';
use Glib qw/TRUE FALSE/;
#Creating Window
my $window = Gtk3::Window->new('toplevel');
$window->set(
title=>rand(int(100)),
# default_height=>'300',
# default_width=>'300',
resizable=>'TRUE',
focus_on_map=>'TRUE'
);
#creating a Vbox
my $vbox = Gtk3::Box->new('vertical',3);
$vbox->set(
visible=>TRUE,
can_focus=>FALSE,
double_buffered=>FALSE,
expand=>'false'
);
#creating button
my $button = &button;
my $menubar = &createmenubar;
my $text_view = Gtk3::TextView->new();
$text_view->set(editable=>FALSE,cursor_visible=>FALSE);
my $scroll = Gtk3::ScrolledWindow->new();
$scroll->add($text_view);
# Vbox
# |--->Menubar
# |--->Button
# |--->TextView
#adding itesm to Vbox
$vbox->pack_start($menubar,FALSE,TRUE,3);
$vbox->pack_start($scroll,TRUE,TRUE,0);
$vbox->pack_start($button,FALSE,FALSE,0);
# Window
# |--->Vbox
$window->add($vbox);
#adding accelerator group
my $accel_group = Gtk3::AccelGroup->new();
$window->add_accel_group($accel_group);
#signale to destroy the main Gtk
$window->signal_connect(destroy=>\&quit);
$window->show_all;
Gtk3->main;
sub changetitle{
print $window->get_title(),"\n";
$window->set(
title=>rand(int(100)),
);
}
sub createmenubar{
my $menu_item_file = Gtk3::MenuItem->new_with_label('File');
my $menu_bar = Gtk3::MenuBar->new();
$menu_bar->add($menu_item_file);
my $menu_file = Gtk3::Menu->new();
my $menu_item_refresh =
Gtk3::ImageMenuItem->new_from_stock('gtk-refresh');
$menu_file->add($menu_item_refresh);
$menu_item_refresh->signal_connect(activate=>\&changetitle);
my $menu_item_quit = Gtk3::ImageMenuItem->new_from_stock('gtk-quit');
$menu_item_quit->signal_connect(activate=>\&quit);
#
$menu_item_quit->add_accelerator('activate',$accel_group,Gtk3::Accelerator->parse('<Control>Q'),'visible');
$menu_file->add($menu_item_quit);
$menu_item_file->set_submenu($menu_file);
return $menu_bar;
}
sub button {
my $button_sub =Gtk3::Button->new_with_label('Click to Change the
Title');
#connecting signale connnect clicked to subroutine
$button_sub->signal_connect(clicked=>\&changetitle);
$button_sub->set(
use_action_appearance=>FALSE,
visible=>TRUE,
can_focus=>TRUE,
receives_default=>TRUE,
use_action_appearance=>FALSE
);
return $button_sub;
}
sub quit {
Gtk3->main_quit;
}
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]