GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Nov 01, 2014 2:01 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: combo box help needed
PostPosted: Wed Mar 19, 2008 5:41 am 
Offline
Familiar Face

Joined: Tue Feb 12, 2008 8:47 am
Posts: 8
i want to display the partitions in a combo box

check the below code

Code:
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

int main (int argc, char *argv[])
{
  GtkWidget *window1;
  GtkWidget *combo1;
  GList *combo1_items = NULL;
  GtkWidget *combo_entry1;
   FILE *f;
   char *p[3];
   char q[10];
  gtk_init (&argc, &argv);
  int n=3;

f=fopen("/proc/partitions","r");

while(n!=0)
{
fgets(q,7,f);
p[n]=q;
g_print("%s",p[n]);
n--;
}
fclose(f);
  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window1), ("window1"));

  combo1 = gtk_combo_box_new_text ();
  gtk_widget_show (combo1);

n=3;
while(n!=0)
{
gtk_combo_box_append_text(GTK_COMBO_BOX(combo1), p[n]);
n--;
}

  gtk_container_add (GTK_CONTAINER (window1), combo1);
  gtk_widget_show_all (window1);

  gtk_main ();
  return 0;
}


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group