From: munkyu.im Date: Sat, 10 Dec 2011 03:27:26 +0000 (+0900) Subject: [Title] add sized dialog message X-Git-Tag: TizenStudio_2.0_p2.3~1694^2~172^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b3ab3bf64110473f1cd9e40369a19ed8e90fb87;p=sdk%2Femulator%2Fqemu.git [Title] add sized dialog message [Type] [Module] [Priority] [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/tizen/src/defines.h b/tizen/src/defines.h index 1dce0b3..8f2268b 100644 --- a/tizen/src/defines.h +++ b/tizen/src/defines.h @@ -170,7 +170,7 @@ extern "C" { #define MIDBUF 128 #define QEMUARGC 70 - +#define DIALOG_MAX_WIDTH 70 #define NON_BUTTON_REGION -1 /* Tag for getting GTK OBJECT POINTER */ diff --git a/tizen/src/dialog.c b/tizen/src/dialog.c index 272faba..c166b4e 100644 --- a/tizen/src/dialog.c +++ b/tizen/src/dialog.c @@ -46,20 +46,73 @@ //DEFAULT_DEBUG_CHANNEL(tizen); MULTI_DEBUG_CHANNEL(tizen, dialog); +void show_message(const char *szTitle, const char *szMessage) +{ + GtkWidget *label; + GtkWidget *button; + GtkWidget *dialog_window; + /* create Dialog */ + + dialog_window = gtk_dialog_new(); + + /* Widget Icon set */ + + GdkPixbuf* tmppixbuf = NULL; + tmppixbuf=gtk_widget_render_icon((GtkWidget *) (dialog_window), GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU, NULL); + gtk_window_set_icon(GTK_WINDOW (dialog_window), tmppixbuf); + + /* set Title and Border */ + + gtk_window_set_title(GTK_WINDOW(dialog_window), szTitle); + gtk_container_set_border_width(GTK_CONTAINER(dialog_window), 0); + + /* set dialog not resizble */ + + gtk_window_set_resizable(GTK_WINDOW(dialog_window), FALSE); + + /* create OK Button and Set Reponse */ + + button = gtk_dialog_add_button(GTK_DIALOG(dialog_window), GTK_STOCK_OK, GTK_RESPONSE_OK); + + /* set OK Button to Default Button */ +#if GTK_CHECK_VERSION(2,20,0) + gtk_widget_set_can_default(button, TRUE); +#else + GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); +#endif + gtk_widget_grab_default(button); + + /* create Label */ + + label = gtk_label_new(szMessage); + + /* set Padding arround Label */ + + gtk_misc_set_padding(GTK_MISC(label), 10, 10); + + /* pack Label to Dialog */ + + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->vbox), label, TRUE, TRUE, 0); + + gtk_widget_show_all(dialog_window); + + gtk_dialog_run(GTK_DIALOG(dialog_window)); + + gtk_widget_destroy(dialog_window); +} /** - * @brief show message dialog + * @brief show sized dialog * @param dialog title * @param dialog message * @date Nov 21. 2008 * */ -void show_message(const char *szTitle, const char *szMessage) +void show_sized_message(const char *szTitle, const char *szMessage, const int maxlength) { GtkWidget *label; GtkWidget *button; GtkWidget *dialog_window; - /* create Dialog */ dialog_window = gtk_dialog_new(); @@ -77,7 +130,7 @@ void show_message(const char *szTitle, const char *szMessage) /* set dialog not resizble */ - gtk_window_set_resizable(GTK_WINDOW(dialog_window), FALSE); + gtk_window_set_resizable(GTK_WINDOW(dialog_window), TRUE); /* create OK Button and Set Reponse */ @@ -95,6 +148,14 @@ void show_message(const char *szTitle, const char *szMessage) label = gtk_label_new(szMessage); + /* set line wrap mode */ + +// gtk_label_set_width_chars(GTK_LABEL(label), 30); + gtk_label_set_max_width_chars(GTK_LABEL(label), maxlength); + gtk_label_set_line_wrap(GTK_LABEL(label),TRUE); + gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_CHAR); + gtk_label_set_ellipsize(GTK_LABEL(label),PANGO_ELLIPSIZE_MIDDLE); + gtk_widget_set_tooltip_text(GTK_LABEL(label),szMessage); /* set Padding arround Label */ gtk_misc_set_padding(GTK_MISC(label), 10, 10); @@ -103,6 +164,7 @@ void show_message(const char *szTitle, const char *szMessage) gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->vbox), label, TRUE, TRUE, 0); + gtk_widget_show_all(dialog_window); gtk_dialog_run(GTK_DIALOG(dialog_window)); diff --git a/tizen/src/dialog.h b/tizen/src/dialog.h index c91127a..6819123 100644 --- a/tizen/src/dialog.h +++ b/tizen/src/dialog.h @@ -47,6 +47,7 @@ #include "utils.h" void show_message(const char *szTitle, const char *szMessage); +void show_sized_message(const char *szTitle, const char *szMessage, const int maxlength); gboolean show_ok_cancel_message(const char *szTitle, const char *szMessage); #define _(String) String diff --git a/tizen/src/menu_callback.c b/tizen/src/menu_callback.c index 631c5a0..f0252c6 100644 --- a/tizen/src/menu_callback.c +++ b/tizen/src/menu_callback.c @@ -654,7 +654,7 @@ void show_info_window(GtkWidget *widget, gpointer data) , target_name, arch, resolution, ram_size_detail , dpi, sdcard_detail, sdcard_path_detail, disk_path, basedisk_path); - show_message("Virtual Target Details", details); + show_sized_message("Virtual Target Details", details, DIALOG_MAX_WIDTH); #else /* _WIN32 */ gchar *details_win = NULL; @@ -674,7 +674,7 @@ void show_info_window(GtkWidget *widget, gpointer data) details_win = change_path_from_slash(details); - show_message("Virtual Target Details", details_win); + show_sized_message("Virtual Target Details", details_win, DIALOG_MAX_WIDTH); free(details_win); #endif diff --git a/tizen/src/vtm.c b/tizen/src/vtm.c index bb97b69..631fb32 100644 --- a/tizen/src/vtm.c +++ b/tizen/src/vtm.c @@ -718,7 +718,7 @@ void details_clicked_cb(GtkWidget *widget, gpointer selection) , target_name, arch, resolution, ram_size_detail , dpi, sdcard_detail, sdcard_path_detail, disk_path, basedisk_path); - show_message("Virtual Target Details", details); + show_sized_message("Virtual Target Details", details, DIALOG_MAX_WIDTH); #else /* _WIN32 */ /* todo: check image & base image */ @@ -739,7 +739,7 @@ void details_clicked_cb(GtkWidget *widget, gpointer selection) details_win = change_path_from_slash(details); - show_message("Virtual Target Details", details_win); + show_sized_message("Virtual Target Details", details_win, DIALOG_MAX_WIDTH); free(details_win); #endif