Forum: Ruby-Gnome 2 gtkWindow auto resizing

Posted by J. K. (j_k)
on 2011-02-25 00:03
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
Posted by hendra kusuma (Guest)
on 2011-02-25 11:18
(Received via mailing list)
On Fri, Feb 25, 2011 at 7:03 AM, J. K. 
<ruby-forum-incoming@andreas-s.net>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
Posted by hendra kusuma (Guest)
on 2011-02-25 11:26
(Received via mailing list)
On Fri, Feb 25, 2011 at 6:17 PM, hendra kusuma 
<penguinroad@gmail.com>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
Posted by J. K. (j_k)
on 2011-02-25 12:32
Attachment: Screenshot.jpg (229 KB)
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
Posted by hendra kusuma (Guest)
on 2011-02-25 18:08
(Received via mailing list)
On Fri, Feb 25, 2011 at 7:32 PM, J. K. 
<ruby-forum-incoming@andreas-s.net>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
Posted by Vincent Carmona (vinc-mai)
on 2011-02-25 18:09
(Received via mailing list)
2011/2/25 hendra kusuma <penguinroad@gmail.com>:
>
> 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 Carmona
Posted by J. K. (j_k)
on 2011-02-25 22:41
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
Posted by hendra kusuma (Guest)
on 2011-02-26 02:24
(Received via mailing list)
On Sat, Feb 26, 2011 at 5:41 AM, J. K. 
<ruby-forum-incoming@andreas-s.net>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 :D




>  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
Posted by Vincent Carmona (vinc-mai)
on 2011-02-26 02:30
(Received via mailing list)
2011/2/26 hendra kusuma <penguinroad@gmail.com>:
>>
>> 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 Carmona
Posted by hendra kusuma (Guest)
on 2011-02-26 10:18
(Received via mailing list)
On Sat, Feb 26, 2011 at 9:30 AM, Vincent Carmona <vinc4mai@gmail.com> 
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
Posted by J. K. (j_k)
on 2011-02-26 15:56
hendra kusuma wrote in post #984086:
> On Sat, Feb 26, 2011 at 9:30 AM, Vincent Carmona <vinc4mai@gmail.com>
> 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.