| View previous topic :: View next topic |
| Author |
Message |
N!cKY
Joined: 19 Apr 2006 Posts: 12 Location: Mosbach/Germany
|
Posted: Sat Apr 22, 2006 6:01 pm Post subject: change label/mnemonic of a menu item |
|
|
hi, i've got a lot of question:
- how can i markup a text (GtkTextView/Buffer) using pango?
- how can i use GtkTextBuffer::paste_clipboard()?what's the second and the third parameter?
- *done* i tried to connect the GtkTextBuffer signal 'changed' and the GtkNotebook signal 'switch-page' to a callback function:
| Code: | $this->buffer->connect_simple('changed', 'onTextChange');
$this->notebook->connect_simple('switch-page', 'loadText'); |
but that occurs many errors:
http://www.eaglescripts.de/upload/32.JPG
i don't know why!what's wrong?
the callbacks' scopes are public
what's the best way for a file selection?there are so many classes..
*new* how can i disable a menu item (like html 'disabled="disabled"'), so that it's not activatable and its text (label) becomes grey.
if i still remember something, i'll post it.
3. is the most important question.
thank you for your help and sorry for the title and my english
Last edited by N!cKY on Sat Apr 29, 2006 1:32 pm; edited 2 times in total |
|
| Back to top |
|
 |
N!cKY
Joined: 19 Apr 2006 Posts: 12 Location: Mosbach/Germany
|
Posted: Sun Apr 23, 2006 11:15 am Post subject: |
|
|
3. is done!
but there's another problem:
i connected the "switch-page" (GtkNotebook) with a callback function and then the CLI crashes:
http://eaglescripts.de/upload/34.jpg
the signal connecting looks like that
| Code: | | $ntbk->connect('switch-page', 'onSwitchPage'); |
and the callback funktion like that:
| Code: | function onSwitchPage(GtkNotebook $ntbk, $page, $nPage) {
echo $nPage.PHP_EOL;
} |
i don't know why the CLI crashes and how i can fix that
the other questions aren't so important, but i'd be happy if anyone replies |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Sun Apr 23, 2006 8:28 pm Post subject: |
|
|
Hello Nicky,
Which version of the php-gtk2.dll do you use? The last one from the gnope channel? If not, try that. If the script does still crash, please try to reduce the script as much as possible by taking all unnecessary code lines while keeping the error intact. If there is nothing to remove, please send the code to the php-gtk mailing list telling that it crashes on your system. The devs will take care for it then.
1. Does just using pango markup don't work? Look at the php-gtk2 demo script in your installation and look how the source code highlighting is done. It definitely uses pango markup to color the code.
2. Please use Dev_Inspector to find out the parameters and the name. The second is "override_location" to (optionally) specify the location to paste to. The original Gtk docs also help greatly until the php-gtk2 manual is finished.
4. GtkFileChooser is the new class while GtkFileSelection is the Gtk1 dialog
5. Disable a menu item as you do it with all widgets: set_sensitive |
|
| Back to top |
|
 |
N!cKY
Joined: 19 Apr 2006 Posts: 12 Location: Mosbach/Germany
|
Posted: Mon Apr 24, 2006 6:40 pm Post subject: |
|
|
thank you very much, the original gtk doc is very useful!
i use the version, which is in the Release 1.0 pack from http://www.gnope.org/download.php . it's the current version, is it?
if not, where can i get the current version?and how?
Can you (or somebody else) test the small script, before I contact the devs?
| Code: | <?php
function onSwitchPage(GtkNotebook $ntbk, $page, $nPage) {
echo "page switched to $nPage\n";
}
$win = new GtkWindow();
$ntbk = new GtkNotebook();
$ntbk->append_page(new GtkLabel('label 1'));
$ntbk->append_page(new GtkLabel('label 2'));
$win ->connect_simple('destroy', array('Gtk', 'main_quit'));
$ntbk->connect('switch-page', 'onSwitchPage');
$win->add($ntbk);
$win->show_all();
Gtk::main();
?> |
PS: how can i use glade? is it advisable to use it? do you know a good tutorial (preferred in german)? i have not the faintest idea of that! |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
|
| Back to top |
|
 |
N!cKY
Joined: 19 Apr 2006 Posts: 12 Location: Mosbach/Germany
|
Posted: Sat Apr 29, 2006 1:22 pm Post subject: |
|
|
thank you very much, you were a big help, but i still have some questions:
i'm writing an application like 'Notepad' and therefore i built a menu with some item.
- how can i change the label of a GtkImageMenuItem()? if i build such a menu item
| Code: | | new GtkImageMenuItem(Gtk::STOCK_NEW); |
the label is always automatically '_New', but i want to set my own label. if you wonder why i need this: i'd like to have a menu item with the 'refresh' stock but a not the '_Refresh' label, instead a 'Reload' label. by the way..can i change the mnemonics of these items somehow?
Neither the mnemonics nor the accelerators of the 'GtkImageMenuItem's works for me
i'll give you a sample code:
| Code: | <?php
function onMenuActivate() {
echo "new\n";
}
$win = new GtkWindow();
$accel = new GtkAccelGroup();
$menubar = new GtkMenuBar();
$menu = new GtkMenu();
$item = new GtkMenuItem('_File');
$subitem = new GtkImageMenuItem(Gtk::STOCK_NEW);
$subitem->connect_simple('activate', 'onMenuActivate');
$subitem->add_accelerator('activate', $accel, GDK::KEY_n, GDK::CONTROL_MASK, GTK::ACCEL_VISIBLE);
$menu->append($subitem);
$item->set_submenu($menu);
$menubar->add($item);
$win->add($menubar);
$win->show_all();
Gtk::main();
?> |
actually i could activate the 'New' - Item either with CTRL + N or with ALT + F (to open the 'File'-submenu) and then ALT + N, but it isn't so
does anyone know why?
i implemented some clipboard functions (cut, copy, paste) by using GtkClipboard, if i close the window i get a warning:
| Quote: | (run.phpw:4748): Gtk-Warning **: GtkClipboard prematurely finalized
(run.phpw:4784): CLib-Critical **: g_main_loop_is_running: assertion `loop "= NULL` failed |
what can i do against that? the clipboard function works fine..
thanks  |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Sat Apr 29, 2006 1:56 pm Post subject: |
|
|
1. Either do a var_dump(count($subitem->get_children())) to see of what the menu item is built of, or use Dev_GuiInspector to inspect the menu item - it will show you the children in a nice way.
2. Using mnemonics work; you do Alt+F to go to the file menu, but as you are in the menu, you don't need to use Alt any more - just type "N", and the item is activated.
To get the accelerator working, learn about accelerator groups and that a window needs one.
3. Maybe you need to close the clipboard somehow. |
|
| Back to top |
|
 |
N!cKY
Joined: 19 Apr 2006 Posts: 12 Location: Mosbach/Germany
|
Posted: Sat Apr 29, 2006 7:57 pm Post subject: |
|
|
thanks, i'm so stupid
but i can't get rid of the warning with the clipboard, where shall i close the clipboard and how?with unset()? |
|
| Back to top |
|
 |
|