Пример #1
0
void getnamepwd_dialog(GtkWidget *widget,gpointer data)
{
	LOGIN_DATA *login_data=g_malloc0(sizeof(LOGIN_DATA));
	GtkWidget *hbox_name,*hbox_pwd;
	GtkWidget *button_ok,*button_cancel;
	GtkWidget *editor1,*editor2;
	GtkWidget *label_name,*label_pwd;
	GtkWidget *getnamepwd_dialog;
	
	getnamepwd_dialog=gtk_dialog_new();
	gtk_window_set_title(GTK_WINDOW(getnamepwd_dialog),"登陆");
	editor1 = gtk_entry_new();
        editor2 = gtk_entry_new();
        gtk_entry_set_visibility( (GtkEntry *)editor2, FALSE );
        login_data->e1=editor1;
        login_data->e2=editor2;
        login_data->e3=getnamepwd_dialog;
        button_ok = gtk_button_new_with_label("登陆");
        button_cancel = gtk_button_new_with_label("取消");
        label_name=gtk_label_new("用户昵称:");
        label_pwd=gtk_label_new("用户密码:");
   	
   	hbox_name=gtk_hbox_new(FALSE, 0);
   	hbox_pwd=gtk_hbox_new(FALSE, 0);
   	
   	gtk_box_pack_start (GTK_BOX(hbox_name),label_name,FALSE,FALSE,5);
   	gtk_box_pack_start (GTK_BOX(hbox_name),editor1,FALSE,FALSE,5);
   	gtk_box_pack_start (GTK_BOX(hbox_pwd),label_pwd,FALSE,FALSE,5);
   	gtk_box_pack_start (GTK_BOX(hbox_pwd),editor2,FALSE,FALSE,5);
   	
 	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (getnamepwd_dialog)->vbox),hbox_name, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (getnamepwd_dialog)->vbox),hbox_pwd, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (getnamepwd_dialog)->action_area),button_cancel, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (getnamepwd_dialog)->action_area),button_ok, TRUE, TRUE, 0);

	g_signal_connect(G_OBJECT(button_ok), "clicked",G_CALLBACK(getnamepwd),login_data);
	g_signal_connect(G_OBJECT(button_cancel), "clicked",G_CALLBACK(cancel),(gpointer)getnamepwd_dialog);


	gtk_widget_show_all(getnamepwd_dialog);
	gtk_dialog_run(GTK_DIALOG(getnamepwd_dialog));

}
Пример #2
0
static void
panda_combo_build_children (GladeXML *xml, GtkWidget *w,
			    GladeWidgetInfo *info, const char *longname)
{
	GList *tmp;
	GladeWidgetInfo *cinfo = NULL;
	GtkEntry *entry;

	for (tmp = info->children; tmp; tmp = tmp->next) {
		GList *tmp2;
		gchar *child_name = NULL;
		cinfo = tmp->data;
		for (tmp2 = cinfo->attributes; tmp2; tmp2 = tmp2->next) {
			GladeAttribute *attr = tmp2->data;
			if (!strcmp(attr->name, "child_name")) {
				child_name = attr->value;
				break;
			}
		}
		if (child_name && !strcmp(child_name, "GtkPandaCombo:entry"))
			break;
	}
	if (!tmp)
		return;
#if 1
	entry = GTK_ENTRY(GTK_PANDA_COMBO(w)->entry);
	for (tmp = cinfo->attributes; tmp; tmp = tmp->next) {
		GladeAttribute *attr = tmp->data;
		if (!strcmp(attr->name, "editable")) {
			gtk_entry_set_editable(entry, attr->value[0] == 'T');
		} else if (!strcmp(attr->name, "text_visible")) {
			gtk_entry_set_visibility(entry, attr->value[0] == 'T');
		} else if (!strcmp(attr->name, "text_max_length")) {
			gtk_entry_set_max_length(entry, strtol(attr->value,NULL, 0));
		} else if (!strcmp(attr->name, "max_length")) {
			gtk_entry_set_max_length(entry, strtol(attr->value,NULL, 0));
		} else if (!strcmp(attr->name, "text")) {
			gtk_entry_set_text(entry, attr->value);
		}
	}
#endif
	glade_xml_set_common_params(xml, GTK_PANDA_COMBO(w)->entry, cinfo, longname);
}
Пример #3
0
static int Gtk3Gui_WLineEdit_Setup(GWEN_WIDGET *w) {
  GtkWidget *g;
  const char *s;
  uint32_t flags;
  GWEN_WIDGET *wParent;
  gulong deleted_text_handler_id;
  gulong inserted_text_handler_id;
  gboolean text_is_visible;

  flags=GWEN_Widget_GetFlags(w);
  text_is_visible = (flags & GWEN_WIDGET_FLAGS_PASSWORD) == 0;
  wParent=GWEN_Widget_Tree_GetParent(w);
  s=GWEN_Widget_GetText(w, 0);

  /* create widget */
  g=gtk_entry_new();
  if (s && *s)
    gtk_entry_set_text(GTK_ENTRY(g), s);
  gtk_entry_set_visibility(GTK_ENTRY(g), text_is_visible);

  GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
  GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);

  GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WLineEdit_SetIntProperty);
  GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WLineEdit_GetIntProperty);
  GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WLineEdit_SetCharProperty);
  GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WLineEdit_GetCharProperty);

  deleted_text_handler_id=g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
                          "deleted-text",
                          G_CALLBACK (Gtk3Gui_WLineEdit_Deleted_text_handler),
                          w);

  inserted_text_handler_id=g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
                           "inserted-text",
                           G_CALLBACK (Gtk3Gui_WLineEdit_Inserted_text_handler),
                           w);

  if (wParent)
    GWEN_Widget_AddChildGuiWidget(wParent, w);

  return 0;
}
Пример #4
0
void create_entry_field(gchar *text, gboolean hidden)
{
   GtkWidget *entry, *label, *box;
   char tmp_text[BUFSIZ];
   gboolean no_margen=FALSE;
   
   entry = gtk_entry_new();
   if (!entry) quit (RETURN_ERROR_NOMEM);
   if (hidden) gtk_entry_set_visibility ((GtkEntry*)entry, FALSE);
   gtk_signal_connect ((GtkObject*)entry, key_press_event,
		       GTK_SIGNAL_FUNC (keypress_cb), NULL);
   
   if(text) {
      if(*text=='^') {
         no_margen=TRUE;
	 strcpy(tmp_text,text+1);
	 strcpy(text,tmp_text);
      }
      box = gtk_hbox_new(FALSE, 1);
      if (!box)	quit (RETURN_ERROR_NOMEM);
#if GTK_MAJOR_VERSION < 2
      label = gtk_label_new(text);
      if (!label) quit (RETURN_ERROR_NOMEM);
#else
      label = gtk_label_new_with_mnemonic(text);
      if (!label) quit (RETURN_ERROR_NOMEM);
      gtk_label_set_mnemonic_widget((GtkLabel *)label, entry);
#endif
      if(no_margen) {
        gtk_box_pack_start((GtkBox *)box, label, FALSE, FALSE, 0);
        gtk_box_pack_end((GtkBox *)box, entry, TRUE, TRUE, 0);
      }
      else {
        gtk_box_pack_start((GtkBox *)box, label, FALSE, TRUE, 0);
        gtk_box_pack_end((GtkBox *)box, entry, FALSE, TRUE, 0);
      }
      add_to_vbox(box);
   } else {
      add_to_vbox(entry);
   }
   widgets = g_slist_append(widgets, entry);
};
Пример #5
0
static void test_hash_func_digest(const enum hash_func_e id, const char *text,
	const char *hmac, const char *digest)
{
	gtk_entry_set_text(gui.entry_check_text, digest);
	gtk_entry_set_text(gui.entry_text, text);

	if (hmac) {
		gtk_toggle_button_set_active(gui.togglebutton_hmac_text, true);
		gtk_entry_set_visibility(gui.entry_hmac_text, true);
		gtk_entry_set_text(gui.entry_hmac_text, hmac);
	} else {
		gtk_toggle_button_set_active(gui.togglebutton_hmac_text, false);
		gtk_entry_set_text(gui.entry_hmac_text, "");
	}

	delay();

	const char *output = gtk_entry_get_text(gui.hash_widgets[id].entry_text);
	g_assert_cmpstr(output, ==, digest);
}
Пример #6
0
gchar *input_dialog_with_invisible(const gchar *title, const gchar *message,
				   const gchar *default_string)
{
	if (dialog && gtk_widget_get_visible(dialog)) return NULL;

	if (!dialog)
		input_dialog_create(TRUE);

	type = INPUT_DIALOG_INVISIBLE;
	gtk_widget_hide(combo);
	gtk_widget_show(entry);
	gtk_widget_hide(remember_checkbtn);

	gtk_widget_hide(icon_q);
	gtk_widget_show(icon_p);
	is_pass = TRUE;
	gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);

	return input_dialog_open(title, message, NULL, default_string, FALSE, NULL);
}
Пример #7
0
/**
   lw_create:
   create login window.
   Return value: The widget pointer of login window.
 */
