Commit 6d638d25 by Herman Ounas

Undo/Redo nupud tootavad. Lisatud ikoon

parent 39c7e92d
Showing with 35 additions and 7 deletions
...@@ -34,6 +34,8 @@ typedef struct ...@@ -34,6 +34,8 @@ typedef struct
GtkWidget *ToolBar; //Tool bar GtkWidget *ToolBar; //Tool bar
GtkWidget *AccelGroup; // Accel group nuppude jaoks GtkWidget *AccelGroup; // Accel group nuppude jaoks
GdkPixbuf *Icon; //akna ikoon
// Viited nuppudele nende sisse/välja lülitamiseks // Viited nuppudele nende sisse/välja lülitamiseks
GtkWidget *FailMenuAva; GtkWidget *FailMenuAva;
GtkWidget *FailMenuSalvesta; GtkWidget *FailMenuSalvesta;
...@@ -47,6 +49,7 @@ typedef struct ...@@ -47,6 +49,7 @@ typedef struct
//toolbari nupud //toolbari nupud
GtkToolItem *Undo; //undo nupp GtkToolItem *Undo; //undo nupp
GtkToolItem *Redo; //redo nupp GtkToolItem *Redo; //redo nupp
GtkSourceUndoManager *UndoManager;
//Stiili asjad //Stiili asjad
GtkSourceStyleSchemeManager *SchemeManager; GtkSourceStyleSchemeManager *SchemeManager;
......
cpic.png

34.9 KB

