void ToolPageLayer::setLayerCount(int layer, int selected)
{
	XOJ_CHECK_TYPE(ToolPageLayer);

	this->inCbUpdate = true;

	int count = gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(this->layerComboBox)), NULL);

	for (int i = count - 1; i >= 0; i--)
	{
		gtk_combo_box_remove_text(GTK_COMBO_BOX(this->layerComboBox), i);
	}

	gtk_combo_box_append_text(GTK_COMBO_BOX(this->layerComboBox), _C("Background"));
	for (int i = 1; i <= layer; i++)
	{
		string text = FS(_F("Layer {1}") % i);
		gtk_combo_box_prepend_text(GTK_COMBO_BOX(this->layerComboBox), text.c_str());
	}

	setSelectedLayer(selected);

	this->layerCount = layer;
	this->inCbUpdate = false;
}
Пример #2
0
void								wififriend_scan_network(GtkWidget* Widget, gpointer Data)
{
	DWORD							Error = ERROR_SUCCESS;
	PWLAN_AVAILABLE_NETWORK_LIST	Network = NULL;
	t_wifi							St;
	int								I;
	GtkWidget						*WinScan = NULL;
	GtkWidget						*ListOfWifi = NULL;

	I = 1;
	St = wififriend_create_handle();
	St = wififriend_retrieve_config(St);
	if((WlanGetAvailableNetworkList(St.MyHandle, &St.MyGuid, 0x00000001, NULL, &Network)) != ERROR_SUCCESS)
		error_scan(0);
	else
	{
		WinScan = create_window(236, 27, "Wifi scan");
		ListOfWifi = gtk_combo_box_new_text();
		while(I != Network->dwNumberOfItems)
		{
			gtk_combo_box_prepend_text(GTK_COMBO_BOX(ListOfWifi), (const gchar *)Network->Network[I].dot11Ssid.ucSSID);
			I++;
		}
		gtk_combo_box_set_active(GTK_COMBO_BOX(ListOfWifi), 0);
		gtk_container_add(GTK_CONTAINER(WinScan), ListOfWifi);
		g_signal_connect(G_OBJECT(ListOfWifi), "changed", G_CALLBACK(wififriend_connect_to_unsecure_network), (gpointer)ListOfWifi);
		display_interface(WinScan);
		WlanCloseHandle(St.MyHandle, NULL);
	}
}
Пример #3
0
void combo_box_prepend_text (gpointer p, const gchar *s)
{
#if GTK_MAJOR_VERSION >= 3
    gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(p), s);
#else
    gtk_combo_box_prepend_text(GTK_COMBO_BOX(p), s);
#endif			   
}
Пример #4
0
  /* Put an allocated string on the history list and combo text list
     |  if it is not a duplicate.  The history_list is just a shadow of the
     |  combo list, but I think is needed because I don't see an api for reading
     |  the combo strings.  The combo box strings take "const gchar *", so the
     |  same allocated string can go in both the history list and the combo list.
     |  If removed from both lists, a string can be freed.
   */
static void
command_history_add (gchar * cmd)
{
  GList *list;
  gchar *s;
  gint i;

  if (!cmd || !*cmd)
    return;

  /* Check for a duplicate command.  If found, move it to the
     |  top of the list and similarly modify the combo box strings.
   */
  for (i = 0, list = history_list; list; list = list->next, ++i)
    {
      s = (gchar *) list->data;
      if (!strcmp (cmd, s))
	{
	  history_list = g_list_remove (history_list, s);
	  history_list = g_list_prepend (history_list, s);
	  gtk_combo_box_remove_text (GTK_COMBO_BOX
				     (ghidgui->command_combo_box), i);
	  gtk_combo_box_prepend_text (GTK_COMBO_BOX
				      (ghidgui->command_combo_box), s);
	  return;
	}
    }

  /* Not a duplicate, so put first in history list and combo box text list.
   */
  s = g_strdup (cmd);
  history_list = g_list_prepend (history_list, s);
  gtk_combo_box_prepend_text (GTK_COMBO_BOX (ghidgui->command_combo_box), s);

  /* And keep the lists trimmed!
   */
  if (g_list_length (history_list) > ghidgui->history_size)
    {
      s = (gchar *) g_list_nth_data (history_list, ghidgui->history_size);
      history_list = g_list_remove (history_list, s);
      gtk_combo_box_remove_text (GTK_COMBO_BOX (ghidgui->command_combo_box),
				 ghidgui->history_size);
      g_free (s);
    }
}
Пример #5
0
int
clip_GTK_COMBOBOXPREPENDTEXT(ClipMachine * cm)
{
	C_widget   *ccmb = _fetch_cw_arg(cm);
        gchar      *text = _clip_parc(cm, 2);

	CHECKCWID(ccmb,GTK_IS_COMBO_BOX);
        CHECKARG(2, CHARACTER_t);

	LOCALE_TO_UTF(text);
	gtk_combo_box_prepend_text(GTK_COMBO_BOX(ccmb->widget), text);
        FREE_TEXT(text);

	return 0;
err:
	return 1;
}
Пример #6
0
static void
gui_hlp_combo_box_prepend_text_or_set_active (GtkComboBox *combobox, const gchar *text, gboolean force_active)
{
    str_cmp_data scd;

    GtkTreeModel *model = gtk_combo_box_get_model(combobox);

    scd.str = text;
    scd.success = FALSE;
    scd.combobox = combobox;
    gtk_tree_model_foreach(model, str_cmp_func, &scd);

    if(!scd.success) {
	gtk_combo_box_prepend_text(combobox, text);
	if(force_active)
	    gtk_combo_box_set_active(combobox, 0);
    }
}
Пример #7
0
static void
init_color_scheme_menu (GtkWidget *combo_box)
{
	#if GTK_CHECK_VERSION(3, 0, 0)

	GtkCellRenderer *renderer;
	GtkTreeIter iter;
	GtkListStore *store;
	int i;

	store = gtk_list_store_new (1, G_TYPE_STRING);
	for (i = 0; i < G_N_ELEMENTS (color_schemes); ++i)
	gtk_list_store_insert_with_values (store, &iter, -1,
	                                   0, _(color_schemes[i].name),
	                                   -1);
	gtk_list_store_insert_with_values (store, &iter, -1,
	                                  0, _("Custom"),
	                                  -1);

	gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
	g_object_unref (store);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, "text", 0, NULL);

	#else

	int i;

	i = G_N_ELEMENTS (color_schemes);
	while (i > 0)
	{
		gtk_combo_box_prepend_text (GTK_COMBO_BOX (combo_box),
		                            _(color_schemes[--i].name));
	}

	#endif
}
Пример #8
0
static void
populate_ui (CEPageWired *self)
{
	CEPageWiredPrivate *priv = CE_PAGE_WIRED_GET_PRIVATE (self);
	NMSettingWired *setting = priv->setting;
	const char *port;
	const char *duplex;
	int port_idx = PORT_DEFAULT;
	int speed_idx;
	int mtu_def;
	char **mac_list, **iter;
	const GByteArray *s_mac;
	char *s_mac_str;
	char *active_mac = NULL;
	GtkWidget *entry;

	/* Port */
	port = nm_setting_wired_get_port (setting);
	if (port) {
		if (!strcmp (port, "tp"))
			port_idx = PORT_TP;
		else if (!strcmp (port, "aui"))
			port_idx = PORT_AUI;
		else if (!strcmp (port, "bnc"))
			port_idx = PORT_BNC;
		else if (!strcmp (port, "mii"))
			port_idx = PORT_MII;
	}
	gtk_combo_box_set_active (priv->port, port_idx);

	/* Speed */
	switch (nm_setting_wired_get_speed (setting)) {
	case 10:
		speed_idx = SPEED_10;
		break;
	case 100:
		speed_idx = SPEED_100;
		break;
	case 1000:
		speed_idx = SPEED_1000;
		break;
	case 10000:
		speed_idx = SPEED_10000;
		break;
	default:
		speed_idx = SPEED_DEFAULT;
		break;
	}
	gtk_combo_box_set_active (priv->speed, speed_idx);

	/* Duplex */
	duplex = nm_setting_wired_get_duplex (setting);
	if (duplex && !strcmp (duplex, "half"))
		gtk_toggle_button_set_active (priv->duplex, FALSE);
	else
		gtk_toggle_button_set_active (priv->duplex, TRUE);

	/* Autonegotiate */
	gtk_toggle_button_set_active (priv->autonegotiate, 
	                              nm_setting_wired_get_auto_negotiate (setting));

	/* Device MAC address */
	mac_list = ce_page_get_mac_list (CE_PAGE (self));
	s_mac = nm_setting_wired_get_mac_address (setting);
	s_mac_str = s_mac ? g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
	                                     s_mac->data[0], s_mac->data[1], s_mac->data[2],
	                                     s_mac->data[3], s_mac->data[4], s_mac->data[5]):
	                    NULL;

	for (iter = mac_list; iter && *iter; iter++) {
#if GTK_CHECK_VERSION (2,24,0)
		gtk_combo_box_text_append_text (priv->device_mac, *iter);
#else
		gtk_combo_box_append_text (GTK_COMBO_BOX (priv->device_mac), *iter);
#endif
		if (s_mac_str && g_ascii_strncasecmp (*iter, s_mac_str, 17) == 0)
			active_mac = *iter;
	}

	if (s_mac_str) {
		if (!active_mac) {
#if GTK_CHECK_VERSION (2,24,0)
			gtk_combo_box_text_prepend_text (priv->device_mac, s_mac_str);
#else
			gtk_combo_box_prepend_text (GTK_COMBO_BOX (priv->device_mac), s_mac_str);
#endif
		}

		entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
		if (entry)
			gtk_entry_set_text (GTK_ENTRY (entry), active_mac ? active_mac : s_mac_str);
	}
	g_strfreev (mac_list);
	g_signal_connect (priv->device_mac, "changed", G_CALLBACK (stuff_changed), self);

	/* Cloned MAC address */
	ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (setting), priv->cloned_mac);
	g_signal_connect (priv->cloned_mac, "changed", G_CALLBACK (stuff_changed), self);

	/* MTU */
	mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRED_MTU);
	g_signal_connect (priv->mtu, "output",
	                  G_CALLBACK (ce_spin_output_with_default),
	                  GINT_TO_POINTER (mtu_def));

	gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wired_get_mtu (setting));
}
Пример #9
0
static void
gmdb_sql_execute_cb(GtkWidget *w, GladeXML *xml)
{

	guint len;
	gchar *buf;
	gchar *bound_data[256];
	int i;
	MdbSQLColumn *sqlcol;
	GtkTextBuffer *txtbuffer;
	GtkTextIter start, end;
	GtkWidget *textview, *combobox, *treeview;
	GtkTreeModel *store;
	/*GtkWidget *window;*/
	GType *gtypes;
	GtkTreeIter iter;
	GtkTreeViewColumn *column;
	long row, maxrow;
	/* GdkCursor *watch, *pointer; */

	/*  need to figure out how to clock during the treeview recalc/redraw
	window = glade_xml_get_widget(xml, "sql_window");
	watch = gdk_cursor_new(GDK_WATCH);
	gdk_window_set_cursor(GTK_WIDGET(window)->window, watch);
	gdk_cursor_unref(watch);
	*/

	/* stuff this query on the history */
	textview = glade_xml_get_widget(xml, "sql_textview");
	combobox = glade_xml_get_widget(xml, "sql_combo");
	txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
	len = gtk_text_buffer_get_char_count(txtbuffer);
	gtk_text_buffer_get_iter_at_offset (txtbuffer, &start, 0);
	gtk_text_buffer_get_iter_at_offset (txtbuffer, &end, len);
	buf = gtk_text_buffer_get_text(txtbuffer, &start, &end, FALSE);

	/* add to the history */
	gtk_combo_box_prepend_text(GTK_COMBO_BOX(combobox), buf);
	gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);

	/* ok now execute it */
	mdb_sql_run_query(sql, buf);
	if (mdb_sql_has_error(sql)) {
		GtkWidget* dlg = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (w)),
		    GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
		    "%s", mdb_sql_last_error(sql));
		gtk_dialog_run (GTK_DIALOG (dlg));
		gtk_widget_destroy (dlg);
		mdb_sql_reset(sql);
		return;
	}

	treeview = glade_xml_get_widget(xml, "sql_results");

	gtypes = g_malloc(sizeof(GType) * sql->num_columns);
	for (i=0;i<sql->num_columns;i++) 
		gtypes[i]=G_TYPE_STRING;

	store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
	if (store) {
		while ((column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), 0))) {
			gtk_tree_view_remove_column(GTK_TREE_VIEW(treeview), column);
		}
		g_object_unref(store);
	}
	store = (GtkTreeModel*)gtk_list_store_newv(sql->num_columns, gtypes);
	g_free(gtypes);

	gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), store);
	
	GtkCellRenderer *renderer;
	renderer = gtk_cell_renderer_text_new(); 

	for (i=0;i<sql->num_columns;i++) { 
		bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE); 
        	mdb_sql_bind_column(sql, i+1, bound_data[i], NULL);
		sqlcol = g_ptr_array_index(sql->columns,i);
		column = gtk_tree_view_column_new_with_attributes(sqlcol->name, renderer, "text", i, NULL); 
		gtk_tree_view_append_column(GTK_TREE_VIEW (treeview), column); 
	}

	maxrow = gmdb_prefs_get_maxrows();

	row = 0;
	while(mdb_fetch_row(sql->cur_table) &&
			(!maxrow || (row < maxrow))) {
		row++;
		gtk_list_store_append(GTK_LIST_STORE(store), &iter);
		for (i=0;i<sql->num_columns;i++) { 
			gtk_list_store_set(GTK_LIST_STORE(store), 
				&iter, i, (gchar *) bound_data[i], -1);
		}
	}


	/* free the memory used to bind */
	for (i=0;i<sql->num_columns;i++) {
		g_free(bound_data[i]);
	}

	mdb_sql_reset(sql);
	g_free(buf);

	/*
	pointer = gdk_cursor_new(GDK_LEFT_PTR);
	gdk_window_set_cursor(GTK_WIDGET(window)->window, pointer);
	gdk_cursor_unref(pointer);
	*/
	
}
Пример #10
0
GtkWidget *
entry_create_widget (GtkWidget * dlg)
{
  GtkWidget *c, *l = NULL, *w = NULL;

#if !GTK_CHECK_VERSION(3,0,0)
  w = gtk_hbox_new (FALSE, 5);
#else
  w = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
#endif

  if (options.entry_data.entry_label)
    {
      l = gtk_label_new (NULL);
      if (options.data.no_markup)
        gtk_label_set_text_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label);
      else
        gtk_label_set_markup_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label);
      gtk_widget_set_name (l, "yad-entry-label");
      gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 1);
    }

  if (options.entry_data.numeric)
    {
      gdouble min, max, step, val;
      guint prec;

      min = 0.0;
      max = 65535.0;
      step = 1.0;
      prec = 0;

      if (options.extra_data && options.extra_data[0])
        {
          min = g_ascii_strtod (options.extra_data[0], NULL);
          if (options.extra_data[1])
            max = g_ascii_strtod (options.extra_data[1], NULL);
          if (options.extra_data[2])
            step = g_ascii_strtod (options.extra_data[2], NULL);
          if (options.extra_data[3])
            {
              prec = (guint) g_ascii_strtoull (options.extra_data[3], NULL, 0);
              if (prec > 20)
                prec = 20;
            }
        }

      c = entry = gtk_spin_button_new_with_range (min, max, step);
      gtk_entry_set_alignment (GTK_ENTRY (c), 1.0);
      gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c), prec);
      gtk_widget_set_name (entry, "yad-entry-spin");

      if (options.entry_data.entry_text)
        {
          val = g_ascii_strtod (options.entry_data.entry_text, NULL);

          if (min >= max)
            {
              g_printerr (_("Maximum value must be greater than minimum value.\n"));
              min = 0.0;
              max = 65535.0;
            }

          if (val < min)
            {
              g_printerr (_("Initial value less than minimal.\n"));
              val = min;
            }
          else if (val > max)
            {
              g_printerr (_("Initial value greater than maximum.\n"));
              val = max;
            }

          gtk_spin_button_set_value (GTK_SPIN_BUTTON (c), val);
        }
    }
  else if (!options.entry_data.completion && options.extra_data && *options.extra_data)
    {
      gint active, i;

      if (options.common_data.editable || settings.combo_always_editable)
        {
#if GTK_CHECK_VERSION(2,24,0)
          c = gtk_combo_box_text_new_with_entry ();
#else
          c = gtk_combo_box_entry_new_text ();
#endif
          gtk_widget_set_name (c, "yad-entry-edit-combo");
          entry = gtk_bin_get_child (GTK_BIN (c));
          if (options.entry_data.licon)
            {
              GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON);

              if (pb)
                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb);
            }
          if (options.entry_data.ricon)
            {
              GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON);

              if (pb)
                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb);
            }
        }
      else
        {
#if GTK_CHECK_VERSION(2,24,0)
          c = entry = gtk_combo_box_text_new ();
#else
          c = entry = gtk_combo_box_new_text ();
#endif
          gtk_widget_set_name (c, "yad-entry-combo");
          is_combo = TRUE;
        }

      i = 0;
      active = -1;
      while (options.extra_data[i] != NULL)
        {
          if (options.entry_data.entry_text &&
              g_ascii_strcasecmp (options.extra_data[i], options.entry_data.entry_text) == 0)
            active = i;
#if GTK_CHECK_VERSION(2,24,0)
          gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (c), options.extra_data[i]);
