示例#1
0
gchar *input_dialog_combo_remember(const gchar *title, const gchar *message,
			  const gchar *default_string, GList *list,
			  gboolean *remember)
{
	if (dialog && gtk_widget_get_visible(dialog)) return NULL;

	if (!dialog)
		input_dialog_create(FALSE);

	type = INPUT_DIALOG_COMBO;
	gtk_widget_hide(entry);
	gtk_widget_show(combo);

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_checkbtn), FALSE);
	if (remember)
		gtk_widget_show(remember_checkbtn);
	else
		gtk_widget_hide(remember_checkbtn);

	gtk_widget_show(icon_q);
	gtk_widget_hide(icon_p);
	is_pass = FALSE;
#if !GTK_CHECK_VERSION(2, 24, 0)
	combobox_unset_popdown_strings(GTK_COMBO_BOX(combo));
	combobox_set_popdown_strings(GTK_COMBO_BOX(combo), list);
#else
	combobox_unset_popdown_strings(GTK_COMBO_BOX_TEXT(combo));
	combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(combo), list);
#endif
	return input_dialog_open(title, message, NULL, default_string, FALSE, remember);
}
示例#2
0
/**************************************************************************
 Popup dialog where the user choose the name of the new city
 punit = (settler) unit which builds the city
 suggestname = suggetion of the new city's name
**************************************************************************/
void popup_newcity_dialog(struct unit *punit, char *suggestname)
{
  input_dialog_create(toplevel, "shellnewcityname",
		      _("What should we call our new city?"), suggestname,
		      name_new_city_callback, INT_TO_XTPOINTER(punit->id),
		      name_new_city_callback, INT_TO_XTPOINTER(0));
}
示例#3
0
gchar *input_dialog_with_checkbtn(const gchar	*title,
				   const gchar	*message,
				   const gchar	*default_string,
				   const gchar  *checkbtn_label,
				   gboolean *checkbtn_state)
{
	if (dialog && gtk_widget_get_visible(dialog)) return NULL;

	if (!dialog)
		input_dialog_create(FALSE);

	type = INPUT_DIALOG_NORMAL;
	gtk_widget_hide(combo);
	gtk_widget_show(entry);

	if (checkbtn_label && checkbtn_state)
		gtk_widget_show(remember_checkbtn);
	else
		gtk_widget_hide(remember_checkbtn);

	gtk_widget_show(icon_q);
	gtk_widget_hide(icon_p);
	is_pass = FALSE;
	gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE);

	return input_dialog_open(title, message, checkbtn_label, default_string, 
	       			 prefs_common.inherit_folder_props, checkbtn_state);
}
示例#4
0
gchar *input_dialog_with_invisible_checkbtn(const gchar *title, const gchar *message,
				   const gchar *default_string, const gchar *checkbtn_label,
				   gboolean *checkbtn_state)
{
	if (dialog && gtk_widget_get_visible(dialog)) return NULL;

	if (!dialog)
		input_dialog_create(TRUE);

	type = INPUT_DIALOG_INVISIBLE;
	gtk_widget_hide(combo);
	gtk_widget_show(entry);

	if (checkbtn_label && checkbtn_state) {
		gtk_widget_show(remember_checkbtn);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_checkbtn), *checkbtn_state);
	}
	else {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_checkbtn), FALSE);
		gtk_widget_hide(remember_checkbtn);
	}

	gtk_widget_hide(icon_q);
	gtk_widget_show(icon_p);
	is_pass = TRUE;
	gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);

	return input_dialog_open(title, message, checkbtn_label, default_string, (checkbtn_state? *checkbtn_state:FALSE), checkbtn_state);
}
示例#5
0
/**************************************************************************
 Popup dialog where the user choose the name of the new city
 punit = (settler) unit which builds the city
 suggestname = suggetion of the new city's name
**************************************************************************/
void popup_newcity_dialog(struct unit *punit, const char *suggestname)
{
  input_dialog_create(GTK_WINDOW(toplevel), /*"shellnewcityname" */
                      _("Build New City"),
                      _("What should we call our new city?"), suggestname,
                      name_new_city_popup_callback,
                      GINT_TO_POINTER(tile_index(unit_tile(punit))));
}
示例#6
0
文件: cma_fe.c 项目: jheusala/freeciv
/****************************************************************
 Create a new preset, first asking for the presets name.
*****************************************************************/
static void add_preset(Widget w, XtPointer client_data,
                       XtPointer call_data)
{
  input_dialog_create(cma_dialog, "cmapresetname",
                      _("What should we name the new preset?"), 
                      _("new preset"),
                      new_preset_callback, INT_TO_XTPOINTER(TRUE),
                      new_preset_callback, INT_TO_XTPOINTER(FALSE));
}
示例#7
0
gchar *input_dialog(const gchar *title, const gchar *message,
		    const gchar *default_string)
{
	if (dialog)
		return NULL;

	input_dialog_create(INPUT_DIALOG_NORMAL);

	return input_dialog_open(title, message, default_string);
}
示例#8
0
gchar *input_dialog_with_invisible(const gchar *title, const gchar *message,
				   const gchar *default_string)
{
	if (dialog)
		return NULL;

	input_dialog_create(INPUT_DIALOG_INVISIBLE);

	return input_dialog_open(title, message, default_string);
}
示例#9
0
gchar *input_dialog_with_filesel(const gchar *title, const gchar *message,
				 const gchar *default_string,
				 GtkFileChooserAction action)
{
	if (dialog)
		return NULL;

	input_dialog_create(INPUT_DIALOG_FILESEL);
	chooser_action = action;

	return input_dialog_open(title, message, default_string);
}
示例#10
0
/****************************************************************
...
*****************************************************************/
void rename_callback(Widget w, XtPointer client_data, XtPointer call_data)
{
  struct city_dialog *pdialog;

  pdialog=(struct city_dialog *)client_data;
  
  input_dialog_create(pdialog->shell, 
		      "shellrenamecity", 
		      "What should we rename the city to?",
		      pdialog->pcity->name,
		      (void*)rename_city_callback, (XtPointer)pdialog,
		      (void*)rename_city_callback, (XtPointer)0);
}
示例#11
0
gchar *input_dialog_with_invisible(const gchar *title, const gchar *message,
				   const gchar *default_string)
{
	if (dialog && gtk_widget_get_visible(dialog)) return NULL;

	if (!dialog)
		input_dialog_create(TRUE);

	type = INPUT_DIALOG_INVISIBLE;
	gtk_widget_hide(combo);
	gtk_widget_show(entry);
	gtk_widget_hide(remember_checkbtn);

	gtk_widget_hide(icon_q);
	gtk_widget_show(icon_p);
	is_pass = TRUE;
	gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);

	return input_dialog_open(title, message, NULL, default_string, FALSE, NULL);
}
示例#12
0
gchar *input_dialog_combo(const gchar *title, const gchar *message,
			  const gchar *default_string, GList *list,
			  gboolean case_sensitive)
{
	if (dialog)
		return NULL;

	input_dialog_create(INPUT_DIALOG_COMBO);

	if (!list) {
		GList empty_list;

		empty_list.data = (gpointer)"";
		empty_list.next = NULL;
		empty_list.prev = NULL;
		gtk_combo_set_popdown_strings(GTK_COMBO(combo), &empty_list);
	} else
		gtk_combo_set_popdown_strings(GTK_COMBO(combo), list);

	gtk_combo_set_case_sensitive(GTK_COMBO(combo), case_sensitive);

	return input_dialog_open(title, message, default_string);
}
示例#13
0
static gchar *input_dialog_open(const gchar *title, const gchar *message,
				const gchar *checkbtn_label,
				const gchar *default_string,
				gboolean default_checkbtn_state,
				gboolean *remember)
{
	gchar *str;

	if (dialog && gtk_widget_get_visible(dialog)) return NULL;

	if (!dialog)
		input_dialog_create(FALSE);

	if (checkbtn_label)
		gtk_button_set_label(GTK_BUTTON(remember_checkbtn), checkbtn_label);
	else
		gtk_button_set_label(GTK_BUTTON(remember_checkbtn), _("Remember this"));

	input_dialog_set(title, message, default_string);
	gtk_window_present(GTK_WINDOW(dialog));

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_checkbtn),
				     default_checkbtn_state);
	if (remember)
		gtk_widget_show(remember_checkbtn);
	else
		gtk_widget_hide(remember_checkbtn);

	gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
	manage_window_set_transient(GTK_WINDOW(dialog));

	ack = fin = FALSE;

	while (fin == FALSE)
		gtk_main_iteration();

	manage_window_focus_out(dialog, NULL, NULL);

	if (ack) {
		GtkEditable *editable;

		if (type == INPUT_DIALOG_COMBO)
			editable = GTK_EDITABLE(gtk_bin_get_child(GTK_BIN((combo))));
		else
			editable = GTK_EDITABLE(entry);

		str = gtk_editable_get_chars(editable, 0, -1);
		if (str && *str == '\0' && !is_pass) {
			g_free(str);
			str = NULL;
		}
	} else
		str = NULL;

	GTK_EVENTS_FLUSH();

	if (remember) {
		*remember = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remember_checkbtn));
	}

	gtk_widget_destroy(dialog);
	dialog = NULL;

	if (is_pass)
		debug_print("return string = %s\n", str ? "********": ("none"));
	else
		debug_print("return string = %s\n", str ? str : "(none)");
	return str;
}