Freeciv-3.3
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_button_mouse_click (GtkWidget *w, GdkEventButton *ev, gpointer userdata)
 
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)
 
static int convert_mouse_button (int gdk_mouse_button)
 
gboolean handle_edit_mouse_button_press (GdkEventButton *ev)
 
gboolean handle_edit_mouse_button_release (GdkEventButton *ev)
 
gboolean handle_edit_mouse_move (GdkEventMotion *ev)
 
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 (GtkWidget *evbox, GdkEventButton *ev, gpointer data)
 
static gboolean editinfobox_handle_mode_image_button_press (GtkWidget *evbox, GdkEventButton *ev, gpointer data)
 
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 (GdkEventKey *ev)
 
static gboolean handle_edit_key_press_with_shift (GdkEventKey *ev)
 
gboolean handle_edit_key_press (GdkEventKey *ev)
 
gboolean handle_edit_key_release (GdkEventKey *ev)
 
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 730 of file editgui.c.

Referenced by clear_tool_stores().

◆ clear_tool_stores()

static void clear_tool_stores ( struct editbar eb)
static

Clears all stores from the editbar.

Definition at line 752 of file editgui.c.

Referenced by editbar_reload_tileset(), and editgui_free().

◆ convert_modifiers()

static int convert_modifiers ( int  gdk_event_state)
static

◆ convert_mouse_button()

static int convert_mouse_button ( int  gdk_mouse_button)
static

Convert gdk mouse button values to editor mouse button values.

Definition at line 918 of file editgui.c.

Referenced by handle_edit_mouse_button_press(), and handle_edit_mouse_button_release().

◆ 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 696 of file editgui.c.

Referenced by editbar_reload_tileset(), and get_tool_value_pixbuf().

◆ 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 994 of file editgui.c.

Referenced by editbar_add_tool_button().

◆ 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 478 of file editgui.c.

Referenced by editbar_create().

◆ 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 407 of file editgui.c.

Referenced by editbar_create().

◆ editbar_create()

static struct editbar * editbar_create ( void  )
static

Create and return an editor toolbar.

Definition at line 519 of file editgui.c.

Referenced by editgui_create_widgets().

◆ 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.

Referenced by editbar_add_mode_button(), and refresh_all_buttons().

◆ 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 277 of file editgui.c.

Referenced by editbar_create().

◆ 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 463 of file editgui.c.

Referenced by editbar_create().

◆ editbar_refresh()

static void editbar_refresh ( struct editbar eb)
static

Refresh the given toolbar according to the current editor state.

Definition at line 669 of file editgui.c.

Referenced by editgui_refresh().

◆ 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 765 of file editgui.c.

Referenced by editgui_tileset_changed().

◆ editbar_tool_button_mouse_click()

static gboolean editbar_tool_button_mouse_click ( GtkWidget w,
GdkEventButton ev,
gpointer  userdata 
)
static

Handle a mouse click on any of the tool buttons.

Definition at line 389 of file editgui.c.

Referenced by editbar_add_tool_button().

◆ 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 201 of file editgui.c.

Referenced by editbar_add_tool_button(), and refresh_all_buttons().

◆ editgui_create_widgets()

void editgui_create_widgets ( void  )

Create all editor GUI widgets.

Definition at line 1822 of file editgui.c.

Referenced by setup_widgets().

◆ editgui_free()

void editgui_free ( void  )

Free everything allocated for the editgui.

Definition at line 1835 of file editgui.c.

Referenced by ui_main().

◆ editgui_get_editbar()

struct editbar * editgui_get_editbar ( void  )

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

Definition at line 1788 of file editgui.c.

Referenced by editgui_free(), editgui_refresh(), editgui_run_tool_selection(), editgui_tileset_changed(), and setup_widgets().

◆ 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 1853 of file editgui.c.

Referenced by editgui_free(), editgui_refresh(), editgui_run_tool_selection(), editgui_tileset_changed(), and editinfobox_spin_button_value_changed().

◆ 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 1907 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 1922 of file editgui.c.

Referenced by handle_edit_object_created(), and handle_edit_startpos().

◆ editgui_popdown_all()

void editgui_popdown_all ( void  )

Popup all dialog window of the editor.

Definition at line 1890 of file editgui.c.

Referenced by client_game_free(), and client_game_reset().

◆ 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 1875 of file editgui.c.

Referenced by popup_properties().

◆ editgui_refresh()

void editgui_refresh ( void  )

◆ 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 356 of file editgui.c.

Referenced by editbar_tool_button_mouse_click(), editbar_tool_right_button(), editinfobox_handle_tool_image_button_press(), editinfobox_handle_tool_image_button_press(), handle_edit_key_press(), handle_edit_key_press(), handle_edit_key_press_with_shift(), and handle_edit_key_press_with_shift().