#else
          gtk_combo_box_append_text (GTK_COMBO_BOX (c), options.extra_data[i]);
#endif
          i++;
        }

      if (options.entry_data.entry_text && active == -1)
        {
#if GTK_CHECK_VERSION(2,24,0)
          gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (c), options.entry_data.entry_text);
#else
          gtk_combo_box_prepend_text (GTK_COMBO_BOX (c), options.entry_data.entry_text);
#endif
        }

      /* set first iter active */
      if (!options.common_data.editable)
        gtk_combo_box_set_active (GTK_COMBO_BOX (c), (active != -1 ? active : 0));
    }
  else
    {
      c = entry = gtk_entry_new ();
      gtk_widget_set_name (c, "yad-entry-widget");

      gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);

      if (options.entry_data.entry_text)
        gtk_entry_set_text (GTK_ENTRY (entry), options.entry_data.entry_text);

      if (options.entry_data.hide_text)
        g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL);

      if (options.entry_data.completion)
        {
          GtkEntryCompletion *completion;
          GtkTreeModel *completion_model;

          completion = gtk_entry_completion_new ();
          gtk_entry_set_completion (GTK_ENTRY (entry), completion);

          completion_model = create_completion_model ();
          gtk_entry_completion_set_model (completion, completion_model);
          g_object_unref (completion_model);

          gtk_entry_completion_set_text_column (completion, 0);
          g_object_unref (completion);
        }

      if (options.entry_data.licon)
        {
          GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON);

          if (pb)
            gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb);
        }
      if (options.entry_data.ricon)
        {
          GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON);

          if (pb)
            gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb);
        }
    }

  if (l)
    gtk_label_set_mnemonic_widget (GTK_LABEL (l), entry);

  if (!is_combo)
    g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (entry_activate_cb), dlg);
  else
    g_signal_connect (G_OBJECT (entry), "key-press-event", G_CALLBACK (combo_activate_cb), dlg);

  if (options.entry_data.licon || options.entry_data.ricon)
    g_signal_connect (G_OBJECT (entry), "icon-press", G_CALLBACK (icon_cb), NULL);

  gtk_box_pack_start (GTK_BOX (w), c, TRUE, TRUE, 1);

  return w;
}
Пример #11
0
void
gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box, const gchar *text) {
    gtk_combo_box_prepend_text (combo_box, text);
}
Пример #12
0
static VALUE
rg_prepend_text(VALUE self, VALUE text)
{
    gtk_combo_box_prepend_text(_SELF(self), RVAL2CSTR(text));
    return self;
}
Пример #13
0
void 
matedialog_entry (MateDialogData *data, MateDialogEntryData *entry_data)
{
  GtkBuilder *builder = NULL;
  GtkWidget *dialog;
  GObject *text;
  GSList *entries = NULL; 
  GSList *tmp;
  GObject *vbox;
  
  builder = matedialog_util_load_ui_file ("matedialog_entry_dialog", NULL);

  if (builder == NULL) {
    data->exit_code = matedialog_util_return_exit_code (MATEDIALOG_ERROR);
    return;
  }
	
  gtk_builder_connect_signals (builder, NULL);
	
  dialog = GTK_WIDGET (gtk_builder_get_object (builder, "matedialog_entry_dialog"));
	
  g_signal_connect (G_OBJECT (dialog), "response",
                    G_CALLBACK (matedialog_entry_dialog_response), data);

  if (data->dialog_title)
    gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
	
  matedialog_util_set_window_icon (dialog, data->window_icon, MATEDIALOG_IMAGE_FULLPATH ("matedialog-entry.png"));

  if (data->width > -1 || data->height > -1)
    gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);

  text = gtk_builder_get_object (builder, "matedialog_entry_text");

  if (entry_data->dialog_text)
    gtk_label_set_text_with_mnemonic (GTK_LABEL (text), g_strcompress (entry_data->dialog_text));
  
  vbox = gtk_builder_get_object (builder, "vbox4");
  
  matedialog_entry_fill_entries(&entries, entry_data->data);
  
  n_entries = g_slist_length (entries);

  if (n_entries > 1) {
    #if GTK_CHECK_VERSION(2,24,0)
      entry = gtk_combo_box_text_new_with_entry ();
    #else
      entry = gtk_combo_box_entry_new_text ();
    #endif

    for (tmp = entries; tmp; tmp = tmp->next) {
      #if GTK_CHECK_VERSION(2,24,0)
        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data);
      #else
        gtk_combo_box_append_text (GTK_COMBO_BOX (entry), tmp->data);
      #endif
    }

    if (entry_data->entry_text) {
      #if GTK_CHECK_VERSION(2,24,0)
        gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text);
      #else
        gtk_combo_box_prepend_text (GTK_COMBO_BOX (entry), entry_data->entry_text);
      #endif
      gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0);
    }

    g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), "activate",
                      G_CALLBACK (matedialog_entry_combo_activate_default),
                      GTK_WINDOW (dialog));
  } else {
    entry = gtk_entry_new();

    gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
    
    if (entry_data->entry_text)
      gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text);

    if (entry_data->hide_text)
      g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL);
  }

  gtk_widget_show (entry);

  gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

  gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry);

  g_object_unref (builder);

  matedialog_util_show_dialog (dialog);

  if(data->timeout_delay > 0) {
    g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) matedialog_util_timeout_handle, NULL);
  }

  gtk_main ();
}
Пример #14
0
static SCM
gnc_style_sheet_new (StyleSheetDialog * ssd)
{
    SCM              make_ss   = scm_c_eval_string("gnc:make-html-style-sheet");
    SCM              templates = scm_c_eval_string("(gnc:get-html-templates)");
    SCM              t_name = scm_c_eval_string("gnc:html-style-sheet-template-name");
    SCM              new_ss = SCM_BOOL_F;
    GtkWidget        * template_combo;
    GtkTreeModel     * template_model;
    GtkWidget        * name_entry;
    gint             dialog_retval;
    GList *template_names = NULL;

    /* get the new name for the style sheet */
    GladeXML *xml = gnc_glade_xml_new ("report.glade",
                                       "New Style Sheet Dialog");
    GtkWidget * dlg = glade_xml_get_widget (xml, "New Style Sheet Dialog");
    template_combo = glade_xml_get_widget (xml, "template_combobox");
    name_entry     = glade_xml_get_widget (xml, "name_entry");

    g_assert(ssd);

    /* Erase the initial dummy entry. */
    template_model = gtk_combo_box_get_model(GTK_COMBO_BOX(template_combo));
    gtk_list_store_clear(GTK_LIST_STORE(template_model));

    /* put in the list of style sheet type names */
    for (; !scm_is_null(templates); templates = SCM_CDR(templates))
    {
        char * str;
        const char* orig_name;

        SCM t = SCM_CAR(templates);
        scm_dynwind_begin (0); 
        str = scm_to_locale_string (scm_call_1(t_name, t));
        orig_name = g_strdup (str);
        scm_dynwind_free (str); 
        scm_dynwind_end (); 

        /* Store the untranslated names for lookup later */
        template_names = g_list_prepend (template_names, (gpointer)orig_name);

        /* The displayed name should be translated */
        gtk_combo_box_prepend_text(GTK_COMBO_BOX(template_combo),
                                   _(orig_name));
    }
    gtk_combo_box_set_active(GTK_COMBO_BOX(template_combo), 0);

    /* get the name */
    gtk_window_set_transient_for (GTK_WINDOW(dlg), GTK_WINDOW(ssd->toplevel));
    dialog_retval = gtk_dialog_run(GTK_DIALOG(dlg));

    if (dialog_retval == GTK_RESPONSE_OK)
    {
        gint choice = gtk_combo_box_get_active (GTK_COMBO_BOX(template_combo));
        const char *template_str = g_list_nth_data (template_names, choice);
        const char *name_str     = gtk_entry_get_text(GTK_ENTRY(name_entry));
        if (name_str && strlen(name_str) == 0)
        {
            /* If the name is empty, we display an error dialog but
             * refuse to create the new style sheet. */
            gnc_error_dialog (ssd->toplevel, "%s", _("You must provide a name for the new style sheet."));
            name_str = NULL;
        }
        if (template_str && name_str)
        {
            new_ss = scm_call_2(make_ss,
                                scm_makfrom0str(template_str),
                                scm_makfrom0str(name_str));
        }
    }

    g_list_free (template_names);
    gtk_widget_destroy(dlg);
    return(new_ss);
}
Пример #15
0
void gtk_combo_box_text_prepend_text(GtkComboBoxText *combo_box,
				     const gchar *text)
{
	gtk_combo_box_prepend_text(GTK_COMBO_BOX(combo_box), text);
}