GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

combo box help needed

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
vinodh
Familiar Face


Joined: 12 Feb 2008
Posts: 8

PostPosted: Wed Mar 19, 2008 5:41 am    Post subject: combo box help needed Reply with quote

i want to display the partitions in a combo box

check the below code

Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

#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;
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP