Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ dkms.conf
.cleaf-backups/
.cleaf-save-*.tmp
.cleaf-latex-build/

# Github actions
.github/
37 changes: 36 additions & 1 deletion src/app/app_about_view_actions.inc.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
/**
* @file src/app/app_about_view_actions.inc.c
* @brief Cleaf app about view actions module.
*/

GtkWidget *pref_section(const char *text) {
GtkWidget *label = gtk_label_new(text ? text : "");
gtk_label_set_xalign(GTK_LABEL(label), 0.0f);
gtk_widget_add_css_class(label, "cleaf-menu-title");
return label;
}

/**
* @brief Pref tab label.
*/
GtkWidget *pref_tab_label(const char *text) {
GtkWidget *label = gtk_label_new(text ? text : "");
// Perhaps this should be in config or part of the themeing engine.
Expand All @@ -17,6 +25,9 @@ GtkWidget *pref_tab_label(const char *text) {
}


/**
* @brief Cleaf prefers dark theme.
*/
static gboolean cleaf_prefers_dark_theme(void) {
GtkSettings *settings = gtk_settings_get_default();
gboolean dark = FALSE;
Expand All @@ -28,6 +39,9 @@ static gboolean cleaf_prefers_dark_theme(void) {
return dark;
}

/**
* @brief Cleaf logo path for theme.
*/
static char *cleaf_logo_path_for_theme(gboolean dark) {
const char *filename = dark ? "cleaf-logo-dark.png" : "cleaf-logo-light.png";

Expand All @@ -42,20 +56,26 @@ static char *cleaf_logo_path_for_theme(gboolean dark) {
return NULL;
}

/**
* @brief Cleaf about logo new.
*/
static GtkWidget *cleaf_about_logo_new(void) {
char *path = cleaf_logo_path_for_theme(cleaf_prefers_dark_theme());
if (!path) return NULL;

GtkWidget *picture = gtk_picture_new_for_filename(path);
gtk_widget_set_size_request(picture, 170, 170);
gtk_picture_set_can_shrink(GTK_PICTURE(picture), TRUE);
gtk_picture_set_keep_aspect_ratio(GTK_PICTURE(picture), TRUE);
gtk_picture_set_content_fit(GTK_PICTURE(picture), GTK_CONTENT_FIT_CONTAIN);
gtk_widget_set_halign(picture, GTK_ALIGN_CENTER);
gtk_widget_set_valign(picture, GTK_ALIGN_CENTER);
g_free(path);
return picture;
}

/**
* @brief Cleaf about label new.
*/
static GtkWidget *cleaf_about_label_new(const char *text, gboolean title) {
GtkWidget *label = gtk_label_new(text ? text : "");
gtk_label_set_xalign(GTK_LABEL(label), 0.5f);
Expand All @@ -65,6 +85,9 @@ static GtkWidget *cleaf_about_label_new(const char *text, gboolean title) {
return label;
}

/**
* @brief Action about.
*/
void action_about(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand Down Expand Up @@ -97,6 +120,9 @@ void action_about(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action show preferences.
*/
void action_show_preferences(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -107,6 +133,9 @@ void action_show_preferences(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action toggle minimap.
*/
void action_toggle_minimap(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -118,6 +147,9 @@ void action_toggle_minimap(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action toggle preview.
*/
void action_toggle_preview(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -128,6 +160,9 @@ void action_toggle_preview(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action render latex.
*/
void action_render_latex(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorTab *tab = app_window_current_tab(user_data);
Expand Down
56 changes: 56 additions & 0 deletions src/app/app_file_search_actions.inc.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @file src/app/app_file_search_actions.inc.c
* @brief Cleaf app file search actions module.
*/

void set_search_panel(EditorWindow *win, gboolean visible, gboolean replace_mode) {
if (!win || !win->search_revealer) return;
/* Find and Replace as one panel.
Expand All @@ -16,6 +21,9 @@ void set_search_panel(EditorWindow *win, gboolean visible, gboolean replace_mode
}


/**
* @brief Action new.
*/
void action_new(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -24,6 +32,9 @@ void action_new(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action open.
*/
void action_open(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -37,6 +48,9 @@ void action_open(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action open folder.
*/
void action_open_folder(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -61,6 +75,9 @@ void action_open_folder(GtkWidget *widget, gpointer user_data) {
g_free(folder);
}

/**
* @brief Cleaf executable path.
*/
static char *cleaf_executable_path(void) {
GError *error = NULL;
char *path = g_file_read_link("/proc/self/exe", &error);
Expand All @@ -72,6 +89,9 @@ static char *cleaf_executable_path(void) {
return g_strdup("cleaf");
}

/**
* @brief Action open folder new instance.
*/
void action_open_folder_new_instance(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand Down Expand Up @@ -111,38 +131,56 @@ void action_open_folder_new_instance(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action save.
*/
void action_save(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorTab *tab = app_window_current_tab(user_data);
if (tab) editor_tab_save(tab, FALSE);
}


/**
* @brief Action save as.
*/
void action_save_as(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorTab *tab = app_window_current_tab(user_data);
if (tab) editor_tab_save(tab, TRUE);
}


/**
* @brief Action show find.
*/
void action_show_find(GtkWidget *widget, gpointer user_data) {
(void)widget;
set_search_panel(user_data, TRUE, FALSE);
}


/**
* @brief Action show replace.
*/
void action_show_replace(GtkWidget *widget, gpointer user_data) {
(void)widget;
set_search_panel(user_data, TRUE, TRUE);
}


/**
* @brief Action hide search.
*/
void action_hide_search(GtkWidget *widget, gpointer user_data) {
(void)widget;
set_search_panel(user_data, FALSE, FALSE);
}


/**
* @brief Action find next.
*/
void action_find_next(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -152,6 +190,9 @@ void action_find_next(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action find prev.
*/
void action_find_prev(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -161,6 +202,9 @@ void action_find_prev(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action replace.
*/
void action_replace(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -171,6 +215,9 @@ void action_replace(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action replace all.
*/
void action_replace_all(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorWindow *win = user_data;
Expand All @@ -181,20 +228,29 @@ void action_replace_all(GtkWidget *widget, gpointer user_data) {
}


/**
* @brief Action comment.
*/
void action_comment(GtkWidget *widget, gpointer user_data) {
(void)widget;
EditorTab *tab = app_window_current_tab(user_data);
if (tab) editor_tab_toggle_comment(tab);
}


/**
* @brief Action reload syntax.
*/
void action_reload_syntax(GtkWidget *widget, gpointer user_data) {
// Syntax definitions are runtime files, so reload them without restarting the editor
(void)widget;
app_window_reload_syntaxes(user_data);
}


/**
* @brief Action syntax diagnostics.
*/
void action_syntax_diagnostics(GtkWidget *widget, gpointer user_data) {
//Should add functional diagnostics. This is just for show.
(void)widget;
Expand Down
Loading