summaryrefslogtreecommitdiff
path: root/callbacks.c
diff options
context:
space:
mode:
authorb0ric <b0risov.alexandr@rambler.ru>2009-08-10 01:08:31 +0300
committerb0ric <b0risov.alexandr@rambler.ru>2009-08-10 01:08:31 +0300
commitd2b347e0aa6e5fc3de95253c43900c15938dbaaf (patch)
tree8f7a3a2756e9cf5292348170a45d971dc061b871 /callbacks.c
parent343357ed1e7907cf4b488058053df280ae63c7bb (diff)
Interface modification and improvement. Lecense changed to GPLv3
Diffstat (limited to 'callbacks.c')
-rw-r--r--callbacks.c178
1 files changed, 0 insertions, 178 deletions
diff --git a/callbacks.c b/callbacks.c
deleted file mode 100644
index d3fe1bc..0000000
--- a/callbacks.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/* This file is a part of WordExtract project
- *
- * Copyright (C) 2009 Borisov Alexandr
- *
- * 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 2 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/>.
- */
-
-#include <gtk/gtk.h>
-#include <stdlib.h>
-#include <string.h>
-#include "callbacks.h"
-#include "main.h"
-#include "mainwin.h"
-#include "listview.h"
-#include "dictwin.h"
-#include "srt.h"
-#include "word.h"
-
-#define QUIT_MSG_CAPTION "Confirmation"
-#define QUIT_MSG_TEXT "Are you sure to exit?"
-#define ERR_READING_FILE "Error reading file"
-#define ERR_MSG_CAPTION "Error"
-
-gint main_window_close(GtkWidget *widget, GdkEvent *event, gpointer main_window)
-{
- GtkWidget *dialog;
- gint response = TRUE;
-
- dialog = gtk_message_dialog_new(main_window, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, QUIT_MSG_TEXT);
- gtk_window_set_title(GTK_WINDOW(dialog), QUIT_MSG_CAPTION);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES)
- response = FALSE;
- gtk_widget_destroy(dialog);
-
- return response;
-}
-
-void main_window_destroy(GtkWidget *widget, gpointer data)
-{
- gtk_main_quit();
-}
-
-void open_btn_click(GtkWidget *widget, gpointer parent)
-{
- GtkWidget *filedialog;
- GtkWidget *errmsg;
- GtkFileFilter *filter;
- char *filename;
- char *errstr;
- FILE *subtitle;
- char **word_list;
-
- filter = gtk_file_filter_new();
- gtk_file_filter_add_mime_type(filter, "application/x-subrip");
- gtk_file_filter_set_name(filter, "SubRip subtitles (*srt)");
- filedialog = gtk_file_chooser_dialog_new("Open File", parent, GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN,
- GTK_RESPONSE_ACCEPT, NULL);
- gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filedialog), filter);
- if (gtk_dialog_run(GTK_DIALOG(filedialog)) == GTK_RESPONSE_ACCEPT) {
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filedialog));
- if (!(subtitle = fopen(filename, "r"))) {
- gtk_widget_destroy(filedialog);
- errstr = malloc(strlen(filename) + strlen(ERR_READING_FILE));
- strcpy(errstr, ERR_READING_FILE);
- strcat(errstr, filename);
- errmsg = gtk_message_dialog_new(GTK_WINDOW(main_window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, errstr);
- gtk_window_set_title(GTK_WINDOW(errmsg), ERR_MSG_CAPTION);
- gtk_dialog_run(GTK_DIALOG(errmsg));
- gtk_widget_destroy(errmsg);
- free(errstr);
- return ;
- }
- if (words != NULL) {
- /*we won't free() 'words' variable, it's statical*/
- free_words(words->lsibl);
- free_words(words->rsibl);
- free(words->word);
- words = NULL;
- clear_word_list();
- clear_sentences();
- }
- else
- enable_search();
- process_srt(subtitle);
- word_list = get_sorted();
- fill_list(word_list);
- free(word_list);
- fclose(subtitle);
- }
- gtk_widget_destroy(filedialog);
-}
-
-void dict_btn_click(GtkWidget *widget, gpointer data)
-{
- create_dict_win();
-}
-
-void show_about(GtkWidget *widget, gpointer data)
-{
- const gchar *authors[] = {"Borisov Alexandr aka b0ric", NULL};
- const gchar comment[] = {"WordExtract is a subtitle parser\n which shows all unique words\n from files."};
- const gchar copyright[] = {"Copyright \xc2\xa9 2009 by Borisov Alexandr"};
-
- gtk_show_about_dialog(GTK_WINDOW(main_window), "name", "WordExtract",
- "version", "v0.2",
- "website", "http://null.net",
- "comments", comment,
- "copyright", copyright,
- "authors", authors,
- "documenters", NULL,
- "translator-credits", NULL,
- "logo", NULL, NULL);
-}
-
-void quit_btn_click(GtkWidget *widget, gpointer data)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, QUIT_MSG_TEXT);
- gtk_window_set_title(GTK_WINDOW(dialog), QUIT_MSG_CAPTION);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES) {
- gtk_widget_destroy(dialog);
- gtk_main_quit();
- }
- else
- gtk_widget_destroy(dialog);
-}
-
-void on_find_text_change(GtkWidget *find_entry, gpointer data)
-{
- const gchar *find_text;
-
- find_text = gtk_entry_get_text(GTK_ENTRY(find_entry));
- change_search_navigation_state(strcmp(find_text, ""));
- if (strcmp(find_text, ""))
- search_sentences(find_text);
-}
-
-void find_next_btn_click(GtkWidget *widget, gpointer entry)
-{
- const gchar *find_text = NULL;
-
- find_text = gtk_entry_get_text(GTK_ENTRY(entry));
- find_other(find_text, SEARCH_FORWARD);
-}
-
-void find_prev_btn_click(GtkWidget *widget, gpointer entry)
-{
- const gchar *find_text = NULL;
-
- find_text = gtk_entry_get_text(GTK_ENTRY(entry));
- find_other(find_text, SEARCH_BACKWARD);
-}
-
-void clear_btn_click(GtkWidget *widget, gpointer find_entry)
-{
- clear_search_tags();
- gtk_entry_set_text(GTK_ENTRY(find_entry), "");
- change_search_navigation_state(FALSE);
-}
-
-