Re: How can I change the background color of a GtkButton when it is activated

2008-11-26 Thread Eero Tamminen
Hi,

ext Yao Wang wrote:
> Thanks for your advice.
> 
> However, my objective is to set two different colors for two different
> buttons. That is to say, for button A, when it is pressed, the color should
> be red; while for button B, in this case, the color should be green.
> 
> Thus I do not think the GTK+ theme can solve this problem.

Sure it can.  You can theme things in Gtk by class, widget_class,
widget or their hierarchy, see gtkrc documentation:
http://library.gnome.org/devel/gtk/unstable/gtk-Resource-Files.html

Just name your button objects differently (e.g. redbutton and
greenbutton) and set suitable theme for each object name.


- Eero

PS. For speed reasons, don't use patterns like "*name*",
if needed, single "*" should be enough for a match pattern.
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How can I change the background color of a GtkButton when it is activated

2008-11-25 Thread Andrew Olmsted
What about connecting two signals to your button widget: pressed and
released
In the function for "pressed" change the background colour to blue.

In the function for "released" change the background colour back to normal.

http://library.gnome.org/devel/gtk/stable/GtkButton.html#GtkButton.signals

I think this should do what you want, though I don't know if it is the
optimal way.

Andrew

2008/11/25 Yao Wang <[EMAIL PROTECTED]>

> Hi, Dave,
>
> Thanks for your advice.
>
> However, my objective is to set two different colors for two different
> buttons. That is to say, for button A, when it is pressed, the color should
> be red; while for button B, in this case, the color should be green.
>
> Thus I do not think the GTK+ theme can solve this problem.
> Is there any other possible solutions?
>
> Thanks in advance.
>
> On Tue, Nov 25, 2008 at 10:23 AM, Dave Neary <[EMAIL PROTECTED]> wrote:
>
>> Hi Yao,
>>
>> Yao Wang wrote:
>> > The default color when I pressed down the button is blue. I want
>> > to change the background color of button when it is pressed and recover
>> > its origin background color when it is released.
>>
>> The default colour for when the button is pressed is set by the GTK+
>> theme. I'd suggest changing the theme so that all buttons, when pressed,
>> will be red. It's in general not a good idea to hack applications with
>> hard-coded widget colours, and it's generally encouraged to write
>> applications which are consistent with the rest of the environment.
>>
>> Hope this helps!
>> Dave.
>>
>> --
>> maemo.org docsmaster
>> Email: [EMAIL PROTECTED]
>> Jabber: [EMAIL PROTECTED]
>>
>>
>
>
> --
>  Sincerely yours,
>
> Yao Wang
>
> Mobile Life Lab
> Beijing University of Posts & Telecommunications
>
> ___
> maemo-developers mailing list
> maemo-developers@maemo.org
> https://lists.maemo.org/mailman/listinfo/maemo-developers
>
>
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How can I change the background color of a GtkButton when it is activated

2008-11-25 Thread Yao Wang
Hi, Dave,

Thanks for your advice.

However, my objective is to set two different colors for two different
buttons. That is to say, for button A, when it is pressed, the color should
be red; while for button B, in this case, the color should be green.

Thus I do not think the GTK+ theme can solve this problem.
Is there any other possible solutions?

Thanks in advance.

On Tue, Nov 25, 2008 at 10:23 AM, Dave Neary <[EMAIL PROTECTED]> wrote:

> Hi Yao,
>
> Yao Wang wrote:
> > The default color when I pressed down the button is blue. I want
> > to change the background color of button when it is pressed and recover
> > its origin background color when it is released.
>
> The default colour for when the button is pressed is set by the GTK+
> theme. I'd suggest changing the theme so that all buttons, when pressed,
> will be red. It's in general not a good idea to hack applications with
> hard-coded widget colours, and it's generally encouraged to write
> applications which are consistent with the rest of the environment.
>
> Hope this helps!
> Dave.
>
> --
> maemo.org docsmaster
> Email: [EMAIL PROTECTED]
> Jabber: [EMAIL PROTECTED]
>
>


-- 
 Sincerely yours,

Yao Wang

Mobile Life Lab
Beijing University of Posts & Telecommunications
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How can I change the background color of a GtkButton when it is activated

2008-11-25 Thread Dave Neary
Hi Yao,

Yao Wang wrote:
> The default color when I pressed down the button is blue. I want
> to change the background color of button when it is pressed and recover
> its origin background color when it is released.

The default colour for when the button is pressed is set by the GTK+
theme. I'd suggest changing the theme so that all buttons, when pressed,
will be red. It's in general not a good idea to hack applications with
hard-coded widget colours, and it's generally encouraged to write
applications which are consistent with the rest of the environment.

Hope this helps!
Dave.

-- 
maemo.org docsmaster
Email: [EMAIL PROTECTED]
Jabber: [EMAIL PROTECTED]

___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


How can I change the background color of a GtkButton when it is activated

2008-11-25 Thread Yao Wang
Hello everyone.
I am developing a GUI application on maemo, in which GtkButton is
used.

The default color when I pressed down the button is blue. I want to
change the background color of button when it is pressed and recover its
origin background color when it is released.

I tried to implemented it using the following code:

  GdkColor color;
gdk_color_parse ("red", &color);
gtk_widget_modify_bg(GTK_WIDGET(button), GTK_STATE_ACTIVE, &color);

However, it dose not work at all.
Could anyone kindly give me some advices or suggestions ?
Thanks in advance.

-- 
 Sincerely yours,

Yao Wang

Mobile Life Lab
Beijing University of Posts & Telecommunications
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers