void FenetrePropriete_validation( GtkButton* button, gpointer data )
{
    FenetrePropriete* fp = (FenetrePropriete*)data;

    double dR,dG,dB,dA = 0;

    /* Maj des couleurs */
	dR = atof( gtk_entry_get_text( GTK_ENTRY( fp->entryR ) ) );
	dG = atof( gtk_entry_get_text( GTK_ENTRY( fp->entryG ) ) );
	dB = atof( gtk_entry_get_text( GTK_ENTRY( fp->entryB ) ) );
	dA = atof( gtk_entry_get_text( GTK_ENTRY( fp->entryA ) ) );

    Objet_set_Color( fp->objet, dR, dG, dB ,dA);

    Groupe* groupe = Groupe_trouver( fp->scene, gtk_combo_box_text_get_active_text( GTK_COMBO_BOX_TEXT(fp->comboBoxGroupe) ) ) ;
    Groupe* ancien = Groupe_trouver_ById( fp->scene, fp->objet->numeroGroupe );

    if( groupe->id != fp->objet->numeroGroupe )
    {
        Groupe_enlever_objet( ancien, fp->objet );
        Groupe_ajouter_Objet( groupe, fp->objet );

        gtk_tree_selection_unselect_iter( fp->scene->treeSelection, fp->objet->iter );
        gtk_tree_store_remove( fp->scene->store, fp->objet->iter );
        gtk_tree_store_append( fp->scene->store, fp->objet->iter, groupe->iter );
        gtk_tree_store_set( fp->scene->store, fp->objet->iter, GROUPE, "Cube", -1);
        gtk_tree_selection_select_iter( fp->scene->treeSelection, fp->objet->iter );

    }

    gtk_widget_queue_draw( fp->scene->zoneDeDessin );
    Selection_deselectionner_tout( fp->scene );
    gtk_widget_destroy( fp->fenetre );

}
Exemplo n.º 2
0
static void
banlist_crop (GtkWidget * wid, banlist_info *banl)
{
	session *sess = banl->sess;
	GtkTreeSelection *select;
	GSList *list = NULL, *node;
	int num_sel;

	/* remember which bans are selected */
	select = gtk_tree_view_get_selection (get_view (sess));
	/* gtk_tree_selected_get_selected_rows() isn't present in gtk 2.0.x */
	gtk_tree_selection_selected_foreach (select, banlist_add_selected_cb,
	                                     &list);

	num_sel = g_slist_length (list);
	/* select all, then unselect those that we remembered */
	if (num_sel)
	{
		gtk_tree_selection_select_all (select);

		for (node = list; node; node = node->next)
			gtk_tree_selection_unselect_iter (select, node->data);

		g_slist_foreach (list, (GFunc)g_free, NULL);
		g_slist_free (list);

		banlist_unban (NULL, banl);
	} else
		fe_message (_("You must select some bans."), FE_MSG_ERROR);
}
Exemplo n.º 3
0
void wxListBox::DoSetSelection( int n, bool select )
{
    wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") );

    wxGtkEventsDisabler<wxListBox> noEvents(this);

    GtkTreeSelection* selection = gtk_tree_view_get_selection(m_treeview);

    // passing -1 to SetSelection() is documented to deselect all items
    if ( n == wxNOT_FOUND )
    {
        gtk_tree_selection_unselect_all(selection);
        return;
    }

    wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetSelection") );


    GtkTreeIter iter;
    wxCHECK_RET( GTKGetIteratorFor(n, &iter), wxT("Invalid index") );

    if (select)
        gtk_tree_selection_select_iter(selection, &iter);
    else
        gtk_tree_selection_unselect_iter(selection, &iter);

    wxGtkTreePath path(
            gtk_tree_model_get_path(GTK_TREE_MODEL(m_liststore), &iter));

    gtk_tree_view_scroll_to_cell(m_treeview, path, NULL, FALSE, 0.0f, 0.0f);
}
Exemplo n.º 4
0
void
userlist_select (session *sess, char *name)
{
	GtkTreeIter iter;
	GtkTreeView *treeview = GTK_TREE_VIEW (sess->gui->user_tree);
	GtkTreeModel *model = gtk_tree_view_get_model (treeview);
	GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
	struct User *row_user;

	if (gtk_tree_model_get_iter_first (model, &iter))
	{
		do
		{
			gtk_tree_model_get (model, &iter, COL_USER, &row_user, -1);
			if (sess->server->p_cmp (row_user->nick, name) == 0)
			{
				if (gtk_tree_selection_iter_is_selected (selection, &iter))
					gtk_tree_selection_unselect_iter (selection, &iter);
				else
					gtk_tree_selection_select_iter (selection, &iter);

				/* and make sure it's visible */
				scroll_to_iter (&iter, treeview, model);
				return;
			}
		}
		while (gtk_tree_model_iter_next (model, &iter));
	}
}
Exemplo n.º 5
0
static void
fsearch_window_action_invert_selection (GSimpleAction *action,
                                        GVariant      *variant,
                                        gpointer       user_data)
{
    // TODO: can be very slow. Find a way how to optimize that.
    FsearchApplicationWindow *self = user_data;
    GtkTreeSelection *selection = fsearch_application_window_get_listview_selection (self);
    if (!selection) {
        return;
    }
    GtkTreeModel *model = NULL;
    GList *selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
    if (!selected_rows) {
        return;
    }
    if (!model) {
        return;
    }
    gtk_tree_selection_select_all (selection);

    GList *temp  = selected_rows;
    while (temp) {
        GtkTreePath *path = temp->data;
        GtkTreeIter iter = {0};
        if (gtk_tree_model_get_iter (model, &iter, path)) {
            gtk_tree_selection_unselect_iter (selection, &iter);
        }
        temp = temp->next;
    }
    g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
}
Exemplo n.º 6
0
static void
tree_selection_unselect_helper(gpointer data, gpointer user_data)
{
	GtkTreeSelection *s = user_data;
	GtkTreeIter *iter = data;

	gtk_tree_selection_unselect_iter(s, iter);
	w_tree_iter_free(iter);
}
Exemplo n.º 7
0
void GtkTreeSelection_::unselect_iter(Php::Parameters &parameters)
{
	Php::Value object_iter = parameters[0];
	GtkTreeIter_ *phpgtk_iter = (GtkTreeIter_ *)object_iter.implementation();
	GtkTreeIter iter = phpgtk_iter->get_instance();

	gtk_tree_selection_unselect_iter (GTK_TREE_SELECTION(instance), &iter);

}
static void
gnc_gen_trans_row_changed_cb (GtkTreeSelection *selection,
                              GNCImportMainMatcher *gui)
{
    GtkTreeModel *model;
    GtkTreeIter iter;

    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
        return;
    gtk_tree_selection_unselect_iter(selection, &iter);
}
Exemplo n.º 9
0
void
music_store_selection_changed(int store_type) {

	GtkTreeIter iter;

	if (gtk_tree_selection_get_selected(music_select, NULL, &iter) &&
	    (store_type == STORE_TYPE_ALL || iter_get_store_type(&iter) == store_type)) {

		gtk_tree_selection_unselect_iter(music_select, &iter);
		gtk_tree_selection_select_iter(music_select, &iter);
	}
}
Exemplo n.º 10
0
void
on_plugin_remove_button_clicked        (GtkButton       *button,
                                        gpointer         user_data)
{
	KTPluginInfoEntry	*plugin;
	GtkWidget		*question_dialog;
	gint			response;
	GtkTreeSelection	*selection;
	GtkTreeIter		iter;
	GtkTreeModel		*model;
	
	plugin = get_selected_plugin();
	if (plugin != NULL)
	{
		question_dialog = gtk_message_dialog_new(
					GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))), 
					GTK_DIALOG_MODAL,
					GTK_MESSAGE_QUESTION,
					GTK_BUTTONS_YES_NO,
					_("Do you really want to remove the plugin \"%s\"?"),
					plugin->info.name);
		/*
		 * Block the interaction with the other windows, so that
		 * the user can only use this window
		 */
		gtk_grab_add (question_dialog);
		response = gtk_dialog_run(GTK_DIALOG(question_dialog));
		gtk_widget_destroy (question_dialog);
		/* If the user pressed the "Yes"-button */
		if (response == GTK_RESPONSE_YES)
		{
			remove_plugin (plugin, &plugin_list);
			reload_plugin_treeview (KTGUI_plugin_treeview(), &plugin_list);
			reload_plugin_list (KTGUI_plugin_combo_list(),
			                    GTK_OBJECT( KTGUI_plugin_combo_entry() ),
			                    on_plugin_combo_entry_changed,
			                    &plugin_list);
			
			selection = gtk_tree_view_get_selection( KTGUI_key_treeview() );
			/* If a key is selected */
			if (gtk_tree_selection_get_selected(selection, &model, &iter))
			{
				/* Reselect it */
				gtk_tree_selection_unselect_iter (selection, &iter);
				gtk_tree_selection_select_iter (selection, &iter);
			}
		}
	}
}
Exemplo n.º 11
0
void gTree::setRowSelected(char *key,bool vl)
{
	GtkTreeSelection *sel;
	gTreeRow *row = (gTreeRow*)g_hash_table_lookup(datakey, (gconstpointer)key);
	if (!row) return;
	
	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
	if (!sel) return;
	
	_no_click++;
	if (vl)
		gtk_tree_selection_select_iter(sel,row->dataiter);
	else
		gtk_tree_selection_unselect_iter(sel,row->dataiter);
	_no_click--;
}
Exemplo n.º 12
0
static void
toggle_selection_window (GdkWindow *window)
{
    GtkTreeSelection *selection;
    GtkTreeIter iter;

    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));

    if (window != NULL &&
            find_window (window, &iter))
    {
        if (gtk_tree_selection_iter_is_selected (selection, &iter))
            gtk_tree_selection_unselect_iter (selection,  &iter);
        else
            gtk_tree_selection_select_iter (selection,  &iter);
    }
}
Exemplo n.º 13
0
void fl_select_next_file()
{
	GtkTreeSelection *selection;
	GtkTreeModel *model;
	GtkTreeIter iter;

	selection = gtk_tree_view_get_selection(tv_files);

	if (gtk_tree_selection_count_selected_rows(selection) != 1)
		return;

	if (gtk_tree_view_get_first_selected(tv_files, &model, &iter)) {
		gtk_tree_selection_unselect_iter(selection, &iter);
		if (gtk_tree_model_iter_next(model, &iter))
			gtk_tree_selection_select_iter(selection, &iter);
	}
}
Exemplo n.º 14
0
/**
 * cryptui_key_store_set_selected_keys:
 * @ckstore: a libcryptui key store
 * @view: a GtkTreeView
 * @keys: a list of libcryptui keys
 *
 * Set the current selection to be the list of keys
 */
