diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-07-16 10:05:09 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2011-07-16 10:05:09 +0200 |
commit | 33a08e17fada81e6998576c21c166fb20365c214 (patch) | |
tree | e12da317bd75aceedd4732d3a86b964f2e5ddb09 /src | |
parent | e39907fc0e1e908c9daef17c4f7fb83040953bb7 (diff) |
Menu layout and initial stylesheet window stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.c | 44 | ||||
-rw-r--r-- | src/presentation.c | 2 | ||||
-rw-r--r-- | src/presentation.h | 53 | ||||
-rw-r--r-- | src/stylesheet.c | 124 | ||||
-rw-r--r-- | src/stylesheet.h | 37 |
5 files changed, 232 insertions, 28 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index 75e5365..d6d98f4 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -36,6 +36,7 @@ #include "slide_render.h" #include "objects.h" #include "slideshow.h" +#include "stylesheet.h" static void add_ui_sig(GtkUIManager *ui, GtkWidget *widget, @@ -201,6 +202,15 @@ static gint last_slide_sig(GtkWidget *widget, struct presentation *p) } +static gint open_stylesheet_sig(GtkWidget *widget, struct presentation *p) +{ + if ( p->stylesheetwindow == NULL ) { + p->stylesheetwindow = open_stylesheet(p); + } /* else already open */ + + return FALSE; +} + static gint set_tool_sig(GtkWidget *widget, GtkRadioAction *action, struct presentation *p) { @@ -222,12 +232,40 @@ static void add_menu_bar(struct presentation *p, GtkWidget *vbox) GtkActionEntry entries[] = { { "FileAction", NULL, "_File", NULL, NULL, NULL }, - { "QuitAction", GTK_STOCK_QUIT, "_Quit", NULL, NULL, - G_CALLBACK(quit_sig) }, + { "NewAction", GTK_STOCK_NEW, "_New", + NULL, NULL, NULL }, + { "OpenAction", GTK_STOCK_OPEN, "_Open...", + NULL, NULL, NULL }, + { "SaveAction", GTK_STOCK_SAVE, "_Save", + NULL, NULL, NULL }, + { "SaveAsAction", GTK_STOCK_SAVE_AS, "Save _As...", + NULL, NULL, NULL }, + { "SaveStyleAction", GTK_STOCK_SAVE_AS, "Save St_ylesheet", + NULL, NULL, NULL }, + { "QuitAction", GTK_STOCK_QUIT, "_Quit", + NULL, NULL, G_CALLBACK(quit_sig) }, + + { "EditAction", NULL, "_Edit", NULL, NULL, NULL }, + { "UndoAction", GTK_STOCK_UNDO, "_Undo", + NULL, NULL, NULL }, + { "RedoAction", GTK_STOCK_REDO, "_Redo", + NULL, NULL, NULL }, + { "CutAction", GTK_STOCK_CUT, "Cut", + NULL, NULL, NULL }, + { "CopyAction", GTK_STOCK_COPY, "Copy", + NULL, NULL, NULL }, + { "PasteAction", GTK_STOCK_PASTE, "Paste", + NULL, NULL, NULL }, + { "DeleteAction", GTK_STOCK_DELETE, "Delete", + NULL, NULL, NULL }, + { "EditStyleAction", NULL, "Stylesheet...", + NULL, NULL, G_CALLBACK(open_stylesheet_sig) }, { "ToolsAction", NULL, "_Tools", NULL, NULL, NULL }, { "TSlideshowAction", GTK_STOCK_FULLSCREEN, "_Start slideshow", - "F5", NULL, G_CALLBACK(start_slideshow_sig) }, + "F5", NULL, G_CALLBACK(start_slideshow_sig) }, + { "PrefsAction", GTK_STOCK_PREFERENCES, "_Preferences", + NULL, NULL, NULL }, { "HelpAction", NULL, "_Help", NULL, NULL, NULL }, { "AboutAction", GTK_STOCK_ABOUT, "_About...", diff --git a/src/presentation.c b/src/presentation.c index f9fe1f3..b30895b 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -149,7 +149,7 @@ struct presentation *new_presentation() { struct presentation *new; - new = malloc(sizeof(struct presentation)); + new = calloc(1, sizeof(struct presentation)); new->titlebar = strdup("(untitled)"); new->filename = NULL; diff --git a/src/presentation.h b/src/presentation.h index a61d87b..791010f 100644 --- a/src/presentation.h +++ b/src/presentation.h @@ -30,6 +30,8 @@ #include <gtk/gtk.h> +#include "stylesheet.h" + struct slide { @@ -54,39 +56,42 @@ enum tool struct presentation { - char *titlebar; - char *filename; + char *titlebar; + char *filename; + + GtkWidget *window; + GtkWidget *drawingarea; + GtkUIManager *ui; + GtkActionGroup *action_group; + GtkIMContext *im_context; - GtkWidget *window; - GtkWidget *drawingarea; - GtkUIManager *ui; - GtkActionGroup *action_group; - GtkIMContext *im_context; + /* Dialogue boxes */ + StylesheetWindow *stylesheetwindow; /* Slideshow stuff */ - GtkWidget *slideshow; - GtkWidget *ss_drawingarea; - GdkCursor *blank_cursor; - int ss_blank; - char ss_geom[256]; + GtkWidget *slideshow; + GtkWidget *ss_drawingarea; + GdkCursor *blank_cursor; + int ss_blank; + char ss_geom[256]; - double slide_width; - double slide_height; - double border_offs_x; - double border_offs_y; + double slide_width; + double slide_height; + double border_offs_x; + double border_offs_y; /* The slide currently being displayed */ - unsigned int view_slide_number; - struct slide *view_slide; - struct object *editing_object; + unsigned int view_slide_number; + struct slide *view_slide; + struct object *editing_object; /* Tool status */ - enum tool tool; - double drag_offs_x; - double drag_offs_y; + enum tool tool; + double drag_offs_x; + double drag_offs_y; - unsigned int num_slides; - struct slide **slides; + unsigned int num_slides; + struct slide **slides; }; diff --git a/src/stylesheet.c b/src/stylesheet.c new file mode 100644 index 0000000..3e3ba80 --- /dev/null +++ b/src/stylesheet.c @@ -0,0 +1,124 @@ +/* + * stylesheet.c + * + * Colloquium - A tiny presentation program + * + * Copyright (c) 2011 Thomas White <taw@bitwiz.org.uk> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <string.h> +#include <gtk/gtk.h> +#include <assert.h> + +#include "presentation.h" +#include "stylesheet.h" + + +struct _stylesheetwindow +{ + struct presentation *p; + GtkWidget *window; +}; + + +static void do_text(struct _stylesheetwindow *s, GtkWidget *b) +{ + GtkWidget *table; + GtkWidget *box; + GtkWidget *label; + GtkWidget *combo; + GtkWidget *font; + GtkWidget *colour; + + table = gtk_table_new(3, 2, FALSE); + gtk_box_pack_start(GTK_BOX(b), table, TRUE, TRUE, 5); + gtk_table_set_row_spacings(GTK_TABLE(table), 5.0); + gtk_table_set_col_spacings(GTK_TABLE(table), 5.0); + + label = gtk_label_new("Style:"); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); + combo = gtk_combo_box_new_text(); + gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 2, 0, 1); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Running text"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Label"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Title"); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); + gtk_widget_set_size_request(GTK_WIDGET(combo), 200, -1); + + label = gtk_label_new("Font:"); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); + font = gtk_font_button_new_with_font("Sans 12"); + gtk_table_attach_defaults(GTK_TABLE(table), font, 1, 2, 1, 2); + + label = gtk_label_new("Colour:"); + gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); + colour = gtk_color_button_new(); + box = gtk_hbox_new(FALSE, 0); + gtk_table_attach_defaults(GTK_TABLE(table), box, 1, 2, 2, 3); + gtk_box_pack_start(GTK_BOX(box), colour, FALSE, FALSE, 0); + + +} + + +StylesheetWindow *open_stylesheet(struct presentation *p) +{ + struct _stylesheetwindow *s; + GtkWidget *nb; + GtkWidget *text_box; + GtkWidget *background_box; + + s = malloc(sizeof(*s)); + if ( s == NULL ) return NULL; + + s->p = p; + + s->window = gtk_dialog_new_with_buttons("Stylesheet", + GTK_WINDOW(p->window), 0, + GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, + NULL); + gtk_dialog_set_has_separator(GTK_DIALOG(s->window), FALSE); + + nb = gtk_notebook_new(); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(nb), GTK_POS_TOP); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(s->window)->vbox), nb, + TRUE, TRUE, 0); + + text_box = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(text_box), 12); + gtk_notebook_append_page(GTK_NOTEBOOK(nb), text_box, + gtk_label_new("Text")); + do_text(s, text_box); + + background_box = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(background_box), 12); + gtk_notebook_append_page(GTK_NOTEBOOK(nb), background_box, + gtk_label_new("Background")); + + gtk_widget_show_all(s->window); + + return s; +} diff --git a/src/stylesheet.h b/src/stylesheet.h new file mode 100644 index 0000000..a9c008c --- /dev/null +++ b/src/stylesheet.h @@ -0,0 +1,37 @@ +/* + * stylesheet.h + * + * Colloquium - A tiny presentation program + * + * Copyright (c) 2011 Thomas White <taw@bitwiz.org.uk> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef STYLESHEET_H +#define STYLESHEET_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + + +typedef struct _stylesheetwindow StylesheetWindow; +struct presentation; + +extern StylesheetWindow *open_stylesheet(struct presentation *p); + + +#endif /* STYLESHEET_H */ |