gtkWindow auto resizing

hello forum,
i’ve got a question concerning Gtk::Window auto-resizing behavior.
i’m working on an audio player, and i’ve got two different versions -
one that is just a basic player, and another that looks like a turntable
(i should be able to share it soon, should anyone give a hoot…) in
the basic player, i set up the gui inside a #Window like this:

##################
…(truncated)
btnBox = Gtk::HBox.new(true,2)

btnBox.pack_start(player.playBtn,false,false,0)

box = Gtk::VBox.new(false, 0)
box.pack_start(player.infoBox, false, false, 2)
box.pack_start(player.progBox, false, false, 2)
box.pack_start(player.artBox, true, true, 2)
box.pack_start(btnBox, false, false, 2)

player.mainWin.add(box)
player.mainWin.show_all
####################

this has the nice effect that the #Window starts up sized to fit
everything, and automatically resizes according to the size of the
infoBox (an #EventBox with a #Label in it)… that is to say, if the
text within the label is longer than the #Window allows for, the #Window
gets bigger vertically to accomodate it. this was through no plan of my
own (i must admit,) but i really like the effect.

the other player is basically the same, but instead of packing the
buttons and the artBox (an EventBox with an album-cover #Image inside
it,) i pack the infoBox and the “table” (an instance of a class which
inherits from Gtk::Layout) into a #VBox, like this:

####################
box = Gtk::VBox.new(false, 0)
box.pack_start(player.infoBox, false, false, 2)
box.pack_start(player.table, true, true, 2)
player.mainWin.add(box)
player.mainWin.show_all
####################

strange thing is that although this seems exactly the same to me, it
has a very different behavior. here, the mainWin #Window is quite small
at startup, and after manually resizing the mainWin, it no longer
resizes to accomodate for different text lengths - the infoBox now
pushes the table #Layout down and cuts it off at the bottom of the
mainWin, rather than pushing the mainWin up and expanding it, as in the
first example.

got me stumped… any ideas what’s going on here?

thanks in advance for any help -

-jk

On Fri, Feb 25, 2011 at 7:03 AM, J. K.
[email protected]wrote:


player.mainWin.show_all
buttons and the artBox (an EventBox with an album-cover #Image inside

thanks in advance for any help -

I’m not really good with this, but I believe Layout is a container that
support scrolled by default, and supposed to be used by adding it to a
ScrolledWindow

On Fri, Feb 25, 2011 at 6:17 PM, hendra kusuma
[email protected]wrote:

box.pack_start(player.artBox, true, true, 2)
gets bigger vertically to accomodate it. this was through no plan of my
box.pack_start(player.table, true, true, 2)
first example.

Also, since you are making an audio player
can I request some feature?

I would like a run-and-go media player that load a directory just like
winamp. I never like to manage my music. If you make a jukebox like,
please
at least make these operations easy to do

that can be controlled by global hotkey, at least command line parameter
to
play/pause/next/prev. I can assign the shortcut myself

and if possible, it search a text file with the same name as the song is
playing, and display it’s content (which is supposed to be lyric of the
playing song) in a window. I’m tired of those media player that fetch
lyric
from internet. That’s only good for western music

Thanks alot

On Fri, Feb 25, 2011 at 7:32 PM, J. K.
[email protected]wrote:

the bottom
half of the image to append files, the top half to prepend fil

Hi J.K.
I see your screenshot, looks nice
This is just an idea, about playlist.

We have two lists, 1st is the list of playlist, 2nd is the songs in
selected
playlist
put them side by side, perhaps looks like below


| list | list |
| of | of |
| playlist | songs in |
| | selected |
| | playlist |
| | |

the idea comes from winamp3, I think its very cool,
but then winamp discard it in ver 4
and since then, this kind of playlist gone forever
never found it elsewhere again

If you can make it, it would be cool
But if you don’t, it shouldn’t be a problem either
afterall 1 playlist is what we all need

Thank you
Hope to see it soon

hi hendra -
thanks for the idea about the scrolled window - i was thinking the
problem might be the layout… i’ll try putting it into a scrolled
window and see what happens.
feature requests for the player are always welcome - at present there
are two ways to load directories or files into the player… through a
file selection dialog that pops-up with a button-press, or by dragging
and dropping files or directories onto the cover image (onto the bottom
half of the image to append files, the top half to prepend files.) a
popup to display lyrics from a .txt would be easy enough to implement
too - and don’t worry - i like the local stuff better than the internet
searches as well! the player is really quite simple - i too prefer to
just load files from my directories which are already organized to my
liking.
i’m cleaning it up now, and will share it when it’s more or less
presentable… some things that still need work (and please feel free
to add anything you like) are playlist management (right now you can
clear the whole thing, but not clear individual files,) hotkeys, and
commandline functions. i’ll post a link here when it’s more or less
done. i’ve attached a screenshot of the thing in action at 100% scale so
you can see it well, i usually scale it down to around 40% so that it
doesn’t eat up the whole screen…

thanks again for the suggestions -

-jk

hey there -

hendra, yes, the two playlist thing can be neat - if i understand what
you’re getting at, the 1st is basically a list of all the songs in your
collection, and the 2nd a list of songs in queue. i wrote this player
after a setup that i had with foobar2000, and i had a nice “1st
playlist,” or media library window, and then an active playlist window.
i’m working on a nice looking directory browser that works with the
player that would be perhaps similar to what you’re talking about.

vincent, i’ll take a look at the hotkey library - it sounds great.
i’m looking now at updating to gtk2-0.19.4 (i’m still with .19.3 which
came in my package manager,) mostly for your gstreamer MessageTag
parsing patch - thanks for working that out! i’m using the mp3info gem
right now, but i would prefer to do without it. i’ll check out your
audio player too, thanks for the link - this is also my first ruby
project.

i should have this thing cleaned up enough to share soon. it’s far
from perfect, but it generally works. i seem to be crashing a lot
lately on a segmentation fault - not sure what that’s about, but i’ll
hopefully figure it out before long.

ah, i solved my resize problem. still not sure why in the first
example the window resizes automatically, but i ended up just writing a
couple of lines to resize the window based on the info text length, and
that’s good enough for me…

thanks again for the input -

-jk

On Sat, Feb 26, 2011 at 5:41 AM, J. K.
[email protected]wrote:

Well, you’re not really getting my idea, but that’s would be cool too
if you’re doing it, then make sure to implement search in 1st playlist
so we can search to narrow the list and then drag-and-drop song we want
to
2nd playlist
I think it would be very nice.

I surely can live with that :smiley:

vincent, i’ll take a look at the hotkey library

I’ll go there also

right now, but i would prefer to do without it. i’ll check out your

audio player too, thanks for the link - this is also my first ruby
project.

I’ll check it too

i should have this thing cleaned up enough to share soon. it’s far
from perfect, but it generally works. i seem to be crashing a lot
lately on a segmentation fault - not sure what that’s about, but i’ll
hopefully figure it out before long.

I’m waiting for the link

2011/2/25 hendra kusuma [email protected]:

that can be controlled by global hotkey, at least command line parameter to
play/pause/next/prev. I can assign the shortcut myself

I have written a ruby library to handle globalhotkeys :
http://zik.rubyforge.org/rghk . If you are interested give me some
feedback. I am working on the next version (0.2.1).

I have also written a audio player. You can take a look at
http://zik.rubyforge.org . It is my first project. I am still working
on it.

Vincent C.

2011/2/26 hendra kusuma [email protected]:

i should have this thing cleaned up enough to share soon. it’s far
from perfect, but it generally works. i seem to be crashing a lot
lately on a segmentation fault - not sure what that’s about, but i’ll
hopefully figure it out before long.

I’m waiting for the link

I will also take a look.


Vincent C.

On Sat, Feb 26, 2011 at 9:30 AM, Vincent C. [email protected]
wrote:

Dear J.K.
You are very bold to jump to make audio player even while you are just
learning programming.
But I like your way to do it, really.
I already graduate my college of Computer Information System 5 years ago
and I never thought of making my own audio player
you make me do it today

Thanks also to Vincent with Zik, your code helps alot

So, basically, I am now trying to make my own audio player because of
you
two guys
and now I’m writing email this while listening to my half complete audio
player playing mp3
alot need to be fixed and add, but now it already can load files from
folder
and play it. Shuffle also already implemented since I always listen song
shuffled

hopefully one day I can join you two and release mine
thank you for your inspiration

hendra kusuma wrote in post #984086:

On Sat, Feb 26, 2011 at 9:30 AM, Vincent C. [email protected]
wrote:

hopefully one day I can join you two and release mine
thank you for your inspiration

i look forward to seeing/hearing it… have fun!

-j