...@@ -18,9 +18,6 @@ void Chooser(GtkWidget *Nupp, gpointer Data){ ...@@ -18,9 +18,6 @@ void Chooser(GtkWidget *Nupp, gpointer Data){
gtk_widget_show_all(Aken); gtk_widget_show_all(Aken);
} }
void SetStyle(GtkWidget *nupp, gpointer Data){ void SetStyle(GtkWidget *nupp, gpointer Data){
ui *UI = (ui *)Data; ui *UI = (ui *)Data;
UI->Scheme = gtk_source_style_scheme_chooser_get_style_scheme(UI->SchemeChooser);
gtk_source_style_scheme_chooser_set_style_scheme(UI->SchemeChooser, UI->Scheme);
} }
...@@ -69,7 +69,7 @@ void LisaTab(ui *UI) ...@@ -69,7 +69,7 @@ void LisaTab(ui *UI)
Tab->Language = gtk_source_language_manager_get_language(Tab->LangManager, "c"); Tab->Language = gtk_source_language_manager_get_language(Tab->LangManager, "c");
gtk_source_buffer_set_language(Tab->Puhver, Tab->Language); gtk_source_buffer_set_language(Tab->Puhver, Tab->Language);
// gtk_source_buffer_set_style_scheme(Tab->Puhver, UI->Scheme); UI->UndoManager = gtk_source_buffer_get_undo_manager(Tab->Puhver);
// Lisa loodud tab notebook'i // Lisa loodud tab notebook'i
gtk_notebook_append_page(GTK_NOTEBOOK(UI->Notebook), Tab->Box, Tab->Pealkiri); gtk_notebook_append_page(GTK_NOTEBOOK(UI->Notebook), Tab->Box, Tab->Pealkiri);
......
#include "ui.h" #include "ui.h"
GdkPixbuf *create_pixbuf(const gchar * filename) {
GdkPixbuf *pixbuf;
GError *error = NULL;
pixbuf = gdk_pixbuf_new_from_file(filename, &error);
if (!pixbuf) {
fprintf(stderr, "%s\n", error->message);
g_error_free(error);
}
return pixbuf;
}
// Sulge programm, tagastab 1 kui kõik vahekaardid sulgeti, 0 kui mitte // Sulge programm, tagastab 1 kui kõik vahekaardid sulgeti, 0 kui mitte
int Sulge(ui *UI) int Sulge(ui *UI)
{ {
...@@ -34,8 +46,21 @@ gboolean SulgeAken(GtkWidget *Nupp, GdkEvent *Event, gpointer Data) ...@@ -34,8 +46,21 @@ gboolean SulgeAken(GtkWidget *Nupp, GdkEvent *Event, gpointer Data)
void Valju(GtkWidget *Nupp, gpointer Data) void Valju(GtkWidget *Nupp, gpointer Data)
{ {
ui *UI = (ui *)Data; ui *UI = (ui *)Data;
if(Sulge(UI)) gtk_main_quit();
}
void UndoFunc(GtkWidget *Nupp, gpointer Data){
ui *UI = (ui *)Data;
if(gtk_source_undo_manager_can_undo(UI->UndoManager) == TRUE){
gtk_source_undo_manager_undo(UI->UndoManager);
}
}
if(Sulge(UI)) gtk_main_quit();; void RedoFunc(GtkWidget *Nupp, gpointer Data){
ui *UI = (ui *)Data;
if(gtk_source_undo_manager_can_redo(UI->UndoManager) == TRUE){
gtk_source_undo_manager_redo(UI->UndoManager);
}
} }
// Lisa menüüsse menu item // Lisa menüüsse menu item
...@@ -60,6 +85,9 @@ ui *LooUI() ...@@ -60,6 +85,9 @@ ui *LooUI()
UI->SchemeManager = gtk_source_style_scheme_manager_get_default(); UI->SchemeManager = gtk_source_style_scheme_manager_get_default();
UI->Icon = create_pixbuf("cpic.png");
gtk_window_set_icon(GTK_WINDOW(UI->Aken), UI->Icon);
// Box // Box
UI->Box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); // Vertikaalne box, 0px vahe UI->Box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); // Vertikaalne box, 0px vahe
gtk_container_add(GTK_CONTAINER(UI->Aken), UI->Box); // Pane box aknasse gtk_container_add(GTK_CONTAINER(UI->Aken), UI->Box); // Pane box aknasse
...@@ -136,13 +164,13 @@ ui *LooUI() ...@@ -136,13 +164,13 @@ ui *LooUI()
GtkWidget *UndoIcon = gtk_image_new_from_icon_name(GTK_STOCK_UNDO, 5); GtkWidget *UndoIcon = gtk_image_new_from_icon_name(GTK_STOCK_UNDO, 5);
GtkWidget *RedoIcon = gtk_image_new_from_icon_name(GTK_STOCK_REDO, 5); GtkWidget *RedoIcon = gtk_image_new_from_icon_name(GTK_STOCK_REDO, 5);
UI->Undo = gtk_tool_button_new(UndoIcon, "undo"); UI->Undo = gtk_tool_button_new(UndoIcon, "undo");
g_signal_connect(UI->Undo, "clicked", G_CALLBACK(UndoFunc), UI);
UI->Redo = gtk_tool_button_new(RedoIcon, "redo"); UI->Redo = gtk_tool_button_new(RedoIcon, "redo");
g_signal_connect(UI->Redo, "clicked", G_CALLBACK(RedoFunc), UI);
//nupud toolbarile //nupud toolbarile
gtk_toolbar_insert(GTK_TOOLBAR(UI->ToolBar), UI->Undo, -1); gtk_toolbar_insert(GTK_TOOLBAR(UI->ToolBar), UI->Undo, -1);
gtk_toolbar_insert(GTK_TOOLBAR(UI->ToolBar), UI->Redo, -1); gtk_toolbar_insert(GTK_TOOLBAR(UI->ToolBar), UI->Redo, -1);
// Pane kõik õiges järjekorras box'i // Pane kõik õiges järjekorras box'i
gtk_box_pack_start(GTK_BOX(UI->Box), UI->MenuBar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(UI->Box), UI->MenuBar, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(UI->Box), UI->ToolBar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(UI->Box), UI->ToolBar, FALSE, FALSE, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment