From: Nicolas B. <nbo...@us...> - 2006-02-23 21:49:04
|
Update of /cvsroot/ddccontrol/ddccontrol/src/gddccontrol In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31930/src/gddccontrol Modified Files: main.c notebook.c notebook.h Log Message: Fallback to generic profiles when a monitor is not supported in the database (displaying a big warning inviting the users to send their dumps to ddccontrol-users). Index: main.c =================================================================== RCS file: /cvsroot/ddccontrol/ddccontrol/src/gddccontrol/main.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- main.c 4 Nov 2005 11:05:37 -0000 1.29 +++ main.c 23 Feb 2006 21:48:56 -0000 1.30 @@ -33,7 +33,9 @@ GtkWidget *combo_box; GtkWidget* refresh_monitors_button; +GtkWidget *messagebox = NULL; GtkWidget *messagelabel = NULL; +GtkWidget *messagebutton = NULL; GtkWidget *statuslabel = NULL; GtkWidget* close_button = NULL; @@ -115,7 +117,6 @@ snprintf(buffer, 256, "%s: %s", current->filename, current->name); create_monitor_manager(current); if (monitor_manager) { - gtk_widget_show(monitor_manager); gtk_widget_set_sensitive(refresh_controls_button, TRUE); } else { @@ -223,11 +224,22 @@ gtk_label_set_text(GTK_LABEL(statuslabel), message); } -/* Show a message on top of every other controls. */ -void set_message(char* message) +static void messagebutton_callback(GtkWidget *widget, gpointer data) +{ + set_message(""); +} + +void set_message(char* message) { + set_message_ok(message, 0); +} + +/* Show a message on top of every other controls, with a ok button + * if the user can hide it himself. */ +void set_message_ok(char* message, int with_ok) { + gtk_widget_show(messagebutton); if (!message[0]) { - gtk_widget_hide(messagelabel); + gtk_widget_hide(messagebox); if (monitor_manager) { set_current_main_component(current_main_component); } @@ -237,9 +249,18 @@ return; } + gtk_label_set_markup(GTK_LABEL(messagelabel), message); + widgets_set_sensitive(FALSE); - gtk_label_set_text(GTK_LABEL(messagelabel), message); - gtk_widget_show(messagelabel); + + gtk_widget_show(messagebox); + if (with_ok) { + gtk_widget_show(messagebutton); + } + else { + gtk_widget_hide(messagebutton); + } + if (monitor_manager) { gtk_widget_hide(monitor_manager); gtk_widget_hide(profile_manager); @@ -483,10 +504,24 @@ gtk_table_attach(GTK_TABLE(table), hsep, 0, 1, crow, crow+1, GTK_FILL_EXPAND, GTK_SHRINK, 0, 0); crow++; - /* Status message label (used when loading or refreshing) */ + /* Status message label (used when loading or refreshing, or when displaying some kind of warnings) */ + messagebox = gtk_vbox_new(FALSE, 10); + messagelabel = gtk_label_new (""); gtk_label_set_line_wrap(GTK_LABEL(messagelabel), TRUE); - gtk_table_attach(GTK_TABLE(table), messagelabel, 0, 1, crow, crow+1, GTK_FILL_EXPAND, GTK_FILL_EXPAND, 5, 5); + gtk_box_pack_start(GTK_BOX(messagebox), messagelabel, 1, 1, 0); + gtk_widget_show(messagelabel); + + GtkWidget* messagealign = gtk_alignment_new(0.5, 0.5, 0, 0); + messagebutton = stock_label_button(GTK_STOCK_OK, _("OK"), NULL); + g_signal_connect(G_OBJECT(messagebutton), "clicked", G_CALLBACK(messagebutton_callback), NULL); + gtk_container_add(GTK_CONTAINER(messagealign), messagebutton); + gtk_widget_show(messagebutton); + + gtk_box_pack_start(GTK_BOX(messagebox), messagealign, 0, 0, 10); + gtk_widget_show(messagealign); + + gtk_table_attach(GTK_TABLE(table), messagebox, 0, 1, crow, crow+1, GTK_FILL_EXPAND, GTK_FILL_EXPAND, 5, 5); mainrow = crow; crow++; Index: notebook.c =================================================================== RCS file: /cvsroot/ddccontrol/ddccontrol/src/gddccontrol/notebook.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- notebook.c 14 Feb 2006 21:59:05 -0000 1.28 +++ notebook.c 23 Feb 2006 21:48:56 -0000 1.29 @@ -113,7 +113,9 @@ unsigned short currentValue = 1; unsigned short currentMaximum = 1; - set_message(g_strdup_printf(_("Refreshing controls values (%d%%)..."), (current*100)/count)); + gchar* tmp = g_strdup_printf(_("Refreshing controls values (%d%%)..."), (current*100)/count); + set_message(tmp); + g_free(tmp); refreshing = 1; /* Tell callbacks not to write values back to the monitor. */ while (list) { @@ -123,7 +125,9 @@ get_value_and_max(control, ¤tValue, ¤tMaximum); change_control_value(list->data, (gpointer)(long)currentValue); } - set_message(g_strdup_printf(_("Refreshing controls values (%d%%)..."), (current*100)/count)); + gchar* tmp = g_strdup_printf(_("Refreshing controls values (%d%%)..."), (current*100)/count); + set_message(tmp); + g_free(tmp); } else { g_warning(_("Could not get the control_db struct related to a control.")); @@ -591,6 +595,18 @@ return; } + if (!mon->db) { + tmp = g_strdup_printf(_( + "The current monitor is not supported, please run\n" + "%s\n" + "and send the output to ddc...@li....\n" + "Thanks."), "<tt>LANG= LC_ALL= ddccontrol -p -c -d</tt>"); + set_message(tmp); + g_free(tmp); + monitor_manager = NULL; + return; + } + GtkWidget *notebook = gtk_notebook_new(); struct group_db* group; @@ -651,9 +667,41 @@ create_profile_manager(); - set_message(""); - monitor_manager = table; + + if (mon->fallback) { + /* Put a big warning. */ + gchar* message; + if (mon->fallback == 1) { + message = g_strdup(_( + "There is no support for your monitor in the database, but ddccontrol is " + "using a generic profile for your monitor's manufacturer. Some controls " + "may not be supported, or may not work as expected.\n")); + } + else if (mon->fallback == 2) { + message = g_strdup(_( + "There is no support for your monitor in the database, but ddccontrol is " + "using a basic generic profile. Many controls will not be supported, and " + "some controls may not work as expected.\n")); + } + + gchar* tmp = g_strconcat("<span size='large' weight='ultrabold'>", _("Warning!"), "</span>\n\n", + message, _( + "Please update ddccontrol-db, or, if you are already using the latest " + "version, please send the output of the following command to " + "ddc...@li...:\n" + ), + "\n<tt>LANG= LC_ALL= ddccontrol -p -c -d</tt>\n\n", + _("Thank you.\n"), NULL); + gtk_widget_show(monitor_manager); + set_message_ok(tmp, 1); + g_free(message); + g_free(tmp); + } + else { + set_message(""); + gtk_widget_show(monitor_manager); + } } // Cleanup Index: notebook.h =================================================================== RCS file: /cvsroot/ddccontrol/ddccontrol/src/gddccontrol/notebook.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- notebook.h 4 Nov 2005 11:05:37 -0000 1.12 +++ notebook.h 23 Feb 2006 21:48:56 -0000 1.13 @@ -87,6 +87,7 @@ /* Show a message on top of every other controls. */ void set_message(char* message); +void set_message_ok(char* message, int with_ok); GtkWidget *stock_label_button(const gchar * stockid, const gchar *label_text, const gchar *tool_tip); |