GtkWidget*
lw_create(void)
{
	GtkBuilder *builder;
	GError* error = NULL;

	builder = gtk_builder_new ();
	if (!gtk_builder_add_from_file (builder, UI_FILE, &error))
	{
		g_error (_("Couldn't load builder file: %s"), error->message);
		g_error_free (error);
		_exit(1);
	}

	/* This is important */
	gtk_builder_connect_signals (builder, NULL);
	/* get gtk widget from builder */
	window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
	ety_pwd = GTK_WIDGET (gtk_builder_get_object (builder, "ety_pwd"));
	cbb_usr = GTK_WIDGET (gtk_builder_get_object (builder, "cbb_usr"));
	chb_svpwd=GTK_WIDGET (gtk_builder_get_object (builder, "chb_svpwd"));
	chb_apoffline=GTK_WIDGET (gtk_builder_get_object (builder,"chb_apoffline"));

	/* set up window */
	gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);

	/* set up password entry  */
	gtk_entry_set_visibility (GTK_ENTRY(ety_pwd), FALSE);

	/* set up user combo box */
	GtkListStore *usr_lst = gtk_list_store_new (1, G_TYPE_STRING);
	gtk_combo_box_set_model (GTK_COMBO_BOX (cbb_usr), GTK_TREE_MODEL (usr_lst));
	gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(cbb_usr), 0); 
	cfg_get_lists_usrlist (&get_usrlist_cb);
	
	g_object_unref (builder);

	//dbg_print("DBG: Login Window is created.");
	return window;
}
Пример #8
0
void
bisho_pane_username_add_entry (BishoPaneUsername *pane, const char *label, const char *key, gboolean visible)
{
  BishoPaneUsernamePrivate *priv;
  GtkWidget *label_w, *entry;
  char *gconf_key, *value;
  ServiceInfo *info;

  g_return_if_fail (BISHO_IS_PANE_USERNAME (pane));
  g_return_if_fail (label);
  g_return_if_fail (key);

  priv = pane->priv;
  g_object_get (pane, "service", &info, NULL);
  g_assert (info);

  label_w = gtk_label_new (label);
  gtk_widget_show (label_w);
  gtk_table_attach (GTK_TABLE (priv->table), label_w,
                    0, 1, priv->rows, priv->rows + 1, GTK_FILL, GTK_FILL, 0, 0);

  entry = gtk_entry_new ();
  gtk_entry_set_visibility (GTK_ENTRY (entry), visible);
  gtk_entry_set_width_chars (GTK_ENTRY (entry), 30);
  g_signal_connect (entry, "focus-out-event", G_CALLBACK (on_entry_left), pane);
  gtk_widget_show (entry);
  gtk_table_attach (GTK_TABLE (priv->table), entry,
                    1, 2, priv->rows, priv->rows + 1, GTK_FILL, GTK_FILL, 0, 0);

  gconf_key = g_strdup_printf ("/apps/libsocialweb/services/%s/%s", info->name, key);
  g_object_set_data_full (G_OBJECT (entry), DATA_GCONF_KEY, gconf_key, g_free);

  value = gconf_client_get_string (priv->gconf, gconf_key, NULL);
  if (value) {
    gtk_entry_set_text (GTK_ENTRY (entry), value);
    g_free (value);
  }

  priv->rows++;
}
Пример #9
0
void execute_replies()
{
	GtkWidget *table, *label1;
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (window), MSG_7);
    	gtk_signal_connect (GTK_OBJECT (window), "delete_event",
        GTK_SIGNAL_FUNC (delete_event), NULL);
	table = gtk_table_new(3,2,FALSE);
	gtk_container_add(GTK_CONTAINER(window),table);
	label1 = gtk_label_new(MSG_24);
	gtk_table_attach_defaults(GTK_TABLE(table),label1,0,1,0,1);
	quit_message_entry = gtk_entry_new();
	gtk_table_attach_defaults(GTK_TABLE(table),quit_message_entry,0,1,1,2);
	gtk_entry_set_visibility(GTK_ENTRY(quit_message_entry),TRUE);
	GtkWidget *button1 = gtk_button_new_with_label (MSG_23);
	gtk_signal_connect (GTK_OBJECT (button1), "clicked", GTK_SIGNAL_FUNC (replies), (gpointer) NULL);
	gtk_box_pack_start(GTK_BOX(table), button1, TRUE, TRUE, 0);
	gtk_table_attach_defaults(GTK_TABLE(table),button1,1,2,1,2);
	gtk_container_add(GTK_CONTAINER(window),table);
        gtk_widget_show_all(window);
        gtk_main();
}
Пример #10
0
int main( int argc, char **argv ) {
  gtk_init( &argc, &argv );
  GtkWidget *window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
  gtk_window_set_title( GTK_WINDOW( window ), "Ex0601" );
  gtk_container_set_border_width( GTK_CONTAINER( window ), 20 );
  gtk_widget_set_size_request( window, 480, 320 );

  GtkWidget *entry = gtk_entry_new();
  gtk_entry_set_visibility( GTK_ENTRY( entry ), TRUE );
  GtkWidget *button = gtk_button_new_with_mnemonic( "_Write to File" );
  gtk_widget_set_sensitive( button, FALSE );
  gtk_widget_set_sensitive( entry, FALSE );

  Data data;
  data.text = '\0';
  data.filename = '\0';
  data.entry = entry;
  data.button = button;

  GtkWidget *chooser = gtk_file_chooser_button_new( "Chooser a folder", 
						    GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER );
  /* gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( chooser ), g_get_home_dir() ); */

  g_signal_connect( G_OBJECT( chooser ), "selection_changed", G_CALLBACK( file_selected ), 
		    (gpointer) &data );
  g_signal_connect( G_OBJECT( entry ), "changed", G_CALLBACK( text_entered ), (gpointer) &data );
  g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( button_clicked ), (gpointer) &data );
  g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), (gpointer) &data );
  /* arragne all widgets together in a container */
  GtkWidget *vbox = gtk_vbox_new( FALSE, 5 );
  gtk_box_pack_start( GTK_BOX( vbox ), chooser, FALSE, FALSE, 10 );
  gtk_box_pack_start( GTK_BOX( vbox ), entry, FALSE, FALSE, 10 );
  gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 10 );

  gtk_container_add( GTK_CONTAINER( window ), vbox );
  gtk_widget_show_all( window );
  gtk_main();
  return 0;
}
Пример #11
0
char *get_input_string(const char *msg)
{
	GtkWidget *entry;
	GtkWidget *dialog;

	dialog=gtk_dialog_new();
	gtk_window_set_title(GTK_WINDOW(dialog),msg);
	entry=gtk_entry_new();
	/*如果传过来的字符为Password则设置密码输入不可见*/
	if(strcmp(msg,"Password")==0)
		gtk_entry_set_visibility(GTK_ENTRY(entry),FALSE);

	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),entry,FALSE,FALSE,10);
	gtk_widget_show(entry);
	gtk_dialog_add_button(GTK_DIALOG(dialog),GTK_STOCK_OK,GTK_RESPONSE_OK);

	gtk_dialog_run(GTK_DIALOG(dialog));

	gtk_widget_hide(dialog);

	return gtk_entry_get_text(GTK_ENTRY(entry));
}
Пример #12
0
static char * get_password (rfbClient *client)
{
	GtkWidget *dialog, *entry;
	char *password;

	gtk_widget_destroy (dialog_connecting);
	dialog_connecting = NULL;

	dialog = gtk_dialog_new_with_buttons ("Password",
	                                       NULL,
	                                       GTK_DIALOG_DESTROY_WITH_PARENT,
	                                       GTK_STOCK_CANCEL,
	                                       GTK_RESPONSE_REJECT,
	                                       GTK_STOCK_OK,
	                                       GTK_RESPONSE_ACCEPT,
	                                       NULL);
	entry = gtk_entry_new ();
	gtk_entry_set_visibility (GTK_ENTRY (entry),
	                          FALSE);
	g_signal_connect (GTK_OBJECT(entry), "key-press-event",
	                    G_CALLBACK(on_entry_key_press_event),
	                    GTK_OBJECT (dialog));
	gtk_widget_show (entry);

	gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
	                   entry);
	gtk_widget_show (dialog);

	switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
	case GTK_RESPONSE_ACCEPT:
		password = strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
		break;
	default:
		password = NULL;
		break;
	}
	gtk_widget_destroy (dialog);
	return password;
}
Пример #13
0
void login_popup(){
    GtkWidget *window_login;
    GtkWidget *table_login;
    GtkWidget *button_login;
    GtkWidget *label_name;
    GtkWidget *label_pass;
    GtkWidget *label_result;
    window_login = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(window_login), GTK_WIN_POS_CENTER);
    gtk_window_set_title(GTK_WINDOW(window_login), "Log In");
    gtk_window_set_modal(GTK_WINDOW(window_login),TRUE);
    gtk_container_set_border_width(GTK_CONTAINER(window_login),10);
    table_login = gtk_table_new(4,2, FALSE);
    label_result = gtk_label_new(NULL);
    gtk_table_attach(GTK_TABLE(table_login), label_result, 0,2,0,1, 
      GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);

    label_name = gtk_label_new("Tai khoan : ");
    gtk_table_attach(GTK_TABLE(table_login), label_name, 0,1,1,2, 
      GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);
    entry1 = gtk_entry_new();
    gtk_table_attach(GTK_TABLE(table_login), entry1, 1,2,1,2,
      GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);
    label_pass = gtk_label_new("Mat Khau :");
    gtk_table_attach(GTK_TABLE(table_login), label_pass, 0,1,2,3, 
      GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);
    entry2 = gtk_entry_new();
    gtk_entry_set_visibility((GtkEntry *)entry2,FALSE);

    gtk_table_attach(GTK_TABLE(table_login),entry2, 1,2,2,3, 
      GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);
    button_login = gtk_button_new_with_label("LOG IN");
    gtk_table_attach(GTK_TABLE(table_login),button_login,1,2,3,4, 
    GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);
    g_signal_connect(GTK_BUTTON(button_login),"clicked",G_CALLBACK(login_funtion),label_result);
    gtk_container_add(GTK_CONTAINER(window_login),table_login);
    gtk_widget_show_all(window_login);
}
Пример #14
0
static void create_window()
{
  GtkWidget *window;
  GtkWidget *label;
  GtkWidget *entry;
  GtkWidget *button;

  window = gtk_dialog_new_with_buttons("Renewing authentication", 
				       NULL, 0,
				       GTK_STOCK_OK, 
				       GTK_RESPONSE_OK,
				       GTK_STOCK_CANCEL,
				       GTK_RESPONSE_CANCEL,
				       NULL);

  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

  label = gtk_label_new("Type your password now to renew your authentication "
			"to the system, which expires every 10 hours.");
  gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
  gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), label, TRUE, TRUE, 0);
  gtk_widget_show(label);

  entry = gtk_entry_new();
  gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), entry, TRUE, TRUE, 0);
  gtk_widget_grab_focus(entry);
  gtk_widget_show(entry);

  g_signal_connect_object(G_OBJECT(entry), "activate",
			  G_CALLBACK(do_renew), entry, 0);
  g_signal_connect_object(G_OBJECT(window), "response", 
			  G_CALLBACK(dialog_response_cb), entry, 0);
  g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(quit), NULL);

  gtk_widget_show(window);
}
Пример #15
0
static void process_single_field(
        GtkWidget * container,
        int row_index,
        const char * label,
        const char * value,
        int is_password) {

    GtkWidget * label_widget = gtk_label_new(label);
    gtk_widget_set_halign(GTK_WIDGET(label_widget), GTK_ALIGN_END);
    gtk_widget_set_margin_end(GTK_WIDGET(label_widget), 5);
    GtkWidget * value_widget = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(value_widget), value);
    gtk_widget_set_hexpand(GTK_WIDGET(value_widget), TRUE);

    g_object_set(G_OBJECT(value_widget),
        "editable", FALSE,
        NULL
    );

    GtkWidget * copy_button = NULL, *reveal_button = NULL;

    if(is_password) {
        gtk_entry_set_visibility(GTK_ENTRY(value_widget), FALSE);
        copy_button = gtk_button_new_with_mnemonic("_Copy");
        g_signal_connect(G_OBJECT(copy_button), "clicked",
            G_CALLBACK(handle_copy_button), value_widget);
        reveal_button = gtk_button_new_with_mnemonic("_Reveal");
        g_signal_connect(G_OBJECT(reveal_button), "clicked",
            G_CALLBACK(handle_reveal_button), value_widget);
    }

    gtk_grid_attach(GTK_GRID(container), label_widget, 0, row_index, 1, 1);
    gtk_grid_attach(GTK_GRID(container), value_widget, 1, row_index, copy_button == NULL ? 3 : 1, 1);
    if(copy_button) {
        gtk_grid_attach(GTK_GRID(container), copy_button, 2, row_index, 1, 1);
        gtk_grid_attach(GTK_GRID(container), reveal_button, 3, row_index, 1, 1);
    }
}
Пример #16
0
void osm_login_widgets (GtkWidget *user_entry, GtkWidget *password_entry)
{
  if (!user_entry || !password_entry)
    return;

  const gchar *default_user = get_default_user();
  const gchar *pref_user = a_preferences_get(VIKING_OSM_TRACES_PARAMS_NAMESPACE "username")->s;
  const gchar *pref_password = a_preferences_get(VIKING_OSM_TRACES_PARAMS_NAMESPACE "password")->s;

  if (osm_user != NULL && osm_user[0] != '\0')
    gtk_entry_set_text(GTK_ENTRY(user_entry), osm_user);
  else if (pref_user != NULL && pref_user[0] != '\0')
    gtk_entry_set_text(GTK_ENTRY(user_entry), pref_user);
  else if (default_user != NULL)
    gtk_entry_set_text(GTK_ENTRY(user_entry), default_user);

  if (osm_password != NULL && osm_password[0] != '\0')
    gtk_entry_set_text(GTK_ENTRY(password_entry), osm_password);
  else if (pref_password != NULL)
    gtk_entry_set_text(GTK_ENTRY(password_entry), pref_password);
  /* This is a password -> invisible */
  gtk_entry_set_visibility(GTK_ENTRY(password_entry), FALSE);
}
Пример #17
0
void osm_login_widgets (GtkWidget *user_entry, GtkWidget *password_entry)
{
  if (!user_entry || !password_entry)
    return;

  const gchar *default_user = get_default_user();
  VikLayerParamData *pref_user = a_preferences_get ( OSM_USERNAME );
  VikLayerParamData *pref_password = a_preferences_get ( OSM_PASSWORD );
 
  if (osm_user != NULL && osm_user[0] != '\0')
    gtk_entry_set_text(GTK_ENTRY(user_entry), osm_user);
  else if (pref_user && pref_user->s && pref_user->s[0] != '\0')
    gtk_entry_set_text(GTK_ENTRY(user_entry), pref_user->s);
  else if (default_user != NULL)
    gtk_entry_set_text(GTK_ENTRY(user_entry), default_user);

  if (osm_password != NULL && osm_password[0] != '\0')
    gtk_entry_set_text(GTK_ENTRY(password_entry), osm_password);
  else if (pref_password && pref_password->s)
    gtk_entry_set_text(GTK_ENTRY(password_entry), pref_password->s);
  /* This is a password -> invisible */
  gtk_entry_set_visibility(GTK_ENTRY(password_entry), FALSE);
}
Пример #18
0
void
html_text_input_init (HTMLTextInput *ti,
                      HTMLTextInputClass *klass,
                      GtkWidget *parent,
                      gchar *name,
                      gchar *value,
                      gint size,
                      gint maxlen,
                      gboolean password)
{
	HTMLEmbedded *element;
	GtkWidget *entry;

	element = HTML_EMBEDDED (ti);

	html_embedded_init (element, HTML_EMBEDDED_CLASS (klass),
			   parent, name, value);

	entry = gtk_entry_new ();
	html_embedded_set_widget (element, entry);
	g_signal_connect_after (entry, "key_press_event", G_CALLBACK (html_text_input_key_pressed), element);

	if (strlen (element->value))
		gtk_entry_set_text (GTK_ENTRY (element->widget), element->value);

	ti->default_text = g_strdup (element->value);

	if (maxlen != -1)
		gtk_entry_set_max_length (GTK_ENTRY (element->widget), maxlen);

	gtk_entry_set_visibility (GTK_ENTRY (element->widget), !password);

	gtk_entry_set_width_chars (GTK_ENTRY (element->widget), size);

	ti->size = size;
	ti->maxlen = maxlen;
}
Пример #19
0
static void remmina_file_editor_create_password(RemminaFileEditor* gfe, GtkWidget* table, gint row)
{
	GtkWidget* widget;
	gchar* s;

	widget = gtk_label_new(_("Password"));
	gtk_widget_show(widget);
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
	gtk_table_attach(GTK_TABLE(table), widget, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);

	widget = gtk_entry_new();
	gtk_widget_show(widget);
	gtk_table_attach_defaults(GTK_TABLE(table), widget, 1, 2, row, row + 1);
	gtk_entry_set_max_length(GTK_ENTRY(widget), 100);
	gtk_entry_set_visibility(GTK_ENTRY(widget), FALSE);
	gfe->priv->password_entry = widget;

	s = remmina_file_get_secret(gfe->priv->remmina_file, "password");
	if (s)
	{
		gtk_entry_set_text(GTK_ENTRY(widget), s);
		g_free(s);
	}
}
Пример #20
0
static void	ug_proxy_form_std_init (UgProxyForm* pform)
{
	GtkGrid*	grid;
	GtkWidget*	widget;
	GtkWidget*	hbox;

	pform->changed.host = FALSE;
	pform->changed.port = FALSE;
	pform->changed.user = FALSE;
	pform->changed.password = FALSE;

	pform->std = gtk_grid_new ();
	grid       = (GtkGrid*) pform->std;
	// host label & entry
	widget = gtk_label_new_with_mnemonic (_("Host:"));
	pform->host = gtk_entry_new ();
	gtk_entry_set_width_chars (GTK_ENTRY (pform->host), 8);
	gtk_entry_set_activates_default (GTK_ENTRY (pform->host), TRUE);
	gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pform->host);
	g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL);
	g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL);
	g_object_set (pform->host, "margin", 1, "hexpand", TRUE, NULL);
	gtk_grid_attach (grid, widget, 0, 0, 1, 1);
	gtk_grid_attach (grid, pform->host, 1, 0, 1, 1);
	// port label & entry
	widget = gtk_label_new_with_mnemonic (_("Port:"));
	pform->port  = gtk_spin_button_new_with_range (0.0, 65535.0, 1.0);
	gtk_entry_set_width_chars (GTK_ENTRY (pform->port), 5);
	gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pform->port);
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start (GTK_BOX (hbox), pform->port, FALSE, FALSE, 0);
	g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL);
	g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL);
	g_object_set (hbox, "margin", 1, NULL);
	gtk_grid_attach (grid, widget, 0, 1, 1, 1);
	gtk_grid_attach (grid, hbox, 1, 1, 1, 1);
	// center separator
	widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
	g_object_set (widget, "margin", 1, NULL);
	gtk_grid_attach (grid, widget, 2, 0, 1, 2);
	// user label & entry
	widget = gtk_label_new_with_mnemonic (_("User:"******"margin-left", 3, "margin-right", 3, NULL);
	g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL);
	g_object_set (pform->user, "margin", 1, "hexpand", TRUE, NULL);
	gtk_grid_attach (grid, widget, 3, 0, 1, 1);
	gtk_grid_attach (grid, pform->user, 4, 0, 1, 1);
	// password label & entry
	widget = gtk_label_new_with_mnemonic (_("Password:"******"margin-left", 3, "margin-right", 3, NULL);
	g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL);
	g_object_set (pform->password, "margin", 1, "hexpand", TRUE, NULL);
	gtk_grid_attach (grid, widget, 3, 1, 1, 1);
	gtk_grid_attach (grid, pform->password, 4, 1, 1, 1);

	g_signal_connect (GTK_EDITABLE (pform->user), "changed",
			G_CALLBACK (on_entry_std_changed), pform);
	g_signal_connect (GTK_EDITABLE (pform->password), "changed",
			G_CALLBACK (on_entry_std_changed), pform);
	g_signal_connect (GTK_EDITABLE (pform->host), "changed",
			G_CALLBACK (on_entry_std_changed), pform);
	g_signal_connect (GTK_EDITABLE (pform->port), "changed",
			G_CALLBACK (on_entry_std_changed), pform);

	gtk_widget_show_all (pform->std);
}
Пример #21
0
static void
tweet_auth_dialog_constructed (GObject *gobject)
{
  TweetAuthDialog *dialog = TWEET_AUTH_DIALOG (gobject);
  TweetAuthDialogPrivate *priv = dialog->priv;
  GtkWidget *main_hbox;
  GtkWidget *hbox, *vbox;
  GtkWidget *label;
  GtkWidget *image;

  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
  gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
  g_signal_connect (dialog, "response", G_CALLBACK (on_response), NULL);

  main_hbox = gtk_hbox_new (FALSE, 6);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
                      main_hbox,
                      FALSE, FALSE, 0);
  gtk_widget_show (main_hbox);

  image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION,
                                    GTK_ICON_SIZE_DIALOG);
  gtk_box_pack_start (GTK_BOX (main_hbox), image, TRUE, TRUE, 0);
  gtk_widget_show (image);

  vbox = gtk_vbox_new (FALSE, 12);
  gtk_box_pack_end (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0);
  gtk_widget_show (vbox);

  priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

  label = gtk_label_new (_("Please insert the email address and password\n"
                           "used when registering the account on Twitter."));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  /* email entry */
  hbox = gtk_hbox_new (FALSE, 6);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  label = gtk_label_new (_("Email address:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_size_group_add_widget (priv->size_group, label);
  gtk_widget_show (label);

  priv->email_entry = gtk_entry_new ();
  g_signal_connect (priv->email_entry,
                    "changed", G_CALLBACK (on_email_changed),
                    dialog);
  gtk_box_pack_end (GTK_BOX (hbox), priv->email_entry, TRUE, TRUE, 0);
  gtk_widget_show (priv->email_entry);

  /* password entry */
  hbox = gtk_hbox_new (FALSE, 6);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  label = gtk_label_new (_("Password:"******"changed", G_CALLBACK (on_password_changed),
                    dialog);
  gtk_box_pack_end (GTK_BOX (hbox), priv->password_entry, TRUE, TRUE, 0);
  gtk_widget_show (priv->password_entry);

  priv->verify_label = gtk_label_new ("");
  gtk_box_pack_end (GTK_BOX (vbox), priv->verify_label, FALSE, FALSE, 0);
  gtk_widget_show (priv->verify_label);

  /* buttons */
  priv->ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
                                           GTK_STOCK_OK,
                                           GTK_RESPONSE_OK);
  gtk_widget_set_sensitive (priv->ok_button, FALSE);
  priv->verify_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
                                               _("Verify credentials"),
                                               1);
  gtk_widget_set_sensitive (priv->verify_button, FALSE);
  gtk_dialog_add_button (GTK_DIALOG (dialog),
                         GTK_STOCK_CANCEL,
                         GTK_RESPONSE_CANCEL);
}
Пример #22
0
/****************************************************************************************************
* construct the widget
****************************************************************************************************/
config_widget_construct(ConfigWidget * config_widget, Config * config)
{
	GtkWidget *box_v = GTK_WIDGET(config_widget); 

	int count = config -> num_entries; 

	GtkWidget * labels[count];
	config_widget -> entries = malloc(sizeof(GtkWidget*) * count);
	GtkWidget ** entries = config_widget -> entries;

	int i; char buf[100];
	for (i = 0; i < count; i++){
		ConfEntry ce = config -> entries[i];
		labels[i] = gtk_label_new(ce.name);
		switch (ce.type){
		case TYPE_STRING:
		case TYPE_DIR:
		case TYPE_IP:{
			sprintf(buf, "%s", (char*)ce.data);
			entries[i] = gtk_entry_new();
			gtk_entry_set_text(GTK_ENTRY(entries[i]), buf) ;
			break;
		}
		case TYPE_PASSWORD:{
			sprintf(buf, "%s", (char*)ce.data);
			entries[i] = gtk_entry_new();
			gtk_entry_set_visibility(GTK_ENTRY(entries[i]), FALSE);
			gtk_entry_set_text(GTK_ENTRY(entries[i]), buf) ;
			break;
		}
		case TYPE_COLOR:{
			sprintdouble(buf, ((ColorQuadriple*)ce.data) -> r, 2);
			sprintf(buf+strlen(buf), "%s", ",");
			sprintdouble(buf+strlen(buf), ((ColorQuadriple*)ce.data) -> g, 2);
			sprintf(buf+strlen(buf), "%s", ",");
			sprintdouble(buf+strlen(buf), ((ColorQuadriple*)ce.data) -> b, 2);
			sprintf(buf+strlen(buf), "%s", ",");
			sprintdouble(buf+strlen(buf), ((ColorQuadriple*)ce.data) -> a, 2);
			entries[i] = color_box_new();
			color_box_set_current_value(GOSM_COLOR_BOX(entries[i]), buf);
			break;
		}
		case TYPE_INT:{
			sprintf(buf, "%d", *(int*)ce.data);
			entries[i] = gtk_entry_new();
			gtk_entry_set_text(GTK_ENTRY(entries[i]), buf);
			break;
		}
		case TYPE_DOUBLE:{
			sprintdouble(buf, *(double*)ce.data, 4);
			entries[i] = gtk_entry_new();
			gtk_entry_set_text(GTK_ENTRY(entries[i]), buf);
			break;
		}
		case TYPE_BOOLEAN:{ 
			entries[i] = gtk_check_button_new();
			gboolean active = *(gboolean*)ce.data;
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entries[i]), active);
			break;
		}
		default:{
			entries[i] = gtk_entry_new();
			gtk_entry_set_text(GTK_ENTRY(entries[i]), ce.data_str);
		}
		}
	}

	GtkWidget * table = gtk_table_new(2, 9, FALSE);
	for (i = 0; i < count; i++){
		GtkWidget * box = gtk_hbox_new(FALSE, 0);
		gtk_box_pack_start(GTK_BOX(box), labels[i], FALSE, FALSE, 0);
		gtk_table_attach(GTK_TABLE(table), box,  0, 1, i, i+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
		gtk_table_attach(GTK_TABLE(table), entries[i], 1, 2, i, i+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
	}

	GtkWidget * scrolled = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), table);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), 
					GTK_POLICY_AUTOMATIC, 
					GTK_POLICY_AUTOMATIC);

	GtkWidget * box_buttons = gtk_hbox_new(FALSE, 0);
	config_widget -> button_confirm = gtk_button_new_from_stock("gtk-apply");
	config_widget -> button_cancel  = gtk_button_new_from_stock("gtk-cancel");
	gtk_box_pack_start(GTK_BOX(box_buttons), config_widget -> button_confirm, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(box_buttons), config_widget -> button_cancel , FALSE, FALSE, 0);

	gtk_box_pack_start(GTK_BOX(box_v), scrolled, TRUE, TRUE, 0);
	gtk_box_pack_end  (GTK_BOX(box_v), box_buttons, FALSE, FALSE, 0);
}
/* Public VpnPasswordDialog methods */
GtkWidget *
vpn_password_dialog_new (const char *title,
                         const char *message,
                         const char *password)
{
	GtkWidget *dialog;
	VpnPasswordDialogPrivate *priv;
	GtkLabel *message_label;
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *main_vbox;
	GtkWidget *dialog_icon;
	GtkBox *content, *action_area;

	dialog = gtk_widget_new (VPN_TYPE_PASSWORD_DIALOG, NULL);
	if (!dialog)
		return NULL;
	priv = VPN_PASSWORD_DIALOG_GET_PRIVATE (dialog);

	gtk_window_set_title (GTK_WINDOW (dialog), title);
	gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

    #if !GTK_CHECK_VERSION(3,10,0)
	gtk_dialog_add_buttons (GTK_DIALOG (dialog),
	                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
	                        GTK_STOCK_OK, GTK_RESPONSE_OK,
	                        NULL);
    #else
    gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                            _Cancel, GTK_RESPONSE_CANCEL,
                            _OK, GTK_RESPONSE_OK,
                            NULL);
    #endif
    
	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

	content = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
	action_area = GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog)));

       /* Set up the dialog */
	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
	gtk_box_set_spacing (content, 2); /* 2 * 5 + 2 = 12 */
	gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
	gtk_box_set_spacing (action_area, 6);

 	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

	g_signal_connect (dialog, "show",
	                  G_CALLBACK (dialog_show_callback),
	                  dialog);
	g_signal_connect (dialog, "close",
	                  G_CALLBACK (dialog_close_callback),
	                  dialog);

       /* The grid that holds the captions */
       priv->grid_alignment = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);

	priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

       priv->grid = gtk_grid_new ();
       gtk_grid_set_column_spacing (GTK_GRID (priv->grid), 12);
       gtk_grid_set_row_spacing (GTK_GRID (priv->grid), 6);
       gtk_container_add (GTK_CONTAINER (priv->grid_alignment), priv->grid);

	priv->password_entry = gtk_entry_new ();
	priv->password_entry_secondary = gtk_entry_new ();

	priv->show_passwords_checkbox = gtk_check_button_new_with_mnemonic (_("Sh_ow passwords"));

       /* We want to hold on to these during the grid rearrangement */
	g_object_ref_sink (priv->password_entry);
	g_object_ref_sink (priv->password_entry_secondary);
	g_object_ref_sink (priv->show_passwords_checkbox);
	
	gtk_entry_set_visibility (GTK_ENTRY (priv->password_entry), FALSE);
	gtk_entry_set_visibility (GTK_ENTRY (priv->password_entry_secondary), FALSE);

	g_signal_connect_swapped (priv->password_entry, "activate",
	                          G_CALLBACK (gtk_window_activate_default),
	                          dialog);
	g_signal_connect_swapped (priv->password_entry_secondary, "activate",
	                          G_CALLBACK (gtk_window_activate_default),
	                          dialog);

	g_signal_connect (priv->show_passwords_checkbox, "toggled",
	                  G_CALLBACK (show_passwords_toggled_cb),
	                  dialog);

       add_grid_rows (VPN_PASSWORD_DIALOG (dialog));

	/* Adds some eye-candy to the dialog */
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
 	gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
    
    #if !GTK_CHECK_VERSION(3,10,0)
	dialog_icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
    #else
    dialog_icon = gtk_image_new_from_icon_name("dialog-password", GTK_ICON_SIZE_DIALOG);
    #endif
    
	gtk_misc_set_alignment (GTK_MISC (dialog_icon), 0.5, 0.0);
	gtk_box_pack_start (GTK_BOX (hbox), dialog_icon, FALSE, FALSE, 0);

	/* Fills the vbox */
	main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);

	if (message) {
		message_label = GTK_LABEL (gtk_label_new (message));
		gtk_label_set_justify (message_label, GTK_JUSTIFY_LEFT);
		gtk_label_set_line_wrap (message_label, TRUE);
		gtk_label_set_max_width_chars (message_label, 35);
		gtk_size_group_add_widget (priv->group, GTK_WIDGET (message_label));
		gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (message_label), FALSE, FALSE, 0);
               gtk_size_group_add_widget (priv->group, priv->grid_alignment);
	}

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
       gtk_box_pack_start (GTK_BOX (vbox), priv->grid_alignment, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), main_vbox, FALSE, FALSE, 0);
	gtk_box_pack_start (content, hbox, FALSE, FALSE, 0);
	gtk_widget_show_all (GTK_WIDGET (content));

	vpn_password_dialog_set_password (VPN_PASSWORD_DIALOG (dialog), password);
	
	return GTK_WIDGET (dialog);
}
Пример #24
0
static void entry_toggle_visibility( GtkWidget *checkbutton,
                                     GtkWidget *entry )
{
  gtk_entry_set_visibility (GTK_ENTRY (entry),
			    GTK_TOGGLE_BUTTON (checkbutton)->active);
}
Пример #25
0
GtkWidget* dialogPasswordCreate(void) {
  GtkWidget *dailogPassword;
  GtkWidget *vbox1;
  GtkWidget *label1;
  GtkWidget *hbox1;
  GtkWidget *button1;

  dailogPassword = gtk_window_new (GTK_WINDOW_DIALOG);
  gtk_object_set_data (GTK_OBJECT (dailogPassword), "dailogPassword", dailogPassword);
  gtk_container_set_border_width (GTK_CONTAINER (dailogPassword), 7);
  gtk_window_set_title (GTK_WINDOW (dailogPassword), "Password");
  gtk_window_set_modal (GTK_WINDOW (dailogPassword), TRUE);
  gtk_window_set_policy (GTK_WINDOW (dailogPassword), FALSE, FALSE, FALSE);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox1);
  gtk_object_set_data_full (GTK_OBJECT (dailogPassword), "vbox1", vbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (dailogPassword), vbox1);
  gtk_container_set_border_width (GTK_CONTAINER (vbox1), 4);

  label1 = gtk_label_new ("This game is password protected.\nEnter the correct password to join:");
  gtk_widget_ref (label1);
  gtk_object_set_data_full (GTK_OBJECT (dailogPassword), "label1", label1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label1);
  gtk_box_pack_start (GTK_BOX (vbox1), label1, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);

  hbox1 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox1);
  gtk_object_set_data_full (GTK_OBJECT (dailogPassword), "hbox1", hbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);

  idc_passwordtxt = gtk_entry_new ();
  gtk_widget_ref (idc_passwordtxt);
  gtk_object_set_data_full (GTK_OBJECT (dailogPassword), "idc_passwordtxt", idc_passwordtxt,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (idc_passwordtxt);
  gtk_box_pack_start (GTK_BOX (hbox1), idc_passwordtxt, TRUE, TRUE, 0);
  gtk_entry_set_visibility (GTK_ENTRY (idc_passwordtxt), FALSE);

  button1 = gtk_button_new_with_label ("OK");
  gtk_widget_ref (button1);
  gtk_object_set_data_full (GTK_OBJECT (dailogPassword), "button1", button1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button1);
  gtk_box_pack_start (GTK_BOX (hbox1), button1, TRUE, TRUE, 0);
  GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT);

  gtk_widget_grab_focus (idc_passwordtxt);
  gtk_widget_grab_default (button1);

  gtk_signal_connect(GTK_OBJECT(dailogPassword), "delete_event", GTK_SIGNAL_FUNC (dialogPasswordClose), NULL);
  gtk_signal_connect(GTK_OBJECT(button1), "clicked", GTK_SIGNAL_FUNC(dialogPasswordClose), 0);
  gtk_signal_connect(GTK_OBJECT(idc_passwordtxt), "key-press-event", GTK_SIGNAL_FUNC(dialogPasswordKey), 0);

  dialogPasswordUs = dailogPassword;
  return dailogPassword;
}
Пример #26
0
//Fonction de création de la fenêtre principale
void creer_fenetre_principale (struct main* m)
{
  //LOCK GTK OK

  GtkWidget *p_window = NULL;
    GtkWidget *p_main_box = NULL;
      GtkWidget *p_menu_bar = NULL;
        GtkWidget *p_menu_item = NULL;
        GtkWidget *p_menu = NULL;
      GtkWidget *p_instruction = NULL;
      GtkWidget *p_box_boutons = NULL;
        GtkWidget *p_bouton_valider = NULL;
        GtkWidget *p_bouton_quitter = NULL;

  /* Creation de la fenêtre principale */
  p_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  m->fenetre_principale.sig_destroy = g_signal_connect (G_OBJECT (p_window), "destroy", G_CALLBACK (arret), m);
  gtk_window_set_title (GTK_WINDOW (p_window), "Puissance 5 en réseau");

  /*Création du conteneur principal*/
  p_main_box = gtk_vbox_new (FALSE, 10);
  gtk_container_add (GTK_CONTAINER (p_window), p_main_box);

  /*Création de la barre menu*/
  p_menu_bar = gtk_menu_bar_new ();
  gtk_box_pack_start (GTK_BOX (p_main_box), p_menu_bar, FALSE, FALSE, 0);

  /*Création du menu Quitter*/
  p_menu = gtk_menu_new ();
  p_menu_item = gtk_menu_item_new_with_mnemonic ("_Fichier");
  menu_item_new (GTK_MENU(p_menu), "Quitter", G_CALLBACK(arret), m);
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (p_menu_item), p_menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (p_menu_bar), p_menu_item);

  /*Création de la ligne de boutons*/
  p_box_boutons = gtk_hbox_new (FALSE, 20); //gtk_hbutton_box_new ();
  gtk_box_pack_end (GTK_BOX (p_main_box), p_box_boutons, FALSE, FALSE, 0);

  /*Création du bouton quitter*/
  p_bouton_quitter = gtk_button_new_from_stock (GTK_STOCK_QUIT);
  g_signal_connect (G_OBJECT (p_bouton_quitter), "clicked", G_CALLBACK (arret), m);
  gtk_box_pack_end (GTK_BOX (p_box_boutons), p_bouton_quitter, FALSE, FALSE, 0);

  /*Création du bouton Valider*/
  p_bouton_valider = gtk_button_new_from_stock (GTK_STOCK_OK); //gtk_button_new_with_label("Valider");
  g_signal_connect (G_OBJECT (p_bouton_valider), "clicked", G_CALLBACK (signal_traitement_champs), (gpointer) m);
  gtk_box_pack_end (GTK_BOX (p_box_boutons), p_bouton_valider, FALSE, FALSE, 0);

  //Création du champ de mot de passe
  m->fenetre_principale.mdp = add_new_champ_end("Mot de passe :", p_main_box, 0);
  gtk_entry_set_visibility(m->fenetre_principale.mdp.entry, FALSE);
  g_signal_connect(GTK_OBJECT(m->fenetre_principale.mdp.entry), "activate", G_CALLBACK(signal_traitement_champs), (gpointer) m);

  //Création du champ de login
  m->fenetre_principale.login = add_new_champ_end("Login :"******"activate", G_CALLBACK(signal_traitement_champs), (gpointer) m);

  //Création du champ de port
  m->fenetre_principale.port = add_new_champ_end("Port :", p_main_box, 0);
  g_signal_connect(GTK_OBJECT(m->fenetre_principale.port.entry), "activate", G_CALLBACK(signal_traitement_champs), (gpointer) m);

  //Création du champ de IP
  m->fenetre_principale.ip = add_new_champ_end("IP :", p_main_box, 16);
  g_signal_connect(GTK_OBJECT(m->fenetre_principale.ip.entry), "activate", G_CALLBACK(signal_traitement_champs), (gpointer) m);

  //Création de l'instruction
  p_instruction = gtk_label_new("Veuillez rentrer les informations pour vous connecter :");
  gtk_box_pack_end (GTK_BOX (p_main_box), p_instruction, FALSE, FALSE, 0);
  m->fenetre_principale.instruction = GTK_LABEL(p_instruction);

  m->fenetre_principale.open = 1;
  m->fenetre_principale.adresse = p_window;
}
Пример #27
0
void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data)
{
  GtkBuilder *builder = NULL;
  GtkWidget *dialog;
  GtkWidget *grid;
  GtkWidget *text;
  GtkWidget *button;

  GSList *tmp;

  int list_count = 0;
  int combo_count = 0;
  int i = 0;

  zen_data = data;

  builder = zenity_util_load_ui_file("zenity_forms_dialog", NULL);

  if (builder == NULL) {
    data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
    return;
  }

  gtk_builder_connect_signals(builder, NULL);
  
  dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_dialog"));

  g_signal_connect (G_OBJECT(dialog), "response",
                    G_CALLBACK (zenity_forms_dialog_response), forms_data);
  
  if (data->dialog_title)
    gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);

  if (data->width > -1 || data->height > -1)
    gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);

  if (data->extra_label) {
    gint i=0;
    while(data->extra_label[i]!=NULL){
      gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
      i++;
    }
  }

  if (data->ok_label) {
    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button"));
    gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
  }  

  if (data->cancel_label) {
    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_cancel_button"));
    gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
  }

  text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text"));

  if (forms_data->dialog_text)
    gtk_label_set_markup (GTK_LABEL (text), g_strcompress (forms_data->dialog_text));
  
  grid = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_grid"));

  for (tmp = forms_data->list; tmp; tmp = tmp->next) {
    ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data;
    GtkWidget *label;

    gchar **values = g_strsplit_set (zenity_value->option_value, "|", 2);
    gchar *label_text = values[0];
    gchar *prefill_text = values[1];
    
    label = gtk_label_new(label_text);
    gtk_widget_set_halign (label, GTK_ALIGN_START);
    gtk_grid_attach (GTK_GRID (grid),
                     label,
                     0, i,
                     1, 1);

    switch(zenity_value->type)
    {
      case ZENITY_FORMS_ENTRY:
        zenity_value->forms_widget = gtk_entry_new();
        if (prefill_text) {
          gtk_entry_set_text(GTK_ENTRY(zenity_value->forms_widget),
                               prefill_text);
        }
        break;
      case ZENITY_FORMS_PASSWORD:
        zenity_value->forms_widget = gtk_entry_new();
        gtk_entry_set_visibility(GTK_ENTRY(zenity_value->forms_widget), 
                                 FALSE);
        break;
      case ZENITY_FORMS_CALENDAR:
        zenity_value->forms_widget = gtk_calendar_new();
        break;
      case ZENITY_FORMS_LIST:
          zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count,
                                                                          zenity_value->option_value);
          list_count++;                                                                           
        break;
      case ZENITY_FORMS_COMBO:
          zenity_value->forms_widget = zenity_forms_create_and_fill_combo (forms_data, combo_count);
          combo_count++;
        break;             
      default:
        zenity_value->forms_widget = gtk_entry_new();
        break;
    }

    g_strfreev(values);

    gtk_grid_attach_next_to (GTK_GRID (grid),
                             GTK_WIDGET (zenity_value->forms_widget),
                             label,
                             GTK_POS_RIGHT,
                             1, 1);
    
    i++;
  }

  gtk_widget_show_all (GTK_WIDGET (dialog));
  
  g_object_unref (builder);

  if (data->timeout_delay > 0) {
    g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
  }

  gtk_main();
}
Пример #28
0
GtkWidget *a_uibuilder_new_widget ( VikLayerParam *param, VikLayerParamData data )
{
  // Perform pre conversion if necessary
  VikLayerParamData vlpd = data;
  if ( param->convert_to_display )
   vlpd = param->convert_to_display ( data );

  GtkWidget *rv = NULL;
  switch ( param->widget_type )
  {
    case VIK_LAYER_WIDGET_COLOR:
      if ( param->type == VIK_LAYER_PARAM_COLOR )
        rv = gtk_color_button_new_with_color ( &(vlpd.c) );
      break;
    case VIK_LAYER_WIDGET_CHECKBUTTON:
      if ( param->type == VIK_LAYER_PARAM_BOOLEAN )
      {
        //rv = gtk_check_button_new_with_label ( //param->title );
        rv = gtk_check_button_new ();
        if ( vlpd.b )
          gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(rv), TRUE );
      }
      break;
    case VIK_LAYER_WIDGET_COMBOBOX:
      if ( param->type == VIK_LAYER_PARAM_UINT && param->widget_data )
      {
        /* Build a simple combobox */
        gchar **pstr = param->widget_data;
        rv = vik_combo_box_text_new ();
        while ( *pstr )
          vik_combo_box_text_append ( rv, *(pstr++) );
        if ( param->extra_widget_data ) /* map of alternate uint values for options */
        {
          /* Set the effective default value */
          int i;
          for ( i = 0; ((const char **)param->widget_data)[i]; i++ )
            if ( ((guint *)param->extra_widget_data)[i] == vlpd.u )
            {
              /* Match default value */
              gtk_combo_box_set_active ( GTK_COMBO_BOX(rv), i );
              break;
            }
        }
        else
          gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), vlpd.u );
      }
      else if ( param->type == VIK_LAYER_PARAM_STRING && param->widget_data && !param->extra_widget_data )
      {
        /* Build a combobox with editable text */
        gchar **pstr = param->widget_data;
#if GTK_CHECK_VERSION (2, 24, 0)
        rv = gtk_combo_box_text_new_with_entry ();
#else
        rv = gtk_combo_box_entry_new_text ();
#endif
        if ( vlpd.s )
          vik_combo_box_text_append ( rv, vlpd.s );
        while ( *pstr )
          vik_combo_box_text_append ( rv, *(pstr++) );
        if ( vlpd.s )
          gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), 0 );
      }
      else if ( param->type == VIK_LAYER_PARAM_STRING && param->widget_data && param->extra_widget_data)
      {
        /* Build a combobox with fixed selections without editable text */
        gchar **pstr = param->widget_data;
        rv = GTK_WIDGET ( vik_combo_box_text_new () );
        while ( *pstr )
          vik_combo_box_text_append ( rv, *(pstr++) );
        if ( vlpd.s )
        {
          /* Set the effective default value */
          /* In case of value does not exist, set the first value */
          gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), 0 );
          int i;
          for ( i = 0; ((const char **)param->widget_data)[i]; i++ )
            if ( strcmp(((const char **)param->extra_widget_data)[i], vlpd.s) == 0 )
            {
              /* Match default value */
              gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), i );
              break; 
            }
        }
        else
          gtk_combo_box_set_active ( GTK_COMBO_BOX ( rv ), 0 );
      }
      break;
    case VIK_LAYER_WIDGET_RADIOGROUP:
      /* widget_data and extra_widget_data are GList */
      if ( param->type == VIK_LAYER_PARAM_UINT && param->widget_data )
      {
        rv = vik_radio_group_new ( param->widget_data );
        if ( param->extra_widget_data ) /* map of alternate uint values for options */
        {
          int i;
          int nb_elem = g_list_length(param->widget_data);
          for ( i = 0; i < nb_elem; i++ )
            if ( GPOINTER_TO_UINT ( g_list_nth_data(param->extra_widget_data, i) ) == vlpd.u )
            {
              vik_radio_group_set_selected ( VIK_RADIO_GROUP(rv), i );
              break;
            }
        }
        else if ( vlpd.u ) /* zero is already default */
          vik_radio_group_set_selected ( VIK_RADIO_GROUP(rv), vlpd.u );
      }
      break;
    case VIK_LAYER_WIDGET_RADIOGROUP_STATIC:
      if ( param->type == VIK_LAYER_PARAM_UINT && param->widget_data )
      {
        rv = vik_radio_group_new_static ( (const gchar **) param->widget_data );
        if ( param->extra_widget_data ) /* map of alternate uint values for options */
        {
          int i;
          for ( i = 0; ((const char **)param->widget_data)[i]; i++ )
            if ( ((guint *)param->extra_widget_data)[i] == vlpd.u )
            {
              vik_radio_group_set_selected ( VIK_RADIO_GROUP(rv), i );
              break;
            }
        }
        else if ( vlpd.u ) /* zero is already default */
          vik_radio_group_set_selected ( VIK_RADIO_GROUP(rv), vlpd.u );
      }
      break;
    case VIK_LAYER_WIDGET_SPINBUTTON:
      if ( (param->type == VIK_LAYER_PARAM_DOUBLE || param->type == VIK_LAYER_PARAM_UINT
           || param->type == VIK_LAYER_PARAM_INT)  && param->widget_data )
      {
        gdouble init_val = (param->type == VIK_LAYER_PARAM_DOUBLE) ? vlpd.d : (param->type == VIK_LAYER_PARAM_UINT ? vlpd.u : vlpd.i);
        VikLayerParamScale *scale = (VikLayerParamScale *) param->widget_data;
        rv = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new( init_val, scale->min, scale->max, scale->step, scale->step, 0 )), scale->step, scale->digits );
      }
    break;
    case VIK_LAYER_WIDGET_ENTRY:
      if ( param->type == VIK_LAYER_PARAM_STRING )
      {
        rv = gtk_entry_new ();
        if ( vlpd.s )
          gtk_entry_set_text ( GTK_ENTRY(rv), vlpd.s );
      }
      break;
    case VIK_LAYER_WIDGET_PASSWORD:
      if ( param->type == VIK_LAYER_PARAM_STRING )
      {
        rv = gtk_entry_new ();
        gtk_entry_set_visibility ( GTK_ENTRY(rv), FALSE );
        if ( vlpd.s )
          gtk_entry_set_text ( GTK_ENTRY(rv), vlpd.s );
        gtk_widget_set_tooltip_text ( GTK_WIDGET(rv),
                                     _("Take care that this password will be stored clearly in a plain file.") );
      }
      break;
    case VIK_LAYER_WIDGET_FILEENTRY:
      if ( param->type == VIK_LAYER_PARAM_STRING )
      {
        rv = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN);
        if ( vlpd.s )
          vik_file_entry_set_filename ( VIK_FILE_ENTRY(rv), vlpd.s );
      }
      break;
    case VIK_LAYER_WIDGET_FOLDERENTRY:
      if ( param->type == VIK_LAYER_PARAM_STRING )
      {
        rv = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
        if ( vlpd.s )
          vik_file_entry_set_filename ( VIK_FILE_ENTRY(rv), vlpd.s );
      }
      break;

    case VIK_LAYER_WIDGET_FILELIST:
      if ( param->type == VIK_LAYER_PARAM_STRING_LIST )
      {
        rv = vik_file_list_new ( _(param->title) );
        vik_file_list_set_files ( VIK_FILE_LIST(rv), vlpd.sl );
      }
      break;
    case VIK_LAYER_WIDGET_HSCALE:
      if ( (param->type == VIK_LAYER_PARAM_DOUBLE || param->type == VIK_LAYER_PARAM_UINT
           || param->type == VIK_LAYER_PARAM_INT)  && param->widget_data )
      {
        gdouble init_val = (param->type == VIK_LAYER_PARAM_DOUBLE) ? vlpd.d : (param->type == VIK_LAYER_PARAM_UINT ? vlpd.u : vlpd.i);
        VikLayerParamScale *scale = (VikLayerParamScale *) param->widget_data;
        rv = gtk_hscale_new_with_range ( scale->min, scale->max, scale->step );
        gtk_scale_set_digits ( GTK_SCALE(rv), scale->digits );
        gtk_range_set_value ( GTK_RANGE(rv), init_val );
      }
  }
  if ( rv && !gtk_widget_get_tooltip_text ( rv ) ) {
    if ( param->tooltip )
      gtk_widget_set_tooltip_text ( rv, _(param->tooltip) );
  }
  return rv;
}
Пример #29
0
void fx_proxy_initialize(FxProxy *fxproxy)
{
	GtkBox *vbox = NULL;
	GtkBox *action_area = NULL;
	GtkWidget *hostLabel = NULL;
	GtkWidget *portLabel = NULL;
	GtkWidget *userLabel = NULL;
	GtkWidget *passLabel = NULL;
	GtkWidget *fixed = NULL;
	GtkWidget *okBtn = NULL;
	GtkWidget *cancelBtn = NULL;
	GdkPixbuf *pb = NULL;
	char text[128];
	Proxy *proxy = fxproxy->fxlogin->proxy;

	fxproxy->dialog = gtk_dialog_new();

	gtk_widget_set_usize(fxproxy->dialog , 350 , 220);
	gtk_window_set_resizable(GTK_WINDOW(fxproxy->dialog) , FALSE);
	gtk_window_set_title(GTK_WINDOW(fxproxy->dialog) , _("Set HTTP Proxy"));
	pb = gdk_pixbuf_new_from_file(SKIN_DIR"proxy.png" , NULL);
	gtk_window_set_icon(GTK_WINDOW(fxproxy->dialog) , pb);

	vbox = GTK_BOX(GTK_DIALOG(fxproxy->dialog)->vbox);
	action_area = GTK_BOX(GTK_DIALOG(fxproxy->dialog)->action_area);

	fixed = gtk_fixed_new();

	fxproxy->enableBtn = gtk_check_button_new_with_label(_("Trun on HTTP proxy"));
	g_signal_connect(fxproxy->enableBtn , "toggled"
			, G_CALLBACK(fx_proxy_enable_toggled) , fxproxy);
	gtk_fixed_put(GTK_FIXED(fixed) , fxproxy->enableBtn , 20 , 20);

	fxproxy->errorLabel = gtk_label_new(NULL);
	gtk_fixed_put(GTK_FIXED(fixed) , fxproxy->errorLabel , 180 , 22);
	
	hostLabel = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(hostLabel) , _("<b>Proxy host</b>"));
	gtk_fixed_put(GTK_FIXED(fixed) , hostLabel , 20 , 55);

	portLabel = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(portLabel) , _("<b>Port</b>"));
	gtk_fixed_put(GTK_FIXED(fixed) , portLabel , 190 , 55);
	
	fxproxy->hostEntry = gtk_entry_new();
	gtk_widget_set_usize(fxproxy->hostEntry , 140 , 25);
	gtk_fixed_put(GTK_FIXED(fixed) , fxproxy->hostEntry , 20 , 75);

	fxproxy->portEntry = gtk_entry_new();
	gtk_widget_set_usize(fxproxy->portEntry , 140 , 25);
	gtk_fixed_put(GTK_FIXED(fixed) , fxproxy->portEntry , 190 , 75);

	userLabel = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(userLabel) , _("<b>Uesrname</b>"));
	gtk_fixed_put(GTK_FIXED(fixed) , userLabel , 20 , 110);

	passLabel = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(passLabel) , _("<b>Password</b>"));
	gtk_fixed_put(GTK_FIXED(fixed) , passLabel , 190 , 110);
	
	fxproxy->userEntry = gtk_entry_new();
	gtk_widget_set_usize(fxproxy->userEntry , 140 , 25);
	gtk_fixed_put(GTK_FIXED(fixed) , fxproxy->userEntry , 20 , 130);

	fxproxy->passEntry = gtk_entry_new();
	gtk_widget_set_usize(fxproxy->passEntry , 140 , 25);
	gtk_entry_set_visibility(GTK_ENTRY(fxproxy->passEntry) , FALSE);
	gtk_fixed_put(GTK_FIXED(fixed) , fxproxy->passEntry , 190 , 130);

	okBtn = gtk_button_new_with_label(_("OK"));
	g_signal_connect(okBtn , "clicked"
			, G_CALLBACK(fx_proxy_on_ok_clicked) , fxproxy);
	cancelBtn = gtk_button_new_with_label(_("Cancel"));
	g_signal_connect(cancelBtn , "clicked"
			, G_CALLBACK(fx_proxy_on_cancel_clicked) , fxproxy);

	gtk_box_pack_start_defaults(vbox , fixed);
	gtk_box_pack_start_defaults(action_area , okBtn);
	gtk_box_pack_start_defaults(action_area , cancelBtn);

	/* bind data*/
	if(proxy != NULL && proxy->proxyEnabled)
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fxproxy->enableBtn) , TRUE);
		fx_proxy_set_sensitive(fxproxy , TRUE);
	}
	else
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fxproxy->enableBtn) , FALSE);
		fx_proxy_set_sensitive(fxproxy , FALSE);
	}
	if(proxy != NULL)
	{
		gtk_entry_set_text(GTK_ENTRY(fxproxy->hostEntry) , proxy->proxyHost);
		snprintf(text, sizeof(text) - 1 , "%d" , proxy->proxyPort);
		gtk_entry_set_text(GTK_ENTRY(fxproxy->portEntry) , text);
		gtk_entry_set_text(GTK_ENTRY(fxproxy->userEntry) , proxy->proxyUser);
		gtk_entry_set_text(GTK_ENTRY(fxproxy->passEntry) , proxy->proxyPass);
	}
	/* show widgets*/
	gtk_widget_show_all(fxproxy->dialog);
}
Пример #30
0
int main(int argc, char **argv)
{
	int fd;
	char raw_data[150];
	if ((fd = open("gsd.config", O_RDONLY)) >= 0) {
		read(fd, raw_data, 150);
		close(fd);
		int y = 0;
		for (int i = 0; i < 3; i++) {
			for (int x = 0; x < 32; x++) {
				data[i][x] = '\0';
			}
			for (int x = 0; raw_data[y] != '\n' && x < 32; x++) {
				data[i][x] = raw_data[y];
				y++;
			}
			y++;
		}
		gtk_init(&argc, &argv);
		password_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
		gtk_window_set_title(GTK_WINDOW(password_window), "Iniciando Sesión");
	    	gtk_signal_connect (GTK_OBJECT (password_window), "delete_event",
		GTK_SIGNAL_FUNC (delete_event), NULL);
		GtkWidget *box1 = gtk_table_new(3,2,FALSE);
		GtkWidget *button1 = gtk_button_new_with_label (MSG_11);
		gtk_signal_connect (GTK_OBJECT (button1), "clicked", GTK_SIGNAL_FUNC (password_load), (gpointer) "button 1");
		gtk_box_pack_start(GTK_BOX(box1), button1, TRUE, TRUE, 0);
		gtk_table_attach_defaults(GTK_TABLE(box1),button1,0,2,9,10);

		GtkWidget *label1 = gtk_label_new(MSG_6);
		gtk_table_attach_defaults(GTK_TABLE(box1),label1,0,1,2,3);
		entry[3] = gtk_entry_new();
		gtk_entry_set_visibility(GTK_ENTRY(entry[3]),FALSE);
		gtk_table_attach_defaults(GTK_TABLE(box1),entry[3],1,2,2,3);
		gtk_container_add(GTK_CONTAINER(password_window), box1);

		gtk_widget_show(box1);
		gtk_widget_show_all(password_window);
		gtk_main();
	}
	else {
		GdkPixbuf *pixbuf;
		GtkWidget *picture;
		GtkWidget *box1;
		GtkWidget *button1;
		GtkWidget *label, *label1, *label2, *label3, *label4;

		gtk_init(&argc, &argv);

		/* Creo la ventana */
		first_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

		/* Le pongo un título */
		gtk_window_set_title(GTK_WINDOW(first_window), "GSD");
	    	gtk_signal_connect (GTK_OBJECT (first_window), "delete_event",
		GTK_SIGNAL_FUNC (delete_event), NULL);
		box1 = gtk_table_new(3,2,FALSE);

		/* Cargamos el logo. */
		pixbuf = gdk_pixbuf_new_from_file_at_scale("logo.png",350,110,FALSE,NULL);
		picture=gtk_image_new_from_pixbuf(pixbuf);
		gtk_table_attach_defaults(GTK_TABLE(box1),picture,0,2,0,1);

		/* Mensaje de Bienvenida ;) */
		label = gtk_label_new(MSG_12);
		gtk_table_attach_defaults(GTK_TABLE(box1),label,0,2,1,2);

		/* Botón 1 */
		button1 = gtk_button_new_with_label (MSG_11);
		gtk_signal_connect (GTK_OBJECT (button1), "clicked", GTK_SIGNAL_FUNC (create_account), (gpointer) "button 1");
		gtk_box_pack_start(GTK_BOX(box1), button1, TRUE, TRUE, 0);
		gtk_table_attach_defaults(GTK_TABLE(box1),button1,0,2,9,10);

		label1 = gtk_label_new(MSG_3);
		gtk_table_attach_defaults(GTK_TABLE(box1),label1,0,1,2,3);
		entry[0] = gtk_entry_new();
		gtk_entry_set_visibility(GTK_ENTRY(entry[0]),TRUE);
		gtk_table_attach_defaults(GTK_TABLE(box1),entry[0],1,2,2,3);

		label2 = gtk_label_new(MSG_4);
		gtk_table_attach_defaults(GTK_TABLE(box1),label2,0,1,3,4);
		entry[1] = gtk_entry_new();
		gtk_entry_set_visibility(GTK_ENTRY(entry[1]),TRUE);
		gtk_table_attach_defaults(GTK_TABLE(box1),entry[1],1,2,3,4);

		label3 = gtk_label_new(MSG_5);
		gtk_table_attach_defaults(GTK_TABLE(box1),label3,0,1,5,6);
		entry[2] = gtk_entry_new();
		gtk_entry_set_visibility(GTK_ENTRY(entry[2]),TRUE);
		gtk_table_attach_defaults(GTK_TABLE(box1),entry[2],1,2,5,6);

		label4 = gtk_label_new(MSG_6);
		gtk_table_attach_defaults(GTK_TABLE(box1),label4,0,1,7,8);
		entry[3] = gtk_entry_new();
		gtk_entry_set_visibility(GTK_ENTRY(entry[3]),FALSE);
		gtk_table_attach_defaults(GTK_TABLE(box1),entry[3],1,2,7,8);

		gtk_container_add(GTK_CONTAINER(first_window), box1);

		gtk_widget_show(box1);
		gtk_widget_show_all(first_window);
		/* Finalmente entramos en el bucle principal. */
		gtk_main();
	}

        return 0;
}