void
cryptui_key_store_set_selected_keys (CryptUIKeyStore *ckstore, GtkTreeView *view,
                                     GList *keys)
{
    GtkTreeModel* model = GTK_TREE_MODEL (ckstore->priv->store);
    GtkTreeSelection *sel;
    GHashTable *keyset;
    GtkTreeIter iter;
    const gchar *key;
    gboolean have;

    g_return_if_fail (CRYPTUI_IS_KEY_STORE (ckstore));
    g_return_if_fail (GTK_IS_TREE_VIEW (view));

    sel = gtk_tree_view_get_selection (view);

    /* A quick lookup table for the keys */
    keyset = g_hash_table_new (g_str_hash, g_str_equal);
    for (; keys; keys = g_list_next (keys))
        g_hash_table_insert (keyset, keys->data, GINT_TO_POINTER (TRUE));

    /* Go through all rows and select deselect as necessary */
    if (gtk_tree_model_get_iter_first (model, &iter)) {
        do {

            /* Is this row in our selection? */
            gtk_tree_model_get (model, &iter, CRYPTUI_KEY_STORE_KEY, &key, -1);
            have = (key && g_hash_table_lookup (keyset, key) != NULL) ? TRUE : FALSE;

            /* Using checks so change data store */
            if (ckstore->priv->use_checks)
                gtk_tree_store_set (ckstore->priv->store, &iter, CRYPTUI_KEY_STORE_CHECK, have, -1);

            /* Using normal selection */
            else if (have)
                gtk_tree_selection_select_iter (sel, &iter);
            else
                gtk_tree_selection_unselect_iter (sel, &iter);

        } while (gtk_tree_model_iter_next (model, &iter));
    }

    g_hash_table_destroy (keyset);
}
Exemplo n.º 15
0
void SelectUnselectRow(int selno, int unselno)
{
  GtkTreeView *table = (GtkTreeView *)glade_xml_get_widget(windowXML, "table");
  GtkTreeModel *model = gtk_tree_view_get_model(table);
  GtkTreeSelection *selection = gtk_tree_view_get_selection(table);
  GtkTreeIter iter;

  if (gtk_tree_model_get_iter_first(model, &iter) == FALSE)  return;
  int i=0;
  do {
    if (i == selno) {
      gtk_tree_selection_select_iter(selection, &iter);
    }
    if (i== unselno) {
      gtk_tree_selection_unselect_iter(selection, &iter);
    }
    i++;
  } while (gtk_tree_model_iter_next(model, &iter));
}
Exemplo n.º 16
0
static void
selection_set_selected(Selection_t *selection, gint row)
{
  GtkTreeIter iter;

  if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selection->store), &iter,
				     NULL, row)) {
    Object_t *obj;

    gtk_tree_model_get (GTK_TREE_MODEL(selection->store), &iter, 0, &obj, -1);

    selection->select_lock = TRUE;

    if (obj->selected) {
      gtk_tree_selection_select_iter (selection->selection, &iter);
    } else {
      gtk_tree_selection_unselect_iter (selection->selection, &iter);
    }
  }
}
Exemplo n.º 17
0
void fm_folder_view_select_invert(FmFolderView* fv)
{
    switch(fv->mode)
    {
    case FM_FV_LIST_VIEW:
        {
            GtkTreeSelection *tree_sel;
            GtkTreeIter it;
            if(!gtk_tree_model_get_iter_first(fv->model, &it))
                return;
            tree_sel = gtk_tree_view_get_selection((GtkTreeView*)fv->view);
            do
            {
                if(gtk_tree_selection_iter_is_selected(tree_sel, &it))
                    gtk_tree_selection_unselect_iter(tree_sel, &it);
                else
                    gtk_tree_selection_select_iter(tree_sel, &it);
            }while( gtk_tree_model_iter_next(fv->model, &it ));
            break;
        }
    case FM_FV_ICON_VIEW:
    case FM_FV_COMPACT_VIEW:
    case FM_FV_THUMBNAIL_VIEW:
        {
            GtkTreePath* path;
            int i, n;
            n = gtk_tree_model_iter_n_children(fv->model, NULL);
            if(n == 0)
                return;
            path = gtk_tree_path_new_first();
            for( i=0; i<n; ++i, gtk_tree_path_next(path) )
            {
                if ( exo_icon_view_path_is_selected((ExoIconView*)fv->view, path))
                    exo_icon_view_unselect_path((ExoIconView*)fv->view, path);
                else
                    exo_icon_view_select_path((ExoIconView*)fv->view, path);
            }
            break;
        }
    }
}
Exemplo n.º 18
0
static void
shapes_selection_removed(GwyCoordsView *view,
                         gint n,
                         G_GNUC_UNUSED GwyIntSet *intset)
{
    CoordsView *priv = view->priv;
    if (priv->sync_view_to_shapes)
        return;

    g_assert(n >= 0);
    GtkTreeView *treeview = GTK_TREE_VIEW(view);
    GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
    GtkTreeIter iter;
    if (gwy_list_store_get_iter(priv->store, n, &iter)) {
        priv->sync_shapes_to_view = TRUE;
        gtk_tree_selection_unselect_iter(selection, &iter);
        priv->sync_shapes_to_view = FALSE;
    }
    else
        g_critical("Cannot get iter for item #%d", n);
}
Exemplo n.º 19
0
static void
gimp_component_editor_active_changed (GimpImage           *image,
                                      GimpChannelType      channel,
                                      GimpComponentEditor *editor)
{
  GtkTreeIter iter;

  if (gimp_component_editor_get_iter (editor, channel, &iter))
    {
      gboolean active = gimp_image_get_component_active (image, channel);

      if (gtk_tree_selection_iter_is_selected (editor->selection, &iter) !=
          active)
        {
          if (active)
            gtk_tree_selection_select_iter (editor->selection, &iter);
          else
            gtk_tree_selection_unselect_iter (editor->selection, &iter);
        }
    }
}
Exemplo n.º 20
0
/**
 * cryptui_key_store_set_selected_key:
 * @ckstore: a libcryptui key store
 * @view: a GtkTreeView
 * @selkey: a libcryptui key
 *
 * Marks the given key as selected
 */
