所有条目均被停用。因此,我无法输入键盘输入。 林间空地中“ can_focus”已经成立。
我应该解决什么才能输入字符?
我在一个空地文件中也有2个对象。 登录成功后,例如使用gtk_main_quit(),我想关闭登录对话框。所以我实际上放了on_login_dialog_close函数。 我如何填充它?
但是,该对话框不是主要应用程序。在这种情况下,最好制作单独的文件(主文件,登录文件)吗?
如果我生成新的林间空地文件,那么如何一次控制两个林间空地文件?
#define DEBUG 1
//login
GtkWidget * userid_input;
GtkWidget *passwd_input;
G_MODULE_EXPORT void on_login_dialog_close()
{
}
G_MODULE_EXPORT void on_login_btn_clicked(GtkButton **button)
{
if(DEBUG)
fprintf(stderr,"Btn Clicked : Log In\n");
const gchar * userid = NULL;
const gchar * passwd = NULL;
userid = gtk_entry_get_text(userid_input);
passwd = gtk_entry_get_text(passwd_input);
if(DEBUG)
if(userid != NULL && passwd != NULL){
fprintf(stderr, "Entry contents : (Id : %s Passwd: %s) \n", userid, passwd);
//g_print("Entry Information : (Id : %s Passwd: %s) \n", *userid, *passwd);
}
}
int main ()
{
GError *err = NULL;
gtk_init(NULL, NULL);
view= gtk_text_view_new();
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
builder = gtk_builder_new();
if(0 == gtk_builder_add_from_file(builder, "gssiot_sconv_main.glade", &err))
{
if(DEBUG)
fprintf(stderr, "Error : Adding build from file. Error, %s\n", err->message);
}
window = GTK_WIDGET( gtk_builder_get_object( builder, "sconv_main_wdw"));
if(NULL == window)
{
if(DEBUG)
fprintf(stderr,"Error : Unable to file object with id: SCONV");
}
loginDialg = GTK_WIDGET( gtk_builder_get_object( builder, "popover_login"));
if(NULL == loginDialg)
{
if(DEBUG)
fprintf(stderr,"Error : Unable to file object with id: loginDialg\n");
}
else
{
//login
userid_input = GTK_WIDGET( gtk_builder_get_object( builder, "username_entry"));
passwd_input = GTK_WIDGET( gtk_builder_get_object( builder, "password_entry"));
if((NULL == userid_input )||(NULL == passwd_input ))
if(DEBUG)
fprintf(stderr,"Error : Unable to file object with id: userid_input or passwd_input\n");
userid_input = gtk_entry_new ();
passwd_input = gtk_entry_new ();
}
viewport1 = GTK_WIDGET(gtk_builder_get_object (builder , "viewpoint_inner_vbox"));
if(NULL == viewport1)
{
if(DEBUG)
fprintf(stderr,"Error : Unable to file object with id: viewport_widget\n");
}
gtk_container_add(GTK_CONTAINER(viewport1), view);
gtk_builder_connect_signals(builder, NULL);
//g_object_unref(G_OBJECT(builder));
gtk_widget_show(loginDialg);
gtk_widget_show(window);
gtk_main();
return 0;
}
.glade
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkDialog" id="login_dialog">
<property name="name">Login</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="type">popup</property>
<property name="resizable">False</property>
<property name="window_position">center-always</property>
<property name="icon_name">login</property>
<property name="type_hint">dialog</property>
<property name="focus_on_map">False</property>
<signal name="close" handler="on_login_dialog_close" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="login_vbox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="login_btn_opion">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="login_btn">
<property name="label" translatable="yes">Log in</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin_left">1</property>
<property name="margin_right">1</property>
<property name="margin_top">1</property>
<property name="margin_bottom">1</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<signal name="clicked" handler="on_login_btn_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="register_btn">
<property name="label" translatable="yes">Sign in</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<signal name="clicked" handler="on_register_btn_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="user_login_input_box">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="user_id_hbox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkLabel" id="id_input_lbl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">USERNAME:</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="userid_input">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin_left">1</property>
<property name="margin_right">1</property>
<property name="margin_top">1</property>
<property name="margin_bottom">1</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="max_length">20</property>
<property name="activates_default">True</property>
<property name="overwrite_mode">True</property>
<property name="placeholder_text" translatable="yes">username</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="user_passwd_hbox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkLabel" id="passwd_input_lbl">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">PASSWORD:</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="passwd_input">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin_top">1</property>
<property name="margin_bottom">1</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="max_length">20</property>
<property name="visibility">False</property>
<property name="invisible_char">*</property>
<property name="placeholder_text" translatable="yes">password</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="sconv_main_wdw">
...
</object>
</interface>