geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dialogs.c File Reference
#include "dialogs.h"
#include "app.h"
#include "build.h"
#include "document.h"
#include "encodings.h"
#include "encodingsprivate.h"
#include "filetypes.h"
#include "main.h"
#include "support.h"
#include "utils.h"
#include "ui_utils.h"
#include "win32.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <string.h>
#include <time.h>
#include <glib/gstdio.h>
Include dependency graph for dialogs.c:

Go to the source code of this file.

Classes

struct  FileSelState
 
struct  InputDialogData
 

Macros

#define S_IRUSR   0
 
#define S_IWUSR   0
 
#define S_IXUSR   0
 
#define S_IRGRP   0
 
#define S_IWGRP   0
 
#define S_IXGRP   0
 
#define S_IROTH   0
 
#define S_IWOTH   0
 
#define S_IXOTH   0
 

Enumerations

enum  { GEANY_RESPONSE_RENAME , GEANY_RESPONSE_VIEW }
 

Functions

static gint filetype_combo_box_get_active_filetype (GtkComboBox *combo)
 
static guint file_chooser_get_filter_idx (GtkFileChooser *chooser)
 
static void file_chooser_set_filter_idx (GtkFileChooser *chooser, guint idx)
 
static gboolean open_file_dialog_handle_response (GtkWidget *dialog, gint response)
 
static void on_file_open_show_hidden_notify (GObject *filechooser, GParamSpec *pspec, gpointer data)
 
static void on_file_open_check_hidden_toggled (GtkToggleButton *togglebutton, GtkWidget *dialog)
 
static void filetype_combo_cell_data_func (GtkCellLayout *cell_layout, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
 
static GtkWidget * create_filetype_combo_box (void)
 
static gboolean filetype_combo_box_set_active_filetype (GtkComboBox *combo, const gint id)
 
static GtkWidget * add_file_open_extra_widget (GtkWidget *dialog)
 
static GtkWidget * create_open_file_dialog (void)
 
static void open_file_dialog_apply_settings (GtkWidget *dialog)
 
void dialogs_show_open_file (void)
 
static gboolean handle_save_as (const gchar *utf8_filename, gboolean rename_file)
 
static gboolean save_as_dialog_handle_response (GtkWidget *dialog, gint response)
 
static GtkWidget * create_save_file_dialog (GeanyDocument *doc)
 
static gboolean show_save_as_gtk (GeanyDocument *doc)
 
gboolean dialogs_show_save_as (void)
 Shows the Save As dialog for the current notebook page. More...
 
static void show_msgbox_dialog (GtkWidget *dialog, GtkMessageType type, GtkWindow *parent)
 
void dialogs_show_msgbox (GtkMessageType type, const gchar *text,...)
 Shows a message box of the type type with text. More...
 
void dialogs_show_msgbox_with_secondary (GtkMessageType type, const gchar *text, const gchar *secondary)
 
static gint run_unsaved_dialog (const gchar *msg, const gchar *msg2)
 
gboolean dialogs_show_unsaved_file (GeanyDocument *doc)
 
static void on_font_dialog_response (GtkDialog *dialog, gint response, gpointer user_data)
 
void dialogs_show_open_font (void)
 
static void on_input_dialog_show (GtkDialog *dialog, GtkWidget *entry)
 
static void on_input_entry_activate (GtkEntry *entry, GtkDialog *dialog)
 
static void on_input_numeric_activate (GtkEntry *entry, GtkDialog *dialog)
 
static void on_input_dialog_response (GtkDialog *dialog, gint response, InputDialogData *data)
 
static GtkWidget * dialogs_show_input_full (const gchar *title, GtkWindow *parent, const gchar *label_text, const gchar *default_text, gboolean persistent, GeanyInputCallback input_cb, gpointer input_cb_data, GCallback insert_text_cb, gpointer insert_text_cb_data)
 
GtkWidget * dialogs_show_input_persistent (const gchar *title, GtkWindow *parent, const gchar *label_text, const gchar *default_text, GeanyInputCallback input_cb, gpointer input_cb_data)
 
static void on_dialog_input (const gchar *str, gpointer data)
 
gchar * dialogs_show_input (const gchar *title, GtkWindow *parent, const gchar *label_text, const gchar *default_text)
 Asks the user for text input. More...
 
gchar * dialogs_show_input_goto_line (const gchar *title, GtkWindow *parent, const gchar *label_text, const gchar *default_text)
 
gboolean dialogs_show_input_numeric (const gchar *title, const gchar *label_text, gdouble *value, gdouble min, gdouble max, gdouble step)
 Shows an input box to enter a numerical value using a GtkSpinButton. More...
 
void dialogs_show_file_properties (GeanyDocument *doc)
 
static gint show_prompt (GtkWidget *parent, const gchar *btn_1, GtkResponseType response_1, const gchar *btn_2, GtkResponseType response_2, const gchar *btn_3, GtkResponseType response_3, const gchar *question_text, const gchar *extra_text)
 
gboolean dialogs_show_question (const gchar *text,...)
 Shows a question message box with text and Yes/No buttons. More...
 
gboolean dialogs_show_question_full (GtkWidget *parent, const gchar *yes_btn, const gchar *no_btn, const gchar *extra_text, const gchar *main_text,...)
 
gint dialogs_show_prompt (GtkWidget *parent, const gchar *btn_1, GtkResponseType response_1, const gchar *btn_2, GtkResponseType response_2, const gchar *btn_3, GtkResponseType response_3, const gchar *extra_text, const gchar *main_text,...)
 

Variables

static struct FileSelState filesel_state
 

Macro Definition Documentation

◆ S_IRGRP

#define S_IRGRP   0

◆ S_IROTH

#define S_IROTH   0

◆ S_IRUSR

#define S_IRUSR   0

◆ S_IWGRP

#define S_IWGRP   0

◆ S_IWOTH

#define S_IWOTH   0

◆ S_IWUSR

#define S_IWUSR   0

◆ S_IXGRP

#define S_IXGRP   0

◆ S_IXOTH

#define S_IXOTH   0

◆ S_IXUSR

#define S_IXUSR   0

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GEANY_RESPONSE_RENAME 
GEANY_RESPONSE_VIEW 

Definition at line 60 of file dialogs.c.

Function Documentation

◆ add_file_open_extra_widget()

◆ create_filetype_combo_box()

◆ create_open_file_dialog()

◆ create_save_file_dialog()

static GtkWidget * create_save_file_dialog ( GeanyDocument doc)
static

◆ dialogs_show_file_properties()

◆ dialogs_show_input()

gchar * dialogs_show_input ( const gchar *  title,
GtkWindow *  parent,
const gchar *  label_text,
const gchar *  default_text 
)

Asks the user for text input.

Parameters
titleDialog title.
parent The currently focused window, usually geany->main_widgets->window. NULL can be used but is discouraged due to window manager effects.
label_text Label text, or NULL.
default_text Text to display in the input field, or NULL.
Returns
New copy of user input or NULL if cancelled.
Since
0.20.

Definition at line 1067 of file dialogs.c.

References dialogs_show_input_full(), NULL, and on_dialog_input().

Referenced by insert_date(), on_label_button_clicked(), and utils_open_browser().

◆ dialogs_show_input_full()

static GtkWidget * dialogs_show_input_full ( const gchar *  title,
GtkWindow *  parent,
const gchar *  label_text,
const gchar *  default_text,
gboolean  persistent,
GeanyInputCallback  input_cb,
gpointer  input_cb_data,
GCallback  insert_text_cb,
gpointer  insert_text_cb_data 
)
static

◆ dialogs_show_input_goto_line()

gchar * dialogs_show_input_goto_line ( const gchar *  title,
GtkWindow *  parent,
const gchar *  label_text,
const gchar *  default_text 
)

◆ dialogs_show_input_numeric()

gboolean dialogs_show_input_numeric ( const gchar *  title,
const gchar *  label_text,
gdouble *  value,
gdouble  min,
gdouble  max,
gdouble  step 
)

Shows an input box to enter a numerical value using a GtkSpinButton.

If the dialog is aborted, value remains untouched.

Parameters
titleThe dialog title.
label_textThe shown dialog label.
valueThe default value for the spin button and the return location of the entered value. Must be non-NULL.
minMinimum allowable value (see documentation for gtk_spin_button_new_with_range()).
maxMaximum allowable value (see documentation for gtk_spin_button_new_with_range()).
stepIncrement added or subtracted by spinning the widget (see documentation for gtk_spin_button_new_with_range()).
Returns
TRUE if a value was entered and the dialog closed with 'OK'. FALSE otherwise.
Since
0.16

Definition at line 1108 of file dialogs.c.

References dialog, gtk_container_add(), gtk_widget_show_all(), label, main_widgets, max, NULL, on_input_numeric_activate(), ui_dialog_vbox_new(), ui_entry_add_clear_icon(), and GeanyMainWidgets::window.

Referenced by editor_replace_spaces().

◆ dialogs_show_input_persistent()

GtkWidget * dialogs_show_input_persistent ( const gchar *  title,
GtkWindow *  parent,
const gchar *  label_text,
const gchar *  default_text,
GeanyInputCallback  input_cb,
gpointer  input_cb_data 
)

Definition at line 1043 of file dialogs.c.

References dialogs_show_input_full(), and NULL.

Referenced by on_build_menu_item().

◆ dialogs_show_msgbox()

void dialogs_show_msgbox ( GtkMessageType  type,
const gchar *  text,
  ... 
)

Shows a message box of the type type with text.

On Unix-like systems a GTK message dialog box is shown, on Win32 systems a native Windows message dialog box is shown.

Parameters
typeA GtkMessageType, e.g. GTK_MESSAGE_INFO, GTK_MESSAGE_WARNING, GTK_MESSAGE_QUESTION, GTK_MESSAGE_ERROR.
textPrintf()-style format string.
...Arguments for the text format string.

Definition at line 729 of file dialogs.c.

References dialog, main_status, main_widgets, NULL, show_msgbox_dialog(), text, and GeanyMainWidgets::window.

Referenced by configure_response_cb(), create_config_dir(), dialogs_show_file_properties(), load_text_file(), open_file_dialog_handle_response(), print_external(), printing_print_gtk(), save_settings(), and set_status().

◆ dialogs_show_msgbox_with_secondary()

void dialogs_show_msgbox_with_secondary ( GtkMessageType  type,
const gchar *  text,
const gchar *  secondary 
)

◆ dialogs_show_open_file()

◆ dialogs_show_open_font()

◆ dialogs_show_prompt()

gint dialogs_show_prompt ( GtkWidget *  parent,
const gchar *  btn_1,
GtkResponseType  response_1,
const gchar *  btn_2,
GtkResponseType  response_2,
const gchar *  btn_3,
GtkResponseType  response_3,
const gchar *  extra_text,
const gchar *  main_text,
  ... 
)

Definition at line 1417 of file dialogs.c.

References show_prompt().

Referenced by kb_find_duplicate().

◆ dialogs_show_question()

gboolean dialogs_show_question ( const gchar *  text,
  ... 
)

Shows a question message box with text and Yes/No buttons.

On Unix-like systems a GTK message dialog box is shown, on Win32 systems a native Windows message dialog box is shown.

Parameters
textPrintf()-style format string.
...Arguments for the text format string.
Returns
TRUE if the user answered with Yes, otherwise FALSE.

Definition at line 1370 of file dialogs.c.

References main_status, main_widgets, NULL, show_prompt(), text, and GeanyMainWidgets::window.

Referenced by handle_current_session(), on_file_save_dialog_response(), print_external(), and setup_config_dir().

◆ dialogs_show_question_full()

gboolean dialogs_show_question_full ( GtkWidget *  parent,
const gchar *  yes_btn,
const gchar *  no_btn,
const gchar *  extra_text,
const gchar *  main_text,
  ... 
)

◆ dialogs_show_save_as()

gboolean dialogs_show_save_as ( void  )

Shows the Save As dialog for the current notebook page.

Returns
TRUE if the file was saved, otherwise FALSE.

Definition at line 667 of file dialogs.c.

References _, document_get_current(), handle_save_as(), interface_prefs, main_widgets, NULL, show_save_as_gtk(), GeanyInterfacePrefs::use_native_windows_dialogs, and GeanyMainWidgets::window.

Referenced by document_save_file(), on_monitor_resave_missing_file_response(), and on_save_as1_activate().

◆ dialogs_show_unsaved_file()

gboolean dialogs_show_unsaved_file ( GeanyDocument doc)

◆ file_chooser_get_filter_idx()

static guint file_chooser_get_filter_idx ( GtkFileChooser *  chooser)
static

Definition at line 93 of file dialogs.c.

References foreach_slist.

Referenced by open_file_dialog_apply_settings(), and open_file_dialog_handle_response().

◆ file_chooser_set_filter_idx()

static void file_chooser_set_filter_idx ( GtkFileChooser *  chooser,
guint  idx 
)
static

Definition at line 113 of file dialogs.c.

Referenced by open_file_dialog_apply_settings().

◆ filetype_combo_box_get_active_filetype()

static gint filetype_combo_box_get_active_filetype ( GtkComboBox *  combo)
static

Definition at line 263 of file dialogs.c.

Referenced by open_file_dialog_handle_response().

◆ filetype_combo_box_set_active_filetype()

static gboolean filetype_combo_box_set_active_filetype ( GtkComboBox *  combo,
const gint  id 
)
static

Definition at line 277 of file dialogs.c.

References ui_tree_model_iter_any_next().

Referenced by open_file_dialog_apply_settings().

◆ filetype_combo_cell_data_func()

static void filetype_combo_cell_data_func ( GtkCellLayout *  cell_layout,
GtkCellRenderer *  cell,
GtkTreeModel *  tree_model,
GtkTreeIter *  iter,
gpointer  data 
)
static

Definition at line 197 of file dialogs.c.

References NULL, and text.

Referenced by create_filetype_combo_box().

◆ handle_save_as()

static gboolean handle_save_as ( const gchar *  utf8_filename,
gboolean  rename_file 
)
static

◆ on_dialog_input()

static void on_dialog_input ( const gchar *  str,
gpointer  data 
)
static

Definition at line 1051 of file dialogs.c.

Referenced by dialogs_show_input(), and dialogs_show_input_goto_line().

◆ on_file_open_check_hidden_toggled()

static void on_file_open_check_hidden_toggled ( GtkToggleButton *  togglebutton,
GtkWidget *  dialog 
)
static

Definition at line 190 of file dialogs.c.

References dialog, filesel_state, FileSelState::open, and FileSelState::show_hidden.

Referenced by add_file_open_extra_widget().

◆ on_file_open_show_hidden_notify()

static void on_file_open_show_hidden_notify ( GObject *  filechooser,
GParamSpec *  pspec,
gpointer  data 
)
static

Definition at line 177 of file dialogs.c.

References ui_lookup_widget().

Referenced by create_open_file_dialog().

◆ on_font_dialog_response()

static void on_font_dialog_response ( GtkDialog *  dialog,
gint  response,
gpointer  user_data 
)
static

Definition at line 849 of file dialogs.c.

References close, ui_set_editor_font(), and ui_widgets.

Referenced by dialogs_show_open_font().

◆ on_input_dialog_response()

static void on_input_dialog_response ( GtkDialog *  dialog,
gint  response,
InputDialogData data 
)
static

◆ on_input_dialog_show()

static void on_input_dialog_show ( GtkDialog *  dialog,
GtkWidget *  entry 
)
static

Definition at line 918 of file dialogs.c.

References entry.

Referenced by dialogs_show_input_full().

◆ on_input_entry_activate()

static void on_input_entry_activate ( GtkEntry *  entry,
GtkDialog *  dialog 
)
static

Definition at line 925 of file dialogs.c.

References dialog.

Referenced by dialogs_show_input_full().

◆ on_input_numeric_activate()

static void on_input_numeric_activate ( GtkEntry *  entry,
GtkDialog *  dialog 
)
static

Definition at line 932 of file dialogs.c.

References dialog.

Referenced by dialogs_show_input_numeric().

◆ open_file_dialog_apply_settings()

◆ open_file_dialog_handle_response()

◆ run_unsaved_dialog()

static gint run_unsaved_dialog ( const gchar *  msg,
const gchar *  msg2 
)
static

Definition at line 771 of file dialogs.c.

References _, dialog, main_widgets, ui_button_new_with_image(), and GeanyMainWidgets::window.

Referenced by dialogs_show_unsaved_file().

◆ save_as_dialog_handle_response()

static gboolean save_as_dialog_handle_response ( GtkWidget *  dialog,
gint  response 
)
static

◆ show_msgbox_dialog()

static void show_msgbox_dialog ( GtkWidget *  dialog,
GtkMessageType  type,
GtkWindow *  parent 
)
static

Definition at line 690 of file dialogs.c.

References _, and dialog.

Referenced by dialogs_show_msgbox(), and dialogs_show_msgbox_with_secondary().

◆ show_prompt()

static gint show_prompt ( GtkWidget *  parent,
const gchar *  btn_1,
GtkResponseType  response_1,
const gchar *  btn_2,
GtkResponseType  response_2,
const gchar *  btn_3,
GtkResponseType  response_3,
const gchar *  question_text,
const gchar *  extra_text 
)
static

◆ show_save_as_gtk()

Variable Documentation

◆ filesel_state

struct FileSelState filesel_state
static
Initial value:
= {
{
0,
-1,
FALSE,
FALSE
}
}
@ GEANY_ENCODINGS_MAX
Definition: encodings.h:124

Referenced by on_file_open_check_hidden_toggled(), open_file_dialog_apply_settings(), and open_file_dialog_handle_response().