Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions | Variables
editgui.c File Reference
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "fcintl.h"
#include "log.h"
#include "shared.h"
#include "support.h"
#include "connection.h"
#include "game.h"
#include "government.h"
#include "packets.h"
#include "chatline_common.h"
#include "client_main.h"
#include "dialogs_g.h"
#include "editor.h"
#include "mapview_common.h"
#include "tilespec.h"
#include "canvas.h"
#include "editgui.h"
#include "editprop.h"
#include "gui_main.h"
#include "gui_stuff.h"
#include "plrdlg.h"
#include "sprite.h"

Go to the source code of this file.

Data Structures

struct  tool_value_selector
 

Enumerations

enum  tool_value_selector_columns { TVS_COL_IMAGE = 0 , TVS_COL_ID , TVS_COL_NAME , TVS_NUM_COLS }
 
enum  player_pov_combo_columns { PPV_COL_FLAG = 0 , PPV_COL_NAME , PPV_COL_PLAYER_NO , PPV_NUM_COLS }
 
enum  tool_applied_player_columns { TAP_COL_FLAG = 0 , TAP_COL_NAME , TAP_COL_PLAYER_NO , TAP_NUM_COLS }
 
enum  spin_button_types { SPIN_BUTTON_SIZE , SPIN_BUTTON_COUNT }
 

Functions

static struct tool_value_selectorcreate_tool_value_selector (struct editbar *eb_parent, enum editor_tool_type ett)
 
static void editinfobox_refresh (struct editinfobox *ei)
 
static void editbar_player_pov_combobox_changed (GtkComboBox *combo, gpointer user_data)
 
static void editbar_mode_button_toggled (GtkToggleButton *tb, gpointer userdata)
 
static void editbar_tool_button_toggled (GtkToggleButton *tb, gpointer userdata)
 
static void try_to_set_editor_tool (enum editor_tool_type ett)
 
static void refresh_all_buttons (struct editbar *eb)
 
static void refresh_player_pov_indicator (struct editbar *eb)
 
static int tool_value_selector_run (struct tool_value_selector *tvs)
 
static bool editgui_run_tool_selection (enum editor_tool_type ett)
 