◆ 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 1862 of file editgui.c.

Referenced by set_client_state(), and tileset_changed().

◆ editinfobox_create()

static struct editinfobox * editinfobox_create ( void  )
static

Create and return an editor info box widget bundle.

Definition at line 1167 of file editgui.c.

Referenced by editgui_create_widgets().

◆ editinfobox_handle_mode_image_button_press()

static gboolean editinfobox_handle_mode_image_button_press ( GtkWidget evbox,
GdkEventButton ev,
gpointer  data 
)
static

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

Definition at line 1093 of file editgui.c.

Referenced by editinfobox_create().

◆ editinfobox_handle_tool_image_button_press()

static gboolean editinfobox_handle_tool_image_button_press ( GtkWidget evbox,
GdkEventButton ev,
gpointer  data 
)
static

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

Definition at line 1082 of file editgui.c.

Referenced by editinfobox_create().

◆ editinfobox_refresh()

static void editinfobox_refresh ( struct editinfobox ei)
static

Refresh the given editinfobox according to the current editor state.

Definition at line 1519 of file editgui.c.

Referenced by editgui_refresh(), editgui_run_tool_selection(), editgui_tileset_changed(), and editinfobox_spin_button_value_changed().

◆ 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 1106 of file editgui.c.

Referenced by editinfobox_create().

◆ 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 1142 of file editgui.c.

Referenced by editinfobox_create().

◆ 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 1477 of file editgui.c.

Referenced by editinfobox_refresh().

◆ 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 1406 of file editgui.c.

Referenced by editinfobox_refresh().

◆ handle_edit_key_press()

gboolean handle_edit_key_press ( GdkEventKey ev)

Handle any kind of key press event.

Definition at line 1662 of file editgui.c.

Referenced by toplevel_key_press_handler(), and toplevel_key_press_handler().

◆ handle_edit_key_press_with_ctrl()

static gboolean handle_edit_key_press_with_ctrl ( GdkEventKey ev)
static

Handle ctrl+[key] combinations.

Definition at line 1606 of file editgui.c.

Referenced by handle_edit_key_press(), and handle_edit_key_press().

◆ handle_edit_key_press_with_shift()

static gboolean handle_edit_key_press_with_shift ( GdkEventKey ev)
static

Handle shift+[key] combinations.

Definition at line 1614 of file editgui.c.

Referenced by handle_edit_key_press(), and handle_edit_key_press().

◆ handle_edit_key_release()

gboolean handle_edit_key_release ( GdkEventKey ev)

Key release handler.

Definition at line 1780 of file editgui.c.

Referenced by toplevel_key_release_handler().

◆ handle_edit_mouse_button_press()

gboolean handle_edit_mouse_button_press ( GdkEventButton ev)

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

Definition at line 940 of file editgui.c.

Referenced by butt_down_mapcanvas(), left_butt_down_mapcanvas(), middle_butt_down_mapcanvas(), and right_butt_down_mapcanvas().

◆ handle_edit_mouse_button_release()

gboolean handle_edit_mouse_button_release ( GdkEventButton ev)

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

Definition at line 956 of file editgui.c.

Referenced by butt_release_mapcanvas(), left_butt_up_mapcanvas(), and right_butt_up_mapcanvas().

◆ handle_edit_mouse_move()

gboolean handle_edit_mouse_move ( GdkEventMotion ev)

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

Definition at line 971 of file editgui.c.

Referenced by move_mapcanvas(), and move_mapcanvas().

◆ 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.

Referenced by editbar_refresh().

◆ 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 651 of file editgui.c.

Referenced by editbar_refresh().

◆ 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 223 of file editgui.c.

Referenced by editbar_refresh().

◆ 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 1338 of file editgui.c.

Referenced by editinfobox_refresh().

◆ 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 612 of file editgui.c.

Referenced by refresh_all_tool_value_selectors().

◆ 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 1501 of file editgui.c.

Referenced by editinfobox_refresh().

◆ 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 319 of file editgui.c.

Referenced by editgui_run_tool_selection().

◆ 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 980 of file editgui.c.

Referenced by create_tool_value_selector().

◆ 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.

Referenced by editbar_tool_button_toggled(), handle_edit_key_press(), and handle_edit_key_press().

Variable Documentation

◆ editor_infobox

struct editinfobox* editor_infobox
static

Definition at line 107 of file editgui.c.

Referenced by editgui_create_widgets(), and editgui_get_editinfobox().

◆ editor_toolbar

struct editbar* editor_toolbar
static

Definition at line 106 of file editgui.c.

Referenced by editgui_create_widgets(), and editgui_get_editbar().