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)  

sidebar.c File Reference
#include "sidebar.h"
#include "app.h"
#include "callbacks.h"
#include "documentprivate.h"
#include "filetypesprivate.h"
#include "geanyobject.h"
#include "keyfile.h"
#include "navqueue.h"
#include "stash.h"
#include "support.h"
#include "symbols.h"
#include "ui_utils.h"
#include "utils.h"
#include "keybindings.h"
#include <string.h>
#include <gdk/gdkkeysyms.h>
Include dependency graph for sidebar.c:

Go to the source code of this file.

Macros

#define CHANGE_TREE(new_child)
 
#define WIDGET(w)   w && GTK_IS_WIDGET(w)
 

Enumerations

enum  { TREEVIEW_SYMBOL = 0 , TREEVIEW_OPENFILES }
 
enum  { OPENFILES_ACTION_REMOVE = 0 , OPENFILES_ACTION_SAVE , OPENFILES_ACTION_RELOAD }
 
enum  {
  DOCUMENTS_ICON , DOCUMENTS_SHORTNAME , DOCUMENTS_DOCUMENT , DOCUMENTS_COLOR ,
  DOCUMENTS_FILENAME
}
 

Functions

static void on_openfiles_document_action (GtkMenuItem *menuitem, gpointer user_data)
 
static gboolean sidebar_button_press_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean sidebar_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 
static void on_list_document_activate (GtkCheckMenuItem *item, gpointer user_data)
 
static void on_list_symbol_activate (GtkCheckMenuItem *item, gpointer user_data)
 
static void documents_menu_update (GtkTreeSelection *selection)
 
static void sidebar_tabs_show_hide (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer data)
 
static void prepare_taglist (GtkWidget *tree, GtkTreeStore *store)
 
static gboolean on_default_tag_tree_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static void create_default_tag_tree (void)
 
void sidebar_update_tag_list (GeanyDocument *doc, gboolean update)
 
static gint documents_sort_func (GtkTreeModel *model, GtkTreeIter *iter_a, GtkTreeIter *iter_b, gpointer data)
 
static void prepare_openfiles (void)
 
static gboolean find_tree_iter_dir (GtkTreeIter *iter, const gchar *dir)
 
static gboolean utils_filename_has_prefix (const gchar *str, const gchar *prefix)
 
static gchar * get_doc_folder (const gchar *path)
 
static GtkTreeIter * get_doc_parent (GeanyDocument *doc)
 
void sidebar_openfiles_add (GeanyDocument *doc)
 
static void openfiles_remove (GeanyDocument *doc)
 
void sidebar_openfiles_update (GeanyDocument *doc)
 
void sidebar_openfiles_update_all (void)
 
void sidebar_remove_document (GeanyDocument *doc)
 
static void on_hide_sidebar (void)
 
static gboolean on_sidebar_display_symbol_list_show (GtkWidget *item)
 
static gboolean on_sidebar_display_open_files_show (GtkWidget *item)
 
void sidebar_add_common_menu_items (GtkMenu *menu)
 
static void on_openfiles_show_paths_activate (GtkCheckMenuItem *item, gpointer user_data)
 
static void on_find_in_files (GtkMenuItem *menuitem, gpointer user_data)
 
static void on_openfiles_expand_collapse (GtkMenuItem *menuitem, gpointer user_data)
 
static void create_openfiles_popup_menu (void)
 
static void unfold_parent (GtkTreeIter *iter)
 