void
cryptui_key_store_set_selected_key (CryptUIKeyStore *ckstore, GtkTreeView *view,
                                    const gchar *selkey)
{
    GtkTreeModel* model = GTK_TREE_MODEL (ckstore->priv->store);
    GtkTreeSelection *sel;
    GtkTreeIter iter, sel_iter;
    const gchar *key;
    gboolean have;

    g_return_if_fail (CRYPTUI_IS_KEY_STORE (ckstore));
    g_return_if_fail (GTK_IS_TREE_VIEW (view));

    sel = gtk_tree_view_get_selection (view);

    /* Go through all rows and select deselect as necessary */
    if (gtk_tree_model_get_iter_first (model, &iter)) {
        do {

            /* Is this row in our selection? */
            gtk_tree_model_get (model, &iter, CRYPTUI_KEY_STORE_KEY, &key, -1);
            have = (key && strcmp (selkey, key) == 0) ? TRUE : FALSE;

            if (ckstore->priv->use_checks) {
                /* Using checks so change data store */
                gtk_tree_store_set (ckstore->priv->store, &iter, CRYPTUI_KEY_STORE_CHECK, have, -1);
            } else {
                key_store_get_view_iter (ckstore, &iter, &sel_iter);

                /* Using normal selection */
                if (have)
                    gtk_tree_selection_select_iter (sel, &sel_iter);
                else
                    gtk_tree_selection_unselect_iter (sel, &sel_iter);
            }

        } while (gtk_tree_model_iter_next (model, &iter));
    }
}
Exemplo n.º 21
0
/****************************************************************
  Remove current itree item from selection
*****************************************************************/
void itree_unselect(GtkTreeSelection *selection, ITree *it)
{
  gtk_tree_selection_unselect_iter(selection, &it->it);
}
Exemplo n.º 22
0
static void
account_list_changed_cb(GtkTreeSelection *selection, gpointer user_data)
{
    ABInitialInfo *info = user_data;
    GtkTreeModel *model;
    GtkTreeIter iter;
    AB_ACCOUNT *ab_acc;
    gchar *longname, *gnc_name;
    Account *old_value, *gnc_acc;
    const gchar *currency;
    gnc_commodity *commodity = NULL;
    gboolean ok_pressed;

    g_return_if_fail(info);

    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
        return;
    gtk_tree_model_get(model, &iter, ACCOUNT_LIST_COL_AB_ACCT, &ab_acc, -1);

    /* Avoid recursion when unselecting the item again */
    g_signal_handlers_block_by_func(selection, account_list_changed_cb, info);
    gtk_tree_selection_unselect_iter(selection, &iter);
    g_signal_handlers_unblock_by_func(selection, account_list_changed_cb, info);

    if (ab_acc)
    {
        old_value = g_hash_table_lookup(info->gnc_hash, ab_acc);

        longname = ab_account_longname(ab_acc);
        currency = AB_Account_GetCurrency(ab_acc);
        if (currency && *currency)
        {
            commodity = gnc_commodity_table_lookup(
                            gnc_commodity_table_get_table(gnc_get_current_book()),
                            GNC_COMMODITY_NS_CURRENCY,
                            currency);
        }

        gnc_acc = gnc_import_select_account(info->window, NULL, TRUE,
                                            longname, commodity, ACCT_TYPE_BANK,
                                            old_value, &ok_pressed);
        g_free(longname);

        if (ok_pressed && old_value != gnc_acc)
        {
            if (gnc_acc)
            {
                RevLookupData data;

                /* Lookup and clear other mappings to gnc_acc */
                data.gnc_acc = gnc_acc;
                data.ab_acc = NULL;
                g_hash_table_find(info->gnc_hash, (GHRFunc) find_gnc_acc_cb,
                                  &data);
                if (data.ab_acc)
                {
                    g_hash_table_remove(info->gnc_hash, data.ab_acc);
                    gtk_tree_model_foreach(
                        GTK_TREE_MODEL(info->account_store),
                        (GtkTreeModelForeachFunc) clear_line_cb,
                        &data);
                }

                /* Map ab_acc to gnc_acc */
                g_hash_table_insert(info->gnc_hash, ab_acc, gnc_acc);
                gnc_name = gnc_account_get_full_name(gnc_acc);
                gtk_list_store_set(info->account_store, &iter,
                                   ACCOUNT_LIST_COL_GNC_NAME, gnc_name,
                                   ACCOUNT_LIST_COL_CHECKED, TRUE,
                                   -1);
                g_free(gnc_name);

            }
            else
            {
                g_hash_table_remove(info->gnc_hash, ab_acc);
                gtk_list_store_set(info->account_store, &iter,
                                   ACCOUNT_LIST_COL_GNC_NAME, "",
                                   ACCOUNT_LIST_COL_CHECKED, TRUE,
                                   -1);
            }
        }
    }
}