diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-03-07 17:09:43 +0100 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-03-07 17:09:43 +0100 |
commit | 75d2a56b6420fd65f596b8ee18b02e121147ea4e (patch) | |
tree | 5bcc4e723c52c3d4f50fe5de50d44271bd6d5a0e | |
parent | 67541b83a1c09ad95ed497da3f90c8bf8ce40676 (diff) | |
download | abrt-75d2a56b6420fd65f596b8ee18b02e121147ea4e.tar.gz abrt-75d2a56b6420fd65f596b8ee18b02e121147ea4e.tar.xz abrt-75d2a56b6420fd65f596b8ee18b02e121147ea4e.zip |
renamed some files, no code changes
-rw-r--r-- | src/gui-gtk/Makefile.am | 1 | ||||
-rw-r--r-- | src/gui-gtk/event_config_dialog.c | 112 | ||||
-rw-r--r-- | src/include/Makefile.am | 2 | ||||
-rw-r--r-- | src/include/abrtlib.h | 2 | ||||
-rw-r--r-- | src/include/report/event_config.h (renamed from src/include/report/event_xml_parser.h) | 10 | ||||
-rw-r--r-- | src/lib/event_xml_parser.c | 2 |
6 files changed, 125 insertions, 4 deletions
diff --git a/src/gui-gtk/Makefile.am b/src/gui-gtk/Makefile.am index a0d0de40..30d4f755 100644 --- a/src/gui-gtk/Makefile.am +++ b/src/gui-gtk/Makefile.am @@ -2,6 +2,7 @@ bin_PROGRAMS = abrt-gtk abrt_gtk_SOURCES = \ abrt-gtk.h abrt-gtk.c \ + event_config_dialog.c \ main.c abrt_gtk_CFLAGS = \ -I$(srcdir)/../include/report -I$(srcdir)/../include \ diff --git a/src/gui-gtk/event_config_dialog.c b/src/gui-gtk/event_config_dialog.c new file mode 100644 index 00000000..36f311c8 --- /dev/null +++ b/src/gui-gtk/event_config_dialog.c @@ -0,0 +1,112 @@ +#include "abrtlib.h" +#include <gtk/gtk.h> + +static GtkWidget *option_table; +static int last_row = 0; + +GtkWidget *gtk_label_new_justify_left(const gchar *label_str) +{ + GtkWidget *label = gtk_label_new(label_str); + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment(GTK_MISC(label), /*xalign:*/ 0, /*yalign:*/ 0.5); + return label; +} + +void add_option_to_dialog(event_option_t *option) +{ + + GtkWidget *label; + GtkWidget *option_input; + GtkWidget *option_hbox = gtk_hbox_new(FALSE, 0); + switch(option->type) + { + case OPTION_TYPE_TEXT: + case OPTION_TYPE_NUMBER: + label = gtk_label_new_justify_left(option->label); + gtk_table_attach(GTK_TABLE(option_table), label, + 0, 1, + last_row, last_row+1, + GTK_FILL, GTK_FILL, + 0,0); + option_input = gtk_entry_new(); + gtk_table_attach(GTK_TABLE(option_table), option_input, + 1, 2, + last_row, last_row+1, + GTK_FILL, GTK_FILL, + 0,0); + + break; + case OPTION_TYPE_BOOL: + option_input = gtk_check_button_new_with_label(option->label); + gtk_table_attach(GTK_TABLE(option_table), option_input, + 0, 2, + last_row, last_row+1, + GTK_FILL, GTK_FILL, + 0,0); + break; + case OPTION_TYPE_PASSWORD: + label = gtk_label_new_justify_left(option->label); + gtk_table_attach(GTK_TABLE(option_table), label, + 0, 1, + last_row, last_row+1, + GTK_FILL, GTK_FILL, + 0,0); + option_input = gtk_entry_new(); + gtk_table_attach(GTK_TABLE(option_table), option_input, + 1, 2, + last_row, last_row+1, + GTK_FILL, GTK_FILL, + 0,0); + + gtk_entry_set_visibility(GTK_ENTRY(option_input), 0); + break; + default: + option_input = gtk_label_new_justify_left("WTF?"); + g_print("unsupported option type\n"); + } + last_row++; + + gtk_widget_show_all(GTK_WIDGET(option_hbox)); +} + +void print_option(gpointer data, gpointer user_data) +{ + event_option_t * option = (event_option_t *)data; + /* + g_print("option:\n"); + g_print("\tlabel: %s\n", option->label); + g_print("\tenv name: %s\n", option->name); + g_print("\ttooltip: %s\n", option->description); + g_print("\ttype: %i\n", option->type); + */ + add_option_to_dialog(option); +} + +void show_event_config_dialog(const char* event_name) +{ + event_config_t ui; + ui.options = NULL; + load_event_description_from_file(&ui, "Bugzilla.xml"); + GtkWidget *dialog = gtk_dialog_new_with_buttons( + ui.name, + NULL, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, + GTK_RESPONSE_APPLY, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + NULL); + int length = g_list_length(ui.options); + //g_print("%i\n", length); + option_table = gtk_table_new(length, 2, 0); + g_list_foreach(ui.options, &print_option, NULL); + GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + gtk_box_pack_start(GTK_BOX(content), option_table, 0, 0, 10); + gtk_widget_show_all(option_table); + int result = gtk_dialog_run(GTK_DIALOG(dialog)); + if(result == GTK_RESPONSE_APPLY) + g_print("apply\n"); + else if(result == GTK_RESPONSE_CANCEL) + g_print("cancel\n"); + gtk_widget_destroy(GTK_WIDGET(dialog)); +} diff --git a/src/include/Makefile.am b/src/include/Makefile.am index e21b043b..e6f0387b 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -3,7 +3,7 @@ libreport_include_HEADERS = \ report/crash_data.h \ report/dump_dir.h \ report/run_event.h \ - report/event_xml_parser.h + report/event_config.h libabrt_includedir = $(includedir)/abrt libabrt_include_HEADERS = \ diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 6122f467..435c4def 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -82,7 +82,7 @@ int vdprintf(int d, const char *format, va_list ap); #include "abrt_types.h" #include "dump_dir.h" #include "run_event.h" -#include "event_xml_parser.h" +#include "event_config.h" #ifdef __cplusplus diff --git a/src/include/report/event_xml_parser.h b/src/include/report/event_config.h index 8e55b1b0..ee0cf7ab 100644 --- a/src/include/report/event_xml_parser.h +++ b/src/include/report/event_config.h @@ -40,4 +40,12 @@ typedef struct GList *options; } event_config_t; -void load_event_description_from_file(event_config_t *event_config, const char* filename);
\ No newline at end of file +void load_event_description_from_file(event_config_t *event_config, const char* filename); + +// (Re)loads data from /etc/abrt/events/*.{conf,xml} +void load_event_config_data(void); +/* Frees all loaded data */ +void free_event_config_data(void); +event_config_t *get_event_config(const char *name); + +extern GList *g_event_config_list; // for iterating through entire list of all loaded configs
\ No newline at end of file diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c index da56a51c..7b9edc4f 100644 --- a/src/lib/event_xml_parser.c +++ b/src/lib/event_xml_parser.c @@ -2,7 +2,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "event_xml_parser.h" +#include "event_config.h" #define EVENT_ELEMENT "event" #define LABEL_ELEMENT "label" |