static gboolean tree_model_find_node (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
 
void sidebar_select_openfiles_item (GeanyDocument *doc)
 
static void document_action (GeanyDocument *doc, gint action)
 
static void change_focus_to_editor (GeanyDocument *doc, GtkWidget *source_widget)
 
static gboolean openfiles_go_to_selection (GtkTreeSelection *selection, guint keyval)
 
static gboolean taglist_go_to_selection (GtkTreeSelection *selection, guint keyval, guint state)
 
static gboolean sidebar_button_press_cb (GtkWidget *widget, GdkEventButton *event, G_GNUC_UNUSED gpointer user_data)
 
static void on_load_settings (void)
 
static void on_save_settings (void)
 
static void on_sidebar_switch_page (GtkNotebook *notebook, gpointer page, guint page_num, gpointer user_data)
 
void sidebar_init (void)
 
void sidebar_finalize (void)
 
void sidebar_focus_openfiles_tab (void)
 
void sidebar_focus_symbols_tab (void)
 

Variables

SidebarTreeviews tv = {NULL, NULL, NULL}
 
static gboolean may_steal_focus = FALSE
 
struct {
   GtkWidget *   close
 
   GtkWidget *   save
 
   GtkWidget *   reload
 
   GtkWidget *   show_paths
 
   GtkWidget *   find_in_files
 
   GtkWidget *   expand_all
 
   GtkWidget *   collapse_all
 
doc_items = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 
static GtkTreeStore * store_openfiles
 
static GtkWidget * openfiles_popup_menu
 
static gboolean documents_show_paths
 
static GtkWidget * tag_window
 
static StashGroupstash_group = NULL
 

Macro Definition Documentation

◆ CHANGE_TREE

#define CHANGE_TREE (   new_child)
Value:
G_STMT_START { \
/* only change the tag tree if it's actually not the same (to avoid flickering) and if
* it's the one of the current document (to avoid problems when e.g. reloading
* configuration files */ \
if (child != new_child && doc == document_get_current()) \
{ \
if (child) \
gtk_container_remove(GTK_CONTAINER(tag_window), child); \
gtk_container_add(GTK_CONTAINER(tag_window), new_child); \
} \
} G_STMT_END
GeanyDocument * document_get_current(void)
Finds the current document.
Definition: document.c:371
static GtkWidget * tag_window
Definition: sidebar.c:92

◆ WIDGET

#define WIDGET (   w)    w && GTK_IS_WIDGET(w)

Definition at line 1113 of file sidebar.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TREEVIEW_SYMBOL 
TREEVIEW_OPENFILES 

Definition at line 66 of file sidebar.c.

◆ anonymous enum

anonymous enum
Enumerator
OPENFILES_ACTION_REMOVE 
OPENFILES_ACTION_SAVE 
OPENFILES_ACTION_RELOAD 

Definition at line 72 of file sidebar.c.

◆ anonymous enum

anonymous enum
Enumerator
DOCUMENTS_ICON 
DOCUMENTS_SHORTNAME 
DOCUMENTS_DOCUMENT 
DOCUMENTS_COLOR 
DOCUMENTS_FILENAME 

Definition at line 80 of file sidebar.c.

Function Documentation

◆ change_focus_to_editor()

static void change_focus_to_editor ( GeanyDocument doc,
GtkWidget *  source_widget 
)
static

Definition at line 857 of file sidebar.c.

References document_try_focus(), and may_steal_focus.

Referenced by openfiles_go_to_selection(), and taglist_go_to_selection().

◆ create_default_tag_tree()

static void create_default_tag_tree ( void  )
static

◆ create_openfiles_popup_menu()

◆ document_action()

static void document_action ( GeanyDocument doc,
gint  action 
)
static

◆ documents_menu_update()

static void documents_menu_update ( GtkTreeSelection *  selection)
static

◆ documents_sort_func()

static gint documents_sort_func ( GtkTreeModel *  model,
GtkTreeIter *  iter_a,
GtkTreeIter *  iter_b,
gpointer  data 
)
static

Definition at line 252 of file sidebar.c.

References DOCUMENTS_SHORTNAME.

Referenced by prepare_openfiles().

◆ find_tree_iter_dir()

static gboolean find_tree_iter_dir ( GtkTreeIter *  iter,
const gchar *  dir 
)
static

◆ get_doc_folder()

static gchar * get_doc_folder ( const gchar *  path)
static

◆ get_doc_parent()

◆ on_default_tag_tree_button_press_event()

static gboolean on_default_tag_tree_button_press_event ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

Definition at line 154 of file sidebar.c.

References NULL, SidebarTreeviews::popup_taglist, and tv.

Referenced by create_default_tag_tree().

◆ on_find_in_files()

static void on_find_in_files ( GtkMenuItem *  menuitem,
gpointer  user_data 
)
static

◆ on_hide_sidebar()

static void on_hide_sidebar ( void  )
static

Definition at line 568 of file sidebar.c.

References ui_prefs, and ui_sidebar_show_hide().

Referenced by sidebar_add_common_menu_items().

◆ on_list_document_activate()

static void on_list_document_activate ( GtkCheckMenuItem *  item,
gpointer  user_data 
)
static

◆ on_list_symbol_activate()

static void on_list_symbol_activate ( GtkCheckMenuItem *  item,
gpointer  user_data 
)
static

◆ on_load_settings()

◆ on_openfiles_document_action()

static void on_openfiles_document_action ( GtkMenuItem *  menuitem,
gpointer  user_data 
)
static

◆ on_openfiles_expand_collapse()

static void on_openfiles_expand_collapse ( GtkMenuItem *  menuitem,
gpointer  user_data 
)
static

Definition at line 670 of file sidebar.c.

References expand(), SidebarTreeviews::tree_openfiles, and tv.

Referenced by create_openfiles_popup_menu().

◆ on_openfiles_show_paths_activate()

static void on_openfiles_show_paths_activate ( GtkCheckMenuItem *  item,
gpointer  user_data 
)
static

Definition at line 622 of file sidebar.c.

References documents_show_paths, and sidebar_openfiles_update_all().

Referenced by create_openfiles_popup_menu().

◆ on_save_settings()

static void on_save_settings ( void  )
static

◆ on_sidebar_display_open_files_show()

static gboolean on_sidebar_display_open_files_show ( GtkWidget *  item)
static

◆ on_sidebar_display_symbol_list_show()

static gboolean on_sidebar_display_symbol_list_show ( GtkWidget *  item)
static

◆ on_sidebar_switch_page()

static void on_sidebar_switch_page ( GtkNotebook *  notebook,
gpointer  page,
guint  page_num,
gpointer  user_data 
)
static

Definition at line 1077 of file sidebar.c.

References document_get_current(), sidebar_update_tag_list(), and TREEVIEW_SYMBOL.

Referenced by sidebar_init().

◆ openfiles_go_to_selection()

static gboolean openfiles_go_to_selection ( GtkTreeSelection *  selection,
guint  keyval 
)
static

◆ openfiles_remove()

static void openfiles_remove ( GeanyDocument doc)
static

◆ prepare_openfiles()

◆ prepare_taglist()

◆ sidebar_add_common_menu_items()

◆ sidebar_button_press_cb() [1/2]

static gboolean sidebar_button_press_cb ( GtkWidget *  widget,
GdkEventButton *  event,
G_GNUC_UNUSED gpointer  user_data 
)
static

◆ sidebar_button_press_cb() [2/2]

static gboolean sidebar_button_press_cb ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

◆ sidebar_finalize()

void sidebar_finalize ( void  )

◆ sidebar_focus_openfiles_tab()

◆ sidebar_focus_symbols_tab()

void sidebar_focus_symbols_tab ( void  )

◆ sidebar_init()

◆ sidebar_key_press_cb()

static gboolean sidebar_key_press_cb ( GtkWidget *  widget,
GdkEventKey *  event,
gpointer  user_data 
)
static

◆ sidebar_openfiles_add()

◆ sidebar_openfiles_update()

◆ sidebar_openfiles_update_all()

void sidebar_openfiles_update_all ( void  )

◆ sidebar_remove_document()

void sidebar_remove_document ( GeanyDocument doc)

Definition at line 554 of file sidebar.c.

References NULL, openfiles_remove(), GeanyDocument::priv, and GeanyDocumentPrivate::tag_tree.

Referenced by remove_page().

◆ sidebar_select_openfiles_item()

void sidebar_select_openfiles_item ( GeanyDocument doc)

Definition at line 790 of file sidebar.c.

References store_openfiles, and tree_model_find_node().

Referenced by main_lib(), and on_notebook1_switch_page_after().

◆ sidebar_tabs_show_hide()

static void sidebar_tabs_show_hide ( GtkNotebook *  notebook,
GtkWidget *  child,
guint  page_num,
gpointer  data 
)
static

◆ sidebar_update_tag_list()

◆ taglist_go_to_selection()

static gboolean taglist_go_to_selection ( GtkTreeSelection *  selection,
guint  keyval,
guint  state 
)
static

◆ tree_model_find_node()

static gboolean tree_model_find_node ( GtkTreeModel *  model,
GtkTreePath *  path,
GtkTreeIter *  iter,
gpointer  data 
)
static

◆ unfold_parent()

static void unfold_parent ( GtkTreeIter *  iter)
static

Definition at line 755 of file sidebar.c.

References store_openfiles, SidebarTreeviews::tree_openfiles, and tv.

Referenced by tree_model_find_node().

◆ utils_filename_has_prefix()

static gboolean utils_filename_has_prefix ( const gchar *  str,
const gchar *  prefix 
)
static

Definition at line 356 of file sidebar.c.

References utils_filenamecmp.

Referenced by get_doc_folder().

Variable Documentation

◆ close

◆ collapse_all

GtkWidget* collapse_all

Definition at line 62 of file sidebar.c.

◆ 

struct { ... } doc_items

◆ documents_show_paths

gboolean documents_show_paths
static

◆ expand_all

GtkWidget* expand_all

Definition at line 61 of file sidebar.c.

◆ find_in_files

GtkWidget* find_in_files

Definition at line 60 of file sidebar.c.

◆ may_steal_focus

gboolean may_steal_focus = FALSE
static

Definition at line 52 of file sidebar.c.

Referenced by change_focus_to_editor(), sidebar_button_press_cb(), and sidebar_key_press_cb().

◆ openfiles_popup_menu

GtkWidget* openfiles_popup_menu
static

◆ reload

GtkWidget* reload

Definition at line 58 of file sidebar.c.

Referenced by document_open_file_full(), and filetypes_load_config().

◆ save

◆ show_paths

GtkWidget* show_paths

Definition at line 59 of file sidebar.c.

◆ stash_group

StashGroup* stash_group = NULL
static

Definition at line 1057 of file sidebar.c.

Referenced by on_load_settings(), on_save_settings(), and sidebar_init().

◆ store_openfiles

◆ tag_window

GtkWidget* tag_window
static

Definition at line 92 of file sidebar.c.

Referenced by create_default_tag_tree(), on_load_settings(), and sidebar_update_tag_list().

◆ tv