Re:My PHP-GTK2 questions (1 viewing) (1) Guest
Favoured: 0
|
|
|
TOPIC: Re:My PHP-GTK2 questions
|
cubii (User)
Fresh Boarder
Posts: 6
|
|
My PHP-GTK2 questions 11 Months, 3 Weeks ago
|
Karma: 0
|
Hello!
I'm having some problems with PHP-GTK for a project that I'm doing for work. I was wondering if you could help me with the following questions. To save forum clutter, I'll use this thread for my questions when possible.
1) I have been using this tutorial, which shows how to hide labels in a GTKIconView. Part of my jobs' project is to make a picture viewer so it says what it does on the tin.
The hidden text that I'm hiding via the set_text_column() function is actually the filename of the image that makes up the icon. How would one get the contents of that "string", so I can pass it to my apps image buffering function as a variable? For example, that tutorial has a square that is loaded from a file called "square_red.jpg". What is needed to get the string of "square_red.jpg" if the person clicks that image?
2. Is it possible to make a function that will jump up/down a row in a GTKTreeView (as seen in something like this example)? For example, one clicks a button and it jumps down a row? One clicks another button and jumps up a row?
Those are my questions for now. I await your answers.
Cheers,
Cubii.
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1678
|
|
Re:My PHP-GTK2 questions 11 Months, 3 Weeks ago
|
Karma: 27
|
Hi Cubii,
1) The GtkIconView uses the same concept as the GtkTreeView - both has an underlying model. When you click on an icon, you will also get a pointer to the model. In the model, in the sample code, I use 2 columns only. The first column to store the image and the second to store the filename. If you need the filename, even though it's not displayed, you can still access it in column 1 of the model.
So first add the callback function that responds to user selection. The callback function will sends you a pointer to the selection. From the selection, you can get access to the $model and $iter. With these 2 variable, you can access column 1 of the model.
2) It can be done, but you have to code everything.
Please refer to the following sample code: Sample Code 347: How to scroll to newly inserted item in a linear list using GtkTreeView - Part 1 - using GtkTreeView scroll_to_cell?
a) Basically, you need a pointer to manually keep track of the current row number. Suppose this is $n.
b) When uesr presses the Up button, $n = $n - 1;
c) When user presses the Down button, $n = $n + 1;
d) Then use GtkTreeView::scroll_to_cell() to scroll to the $nth row
Hope this helps.
Regards,
/kksou
|
|
|
|
|
|
|
Last Edit: 2012/06/03 16:16 By kksou.
|
|
|
The administrator has disabled public write access.
|
cubii (User)
Fresh Boarder
Posts: 6
|
|
Re:My PHP-GTK2 questions 11 Months, 3 Weeks ago
|
Karma: 0
|
Thanks a bunch, it's starting to lift the fog. However, what do you mean by "So first add the callback function that responds to user selection"? Do you mean something like $myVar->connect_simple('on_changed',doSomething()); ? If so, this is what I have:
| Code: |
(...)
$myVar->connect_simple('item-activated',myFunc($myVar->get_selected_items()));
function myFunc($what){
print_r($what);
}
|
This works initially (it outputs Array( ) in the console) but when you click on a icon, it doesn't do anything. Could you post a little function skeleton that I could then expand?
Thanks again for your assistance.
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1678
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1678
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
cubii (User)
Fresh Boarder
Posts: 6
|
|
Re:My PHP-GTK2 questions 11 Months, 2 Weeks ago
|
Karma: 0
|
Thanks for that - it worked, more or less. Managed to get the result I wanted anyway.
Another question - is it possible to make rows in a table have variable font sizes for lines within a cell? Let me put a image of what I'd like:
Note: each line below the text means end of row/cell.
One method I thought about was using an HTML widget embedded into the row, so that I could use HTML to display what I want in various sizes, etc.
Is it possible to do something like this or what would you suggest? The design I'm following for my project ideally wants one row, one column per item.
Thanks!
|
|
|
|
|
|
|
Last Edit: 2012/06/05 13:18 By cubii.
Reason: clarify
|
|
|
The administrator has disabled public write access.
|
cubii (User)
Fresh Boarder
Posts: 6
|
|
Re:My PHP-GTK2 questions 11 Months, 2 Weeks ago
|
Karma: 0
|
|
No responses?
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1678
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
cubii (User)
Fresh Boarder
Posts: 6
|
|
Re:My PHP-GTK2 questions 10 Months, 3 Weeks ago
|
Karma: 0
|
|
I'm back. I'm making some excellent progress, both thanks to my PHP skills and your code snippets. However, I have another interesting challenge for you.
I have two buttons that change the data that a TreeView shows. The single column of the TreeView says what date it is, for example, "Orders for X/Y/2012". This part is working fine at the start of the app, initial data is fed into the drawing function and it creates the columns, populates data, etc.
However, what I'd like to achieve is that if you click on the Newer/Older buttons, then it will modify the column header accordingly. Say for example, "Orders for 3/7/2012" would change to "Orders for 2/7/2012".
Is this possible? If it's not possible to do so, I'm up against a brick wall.
Cheers!
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
|