static gboolean editbar_tool_right_button (GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
 
static void editbar_add_tool_button (struct editbar *eb, enum editor_tool_type ett)
 
static void editbar_player_properties_button_clicked (GtkButton *b, gpointer userdata)
 
static void editbar_add_mode_button (struct editbar *eb, enum editor_tool_mode etm)
 
static struct editbareditbar_create (void)
 
static void refresh_tool_value_selector (struct editbar *eb, enum editor_tool_type ett)
 
static void refresh_all_tool_value_selectors (struct editbar *eb)
 
static void editbar_refresh (struct editbar *eb)
 
static GdkPixbufcreate_terrain_pixbuf (struct terrain *pterrain)
 
static void clear_tool_store (GtkListStore *store)
 
static void clear_tool_stores (struct editbar *eb)
 
static void editbar_reload_tileset (struct editbar *eb)
 
static int convert_modifiers (int gdk_event_state)
 
gboolean handle_edit_mouse_button_press (GtkGestureClick *gesture, int editor_mouse_button, double x, double y)
 
gboolean handle_edit_mouse_button_release (GtkGestureClick *gesture, int editor_mouse_button, double x, double y)
 
gboolean handle_edit_mouse_move (GtkEventControllerMotion *controller, gdouble x, gdouble y)
 
static void tool_value_selector_treeview_row_activated (GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
 
static gboolean editinfobox_handle_tool_image_button_press (GtkGestureClick *gesture, int n_press, double x, double y)
 
static gboolean editinfobox_handle_mode_image_button_press (GtkGestureClick *gesture, int n_press, double x, double y)
 
static void editinfobox_spin_button_value_changed (GtkSpinButton *spinbutton, gpointer userdata)
 
static void editinfobox_tool_applied_player_changed (GtkComboBox *combo, gpointer userdata)
 
static struct editinfoboxeditinfobox_create (void)
 
static void refresh_tool_applied_player_combo (struct editinfobox *ei)
 
static GdkPixbufget_tool_value_pixbuf (enum editor_tool_type ett, int value)
 
static GdkPixbufget_tool_mode_pixbuf (enum editor_tool_mode etm)
 
static void replace_widget (GtkWidget *old, GtkWidget *new)
 
static gboolean handle_edit_key_press_with_ctrl (guint keyval)
 
static gboolean handle_edit_key_press_with_shift (guint keyval)
 
gboolean handle_edit_key_press (guint keyval, GdkModifierType state)
 
struct editbareditgui_get_editbar (void)
 
void editgui_refresh (void)
 
void editgui_create_widgets (void)
 
void editgui_free (void)
 
struct editinfoboxeditgui_get_editinfobox (void)
 
void editgui_tileset_changed (void)
 
void editgui_popup_properties (const struct tile_list *tiles, int objtype)
 
void editgui_popdown_all (void)
 
void editgui_notify_object_changed (int objtype, int object_id, bool removal)
 
void editgui_notify_object_created (int tag, int id)
 

Variables

static struct editbareditor_toolbar
 
static struct editinfoboxeditor_infobox
 

Enumeration Type Documentation

◆ player_pov_combo_columns

Enumerator
PPV_COL_FLAG 
PPV_COL_NAME 
PPV_COL_PLAYER_NO 
PPV_NUM_COLS 

Definition at line 64 of file editgui.c.

◆ spin_button_types

Enumerator
SPIN_BUTTON_SIZE 
SPIN_BUTTON_COUNT 

Definition at line 80 of file editgui.c.

◆ tool_applied_player_columns

Enumerator
TAP_COL_FLAG 
TAP_COL_NAME 
TAP_COL_PLAYER_NO 
TAP_NUM_COLS 

Definition at line 72 of file editgui.c.

◆ tool_value_selector_columns

Enumerator
TVS_COL_IMAGE 
TVS_COL_ID 
TVS_COL_NAME 
TVS_NUM_COLS 

Definition at line 56 of file editgui.c.

Function Documentation

◆ clear_tool_store()

static void clear_tool_store ( GtkListStore store)
static

Clear icons from tool store, and the store itself.

Definition at line 736 of file editgui.c.

◆ clear_tool_stores()

static void clear_tool_stores ( struct editbar eb)
static

Clears all stores from the editbar.

Definition at line 758 of file editgui.c.

◆ convert_modifiers()

static int convert_modifiers ( int  gdk_event_state)
static

Convert gdk modifier values to editor modifier values.

Definition at line 904 of file editgui.c.

◆ create_terrain_pixbuf()

static GdkPixbuf * create_terrain_pixbuf ( struct terrain pterrain)
static

Create a pixbuf containing a representative image for the given terrain type, to be used as an icon in the GUI.

May return NULL on error.

NB: You must call g_object_unref on the non-NULL return value when you no longer need it.

Definition at line 702 of file editgui.c.

◆ create_tool_value_selector()

static struct tool_value_selector * create_tool_value_selector ( struct editbar eb,
enum editor_tool_type  ett 
)
static

Create a tool value selection dialog for the given toolbar.

Definition at line 985 of file editgui.c.

◆ editbar_add_mode_button()

static void editbar_add_mode_button ( struct editbar eb,
enum editor_tool_mode  etm 
)
static

Helper function to add a tool mode button to the editor toolbar. The button will be packed into the start of the hbox 'eb->widget'.

Definition at line 483 of file editgui.c.

◆ editbar_add_tool_button()

static void editbar_add_tool_button ( struct editbar eb,
enum editor_tool_type  ett 
)
static

A helper function to create a toolbar button for the given editor tool. Packs the newly created button into the hbox 'eb->widget'.

Definition at line 401 of file editgui.c.

◆ editbar_create()

static struct editbar * editbar_create ( void  )
static

Create and return an editor toolbar.

Definition at line 525 of file editgui.c.

◆ editbar_mode_button_toggled()

static void editbar_mode_button_toggled ( GtkToggleButton tb,
gpointer  userdata 
)
static

Callback for all tool mode toggle buttons.

Definition at line 154 of file editgui.c.

◆ editbar_player_pov_combobox_changed()

static void editbar_player_pov_combobox_changed ( GtkComboBox combo,
gpointer  user_data 
)
static

Callback to handle selection of a player/global observer in the player pov indicator.

NB: The convention is that the first entry (index 0) in the combo box corresponds to the "global observer".

Definition at line 278 of file editgui.c.

◆ editbar_player_properties_button_clicked()

static void editbar_player_properties_button_clicked ( GtkButton b,
gpointer  userdata 
)
static

Handle a click on the player properties button in the editor toolbar.

Definition at line 468 of file editgui.c.

◆ editbar_refresh()

static void editbar_refresh ( struct editbar eb)
static

Refresh the given toolbar according to the current editor state.

Definition at line 675 of file editgui.c.

◆ editbar_reload_tileset()

static void editbar_reload_tileset ( struct editbar eb)
static

Reload all tool value data from the tileset for the given toolbar.

Definition at line 771 of file editgui.c.

◆ editbar_tool_button_toggled()

static void editbar_tool_button_toggled ( GtkToggleButton tb,
gpointer  userdata 
)
static

Callback to handle toggling of any of the tool buttons.

Definition at line 202 of file editgui.c.

◆ editbar_tool_right_button()

static gboolean editbar_tool_right_button ( GtkGestureClick gesture,
int  n_press,
double  x,
double  y,
gpointer  data 
)
static

Handle a mouse click on any of the tool buttons.

Definition at line 390 of file editgui.c.

Referenced by editbar_add_tool_button().

◆ editgui_create_widgets()

void editgui_create_widgets ( void  )

Create all editor GUI widgets.

Definition at line 1828 of file editgui.c.

◆ editgui_free()

void editgui_free ( void  )

Free everything allocated for the editgui.

Definition at line 1841 of file editgui.c.

◆ editgui_get_editbar()

struct editbar * editgui_get_editbar ( void  )

Get the pointer for the editbar embedded in the client's GUI.

Definition at line 1794 of file editgui.c.

◆ editgui_get_editinfobox()

struct editinfobox * editgui_get_editinfobox ( void  )

Return a pointer to the editor info box embedded in the client's GUI.

Definition at line 1859 of file editgui.c.

◆ editgui_notify_object_changed()

void editgui_notify_object_changed ( int  objtype,
int  object_id,
bool  removal 
)

This is called to notify the editor GUI that some object (e.g. tile, unit, etc.) has changed (usually because the corresponding packet was received) and that widgets displaying the object should be updated.

Currently this is used to notify the property editor that some object has been removed or some property value has changed at the server.

Definition at line 1913 of file editgui.c.

◆ editgui_notify_object_created()

void editgui_notify_object_created ( int  tag,
int  id 
)

Pass on the object creation notification to the property editor.

Definition at line 1928 of file editgui.c.

◆ editgui_popdown_all()

void editgui_popdown_all ( void  )

Popup all dialog window of the editor.

Definition at line 1896 of file editgui.c.

◆ editgui_popup_properties()

void editgui_popup_properties ( const struct tile_list tiles,
int  objtype 
)

Popup the property editor. If 'tiles' is non-NULL, the tiles, units and cities in those tiles are added to the property editor's object list. If 'objtype' is a valid object type, the corresponding page of the property editor notebook is focused. Otherwise which page is focused depends on what was loaded from 'tiles'.

Definition at line 1881 of file editgui.c.

◆ editgui_refresh()

void editgui_refresh ( void  )

Refresh all editor GUI widgets according to the current editor state.

Definition at line 1802 of file editgui.c.

◆ editgui_run_tool_selection()

static bool editgui_run_tool_selection ( enum editor_tool_type  ett)
static

Run the tool value selector for the given tool type. Sets the editor state and refreshes the editor GUI depending on the user's choices.

Returns FALSE if running the dialog is not possible.

Definition at line 357 of file editgui.c.

◆ editgui_tileset_changed()

void editgui_tileset_changed ( void  )

Update all editor widget internal data for the new tileset. Call this after a new tileset has finished loading.

Definition at line 1868 of file editgui.c.

◆ editinfobox_create()

static struct editinfobox * editinfobox_create ( void  )
static

Create and return an editor info box widget bundle.

Definition at line 1161 of file editgui.c.

◆ editinfobox_handle_mode_image_button_press()

static gboolean editinfobox_handle_mode_image_button_press ( GtkGestureClick gesture,
int  n_press,
double  x,
double  y 
)
static

Handle a mouse click on the mode image area in the editor info box.

Definition at line 1086 of file editgui.c.

◆ editinfobox_handle_tool_image_button_press()

static gboolean editinfobox_handle_tool_image_button_press ( GtkGestureClick gesture,
int  n_press,
double  x,
double  y 
)
static

Handle a mouse click on the tool image area in the editor info box.

Definition at line 1073 of file editgui.c.

◆ editinfobox_refresh()

static void editinfobox_refresh ( struct editinfobox ei)
static

Refresh the given editinfobox according to the current editor state.

Definition at line 1529 of file editgui.c.

◆ editinfobox_spin_button_value_changed()

static void editinfobox_spin_button_value_changed ( GtkSpinButton spinbutton,
gpointer  userdata 
)
static

Callback for spin button changes in the editor info box.

Definition at line 1100 of file editgui.c.

◆ editinfobox_tool_applied_player_changed()

static void editinfobox_tool_applied_player_changed ( GtkComboBox combo,
gpointer  userdata 
)
static

Callback for changes in the applied player combobox in the editor info box.

Definition at line 1136 of file editgui.c.

◆ get_tool_mode_pixbuf()

static GdkPixbuf * get_tool_mode_pixbuf ( enum editor_tool_mode  etm)
static

Return a pixbuf containing an image suitable for use as an icon respresenting the given editor tool mode.

NB: May return NULL. Must call g_object_unref on non-NULL when done.

Definition at line 1479 of file editgui.c.

◆ get_tool_value_pixbuf()

static GdkPixbuf * get_tool_value_pixbuf ( enum editor_tool_type  ett,
int  value 
)
static

Return a pixbuf containing an image for the given editor tool sub-value, if one exists.

NB: Can return NULL. Must call g_object_unref on non-NULL when done.

Definition at line 1408 of file editgui.c.

◆ handle_edit_key_press()

gboolean handle_edit_key_press ( guint  keyval,
GdkModifierType  state 
)

Handle any kind of key press event.

Definition at line 1672 of file editgui.c.

◆ handle_edit_key_press_with_ctrl()

static gboolean handle_edit_key_press_with_ctrl ( guint  keyval)
static

Handle ctrl+[key] combinations.

Definition at line 1616 of file editgui.c.

◆ handle_edit_key_press_with_shift()

static gboolean handle_edit_key_press_with_shift ( guint  keyval)
static

Handle shift+[key] combinations.

Definition at line 1624 of file editgui.c.

◆ handle_edit_mouse_button_press()

gboolean handle_edit_mouse_button_press ( GtkGestureClick gesture,
int  editor_mouse_button,
double  x,
double  y 
)

Pass on the gdk mouse event to the editor's handler.

Definition at line 924 of file editgui.c.

◆ handle_edit_mouse_button_release()

gboolean handle_edit_mouse_button_release ( GtkGestureClick gesture,
int  editor_mouse_button,
double  x,
double  y 
)

Pass on the gdk mouse event to the editor's handler.

Definition at line 941 of file editgui.c.

◆ handle_edit_mouse_move()

gboolean handle_edit_mouse_move ( GtkEventControllerMotion controller,
gdouble  x,
gdouble  y 
)

Pass on the gdk mouse event to the editor's handler.

Definition at line 957 of file editgui.c.

◆ refresh_all_buttons()

static void refresh_all_buttons ( struct editbar eb)
static

Refresh the buttons in the given editbar according to the current editor state.

Definition at line 113 of file editgui.c.

◆ refresh_all_tool_value_selectors()

static void refresh_all_tool_value_selectors ( struct editbar eb)
static

Refresh all tool value selectors in the given toolbar according to the current editor state.

Definition at line 657 of file editgui.c.

◆ refresh_player_pov_indicator()

static void refresh_player_pov_indicator ( struct editbar eb)
static

Refresh the player point-of-view indicator based on the client and editor state.

NB: The convention is that the first entry (index 0) in the combo box corresponds to the "global observer".

Definition at line 224 of file editgui.c.

◆ refresh_tool_applied_player_combo()

static void refresh_tool_applied_player_combo ( struct editinfobox ei)
static

Refresh the given editinfobox's applied player combobox according to the current editor state.

Definition at line 1340 of file editgui.c.

◆ refresh_tool_value_selector()

static void refresh_tool_value_selector ( struct editbar eb,
enum editor_tool_type  ett 
)
static

Refresh the tool value selector in the given toolbar for the given tool type with data from the editor state.

Definition at line 618 of file editgui.c.

◆ replace_widget()

static void replace_widget ( GtkWidget old,
GtkWidget new 
)
static

NB: Assumes that widget 'old' has enough references to not be destroyed when removed from its parent container, and that the parent container is a GtkBox (or is descended from it).

Definition at line 1503 of file editgui.c.

◆ tool_value_selector_run()

static int tool_value_selector_run ( struct tool_value_selector tvs)
static

Run the tool value selection dialog and return the value ID selected. Returns -1 if cancelled.

Definition at line 320 of file editgui.c.

◆ tool_value_selector_treeview_row_activated()

static void tool_value_selector_treeview_row_activated ( GtkTreeView view,
GtkTreePath path,
GtkTreeViewColumn col,
gpointer  user_data 
)
static

Handle a double-click on the tool value list.

Definition at line 971 of file editgui.c.

◆ try_to_set_editor_tool()

static void try_to_set_editor_tool ( enum editor_tool_type  ett)
static

Try to set the given tool as the current editor tool. If the tool is unavailable (editor_tool_is_usable) an error popup is displayed.

Definition at line 177 of file editgui.c.

Variable Documentation

◆ editor_infobox

struct editinfobox* editor_infobox
static

Definition at line 107 of file editgui.c.

◆ editor_toolbar

struct editbar* editor_toolbar
static

Definition at line 106 of file editgui.c.