Пример #1
0
static int
delete_text_in_gtk_entry(GtkEntry *entry, enum UTextOrigin origin,
			 int former_req_len, int latter_req_len)
{
  gint start_pos, end_pos, current_pos;

  current_pos = gtk_editable_get_position(GTK_EDITABLE(entry));

  switch (origin) {
  case UTextOrigin_Cursor:
    if (former_req_len >= 0) {
      start_pos = current_pos - former_req_len;
    } else {
      if (!(~former_req_len & (~UTextExtent_Line | ~UTextExtent_Full)))
	return -1;
      start_pos = 0;
    }

    if (latter_req_len >= 0)
      end_pos = current_pos + latter_req_len;
    else {
      if (!(~latter_req_len & (~UTextExtent_Line | ~UTextExtent_Full)))
	return -1;
      end_pos = gtk_entry_get_text_length(entry);
    }
    break;

  case UTextOrigin_Beginning:
    start_pos = 0;

    if (latter_req_len >= 0)
      end_pos = latter_req_len;
    else {
      if (!(~latter_req_len & (~UTextExtent_Line | ~UTextExtent_Full)))
	return -1;
      end_pos = gtk_entry_get_text_length(entry);
    }
    break;

  case UTextOrigin_End:
    if (former_req_len >= 0)
      start_pos = gtk_entry_get_text_length(entry) - former_req_len;
    else {
      if (!(~former_req_len & (~UTextExtent_Line | ~UTextExtent_Full)))
	return -1;
      start_pos = 0;
    }

    end_pos = gtk_entry_get_text_length(entry);
    break;

  case UTextOrigin_Unspecified:
  default:
    return -1;
  }

  gtk_editable_delete_text(GTK_EDITABLE(entry), start_pos, end_pos);

  return 0;
}
//===========
void add2_clicked(GtkWidget *widget, gpointer data) {

 FILE *fd;
 int fd1;
  int len;
  char temp[100],nu[4];
  GtkWidget *label;
 
  if(0==(int)gtk_entry_get_text_length(GTK_ENTRY(entry2))){
	show_error();
	goto NODATA;
	}


  fd = fopen("/etc/lsm/file_security.cfg","a+");


  fseek(fd,0,SEEK_END);	
  fwrite((char *)gtk_entry_get_text(GTK_ENTRY(entry2)),(int)gtk_entry_get_text_length(GTK_ENTRY(entry2)),1,fd);
  fseek(fd,0,SEEK_END);
  fwrite("\n",1,1,fd);
			

  fd1 = open("log.txt",O_CREAT|O_RDWR);
  sprintf(temp,"FILE list : %s\n",(char *)gtk_entry_get_text(GTK_ENTRY(entry2)));
  lseek(fd1,0,SEEK_END);	
  write(fd1,temp,strlen(temp));
//  fseek(fd1,0,SEEK_END);
//  fwrite("\0\n",2,1,fd1);

NODATA:
  gtk_entry_set_text(GTK_ENTRY(entry2),"");
  g_print("clicked\n");
}
Пример #3
0
gboolean
parse_user_data(GtkWidget *widget, gpointer gdata) {
    Data *data = (Data *) gdata;


    if (!gtk_entry_get_text_length(GTK_ENTRY(data->player1Entry)) ||
            !gtk_entry_get_text_length(GTK_ENTRY(data->player2Entry))) {
        GdkColor *baseColor = (GdkColor *) calloc(1, sizeof (GdkColor)),
                *textColor = (GdkColor *) calloc(1, sizeof (GdkColor));
        gdk_color_parse(INVALID_BASE_COLOR, baseColor);
        gdk_color_parse(INVALID_TEXT_COLOR, textColor);
        if (!gtk_entry_get_text_length(GTK_ENTRY(data->player1Entry))) {
            gtk_widget_modify_base((data->player1Entry), GTK_STATE_NORMAL,
                    baseColor);
            gtk_widget_modify_text((data->player1Entry), GTK_STATE_NORMAL,
                    textColor);
            gtk_entry_set_text(GTK_ENTRY(data->player1Entry), "Invalid Name");
        }
        if (!gtk_entry_get_text_length(GTK_ENTRY(data->player2Entry))) {
            gtk_widget_modify_base((data->player2Entry), GTK_STATE_NORMAL,
                    baseColor);
            gtk_widget_modify_text((data->player2Entry), GTK_STATE_NORMAL,
                    textColor);
            gtk_entry_set_text(GTK_ENTRY(data->player2Entry), "Invalid Name");
        }
        free(baseColor);
        free(textColor);
        return FALSE;
    }
    strcpy(data->player1Name, (const char *) gtk_entry_get_text(GTK_ENTRY
            (data->player1Entry)));
    strcpy(data->player2Name, (const char *) gtk_entry_get_text(GTK_ENTRY
            (data->player2Entry)));

    if (!strcmp(data->player1Name, "Invalid Name") ||
            !strcmp(data->player2Name, "Invalid Name"))
        return FALSE;
    if (!strcmp(data->player1Name, data->player2Name)) {
        strcat(data->player1Name, " (Player 1)");
        strcat(data->player2Name, " (Player 2)");
    }
    data->horizontalLines = atoi((char *) gtk_combo_box_get_active_text
            (GTK_COMBO_BOX(data->comboBoxHorizontal)));
    data->verticalLines = atoi((char *) gtk_combo_box_get_active_text
            (GTK_COMBO_BOX(data->comboBoxVertical)));
    data->opponent = (GTK_TOGGLE_BUTTON(data->radioButtonComputer))->active ?
            COMPUTER : HUMAN;
    if (data->opponent == COMPUTER) {
        char *diff;
        diff = gtk_combo_box_get_active_text(GTK_COMBO_BOX(data->difficulty_combo));
        if (!strcmp(diff, "Easy"))
            data->difficulty = easy;
        else if (!strcmp(diff, "Medium"))
            data->difficulty = medium;
        else data->difficulty = hard;
    }
    gtk_main_quit();
    return TRUE;
}
Пример #4
0
void on_install_btn_clicked (GtkWidget *widget, gpointer user_data) {
	GtkWidget *dialog;
	GtkWidget *rootpassword;
	GtkWidget *username;
	GtkWidget *userpassword;
	GtkWidget *rootpassword1;
	GtkWidget *userpassword1;
	
	gchar *fstype, *usbfstype;
	GtkComboBox *listwidget;
	GtkTreeIter iter;
	GtkListStore *list;
		
	rootpassword = (GtkWidget *) gtk_builder_get_object(widgetstree, "rootpassword");
	username = (GtkWidget *) gtk_builder_get_object(widgetstree, "username");
	userpassword = (GtkWidget *) gtk_builder_get_object(widgetstree, "userpassword");
    
    rootpassword1 = (GtkWidget *) gtk_builder_get_object(widgetstree, "rootpassword1");
	userpassword1 = (GtkWidget *) gtk_builder_get_object(widgetstree, "userpassword1");
	
	listwidget = (GtkComboBox *) gtk_builder_get_object(widgetstree, "filesystem");
	gtk_combo_box_get_active_iter(listwidget, &iter);
	list = (GtkListStore *) gtk_combo_box_get_model(listwidget);
	gtk_tree_model_get((GtkTreeModel *) list, &iter, 0, &fstype, -1);
	
	listwidget = (GtkComboBox *) gtk_builder_get_object(widgetstree, "usbfilesystem");
	gtk_combo_box_get_active_iter(listwidget, &iter);
	list = (GtkListStore *) gtk_combo_box_get_model(listwidget);
	gtk_tree_model_get((GtkTreeModel *) list, &iter, 0, &usbfstype, -1);
	
	if (gtk_entry_get_text_length (GTK_ENTRY(rootpassword)) == 0  ||  gtk_entry_get_text_length (GTK_ENTRY(username)) == 0
			|| (gtk_entry_get_text_length (GTK_ENTRY(userpassword)) == 0)) {
				dialog = (GtkWidget *) gtk_builder_get_object(widgetstree, "dialogusers");
				gtk_widget_show(dialog);
	       }
	 else if (gtk_entry_get_text_length (GTK_ENTRY(rootpassword)) < 5  ||  gtk_entry_get_text_length (GTK_ENTRY(userpassword)) < 5) {
		 	    dialog = (GtkWidget *) gtk_builder_get_object(widgetstree, "dialogusers");
				gtk_widget_show(dialog);
	       }  
	else if  ( strcmp(gtk_entry_get_text(GTK_ENTRY(rootpassword)),gtk_entry_get_text (GTK_ENTRY(rootpassword1)))!=0 ) {
			    dialog = (GtkWidget *) gtk_builder_get_object(widgetstree, "dialogrootpass");
				gtk_widget_show(dialog);				
		   }
    else if  (strcmp(gtk_entry_get_text (GTK_ENTRY(userpassword)),gtk_entry_get_text (GTK_ENTRY(userpassword1)))!=0 ) {
				dialog = (GtkWidget *) gtk_builder_get_object(widgetstree, "dialoguserpass");
				gtk_widget_show(dialog);				
		   }
    else if (gtk_toggle_button_get_active((GtkToggleButton*) gtk_builder_get_object(widgetstree, "lilo")) 
		&& gtk_toggle_button_get_active((GtkToggleButton*) gtk_builder_get_object(widgetstree, "grub"))){ 
			dialog = (GtkWidget *) gtk_builder_get_object(widgetstree, "dialogbootloader");
			gtk_widget_show(dialog);}
	else if (gtk_toggle_button_get_active((GtkToggleButton*) gtk_builder_get_object(widgetstree, "grub")) && (strcmp(fstype,"xfs") == 0)){
		dialog = (GtkWidget *) gtk_builder_get_object(widgetstree, "dialog_grub_xfs");
		gtk_widget_show(dialog);}	
	else {
	do_action(FALSE);
	}
}
static void
on_email_address_or_password_changed (GtkEditable *editable, gpointer user_data)
{
  AddAccountData *data = user_data;
  gboolean can_add;
  const gchar *email;
  gchar *domain;
  gchar *url;
  gchar *username;

  can_add = FALSE;
  domain = NULL;
  url = NULL;
  username = NULL;

  email = gtk_entry_get_text (GTK_ENTRY (data->email_address));
  if (!is_valid_email_address (email, &username, &domain))
    goto out;

  if (data->username != NULL)
    gtk_entry_set_text (GTK_ENTRY (data->username), username);

  if (data->server != NULL)
    gtk_entry_set_text (GTK_ENTRY (data->server), domain);

  can_add = gtk_entry_get_text_length (GTK_ENTRY (data->password)) != 0;

 out:
  gtk_dialog_set_response_sensitive (data->dialog, GTK_RESPONSE_OK, can_add);
  g_free (url);
  g_free (domain);
  g_free (username);
}
Пример #6
0
static void
entry_populate_popup (GtkEntry *entry,
                      GtkMenu  *menu,
                      gpointer user_data)
{
  GtkWidget *item;
  GtkWidget *search_menu;
  gboolean has_text;

  has_text = gtk_entry_get_text_length (entry) > 0;

  item = gtk_separator_menu_item_new ();
  gtk_widget_show (item);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

  item = gtk_menu_item_new_with_mnemonic ("C_lear");
  gtk_widget_show (item);
  g_signal_connect_swapped (item, "activate",
                            G_CALLBACK (clear_entry), entry);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
  gtk_widget_set_sensitive (item, has_text);

  search_menu = create_search_menu (GTK_WIDGET (entry));
  item = gtk_menu_item_new_with_label ("Search by");
  gtk_widget_show (item);
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), search_menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}
Пример #7
0
static void
cb_entry_insert_text (GtkEditable *editable,
		      gchar const *text,
		      gint         len_bytes,
		      gint        *pos_in_chars,
		      WBCGtk *wbcg)
{
	char const *str = gtk_entry_get_text (GTK_ENTRY (editable));
	int pos_in_bytes = g_utf8_offset_to_pointer (str, *pos_in_chars) - str;

	if (wbcg->auto_completing &&
	    len_bytes != 0 &&
	    (!g_unichar_isalpha (g_utf8_get_char (text)) ||
	     *pos_in_chars != gtk_entry_get_text_length (GTK_ENTRY (editable)))) {
		wbcg->auto_completing = FALSE;
	}

	if (wbcg->edit_line.full_content) {
		(void)pango_attr_list_filter (wbcg->edit_line.cur_fmt,
					      cb_set_attr_list_len,
					      GINT_TO_POINTER (len_bytes));

		go_pango_attr_list_open_hole (wbcg->edit_line.full_content,
					      pos_in_bytes, len_bytes);
		pango_attr_list_splice (wbcg->edit_line.full_content,
					wbcg->edit_line.cur_fmt,
					pos_in_bytes, 0);

		go_pango_attr_list_open_hole (wbcg->edit_line.markup,
					      pos_in_bytes, len_bytes);
		pango_attr_list_splice (wbcg->edit_line.markup,
					wbcg->edit_line.cur_fmt,
					pos_in_bytes, 0);
	}
}
Пример #8
0
static void
gb_search_box_popover_set_visible (GbSearchBox *self,
                                   gboolean     visible)
{
  gboolean entry_has_text;

  g_return_if_fail (GB_IS_SEARCH_BOX (self));

  entry_has_text = !!(gtk_entry_get_text_length (GTK_ENTRY (self->entry)));

  if (visible == gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->button)))
    return;

  if (visible && entry_has_text)
    {
      if (!gtk_widget_has_focus (GTK_WIDGET (self->entry)))
        gtk_widget_grab_focus (GTK_WIDGET (self->entry));

      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->button), TRUE);
    }
  else if (!visible)
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->button), FALSE);
    }
}
Пример #9
0
void delete_text_handler(GtkEntry    *entry,
			 gint        start_pos,
			 gint        end_pos,
			 gpointer    data)
{
	GtkWidget * button = (GtkWidget *) data;
	GtkEditable *editable = GTK_EDITABLE(entry);
	int issensitive;
	int entrylen;
	char * text;

	g_signal_handlers_block_by_func (G_OBJECT (editable),
					 G_CALLBACK (delete_text_handler),
					 data);

	gtk_editable_delete_text(editable, start_pos, end_pos);

	g_signal_handlers_unblock_by_func (G_OBJECT (editable),
					   G_CALLBACK (delete_text_handler),
					   data);

	g_signal_stop_emission_by_name (G_OBJECT (entry), "delete_text");

	text =  gtk_entry_get_text(GTK_ENTRY(entry));
	entrylen = gtk_entry_get_text_length(GTK_ENTRY(entry));
	issensitive = (!(entrylen < 6) && !(text[entrylen-1] == '.'));

	gtk_widget_set_sensitive(button,issensitive);
}
Пример #10
0
static gboolean
simple_filter_search_keyrelease_handler(GtkEntry *entry,
					PraghaFilterDialog *fdialog)
{
	gchar *text = NULL;
	gchar *u_str = NULL;
	gboolean has_text;

	if (fdialog->filter_string != NULL) {
		g_free (fdialog->filter_string);
		fdialog->filter_string = NULL;
	}

	has_text = gtk_entry_get_text_length (GTK_ENTRY(entry)) > 0;

	if (has_text) {
		text = gtk_editable_get_chars (GTK_EDITABLE(entry), 0, -1);
		u_str = g_utf8_strdown (text, -1);
		fdialog->filter_string = u_str;
	}

	gtk_entry_set_icon_sensitive (GTK_ENTRY(entry),
				GTK_ENTRY_ICON_SECONDARY,
				has_text);

	if (!pragha_preferences_get_instant_search(fdialog->preferences))
		return FALSE;

	queue_filter_dialog_refilter(fdialog);

	return FALSE;
}
static void url_entry_changed(GtkWidget * w, gpointer data)
{
    TrgTorrentAddUrlDialogPrivate *priv =
        TRG_TORRENT_ADD_URL_DIALOG_GET_PRIVATE(data);
    gtk_widget_set_sensitive(priv->addButton,
                             gtk_entry_get_text_length(GTK_ENTRY(w)) > 0);
}
Пример #12
0
static void
simple_filter_search_keyrelease_handler (GtkEntry           *entry,
                                         PraghaFilterDialog *fdialog)
{
	const gchar *text = NULL;
	gchar *u_str = NULL;
	gboolean has_text;

	if (fdialog->filter_string != NULL) {
		g_free (fdialog->filter_string);
		fdialog->filter_string = NULL;
	}

	has_text = gtk_entry_get_text_length (GTK_ENTRY(entry)) > 0;

	if (has_text) {
		text = gtk_entry_get_text (entry);
		u_str = g_utf8_strdown (text, -1);
		fdialog->filter_string = u_str;
	}

	if (!pragha_preferences_get_instant_search(fdialog->preferences))
		return;

	queue_filter_dialog_refilter(fdialog);
}
Пример #13
0
static gboolean
simple_filter_search_activate_handler(GtkEntry *entry,
				    PraghaFilterDialog *fdialog)
{

	const gchar *text = NULL;
	gchar *u_str = NULL;
	gboolean has_text;

	has_text = gtk_entry_get_text_length (GTK_ENTRY(entry)) > 0;

	if (fdialog->filter_string != NULL) {
		g_free (fdialog->filter_string);
		fdialog->filter_string = NULL;
	}

	if (has_text) {
		text = gtk_entry_get_text (entry);
		u_str = g_utf8_strdown (text, -1);
		fdialog->filter_string = u_str;
	}

	gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER(fdialog->filter_model));

	return FALSE;
}
Пример #14
0
static gboolean
simple_filter_search_activate_handler(GtkEntry *entry,
				    PraghaFilterDialog *fdialog)
{

	gchar *text = NULL;
	gchar *u_str = NULL;
	gboolean has_text;

	has_text = gtk_entry_get_text_length (GTK_ENTRY(entry)) > 0;

	if (fdialog->filter_string != NULL) {
		g_free (fdialog->filter_string);
		fdialog->filter_string = NULL;
	}

	if (has_text) {
		text = gtk_editable_get_chars (GTK_EDITABLE(entry), 0, -1);
		u_str = g_utf8_strdown (text, -1);
		fdialog->filter_string = u_str;
	}

	gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER(fdialog->filter_model));

	gtk_entry_set_icon_sensitive (GTK_ENTRY(entry),
				GTK_ENTRY_ICON_SECONDARY,
				has_text);

	g_free (text);

	return FALSE;
}
Пример #15
0
static void on_menuitem_edit_activate(void)
{
	GtkWidget *widget = gtk_window_get_focus(gui.window);
	bool selectable = false;
	bool editable = false;
	bool selection_ready = false;
	bool clipboard_ready = false;

	if (GTK_IS_ENTRY(widget)) {
		selectable = gtk_entry_get_text_length(GTK_ENTRY(widget));
		editable = gtk_editable_get_editable(GTK_EDITABLE(widget));
		selection_ready = gtk_editable_get_selection_bounds(
			GTK_EDITABLE(widget), NULL, NULL);
		clipboard_ready = gtk_clipboard_wait_is_text_available(
			gtk_clipboard_get(GDK_NONE));
	}

	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_cut),
		selection_ready && editable);
	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_copy),
		selection_ready);
	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_paste),
		editable && clipboard_ready);
	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_delete),
		selection_ready && editable);
	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_select_all),
		selectable);
}
Пример #16
0
void
button_save_conf_clicked (GtkButton *button, gpointer user_data){
    
    GError *error=NULL;
    GKeyFile *key_file;
    gchar *filename;
    FZ_Advanced *field = user_data;
    /*if (!conn)
        if (connection() != 0){
            g_print("Configure a Conexão do Sistema");
            return;
        }
    */
    key_file = g_key_file_new();
    
    // Attrs
    gchar *host = gtk_entry_get_text(field->Host);
    if (!host)
        host = "localhost";
    g_key_file_set_value (key_file, "DBConf", "IP", host);
    //g_free (host);
    
    gint port = gtk_spin_button_get_value_as_int (field->Port);
    if (!port)
        port = 5432;
    g_key_file_set_integer (key_file, "DBConf", "port", port);
    
    gchar *login = gtk_entry_get_text(field->Login);
    g_key_file_set_value (key_file, "DBConf", "user", login);
    //g_free (login);
    
    gchar *password = gtk_entry_get_text(field->PassWord);
    int len_password = gtk_entry_get_text_length(field->PassWord);
    if (len_password){
        g_key_file_set_integer (key_file, "DBConf", "len", len_password);
        password = g_utf8_strreverse (password, len_password);
        password = g_base64_encode (password, len_password);
        g_key_file_set_value (key_file, "DBConf", "password", password);
        //g_free (password);
    }
    
    filename = g_strdup_printf("%s/%s", g_get_home_dir (), LOCAL_SHARE);
    
    if (!g_file_test (filename, G_FILE_TEST_IS_DIR))
        if ( g_mkdir(filename, 0777) == -1 )
            g_print("Error: Criar Dir.\n");
    
    filename = g_build_filename (filename, "firezero.conf", NULL);
    
    if (!g_key_file_save_to_file (key_file, filename, &error))
        g_print("ERROR: %s\n", error->message);//TODO Create Dialog
    
    g_key_file_free (key_file);
    g_free (filename);

    //
    //TODO using to field DBConf and to save in filename
    //
}
Пример #17
0
void on_btFind_clicked(GtkWidget *btMedialib,
                       InterFace *ui)
{
	if (! gtk_entry_get_text_length (GTK_ENTRY(ui->etFind)))
		gtk_entry_set_text ((GTK_ENTRY(ui->etFind)), "*");
	main_core(MEDIALIB_FIND, ui);
	main_core(MEDIALIB_BRUSH, ui);
}
Пример #18
0
static void login_pushed(GtkWidget *widget) {

  if (gtk_entry_get_text_length(GTK_ENTRY(g_usernameEntry)) > 0 &&
      gtk_entry_get_text_length(GTK_ENTRY(g_passwordEntry)) > 0) {
    const char *username = gtk_entry_get_text(GTK_ENTRY(g_usernameEntry));
    const char *password = gtk_entry_get_text(GTK_ENTRY(g_passwordEntry));

    printf("login_pushed - username: %s, password: %s\n", username, password); //TODO: Remove

    session_login(username, password);

  } else {
    printf("login_pushed - username or password is not entered!\n");
    //TODO: Mark that entry fields are empty.    
  }

}
Пример #19
0
/*! \brief Update the sensitivity of the find button
 */
static void
notify_entry_text (GtkWidget *entry, GParamSpec *pspec, GschemShowHideTextWidget *widget)
{
  g_return_if_fail (widget != NULL);

  gtk_widget_set_sensitive (widget->ok_button,
                            (gtk_entry_get_text_length (GTK_ENTRY (widget->entry)) > 0));
}
Пример #20
0
static void	
nsp_window_cmd_search (GtkEntry *entry, NspWindow *win)
{
	NspApp *app = nsp_app_get();
	if ( gtk_entry_get_text_length(entry) > 0 && app->window->on_feeds_search != NULL) {
		nsp_jobs_queue(app->jobs, nsp_job_new(app->window->on_feeds_search, (void*)gtk_entry_get_text(entry)));
	}
}
Пример #21
0
/**
 * search entry text changed
 */
void on_search_entry_changed(GtkEditable *edit, gpointer data)
{
	gboolean has_text;

	has_text = gtk_entry_get_text_length(GTK_ENTRY(edit)) > 0;
	gtk_entry_set_icon_sensitive(GTK_ENTRY(edit),
				GTK_ENTRY_ICON_SECONDARY,
				has_text);
}
Пример #22
0
/* Callback for when the user clicks the find button
 */
static void
click_ok (GtkWidget *entry, GschemShowHideTextWidget *widget)
{
  g_return_if_fail (widget != NULL);

  if (gtk_entry_get_text_length (GTK_ENTRY (widget->entry)) > 0) {
    gtk_info_bar_response (GTK_INFO_BAR (widget), GTK_RESPONSE_OK);
  }
}
Пример #23
0
void values_changed_cb (GtkWidget *widget, GtkBuilder *builder) {
  GObject *obj;
  gint u, p;

  obj = gtk_builder_get_object(builder, "username");
  u = gtk_entry_get_text_length (GTK_ENTRY(obj));

  obj = gtk_builder_get_object(builder, "password");
  p = gtk_entry_get_text_length (GTK_ENTRY(obj));
  
  obj = gtk_builder_get_object(builder, "btn_connect");

  if ((u < 1) || (p < 1))
    gtk_widget_set_sensitive (GTK_WIDGET(obj), FALSE);
  else 
    gtk_widget_set_sensitive (GTK_WIDGET(obj), TRUE);
  
}
Пример #24
0
static void
text_changed_cb (GtkEntry   *entry,
                 GParamSpec *pspec,
                 GtkWidget  *button)
{
  gboolean has_text = gtk_entry_get_text_length(entry) > 0;
  gtk_entry_set_icon_sensitive ( entry, GTK_ENTRY_ICON_SECONDARY, has_text );
  gtk_widget_set_sensitive ( button, has_text );
}
Пример #25
0
static void
text_changed_cb (GtkEntry   *entry,
                 GParamSpec *pspec,
                 gpointer   data)
{
	if ( data ) {
		gboolean has_text = gtk_entry_get_text_length(entry) > 0;
		gtk_entry_set_icon_sensitive ( entry, GPOINTER_TO_INT(data), has_text );
	}
}
Пример #26
0
static void
gimp_action_editor_filter_changed (GtkEntry         *entry,
                                   GimpActionEditor *editor)
{
  gimp_action_view_set_filter (GIMP_ACTION_VIEW (editor->view),
                               gtk_entry_get_text (entry));
  gtk_entry_set_icon_sensitive (entry,
                                GTK_ENTRY_ICON_SECONDARY,
                                gtk_entry_get_text_length (entry) > 0);
}
Пример #27
0
long wxTextEntry::GetLastPosition() const
{
    // this can't be implemented for arbitrary GtkEditable so only do it for
    // GtkEntries
    long pos = -1;
    GtkEntry* entry = (GtkEntry*)GetEditable();
    if (GTK_IS_ENTRY(entry))
        pos = gtk_entry_get_text_length(entry);

    return pos;
}
Пример #28
0
	/**
	 * @brief This method does the filtering work for prefab list
	 * @param model current model to filter
	 * @param iter iterator to current row which should be checked
	 * @return true if entry should be visible (being a directory or matching search content), otherwise false
	 */
	gboolean PrefabSelector::callbackFilterFiles (GtkTreeModel *model, GtkTreeIter *iter, PrefabSelector *self)
	{
#if GTK_CHECK_VERSION(2,14,0)
		if (gtk_entry_get_text_length(self->_filterEntry) == 0)
			return true;
#else
		if (strlen(gtk_entry_get_text(self->_filterEntry)) == 0)
		return true;
#endif
		return FilterFileOrDirectory(model, iter, self);
	}
Пример #29
0
static unsigned int GetEntryTextLength(GtkEntry* entry)
{
#if GTK_CHECK_VERSION(2, 14, 0)
    if ( wx_is_at_least_gtk2(14) )
    {
        return gtk_entry_get_text_length(entry);
    }
#endif // GTK+ 2.14+

    return strlen(gtk_entry_get_text(entry));
}
Пример #30
0
static void
update_bookmark_from_text (NautilusBookmarksWindow *self)
{
	NautilusBookmark *bookmark, *bookmark_in_list;
	const char *name;
	GIcon *icon;
	guint selected_row;
	GtkTreeIter iter;
	GFile *location;

	if (!self->priv->text_changed ||
	    gtk_entry_get_text_length (GTK_ENTRY (self->priv->uri_field)) == 0) {
		return;
	}

	location = g_file_parse_name 
		(gtk_entry_get_text (GTK_ENTRY (self->priv->uri_field)));

	bookmark = nautilus_bookmark_new (location,
					  self->priv->name_text_changed ?
					  gtk_entry_get_text (GTK_ENTRY (self->priv->name_field)) : NULL,
					  NULL);
	g_object_unref (location);

	selected_row = get_selected_row (self);

	/* turn off list updating 'cuz otherwise the list-reordering code runs
	 * after repopulate(), thus reordering the correctly-ordered list.
	 */
	g_signal_handler_block (self->priv->bookmarks, self->priv->bookmarks_changed_id);
	nautilus_bookmark_list_delete_item_at (self->priv->bookmarks, selected_row);
	nautilus_bookmark_list_insert_item (self->priv->bookmarks, bookmark, selected_row);
	g_signal_handler_unblock (self->priv->bookmarks, self->priv->bookmarks_changed_id);
	g_object_unref (bookmark);

	/* We also have to update the bookmark pointer in the list
	   store. */
	gtk_tree_selection_get_selected (self->priv->selection, NULL, &iter);
	g_signal_handler_block (self->priv->model, self->priv->row_changed_id);

	bookmark_in_list = nautilus_bookmark_list_item_at (self->priv->bookmarks, selected_row);
	name = nautilus_bookmark_get_name (bookmark_in_list);
	icon = nautilus_bookmark_get_icon (bookmark_in_list);

	gtk_list_store_set (self->priv->model, &iter,
			    BOOKMARK_LIST_COLUMN_BOOKMARK, bookmark_in_list,
			    BOOKMARK_LIST_COLUMN_NAME, name,
			    BOOKMARK_LIST_COLUMN_ICON, icon,
			    -1);

	g_signal_handler_unblock (self->priv->model, self->priv->row_changed_id);
	g_object_unref (icon);
}