Пример #1
0
static GtkListBoxRow *
get_next_row_to_focus (GtkListBox    *listbox,
                       GtkListBoxRow *row)
{
  g_autoptr(GList) children = NULL;
  gint index;
  gint new_index;
  gint len;

  g_assert (GTK_IS_LIST_BOX (listbox));
  g_assert (GTK_IS_LIST_BOX_ROW (row));

  children = gtk_container_get_children (GTK_CONTAINER (listbox));
  if (0 == (len = g_list_length (children)))
    return NULL;

  index = gtk_list_box_row_get_index (row);
  if (index < len - 1)
    new_index = index + 1;
  else if (index == len - 1 && len > 1)
    new_index = index - 1;
  else
    return NULL;

  return gtk_list_box_get_row_at_index (listbox, new_index);
}
void set_listbox_active_path(GtkListBox*  widget,
                             GtkTreePath* path)
{
    GtkListBoxRow* row = gtk_list_box_get_row_at_index(widget, gtk_tree_path_get_indices(path)[0]);
    if(row)
        gtk_list_box_select_row(widget, row);
}
static void on_listbox_row_changed(GtkTreeModel*       model,
                                   GtkTreePath*        path,
                                   GtkTreeIter*        iter,
                                   PrivateListBoxData* data)
{
    GtkListBoxRow* row = gtk_list_box_get_row_at_index(data->widget, gtk_tree_path_get_indices(path)[0]);
    if(row)
    {
        GtkWidget* content = gtk_bin_get_child(GTK_BIN(row));
        for(GSList* item = data->model_bindings; item != NULL; item = item->next)
        {
            const ModelPropertyBinding* bind = item->data;
            GValue value = G_VALUE_INIT;
            gtk_tree_model_get_value(GTK_TREE_MODEL(model), iter, bind->column, &value);
            if(bind->widget)
            {
                GObject* child = gtk_widget_get_template_child(content, G_TYPE_FROM_INSTANCE(content), bind->widget);
                if(child)
                    g_object_set_property(child, bind->prop, &value);
            }
            else
                g_object_set_property(G_OBJECT(content), bind->prop, &value);
            g_value_unset(&value);
        }
    }
}
static void on_listbox_row_deleted(GtkTreeModel*       tree_model,
                                   GtkTreePath*        path,
                                   PrivateListBoxData* data)
{
    GtkListBoxRow* row = gtk_list_box_get_row_at_index(data->widget, gtk_tree_path_get_indices(path)[0]);
    if(row)
         gtk_widget_destroy(GTK_WIDGET(row));
}
Пример #5
0
static void on_delete_button_clicked(GtkButton* delete_button, Data* data) {
	if (data->index < 1) {
		return;
	}
	GtkListBoxRow* row = gtk_list_box_get_row_at_index(GTK_LIST_BOX(data->recordings_list_box), data->index - 1);

	const char* filename = gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(row))));
	char full_filename[strlen(data->recordings_dir_path) + 1 + strlen(filename)];
	sprintf(full_filename, "%s/%s", data->recordings_dir_path, filename);
	g_unlink(full_filename);
	update_recordings_list(data);
}
Пример #6
0
static void
ide_editor_spell_widget__language_notify_cb (IdeEditorSpellWidget *self,
                                             GParamSpec           *pspec,
                                             GtkButton            *language_chooser_button)
{
  const GspellLanguage *current_language;
  const GspellLanguage *spell_language;
  g_autofree gchar *word = NULL;
  g_autofree gchar *first_result = NULL;
  GtkListBoxRow *row;

  g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));
  g_assert (GTK_IS_BUTTON (language_chooser_button));

  current_language = gspell_checker_get_language (self->checker);
  spell_language = gspell_language_chooser_get_language (GSPELL_LANGUAGE_CHOOSER (language_chooser_button));
  if (gspell_language_compare (current_language, spell_language) != 0)
    {
      gspell_checker_set_language (self->checker, spell_language);
      fill_suggestions_box (self, word, &first_result);
      if (!ide_str_empty0 (first_result))
        {
          row = gtk_list_box_get_row_at_index (self->suggestions_box, 0);
          gtk_list_box_select_row (self->suggestions_box, row);
        }

      g_clear_pointer (&self->words_array, g_ptr_array_unref);
      if (current_language == NULL)
        {
          dict_clean_listbox (self);
          gtk_widget_set_sensitive (GTK_WIDGET (self->dict_add_button), FALSE);
          gtk_widget_set_sensitive (GTK_WIDGET (self->dict_words_list), FALSE);

          return;
        }

      ide_editor_spell_widget__dict_word_entry_changed_cb (self, GTK_ENTRY (self->dict_word_entry));
      gtk_widget_set_sensitive (GTK_WIDGET (self->dict_words_list), TRUE);

      ide_editor_spell_navigator_goto_word_start (IDE_EDITOR_SPELL_NAVIGATOR (self->navigator));
      jump_to_next_misspelled_word (self);
    }
}
Пример #7
0
static gboolean
jump_to_next_misspelled_word (IdeEditorSpellWidget *self)
{
  GspellChecker *checker = NULL;
  g_autofree gchar *word = NULL;
  g_autofree gchar *first_result = NULL;
  GtkListBoxRow *row;
  g_autoptr(GError) error = NULL;
  gboolean ret = FALSE;

  g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));

  gtk_widget_grab_focus (GTK_WIDGET (self->word_entry));
  if ((ret = gspell_navigator_goto_next (self->navigator, &word, &checker, &error)))
    {
      gtk_label_set_text (self->word_label, word);
      update_count_label (self);

      fill_suggestions_box (self, word, &first_result);
      if (!ide_str_empty0 (first_result))
        {
          row = gtk_list_box_get_row_at_index (self->suggestions_box, 0);
          gtk_list_box_select_row (self->suggestions_box, row);
        }
    }
  else
    {
      if (error != NULL)
        gtk_label_set_text (GTK_LABEL (self->placeholder), error->message);

      self->spellchecking_status = FALSE;

      gtk_label_set_text (GTK_LABEL (self->placeholder), _("Completed spell checking"));
      gtk_widget_grab_focus (self->dict_word_entry);
      update_global_sensiblility (self, FALSE);
    }

  return ret;
}