/**
 * gimp_color_profile_combo_box_set_active_file:
 * @combo: a #GimpColorProfileComboBox
 * @file:  file of the profile to select
 * @label: label to use when adding a new entry (can be %NULL)
 *
 * Selects a color profile from the @combo and makes it the active
 * item.  If the profile is not listed in the @combo, then it is added
 * with the given @label (or @file in case that @label is %NULL).
 *
 * Since: 2.10
 **/
void
gimp_color_profile_combo_box_set_active_file (GimpColorProfileComboBox *combo,
                                              GFile                    *file,
                                              const gchar              *label)
{
  GimpColorProfile *profile = NULL;
  GtkTreeModel     *model;
  GtkTreeIter       iter;

  g_return_if_fail (GIMP_IS_COLOR_PROFILE_COMBO_BOX (combo));
  g_return_if_fail (file == NULL || G_IS_FILE (file));

  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));

  if (file && ! (label && *label))
    {
      GError *error = NULL;

      profile = gimp_color_profile_new_from_file (file, &error);

      if (! profile)
        {
          g_message ("%s", error->message);
          g_clear_error (&error);
        }
      else
        {
          label = gimp_color_profile_get_label (profile);
        }
    }

  if (_gimp_color_profile_store_history_add (GIMP_COLOR_PROFILE_STORE (model),
                                             file, label, &iter))
    {
      gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter);
    }

  if (profile)
    g_object_unref (profile);
}
static void
set_lock_value_for_combo (GtkComboBox *combo_box, CcScreenPanel *self)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  guint value;
  gint value_tmp, value_prev;
  gboolean ret;
  guint i;

  /* get entry */
  model = gtk_combo_box_get_model (combo_box);
  ret = gtk_tree_model_get_iter_first (model, &iter);
  if (!ret)
    return;

  value_prev = 0;
  i = 0;

  /* try to make the UI match the lock setting */
  g_settings_get (self->priv->lock_settings, "lock-delay", "u", &value);

  do
    {
      gtk_tree_model_get (model, &iter,
                          1, &value_tmp,
                          -1);
      if (value == value_tmp ||
          (value_tmp > value_prev && value < value_tmp))
        {
          gtk_combo_box_set_active_iter (combo_box, &iter);
          return;
        }
      value_prev = value_tmp;
      i++;
    } while (gtk_tree_model_iter_next (model, &iter));

  /* If we didn't find the setting in the list */
  gtk_combo_box_set_active (combo_box, i - 1);
}
Esempio n. 3
0
static void fill_combo_box_entry(GtkComboBox **box, uint32_t count, GList **items, gboolean *multi)
{
  GList *iter;

  // FIXME: use gtk_combo_box_text_remove_all() in future (gtk 3.0)
  // https://bugzilla.gnome.org/show_bug.cgi?id=324899
  gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(*box))));

  // FIXME: how to make a nice empty combo box without the append/remove?
  if(count == 0)
  {
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(*box), "");
    gtk_combo_box_set_active(GTK_COMBO_BOX(*box), 0);
    gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(*box), 0);

    *multi = FALSE;
    return;
  }

  if(count>1)
  {
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(*box), _("<leave unchanged>")); // FIXME: should be italic!
    gtk_combo_box_set_button_sensitivity(GTK_COMBO_BOX(*box), GTK_SENSITIVITY_AUTO);
    *multi = TRUE;
  }
  else
  {
    gtk_combo_box_set_button_sensitivity(GTK_COMBO_BOX(*box), GTK_SENSITIVITY_OFF);
    *multi = FALSE;
  }
  if((iter = g_list_first(*items)) != NULL)
  {
    do
    {
      gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(*box), iter->data); // FIXME: dt segfaults when there are illegal characters in the string.
    }
    while((iter=g_list_next(iter)) != NULL);
  }
  gtk_combo_box_set_active(GTK_COMBO_BOX(*box), 0);
}
static void
screen_position_notify_cb (GSettings *settings,
                           const gchar *key,
                           ZoomOptions *options)
{
  ZoomOptionsPrivate *priv = options->priv;
  gchar *position;
  GtkTreeIter iter;
  GtkTreeModel *model;
  GtkComboBox *combobox;
  gboolean valid;
  gchar *combo_value;

  position = g_settings_get_string (settings, key);
  position = g_settings_get_string (priv->settings, key);
  combobox = GTK_COMBO_BOX (WID ("screen_position_combo_box"));
  model = gtk_combo_box_get_model (combobox);

  /* Find the matching screen position value in the combobox model.  If nothing
   * matches, leave the combobox as is.
   */
  valid = gtk_tree_model_get_iter_first (model, &iter);
  while (valid)
    {
        gtk_tree_model_get (model, &iter,
                            POSITION_MODEL_VALUE_COLUMN, &combo_value,
                            -1);
        if (!g_strcmp0 (combo_value, position))
          {
            g_signal_handlers_block_by_func (combobox, screen_position_combo_changed_cb, priv);
            gtk_combo_box_set_active_iter (combobox, &iter);
            g_signal_handlers_unblock_by_func (combobox, screen_position_combo_changed_cb, priv);
            g_free (combo_value);
            break;
          }

        g_free (combo_value);
        valid = gtk_tree_model_iter_next (model, &iter);
    }
}
Esempio n. 5
0
static gint
get_combo_box_index_by_value (GtkComboBox *combobox,
                              gint         value)
{
    GtkTreeModel *model;
    GtkTreeIter iter;
    gint index;

    index = 0;
    model = gtk_combo_box_get_model (combobox);
    if (!gtk_tree_model_get_iter_first (model, &iter))
        return -1;

    do {
        gint _value;
        gtk_tree_model_get (model, &iter, COLUMN_VALUE, &_value, -1);
        if (_value == value)
            return index;
        index++;
    } while (gtk_tree_model_iter_next (model, &iter));
    return -1;
}
Esempio n. 6
0
guint
get_selected_renderer_volume (void)
{
    GtkComboBox  *combo;
    GtkTreeModel *model;
    GtkTreeIter   iter;
    guint         volume;

    combo = GTK_COMBO_BOX (renderer_combo);
    model = gtk_combo_box_get_model (combo);
    g_assert (model != NULL);

    if (!gtk_combo_box_get_active_iter (combo, &iter)) {
        return 0;
    }

    gtk_tree_model_get (model, &iter,
                        RENDERER_COMBO_COLUMN_VOLUME, &volume,
                        -1);

    return volume;
}
Esempio n. 7
0
static void
state_changed_cb(MafwRenderer *renderer,
                 MafwPlayState state,
                 gpointer user_data)
{
    const gchar  *uuid;
    GtkTreeModel *model;
    GtkTreeIter   iter;

    mtg_print_signal (MAFW_EXTENSION (renderer), "Renderer::state-changed",
                      "state:%s (%d)\n", state_to_string (state), state);

    uuid = mafw_extension_get_uuid(MAFW_EXTENSION(renderer));

    model = gtk_combo_box_get_model
            (GTK_COMBO_BOX (renderer_combo));
    g_assert (model != NULL);

    if (find_renderer (model, uuid, &iter)) {
        set_state (model, &iter, state);
    }
}
Esempio n. 8
0
static gboolean remmina_file_editor_iterate_protocol(gchar* protocol, RemminaPlugin* plugin, gpointer data)
{
	RemminaFileEditor* gfe = REMMINA_FILE_EDITOR(data);
	GtkListStore* store;
	GtkTreeIter iter;
	gboolean first;

	store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(gfe->priv->protocol_combo)));

	first = !gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);

	gtk_list_store_append(store, &iter);
	gtk_list_store_set(store, &iter, 0, protocol, 1, g_dgettext(plugin->domain, plugin->description), 2,
			((RemminaProtocolPlugin*) plugin)->icon_name, -1);

	if (first || g_strcmp0(protocol, remmina_file_get_string(gfe->priv->remmina_file, "protocol")) == 0)
	{
		gtk_combo_box_set_active_iter(GTK_COMBO_BOX(gfe->priv->protocol_combo), &iter);
	}

	return FALSE;
}
Esempio n. 9
0
static const char *getActiveValue( GtkComboBox *comboBox )
{
   const char *val = NULL;
   if( GTK_IS_COMBO_BOX_ENTRY( comboBox ) )
   {
      val = gtk_entry_get_text( getEntry( comboBox ) );
   }
   else
   {
      const int active  = gtk_combo_box_get_active( comboBox );
      if( active > -1 )
      {
         GtkTreePath  *path  = gtk_tree_path_new_from_indices( active, -1 );
         GtkTreeModel *model = gtk_combo_box_get_model( comboBox );
         GtkTreeIter  iter;
         gtk_tree_model_get_iter( model, &iter, path );
         gtk_tree_path_free( path );
         gtk_tree_model_get( model, &iter, VALUE_COLUMN, &val, -1 );
      }
   }
   return val;
}
static void
source_changed_cb (GtkComboBox              *combo,
                   CcBackgroundPanelPrivate *priv)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  GtkIconView *view;
  guint type;
  BgSource *source;

  gtk_combo_box_get_active_iter (combo, &iter);
  model = gtk_combo_box_get_model (combo);
  gtk_tree_model_get (model, &iter,
                      COL_SOURCE_TYPE, &type,
                      COL_SOURCE, &source, -1);

  view = (GtkIconView *) gtk_builder_get_object (priv->builder,
                                                 "backgrounds-iconview");

  gtk_icon_view_set_model (view,
                           GTK_TREE_MODEL (bg_source_get_liststore (source)));
}
Esempio n. 11
0
static void remote_content_set_labels_cb(GtkWidget *button, FancyPrefsPage *prefs_page)
{
	GtkTreeModel *model;
	GtkTreeIter iter;
	gboolean remote_enabled = gtk_toggle_button_get_active(
					GTK_TOGGLE_BUTTON(prefs_page->enable_remote_content));

	/* Enable images */
	gtk_button_set_label(GTK_BUTTON(prefs_page->enable_images),
			     remote_enabled ? _("Display images")
					    : _("Display embedded images"));

	/* Enable Javascript */
	gtk_button_set_label(GTK_BUTTON(prefs_page->enable_scripts),
			     remote_enabled ? _("Execute javascript")
					    : _("Execute embedded javascript"));

	/* Enable java */
	gtk_button_set_label(GTK_BUTTON(prefs_page->enable_java),
			     remote_enabled ? _("Execute Java applets")
					    : _("Execute embedded Java applets"));

	/* Enable plugins */
	gtk_button_set_label(GTK_BUTTON(prefs_page->enable_plugins),
			     remote_enabled ? _("Render objects using plugins")
					    : _("Render embedded objects using plugins"));

	/* Open links */
	model = gtk_combo_box_get_model(GTK_COMBO_BOX(prefs_page->open_external));
	if (gtk_tree_model_get_iter_first (model, &iter)) {
		if (remote_enabled)
			gtk_list_store_set(GTK_LIST_STORE(model), &iter, COMBOBOX_TEXT,
					   _("Open in viewer (remote content is enabled)"), -1);
		else
			gtk_list_store_set(GTK_LIST_STORE(model), &iter, COMBOBOX_TEXT,
					   _("Do nothing (remote content is disabled)"), -1);
	}

}
Esempio n. 12
0
static gboolean rygel_general_pref_section_find_interface (RygelGeneralPrefSection* self, const char* iface, GtkTreeIter* iter) {
#line 512 "rygel-general-pref-section.c"
	gboolean result = FALSE;
	GtkTreeModel* model;
	gboolean more;
#line 143 "rygel-general-pref-section.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 143 "rygel-general-pref-section.vala"
	g_return_val_if_fail (iface != NULL, FALSE);
#line 144 "rygel-general-pref-section.vala"
	model = _g_object_ref0 (gtk_combo_box_get_model ((GtkComboBox*) self->priv->iface_entry));
#line 145 "rygel-general-pref-section.vala"
	more = gtk_tree_model_get_iter_first (model, iter);
#line 146 "rygel-general-pref-section.vala"
	while (TRUE) {
#line 146 "rygel-general-pref-section.vala"
		if (!more) {
#line 146 "rygel-general-pref-section.vala"
			break;
#line 530 "rygel-general-pref-section.c"
		}
#line 147 "rygel-general-pref-section.vala"
		gtk_tree_model_get (model, iter, 0, &((RygelPreferencesSection*) self)->name, -1, -1);
#line 149 "rygel-general-pref-section.vala"
		if (_vala_strcmp0 (((RygelPreferencesSection*) self)->name, iface) == 0) {
#line 150 "rygel-general-pref-section.vala"
			break;
#line 538 "rygel-general-pref-section.c"
		}
#line 153 "rygel-general-pref-section.vala"
		more = gtk_tree_model_iter_next (model, iter);
#line 542 "rygel-general-pref-section.c"
	}
	result = more;
	_g_object_unref0 (model);
#line 156 "rygel-general-pref-section.vala"
	return result;
#line 548 "rygel-general-pref-section.c"
}
Esempio n. 13
0
static void rygel_general_pref_section_on_context_unavailable (RygelGeneralPrefSection* self, GUPnPContextManager* manager, GUPnPContext* context) {
#line 487 "rygel-general-pref-section.c"
	GtkTreeIter iter = {0};
#line 133 "rygel-general-pref-section.vala"
	g_return_if_fail (self != NULL);
#line 133 "rygel-general-pref-section.vala"
	g_return_if_fail (manager != NULL);
#line 133 "rygel-general-pref-section.vala"
	g_return_if_fail (context != NULL);
#line 137 "rygel-general-pref-section.vala"
	if (rygel_general_pref_section_find_interface (self, gssdp_client_get_interface ((GSSDPClient*) context), &iter)) {
#line 497 "rygel-general-pref-section.c"
		GtkTreeModel* _tmp0_;
		GtkListStore* list_store;
#line 138 "rygel-general-pref-section.vala"
		list_store = _g_object_ref0 ((_tmp0_ = gtk_combo_box_get_model ((GtkComboBox*) self->priv->iface_entry), GTK_IS_LIST_STORE (_tmp0_) ? ((GtkListStore*) _tmp0_) : NULL));
#line 139 "rygel-general-pref-section.vala"
		gtk_list_store_remove (list_store, &iter);
#line 504 "rygel-general-pref-section.c"
		_g_object_unref0 (list_store);
	}
}
Esempio n. 14
0
static void _xfdashboard_settings_xfconf_changed_switch_view_on_resume(XfdashboardSettings *self,
																		const gchar *inProperty,
																		const GValue *inValue,
																		XfconfChannel *inChannel)
{
	XfdashboardSettingsPrivate		*priv;
	GtkTreeModel					*model;
	GtkTreeIter						iter;
	gchar							*value;
	const gchar						*newValue;

	g_return_if_fail(XFDASHBOARD_IS_SETTINGS(self));
	g_return_if_fail(inValue);
	g_return_if_fail(XFCONF_IS_CHANNEL(inChannel));

	priv=self->priv;

	/* Get new value to lookup and set at combo box */
	if(G_UNLIKELY(G_VALUE_TYPE(inValue)!=G_TYPE_STRING)) newValue="";
		else newValue=g_value_get_string(inValue);

	/* Iterate through combo box value and set new value if match is found */
	model=gtk_combo_box_get_model(GTK_COMBO_BOX(priv->widgetSwitchViewOnResume));
	if(gtk_tree_model_get_iter_first(model, &iter))
	{
		do
		{
			gtk_tree_model_get(model, &iter, 1, &value, -1);
			if(G_UNLIKELY(g_str_equal(value, newValue)))
			{
				g_free(value);
				gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->widgetSwitchViewOnResume), &iter);
				break;
			}
			g_free(value);
		}
		while(gtk_tree_model_iter_next(model, &iter));
	}
}
static void
preferences_theme_changed_cb (GtkComboBox        *combo,
			      EmpathyPreferences *preferences)
{
	EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
	GtkTreeIter   iter;

	if (gtk_combo_box_get_active_iter (combo, &iter)) {
		GtkTreeModel *model;
		gboolean      is_adium;
		gchar        *name;
		gchar        *path;
		GHashTable   *info;

		model = gtk_combo_box_get_model (combo);
		gtk_tree_model_get (model, &iter,
				    COL_THEME_IS_ADIUM, &is_adium,
				    COL_THEME_NAME, &name,
				    COL_THEME_ADIUM_PATH, &path,
				    COL_THEME_ADIUM_INFO, &info,
				    -1);

		g_settings_set_string (priv->gsettings_chat,
				       EMPATHY_PREFS_CHAT_THEME,
				       name);
		if (is_adium) {
			g_settings_set_string (priv->gsettings_chat,
					       EMPATHY_PREFS_CHAT_ADIUM_PATH,
					       path);
			preferences_theme_variants_fill (preferences, info);
			gtk_widget_show (priv->hbox_chat_theme_variant);
		} else {
			gtk_widget_hide (priv->hbox_chat_theme_variant);
		}
		g_free (name);
		g_free (path);
		tp_clear_pointer (&info, g_hash_table_unref);
	}
}
Esempio n. 16
0
void change_mouse(GtkComboBox *combo, gpointer data)
{
	char* mouse_type;

	GtkTreeIter iter;
	GtkTreeModel *model;
	gtk_combo_box_get_active_iter(combo, &iter);
	model = gtk_combo_box_get_model(combo);
	gtk_tree_model_get (model, &iter, 0, &mouse_type, -1);

	if(!strcmp(mouse_type, "bar") || !strcmp(mouse_type, "ms") || !strcmp(mouse_type, "mman") ||
		!strcmp(mouse_type, "msc") || !strcmp(mouse_type, "genitizer") || !strcmp(mouse_type, "pnp") ||
		!strcmp(mouse_type, "ms3") || !strcmp(mouse_type, "logi") || !strcmp(mouse_type, "logim") ||
		!strcmp(mouse_type, "wacom") || !strcmp(mouse_type, "twid"))
	{
		g_object_set (GTK_WIDGET(data), "sensitive", TRUE, NULL);
	}
	else
	{
		g_object_set (GTK_WIDGET(data), "sensitive", FALSE, NULL);
	}
}
Esempio n. 17
0
static void
account_chooser_update_iter (EmpathyAccountChooser *chooser,
			     GtkTreeIter           *iter)
{
	EmpathyAccountChooserPriv *priv;
	GtkListStore              *store;
	GtkComboBox               *combobox;
	EmpathyAccount            *account;
	const gchar               *icon_name;
	gboolean                   is_enabled = TRUE;

	priv = GET_PRIV (chooser);

	combobox = GTK_COMBO_BOX (chooser);
	store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox));

	gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
			    COL_ACCOUNT_POINTER, &account,
			    -1);

	icon_name = empathy_icon_name_from_account (account);
	if (priv->filter) {
		is_enabled = priv->filter (account, priv->filter_data);
	}

	gtk_list_store_set (store, iter,
			    COL_ACCOUNT_IMAGE, icon_name,
			    COL_ACCOUNT_TEXT, empathy_account_get_display_name (account),
			    COL_ACCOUNT_ENABLED, is_enabled,
			    -1);

	/* set first connected account as active account */
	if (priv->set_active_item == FALSE && is_enabled) {
		priv->set_active_item = TRUE;
		gtk_combo_box_set_active_iter (combobox, iter);
	}

	g_object_unref (account);
}
Esempio n. 18
0
int
clip_GTK_COMBOBOXGETMODEL(ClipMachine * cm)
{
	C_widget   *ccmb = _fetch_cw_arg(cm);
        GtkTreeModel *model;
        C_object *cmodel ;

	CHECKCWID(ccmb,GTK_IS_COMBO_BOX);

	model = gtk_combo_box_get_model(GTK_COMBO_BOX(ccmb->widget));

	if (model)
        {
         	cmodel = _list_get_cobject(cm, model);
                if (!cmodel) cmodel = _register_object(cm, Iter, GTK_TYPE_TREE_MODEL, NULL, NULL);
                if (cmodel) _clip_mclone(cm, RETPTR(cm), &cmodel->obj);
	}

	return 0;
err:
	return 1;
}
void CLuaCFGMenu::ComboBoxChangedCB(GtkComboBox *widget, gpointer data)
{
    CLuaCFGMenu *menu = static_cast<CLuaCFGMenu *>(data);
    std::string selection = menu->CurSelection();

    if (!selection.empty())
    {
        GtkTreeIter iter;
        if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(menu->m_pComboBox), &iter))
        {
            gchar *text;
            gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(menu->m_pComboBox)), &iter,
                               0, &text, -1);
            if (text)
            {
                menu->GetVariables()[selection]->val = text;
                menu->SafeLuaDataChanged();
                g_free(text);
            }
        }
    }
}
Esempio n. 20
0
static void remmina_rdp_settings_set_combo_active_item(GtkComboBox* combo, int itemval)
{
	GtkTreeIter iter;
	int i;
	GtkTreeModel *m;
	gboolean valid;

	m = gtk_combo_box_get_model(combo);
	if (!m) {
		return;
	}

	valid = gtk_tree_model_get_iter_first(m, &iter);
	while (valid) {
		gtk_tree_model_get(m, &iter, 0, &i, -1);
		if (i == itemval) {
			gtk_combo_box_set_active_iter(combo, &iter);
		}
		valid = gtk_tree_model_iter_next(m, &iter);
	}

}
Esempio n. 21
0
/**
 * revert to default the selected color into the combobox
 *
 * \param button
 * \param combobox
 *
 * \return FALSE
 * */
static gboolean preferences_view_color_default ( GtkWidget *button,
                        GtkWidget *combobox )
{
    GtkTreeIter iter;

    if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &iter))
    {
	GtkTreeModel *model;
	GdkColor *color;
	GdkColor *default_color;

	model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
	gtk_tree_model_get ( GTK_TREE_MODEL (model),
			     &iter,
			     1, &color,
			     2, &default_color,
			     -1 );
	if (color && default_color)
	{
	    gboolean return_val;

	    color -> pixel = default_color -> pixel;
	    color -> red = default_color -> red;
	    color -> green = default_color -> green;
	    color -> blue = default_color -> blue;

	    g_signal_emit_by_name (combobox,
				   "changed",
				   &return_val);

	    /* update the colors in the list */
	    transaction_list_redraw ();

	    /* update scheduled list */
	    gsb_scheduler_list_redraw ();
	}
    }
    return FALSE;
}
static void
on_row_action_combo_box_changed (GtkComboBox      *combo,
                                 CcWacomButtonRow *row)
{
  GsdWacomActionType type;
  GtkTreeModel *model;
  GtkListBox *list_box;
  GtkTreeIter iter;

  if (!gtk_combo_box_get_active_iter (combo, &iter))
    return;

  /* Select the row where we changed the combo box (if not yet selected) */
  list_box = GTK_LIST_BOX (gtk_widget_get_parent (GTK_WIDGET (row)));
  if (list_box && gtk_list_box_get_selected_row (list_box) != GTK_LIST_BOX_ROW (row))
    gtk_list_box_select_row (list_box, GTK_LIST_BOX_ROW (row));

  model = gtk_combo_box_get_model (combo);
  gtk_tree_model_get (model, &iter, ACTION_TYPE_COLUMN, &type, -1);

  change_button_action_type (row, type);
}
Esempio n. 23
0
static void
on_combo_orientation_changed (GtkComboBox *combo_box,
                              gpointer     user_data)
{
  GtkToolPalette *palette = GTK_TOOL_PALETTE (user_data);
  GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (palette)));
  GtkTreeModel *model = gtk_combo_box_get_model (combo_box);
  GtkTreeIter iter;
  gint val = 0;

  if (!gtk_combo_box_get_active_iter (combo_box, &iter))
    return;

  gtk_tree_model_get (model, &iter, 1, &val, -1);

  gtk_orientable_set_orientation (GTK_ORIENTABLE (palette), val);

  if (val == GTK_ORIENTATION_HORIZONTAL)
    gtk_scrolled_window_set_policy (sw, GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
  else
    gtk_scrolled_window_set_policy (sw, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
}
Esempio n. 24
0
/** Find an entry in the GtkComboBox by its text value, and set
 *  the widget to that value.  This function also records the index of
 *  that text value for use when the user leaves the widget.
 *
 *  @param cbwe A pointer to a GtkComboBox with entry widget.
 *
 *  @param text The entry text to find in the model of the combo box
 *  entry. */
void
gnc_cbwe_set_by_string(GtkComboBox *cbwe,
                      const gchar *text)
{
    GtkTreeModel *model;
    GtkTreeIter iter;
    gchar *tree_string;
    gint column, index, id;
    gboolean match;

    model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbwe));
    if (!gtk_tree_model_get_iter_first(model, &iter))
    {
        /* empty tree */
        gtk_combo_box_set_active(GTK_COMBO_BOX(cbwe), -1);
        return;
    }

    column = gtk_combo_box_get_entry_text_column(cbwe);
    do
    {
        gtk_tree_model_get(model, &iter, column, &tree_string, -1);
        match = g_utf8_collate(text, tree_string) == 0;
        g_free(tree_string);
        if (!match)
            continue;

        /* Found a matching string */
        id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cbwe), CHANGED_ID));
        g_signal_handler_block(cbwe, id);
        gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cbwe), &iter);
        g_signal_handler_unblock(cbwe, id);

        index = gtk_combo_box_get_active(GTK_COMBO_BOX(cbwe));
        g_object_set_data(G_OBJECT(cbwe), LAST_INDEX, GINT_TO_POINTER(index));
        return;
    }
    while (gtk_tree_model_iter_next(model, &iter));
}
Esempio n. 25
0
static void
add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
{
	EAPMethodPEAP *method = (EAPMethodPEAP *) parent;
	GtkWidget *widget;
	GtkTreeModel *model;
	GtkTreeIter iter;
	EAPMethod *eap;

	if (method->size_group)
		g_object_unref (method->size_group);
	method->size_group = g_object_ref (group);

	widget = glade_xml_get_widget (parent->xml, "eap_peap_anon_identity_label");
	g_assert (widget);
	gtk_size_group_add_widget (group, widget);

	widget = glade_xml_get_widget (parent->xml, "eap_peap_ca_cert_label");
	g_assert (widget);
	gtk_size_group_add_widget (group, widget);

	widget = glade_xml_get_widget (parent->xml, "eap_peap_version_label");
	g_assert (widget);
	gtk_size_group_add_widget (group, widget);

	widget = glade_xml_get_widget (parent->xml, "eap_peap_inner_auth_label");
	g_assert (widget);
	gtk_size_group_add_widget (group, widget);

	widget = glade_xml_get_widget (parent->xml, "eap_peap_inner_auth_combo");
	g_assert (widget);

	model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
	gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
	gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
	g_assert (eap);
	eap_method_add_to_size_group (eap, group);
	eap_method_unref (eap);
}
static void
map_source_changed (GtkWidget *widget,
    ChamplainView *view)
{
  gchar *id;
  ChamplainMapSource *source;
  GtkTreeIter iter;
  GtkTreeModel *model;

  if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
    return;

  model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));

  gtk_tree_model_get (model, &iter, COL_ID, &id, -1);

  ChamplainMapSourceFactory *factory = champlain_map_source_factory_dup_default ();
  source = champlain_map_source_factory_create_cached_source (factory, id);

  g_object_set (G_OBJECT (view), "map-source", source, NULL);
  g_object_unref (factory);
}
Esempio n. 27
0
gboolean
basic_combo_get_iter_at_index(GtkWidget* combo, int index,
                                                GtkTreeIter* iter)
{
    GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
    gboolean valid = gtk_tree_model_get_iter_first(model, iter);

    while(valid)
    {
        char *str;
        int   opt;

        gtk_tree_model_get(model, iter, COLUMN_STRING, &str,
                                        COLUMN_INT,    &opt, -1);
        if (opt == index)
            return TRUE;

        valid = gtk_tree_model_iter_next(model, iter);
    }

    return FALSE;
}
gboolean
gis_account_page_enterprise_validate (GisAccountPageEnterprise *page)
{
  const gchar *name;
  gboolean valid_name;
  gboolean valid_domain;
  GtkTreeIter iter;
  GisAccountPageEnterprisePrivate *priv = gis_account_page_enterprise_get_instance_private (page);

  name = gtk_entry_get_text (GTK_ENTRY (priv->login));
  valid_name = is_valid_name (name);

  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->domain), &iter)) {
    gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (priv->domain)),
                        &iter, 0, &name, -1);
  } else {
    name = gtk_entry_get_text (GTK_ENTRY (priv->domain_entry));
  }

  valid_domain = is_valid_name (name);
  return valid_name && valid_domain;
}
Esempio n. 29
0
static void
gimp_gegl_tool_operation_changed (GtkWidget    *widget,
                                  GimpGeglTool *tool)
{
  GtkTreeModel *model;
  GtkTreeIter   iter;
  gchar        *operation;

  if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
    return;

  model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));

  gtk_tree_model_get (model, &iter,
                      COLUMN_NAME, &operation,
                      -1);

  if (operation)
    {
      const gchar *description;

      description = gegl_operation_get_key (operation, "description");

      if (description)
        {
          gtk_label_set_text (GTK_LABEL (tool->description_label), description);
          gtk_widget_show (tool->description_label);
        }
      else
        {
          gtk_widget_hide (tool->description_label);
        }

      gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (tool),
                                         operation, NULL);
      g_free (operation);
    }
}
Esempio n. 30
0
/*  Retrieve the displayed currency of the widget.
 *
 *  @param gce The currency editor widget whose values should be retrieved.
 *
 *  @return A pointer to the selected currency (a gnc_commodity
 *  structure).
 */
gnc_commodity *
gnc_currency_edit_get_currency (GNCCurrencyEdit *gce)
{
    gnc_commodity *commodity;
    const char *fullname;
    char *mnemonic, *name;
    GtkTreeModel *model;
    GtkTreeIter iter;
    GValue value = { 0 };

    g_return_val_if_fail(gce != NULL, NULL);
    g_return_val_if_fail(GNC_IS_CURRENCY_EDIT(gce), NULL);

    if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(gce), &iter))
    {
        model = gtk_combo_box_get_model(GTK_COMBO_BOX(gce));
        gtk_tree_model_get_value(model, &iter, 0, &value);
        fullname = g_value_get_string(&value);
        mnemonic = g_strdup(fullname);
        g_value_unset(&value);

        name = strchr(mnemonic, ' ');
        if (name != NULL)
            *name = '\0';
        commodity = gnc_commodity_table_lookup (gnc_get_current_commodities (),
                                                GNC_COMMODITY_NS_CURRENCY,
                                                mnemonic);
        g_free(mnemonic);
    }
    else
    {
        g_warning("Combo box returned 'inactive'. Using locale default currency.");
        commodity = gnc_locale_default_currency();
    }


    return commodity;
}