Skip to content

Instantly share code, notes, and snippets.

@lucasg
Created August 27, 2014 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasg/a395c283be4472db9f66 to your computer and use it in GitHub Desktop.
Save lucasg/a395c283be4472db9f66 to your computer and use it in GitHub Desktop.
gtk popup whose entries are being masked when pressing TAB
#include <gtk/gtk.h>
#include <glib/gstdio.h>
/*
* Network Configuration window being popped-up
*/
typedef struct network_conf_t
{
GtkWidget *window ;
GtkWidget *vbox_frames ;
GtkWidget *recv_frame ;
GtkWidget *send_frame ;
GtkWidget *recv_frame_hbox ;
GtkWidget *recv_port_number_label;
GtkWidget *recv_port_number_entry;
GtkWidget *vbox ;
GtkWidget *hbox ;
GtkWidget *hbox2 ;
GtkWidget * ip_address_label ;
GtkWidget * port_number_label ;
GtkWidget *ip_address_entry ;
GtkWidget *port_number_entry ;
} network_conf;
unsigned int launch_netconf_popup()
{
network_conf netconf;
/*
Window configuration
*/
netconf.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_events ( netconf.window , GDK_FOCUS_CHANGE_MASK);
gtk_window_set_resizable (GTK_WINDOW(netconf.window), FALSE);
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(netconf.window), TRUE );
gtk_window_set_title (GTK_WINDOW(netconf.window), "Network Configuration" );
gtk_window_set_skip_pager_hint (GTK_WINDOW(netconf.window), TRUE );
g_signal_connect(G_OBJECT (netconf.window), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
gtk_window_set_position (GTK_WINDOW(netconf.window), GTK_WIN_POS_MOUSE);
netconf.vbox_frames = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
netconf.recv_frame = gtk_frame_new( "Receive Options");
netconf.send_frame = gtk_frame_new( "Send Options" );
gtk_container_add (GTK_CONTAINER (netconf.window), netconf.vbox_frames);
gtk_container_add (GTK_CONTAINER (netconf.vbox_frames), netconf.recv_frame);
gtk_container_add (GTK_CONTAINER (netconf.vbox_frames), netconf.send_frame);
/*
Reception Port
*/
netconf.recv_frame_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
netconf.recv_port_number_label = gtk_label_new ("Port :");
netconf.recv_port_number_entry = gtk_entry_new_with_buffer( gtk_entry_buffer_new("10", 8 ) );
//gtk_entry_set_alignment ( GTK_ENTRY(netconf.recv_port_number_entry), 0x1 );
gtk_container_add (GTK_CONTAINER (netconf.recv_frame), netconf.recv_frame_hbox);
gtk_box_pack_start (GTK_BOX (netconf.recv_frame_hbox) , netconf.recv_port_number_label, FALSE, FALSE, 5);
gtk_box_pack_end (GTK_BOX (netconf.recv_frame_hbox) , netconf.recv_port_number_entry, FALSE, FALSE, 5);
/*
Send Port and IP
*/
netconf.vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL , 2 );
netconf.hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20);
netconf.hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20);
netconf.ip_address_label = gtk_label_new("IP address :" );
netconf.port_number_label = gtk_label_new( "Port :" );
netconf.port_number_entry = gtk_entry_new_with_buffer( gtk_entry_buffer_new("0", 8 ) );
netconf.ip_address_entry = gtk_entry_new_with_buffer( gtk_entry_buffer_new("127.0.0.1", 16 ));
//gtk_entry_set_alignment( GTK_ENTRY(netconf.ip_address_entry) , 0x1 );
//gtk_entry_set_alignment( GTK_ENTRY(netconf.port_number_entry), 0x1 );
gtk_container_add (GTK_CONTAINER (netconf.send_frame), netconf.vbox );
gtk_container_add (GTK_CONTAINER (netconf.vbox) , netconf.hbox );
gtk_container_add (GTK_CONTAINER (netconf.vbox) , netconf.hbox2);
gtk_box_pack_start (GTK_BOX (netconf.hbox) , netconf.ip_address_label , FALSE, FALSE, 5);
gtk_box_pack_start (GTK_BOX (netconf.hbox2), netconf.port_number_label, FALSE, FALSE, 5);
gtk_box_pack_end (GTK_BOX (netconf.hbox) , netconf.ip_address_entry , FALSE, FALSE, 5);
gtk_box_pack_end (GTK_BOX (netconf.hbox2), netconf.port_number_entry, FALSE, FALSE, 5);
gtk_widget_show_all(netconf.window);
return 0x00;
}
int main(int argc, char **argv) {
gtk_init(0, NULL);
launch_netconf_popup();
gtk_main();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment