GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Dec 21, 2014 3:52 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Attaching system default stule in gtkrc
PostPosted: Mon Sep 08, 2008 9:40 am 
Offline

Joined: Mon Aug 04, 2008 2:19 pm
Posts: 3
Hello. I'm working at a project in which I use a gtkrc file to skin my widgets. Now, when I open a GtkFileChooserDialog, I want to have the system default skin, but instead I have my widgets skins in it. It is normal to do so unless I attach to my dialog a style. The problem is that I don't know how to attach the system default style... Any help please


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 08, 2008 2:18 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
you can probably do this a couple of ways, one way is to name your widgets with gtk_widget_set_name
http://library.gnome.org/devel/gtk/stab ... t-set-name
then use the widget syntax instead of widget_class in your rc file
http://library.gnome.org/devel/gtk-tuto ... c2118.html
here's an example:
Code:
#include <gtk/gtk.h>

void create_fc_dialog(GtkWidget *button, gchar *name)
{
   GtkWidget *dlg;

   dlg = gtk_file_chooser_dialog_new("Open", GTK_WINDOW(gtk_widget_get_toplevel(button)),
                                 GTK_FILE_CHOOSER_ACTION_OPEN,
                                 "_Open", GTK_RESPONSE_ACCEPT,
                                 "_Cancel", GTK_RESPONSE_CANCEL,
                                 NULL);
   gtk_widget_set_name(dlg, name);

   gtk_dialog_run(GTK_DIALOG(dlg));
   gtk_widget_destroy(dlg);
}

int main(int argc, char **argv)
{
   GtkWidget *win;
   GtkWidget *vbox;
   GtkWidget *button;

   gtk_init(&argc, &argv);
   gtk_rc_parse("examplerc.rc");

   win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   g_signal_connect(win, "delete-event", G_CALLBACK(gtk_main_quit), NULL);

   vbox = gtk_vbox_new(TRUE, 2);
   gtk_container_add(GTK_CONTAINER(win), vbox);
   gtk_widget_show(vbox);

   button = gtk_button_new_with_label("Green: Application themed dialog");
   g_signal_connect(button, "clicked", G_CALLBACK(create_fc_dialog), (gpointer)"Green");
   gtk_widget_set_name(button, "Green");
   gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
   gtk_widget_show(button);

   button = gtk_button_new_with_label("Red: System themed dialog");
   g_signal_connect(button, "clicked", G_CALLBACK(create_fc_dialog), (gpointer)NULL);
   gtk_widget_set_name(button, "Red");
   gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
   gtk_widget_show(button);

   gtk_widget_show(win);

   gtk_main();

   return 0;
}

and here's "examplerc.rc":
[code=]# Green style with white foreground (text)
style "Green"
{
bg[NORMAL] = { 0, 0.5, 0 }
fg[NORMAL] = { 1.0, 1.0, 1.0 }

bg[PRELIGHT] = { 0, 0.7, 0 }
fg[PRELIGHT] = { 1.0, 1.0, 1.0 }

bg[ACTIVE] = { 0, 0.3, 0 }
fg[ACTIVE] = { 1.0, 1.0, 1.0 }
}

# Red style with white foreground (text)
style "Red"
{
bg[NORMAL] = { 0.5, 0, 0 }
fg[NORMAL] = { 1.0, 1.0, 1.0 }

bg[PRELIGHT] = { 0.7, 0, 0 }
fg[PRELIGHT] = { 1.0, 1.0, 1.0 }

bg[ACTIVE] = { 0.3, 0, 0 }
fg[ACTIVE] = { 1.0, 1.0, 1.0 }
}

# Anything named "Green" will get the "Green" style
widget "*Green*" style "Green"
# Anything named "Red" will get the "Red" style
widget "*Red*" style "Red"[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group