From 67d8860c8d4ae55013d7e4720b93ec571c5bc95e Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Wed, 6 Aug 2014 07:43:18 -0700 Subject: 343.13 --- doc/version.mk | 2 +- samples/version.mk | 2 +- src/common-utils/gen-manpage-opts-helper.c | 21 +- src/gtk+-2.x/ctk3dvisionpro.c | 62 ++--- src/gtk+-2.x/ctkappprofile.c | 107 +++++---- src/gtk+-2.x/ctkbanner.c | 70 ++++++ src/gtk+-2.x/ctkclocks.c | 56 ++--- src/gtk+-2.x/ctkcolorcontrols.c | 11 +- src/gtk+-2.x/ctkcolorcorrection.c | 35 +-- src/gtk+-2.x/ctkcolorcorrection.h | 6 +- src/gtk+-2.x/ctkcolorcorrectionpage.h | 6 +- src/gtk+-2.x/ctkconfig.c | 42 ++-- src/gtk+-2.x/ctkconfig.h | 8 + src/gtk+-2.x/ctkcurve.c | 157 +++++++++++-- src/gtk+-2.x/ctkcurve.h | 7 + src/gtk+-2.x/ctkdisplayconfig-utils.c | 31 +-- src/gtk+-2.x/ctkdisplayconfig.c | 290 +++++++++++------------ src/gtk+-2.x/ctkdisplayconfig.h | 2 +- src/gtk+-2.x/ctkdisplaydevice.c | 21 +- src/gtk+-2.x/ctkdisplaylayout.c | 341 +++++++++++++++++++++++----- src/gtk+-2.x/ctkdisplaylayout.h | 8 +- src/gtk+-2.x/ctkditheringcontrols.c | 11 +- src/gtk+-2.x/ctkdropdownmenu.c | 15 +- src/gtk+-2.x/ctkecc.c | 4 +- src/gtk+-2.x/ctkedid.c | 51 +++-- src/gtk+-2.x/ctkevent.c | 9 +- src/gtk+-2.x/ctkevent.h | 6 +- src/gtk+-2.x/ctkframelock.c | 168 +++++++------- src/gtk+-2.x/ctkgauge.c | 182 +++++++++++++-- src/gtk+-2.x/ctkgauge.h | 10 +- src/gtk+-2.x/ctkglx.c | 4 +- src/gtk+-2.x/ctkgpu.c | 4 +- src/gtk+-2.x/ctkgvi.c | 6 +- src/gtk+-2.x/ctkgvo-banner.c | 8 +- src/gtk+-2.x/ctkgvo-csc.c | 10 +- src/gtk+-2.x/ctkgvo-sync.c | 11 +- src/gtk+-2.x/ctkgvo.c | 4 +- src/gtk+-2.x/ctkimagesliders.c | 21 +- src/gtk+-2.x/ctkmultisample.c | 36 +-- src/gtk+-2.x/ctkopengl.c | 31 +-- src/gtk+-2.x/ctkpowermizer.c | 12 +- src/gtk+-2.x/ctkscale.c | 22 +- src/gtk+-2.x/ctkscreen.c | 4 +- src/gtk+-2.x/ctkslimm.c | 2 +- src/gtk+-2.x/ctkthermal.c | 16 +- src/gtk+-2.x/ctkutils.c | 256 ++++++++++++++++++++- src/gtk+-2.x/ctkutils.h | 33 +++ src/gtk+-2.x/ctkvcs.c | 6 +- src/gtk+-2.x/ctkwindow.c | 118 ++++++---- src/gtk+-2.x/ctkxvideo.c | 4 +- src/libXNVCtrl/NVCtrl.h | 10 +- src/libXNVCtrl/version.mk | 2 +- src/libXNVCtrlAttributes/NvCtrlAttributes.c | 18 +- src/parse.c | 3 +- src/query-assign.c | 44 +++- src/version.mk | 2 +- version.mk | 2 +- 57 files changed, 1734 insertions(+), 696 deletions(-) diff --git a/doc/version.mk b/doc/version.mk index a7b8a27..043e890 100644 --- a/doc/version.mk +++ b/doc/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 340.24 +NVIDIA_VERSION = 343.13 diff --git a/samples/version.mk b/samples/version.mk index a7b8a27..043e890 100644 --- a/samples/version.mk +++ b/samples/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 340.24 +NVIDIA_VERSION = 343.13 diff --git a/src/common-utils/gen-manpage-opts-helper.c b/src/common-utils/gen-manpage-opts-helper.c index c05ef38..84bac62 100644 --- a/src/common-utils/gen-manpage-opts-helper.c +++ b/src/common-utils/gen-manpage-opts-helper.c @@ -90,7 +90,9 @@ static void print_option(const NVGetoptOption *o) * '&' : toggles italics on and off * '^' : toggles bold on and off * '-' : is backslashified: "\-" + * '\n': resets the first character flag * '.' : must not be the first character of a line + * '\'': must not be the first character of a line * * Trailing whitespace is omitted when italics or bold is on */ @@ -110,8 +112,8 @@ static void print_option(const NVGetoptOption *o) printf("\n.I "); } omitWhiteSpace = italics; + firstchar = italics; italics = !italics; - firstchar = TRUE; break; case '^': if (bold) { @@ -120,8 +122,8 @@ static void print_option(const NVGetoptOption *o) printf("\n.B "); } omitWhiteSpace = bold; + firstchar = bold; bold = !bold; - firstchar = TRUE; break; case '-': printf("\\-"); @@ -134,6 +136,11 @@ static void print_option(const NVGetoptOption *o) firstchar = FALSE; } break; + case '\n': + printf("\n"); + omitWhiteSpace = FALSE; + firstchar = TRUE; + break; case '.': if (firstchar) { fprintf(stderr, "Error: *roff can't start a line with '.' " @@ -144,6 +151,16 @@ static void print_option(const NVGetoptOption *o) exit(1); } /* fall through */ + case '\'': + if (firstchar) { + fprintf(stderr, "Error: *roff can't start a line with '\''. " + "If you started a line with '\'' in the description " + "of the '%s' option, please add some text at the " + "beginning of the sentence, so that a valid manpage " + "can be generated.\n", o->name); + exit(1); + } + /* fall through */ default: printf("%c", *s); omitWhiteSpace = FALSE; diff --git a/src/gtk+-2.x/ctk3dvisionpro.c b/src/gtk+-2.x/ctk3dvisionpro.c index ec1e30c..6dfa8d7 100644 --- a/src/gtk+-2.x/ctk3dvisionpro.c +++ b/src/gtk+-2.x/ctk3dvisionpro.c @@ -514,8 +514,8 @@ static void init_glasses_info_widgets(GlassesInfo *glasses) glasses->image = NULL; } -static void callback_glasses_paired(GtkObject *object, gpointer arg1, - gpointer user_data) +static void callback_glasses_paired(GObject *object, gpointer arg1, + gpointer user_data) { int battery_level; char *glasses_name = NULL; @@ -612,7 +612,7 @@ static void callback_glasses_paired(GtkObject *object, gpointer arg1, free(glasses_name); } -static void callback_glasses_unpaired(GtkObject *object, gpointer arg1, +static void callback_glasses_unpaired(GObject *object, gpointer arg1, gpointer user_data) { int j; @@ -696,7 +696,7 @@ static void enable_widgets(Ctk3DVisionPro *ctk_3d_vision_pro, Bool enable) gtk_widget_set_sensitive(ctk_3d_vision_pro->table.hscrollbar, enable); } -static void svp_config_changed(GtkObject *object, gpointer arg1, +static void svp_config_changed(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct; @@ -856,8 +856,7 @@ static AddGlassesDlg *create_add_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision_pro) dlg->dlg_add_glasses = gtk_dialog_new_with_buttons ("Add glasses", ctk_3d_vision_pro->parent_wnd, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, @@ -873,24 +872,24 @@ static AddGlassesDlg *create_add_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision_pro) gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 10); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_add_glasses)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_add_glasses))), hbox, TRUE, TRUE, 5); hbox = gtk_hbox_new(TRUE, 0); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_add_glasses)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_add_glasses))), hbox, TRUE, TRUE, 5); image = gtk_image_new_from_pixbuf(gdk_pixbuf_new_from_xpm_data( svp_add_glasses_xpm)); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg->dlg_add_glasses)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_add_glasses))), image, FALSE, FALSE, 0); label = gtk_label_new("2. List of glasses connected:"); hbox = gtk_hbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_add_glasses)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_add_glasses))), hbox, TRUE, TRUE, 5); //generate menu option for glasses' name @@ -903,11 +902,10 @@ static AddGlassesDlg *create_add_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision_pro) ctk_3d_vision_pro->ctk_config); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_add_glasses)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_add_glasses))), hbox, TRUE, TRUE, 5); - gtk_dialog_set_has_separator(GTK_DIALOG(dlg->dlg_add_glasses), TRUE); - gtk_widget_show_all(GTK_DIALOG(dlg->dlg_add_glasses)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_add_glasses))); return dlg; } @@ -1000,8 +998,7 @@ static RemoveGlassesDlg *create_remove_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision dlg->dlg_remove_glasses = gtk_dialog_new_with_buttons ("Remove glasses", ctk_3d_vision_pro->parent_wnd, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, @@ -1022,12 +1019,10 @@ static RemoveGlassesDlg *create_remove_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision gtk_box_pack_start(GTK_BOX(hbox), dlg->mnu_glasses_name, TRUE, TRUE, 0); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_remove_glasses)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_remove_glasses))), hbox, TRUE, TRUE, 20); - gtk_dialog_set_has_separator(GTK_DIALOG(dlg->dlg_remove_glasses), TRUE); - - gtk_widget_show_all(GTK_DIALOG(dlg->dlg_remove_glasses)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_remove_glasses))); return dlg; } @@ -1101,8 +1096,7 @@ static IdentifyGlassesDlg *create_identify_glasses_dlg(Ctk3DVisionPro *ctk_3d_vi dlg->dlg_identify_glasses = gtk_dialog_new_with_buttons ("Identify glasses", ctk_3d_vision_pro->parent_wnd, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, @@ -1123,12 +1117,10 @@ static IdentifyGlassesDlg *create_identify_glasses_dlg(Ctk3DVisionPro *ctk_3d_vi gtk_box_pack_start(GTK_BOX(hbox), dlg->mnu_glasses_name, TRUE, TRUE, 0); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_identify_glasses)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_identify_glasses))), hbox, TRUE, TRUE, 20); - gtk_dialog_set_has_separator(GTK_DIALOG(dlg->dlg_identify_glasses), TRUE); - - gtk_widget_show_all(GTK_DIALOG(dlg->dlg_identify_glasses)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_identify_glasses))); return dlg; } @@ -1204,8 +1196,7 @@ static RenameGlassesDlg *create_rename_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision dlg->dlg_rename_glasses = gtk_dialog_new_with_buttons ("Rename glasses", ctk_3d_vision_pro->parent_wnd, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, @@ -1228,7 +1219,7 @@ static RenameGlassesDlg *create_rename_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision TRUE, TRUE, 0); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_rename_glasses)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_rename_glasses))), hbox, TRUE, TRUE, 20); new_glasses_name = gtk_entry_new(); @@ -1241,12 +1232,10 @@ static RenameGlassesDlg *create_rename_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision G_CALLBACK(new_glasses_name_focus_out), (gpointer) dlg); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg->dlg_rename_glasses)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_rename_glasses))), new_glasses_name, TRUE, TRUE, 0); - gtk_dialog_set_has_separator(GTK_DIALOG(dlg->dlg_rename_glasses), TRUE); - - gtk_widget_show_all(GTK_DIALOG(dlg->dlg_rename_glasses)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_rename_glasses))); return dlg; } @@ -1348,8 +1337,7 @@ static ChannelRangeDlg *create_channel_range_change_dlg(Ctk3DVisionPro *ctk_3d_v dlg->dlg_channel_range = gtk_dialog_new_with_buttons ("Modify Hub Range", ctk_3d_vision_pro->parent_wnd, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_YES, GTK_RESPONSE_YES, GTK_STOCK_NO, @@ -1379,12 +1367,10 @@ static ChannelRangeDlg *create_channel_range_change_dlg(Ctk3DVisionPro *ctk_3d_v hbox = gtk_hbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 20); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_channel_range)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_channel_range))), hbox, TRUE, TRUE, 20); - gtk_dialog_set_has_separator(GTK_DIALOG(dlg->dlg_channel_range), TRUE); - - gtk_widget_show_all(GTK_DIALOG(dlg->dlg_channel_range)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_channel_range))); return dlg; } diff --git a/src/gtk+-2.x/ctkappprofile.c b/src/gtk+-2.x/ctkappprofile.c index 60b3e69..70a2ecf 100644 --- a/src/gtk+-2.x/ctkappprofile.c +++ b/src/gtk+-2.x/ctkappprofile.c @@ -33,6 +33,10 @@ #include "common-utils.h" #include "msg.h" +#ifdef CTK_GTK3 +#include +#endif + #define UPDATE_RULE_LABEL "Update Rule" #define UPDATE_PROFILE_LABEL "Update Profile" @@ -376,8 +380,10 @@ static void populate_toolbar(GtkToolbar *toolbar, WidgetDataItem *widget_data_item; GtkWidget *widget; GtkWidget *icon; - GtkTooltips *tooltips = gtk_tooltips_new(); GtkToolItem *tool_item; +#ifndef CTK_GTK3 + GtkTooltips *tooltips = gtk_tooltips_new(); +#endif if (help_data) { *help_data = NULL; @@ -397,8 +403,12 @@ static void populate_toolbar(GtkToolbar *toolbar, widget = (*item->init_callback)(item->init_data); if (widget) { tool_item = gtk_tool_item_new(); +#ifdef CTK_GTK3 + gtk_tool_item_set_tooltip_text(tool_item, item->help_text); +#else gtk_tool_item_set_tooltip(tool_item, tooltips, item->help_text, NULL); +#endif gtk_container_add(GTK_CONTAINER(tool_item), widget); gtk_toolbar_insert(toolbar, tool_item, -1); } else { @@ -413,8 +423,12 @@ static void populate_toolbar(GtkToolbar *toolbar, gtk_toolbar_insert(toolbar, GTK_TOOL_ITEM(widget), -1); } else { tool_item = GTK_TOOL_ITEM(gtk_tool_button_new(icon, item->text)); +#ifdef CTK_GTK3 + gtk_tool_item_set_tooltip_text(tool_item, item->help_text); +#else gtk_tool_item_set_tooltip(tool_item, tooltips, item->help_text, NULL); +#endif g_signal_connect(G_OBJECT(tool_item), "clicked", G_CALLBACK(item->callback), @@ -507,7 +521,11 @@ static void cell_renderer_editable(gpointer data, gpointer user_data) static gboolean tree_view_column_is_editable(GtkTreeViewColumn *tree_column) { gboolean editable = FALSE; +#ifdef CTK_GTK3 + GList *renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(tree_column)); +#else GList *renderers = gtk_tree_view_column_get_cell_renderers(tree_column); +#endif g_list_foreach(renderers, cell_renderer_editable, &editable); return editable; } @@ -970,7 +988,7 @@ static void string_list_free_full(GList *list) } static void populate_source_combo_box(CtkAppProfile *ctk_app_profile, - GtkComboBoxEntry *combo_box_entry) + GtkComboBox *combo_box_entry) { size_t i, size; json_t *json_filename, *json_filenames; @@ -982,8 +1000,8 @@ static void populate_source_combo_box(CtkAppProfile *ctk_app_profile, for (i = 0, size = json_array_size(json_filenames); i < size; i++) { json_filename = json_array_get(json_filenames, i); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box_entry), - strdup(json_string_value(json_filename))); + ctk_combo_box_text_append_text(GTK_WIDGET(combo_box_entry), + strdup(json_string_value(json_filename))); } json_decref(json_filenames); @@ -994,12 +1012,12 @@ static gboolean append_profile_name(GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { - GtkComboBoxEntry *combo_box = GTK_COMBO_BOX_ENTRY(data); + GtkWidget *combo_box = GTK_WIDGET(data); gchar *profile_name; gtk_tree_model_get(model, iter, CTK_APC_PROFILE_MODEL_COL_NAME, &profile_name, -1); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), profile_name); + ctk_combo_box_text_append_text(combo_box, profile_name); return FALSE; } @@ -1052,10 +1070,10 @@ static void edit_rule_dialog_load_profile(EditRuleDialog *dialog, const char *profile_name) { CtkAppProfile *ctk_app_profile = CTK_APP_PROFILE(dialog->parent); - GtkComboBoxEntry *combo_box_entry; + GtkComboBox *combo_box_entry; // profile name - combo_box_entry = GTK_COMBO_BOX_ENTRY(dialog->profile_name_combo); + combo_box_entry = GTK_COMBO_BOX(dialog->profile_name_combo); gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model( GTK_COMBO_BOX(combo_box_entry)))); @@ -1069,10 +1087,10 @@ static void edit_rule_dialog_load_profile(EditRuleDialog *dialog, gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box_entry), 0); g_string_assign(dialog->profile_name, gtk_entry_get_text( - GTK_ENTRY(GTK_BIN(combo_box_entry)->child))); + GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box_entry))))); } else { g_string_assign(dialog->profile_name, profile_name); - gtk_entry_set_text(GTK_ENTRY(GTK_BIN(combo_box_entry)->child), + gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box_entry))), dialog->profile_name->str); } @@ -1084,7 +1102,7 @@ static void edit_rule_dialog_load_profile(EditRuleDialog *dialog, static void edit_rule_dialog_load_values(EditRuleDialog *dialog) { - GtkComboBoxEntry *combo_box_entry; + GtkComboBox *combo_box_entry; char *profile_name_copy; // window title @@ -1097,17 +1115,17 @@ static void edit_rule_dialog_load_values(EditRuleDialog *dialog) dialog->new_rule ? GTK_STOCK_ADD : GTK_STOCK_PREFERENCES); // source file - combo_box_entry = GTK_COMBO_BOX_ENTRY(dialog->source_file_combo); + combo_box_entry = GTK_COMBO_BOX(dialog->source_file_combo); populate_source_combo_box(CTK_APP_PROFILE(dialog->parent), combo_box_entry); gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box_entry), 0); if (dialog->new_rule) { g_string_assign(dialog->source_file, - gtk_entry_get_text(GTK_ENTRY(GTK_BIN(combo_box_entry)->child))); + gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box_entry))))); } - gtk_entry_set_text(GTK_ENTRY(GTK_BIN(combo_box_entry)->child), + gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box_entry))), dialog->source_file->str); // feature and matches @@ -1130,7 +1148,7 @@ static void edit_rule_dialog_show(EditRuleDialog *dialog) g_signal_handler_block(G_OBJECT(dialog->feature_menu), dialog->feature_changed_signal); g_signal_handler_block( - G_OBJECT(GTK_ENTRY(GTK_BIN(dialog->profile_name_combo)->child)), + G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dialog->profile_name_combo)))), dialog->rule_profile_name_changed_signal); edit_rule_dialog_load_values(dialog); @@ -1138,7 +1156,7 @@ static void edit_rule_dialog_show(EditRuleDialog *dialog) g_signal_handler_unblock(G_OBJECT(dialog->feature_menu), dialog->feature_changed_signal); g_signal_handler_unblock( - G_OBJECT(GTK_ENTRY(GTK_BIN(dialog->profile_name_combo)->child)), + G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dialog->profile_name_combo)))), dialog->rule_profile_name_changed_signal); // disable focusing to main window until this window closed @@ -1327,15 +1345,15 @@ static gboolean rule_browse_button_clicked(GtkWidget *widget, gpointer user_data gtk_window_set_transient_for(GTK_WINDOW(dialog->file_sel), GTK_WINDOW(dialog->top_window)); - gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->file_sel), filename); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog->file_sel), filename); result = gtk_dialog_run(GTK_DIALOG(dialog->file_sel)); switch (result) { case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: - filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog->file_sel)); - gtk_entry_set_text(GTK_ENTRY(GTK_BIN(dialog->source_file_combo)->child), + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->file_sel)); + gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dialog->source_file_combo))), filename); default: break; @@ -1354,15 +1372,15 @@ static gboolean profile_browse_button_clicked(GtkWidget *widget, gpointer user_d gtk_window_set_transient_for(GTK_WINDOW(dialog->file_sel), GTK_WINDOW(dialog->top_window)); - gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->file_sel), filename); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog->file_sel), filename); result = gtk_dialog_run(GTK_DIALOG(dialog->file_sel)); switch (result) { case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: - filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog->file_sel)); - gtk_entry_set_text(GTK_ENTRY(GTK_BIN(dialog->source_file_combo)->child), + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->file_sel)); + gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dialog->source_file_combo))), filename); default: break; @@ -1427,7 +1445,7 @@ static void config_create_source_file_entry(CtkConfig *ctk_config, help_string->str, NULL); - combo_box_entry = gtk_combo_box_entry_new_text(); + combo_box_entry = ctk_combo_box_text_new_with_entry(); browse_button = gtk_button_new(); button_set_label_and_stock_icon(GTK_BUTTON(browse_button), @@ -1587,12 +1605,12 @@ static GtkWidget *create_rule_profile_name_entry(EditRuleDialog *dialog) gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - dialog->profile_name_combo = combo_box_entry = gtk_combo_box_entry_new_text(); + dialog->profile_name_combo = combo_box_entry = ctk_combo_box_text_new_with_entry(); gtk_box_pack_start(GTK_BOX(hbox), combo_box_entry, TRUE, TRUE, 0); dialog->rule_profile_name_changed_signal = - g_signal_connect(G_OBJECT(GTK_BIN(combo_box_entry)->child), "changed", + g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(combo_box_entry))), "changed", G_CALLBACK(rule_profile_name_changed), (gpointer)dialog); @@ -1848,7 +1866,7 @@ static void edit_rule_dialog_save_changes(GtkWidget *widget, gpointer user_data) { EditRuleDialog *dialog = (EditRuleDialog *)user_data; CtkAppProfile *ctk_app_profile = CTK_APP_PROFILE(dialog->parent); - GtkWidget *source_file_entry = GTK_BIN(dialog->source_file_combo)->child; + GtkWidget *source_file_entry = gtk_bin_get_child(GTK_BIN(dialog->source_file_combo)); json_t *rule_json = json_object(); json_t *pattern_json = json_object(); @@ -2015,7 +2033,12 @@ static EditRuleDialog* edit_rule_dialog_new(CtkAppProfile *ctk_app_profile) dialog->matches = g_string_new(""); dialog->profile_name = g_string_new(""); dialog->profile_settings_store = gtk_list_store_new(SETTING_LIST_STORE_NUM_COLS, G_TYPE_POINTER); - dialog->file_sel = gtk_file_selection_new("Please select a source file for the rule"); + dialog->file_sel = gtk_file_chooser_dialog_new("Please select a source file for the rule", + GTK_WINDOW(NULL), GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + gtk_widget_set_size_request(dialog->top_window, 500, 480); gtk_container_set_border_width(GTK_CONTAINER(dialog->top_window), 8); @@ -2430,9 +2453,9 @@ static void edit_profile_dialog_save_changes(GtkWidget *widget, gpointer user_da EditRuleDialog *rule_dialog; CtkAppProfile *ctk_app_profile = CTK_APP_PROFILE(profile_dialog->parent); GtkWidget *source_file_entry = - GTK_BIN(profile_dialog->source_file_combo)->child; + gtk_bin_get_child(GTK_BIN(profile_dialog->source_file_combo)); json_t *profile_json = json_object(); - GtkComboBoxEntry *combo_box_entry; + GtkComboBox *combo_box_entry; gboolean rules_fixed_up = FALSE; rule_dialog = ctk_app_profile->edit_rule_dialog; @@ -2482,9 +2505,9 @@ static void edit_profile_dialog_save_changes(GtkWidget *widget, gpointer user_da if (widget_get_visible(rule_dialog->top_window)) { // XXX could this be abstracted? edit_rule_dialog_load_profile(rule_dialog, profile_dialog->name->str); - combo_box_entry = GTK_COMBO_BOX_ENTRY(rule_dialog->source_file_combo); + combo_box_entry = GTK_COMBO_BOX(rule_dialog->source_file_combo); populate_source_combo_box(ctk_app_profile, combo_box_entry); - gtk_entry_set_text(GTK_ENTRY(GTK_BIN(combo_box_entry)->child), + gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box_entry))), rule_dialog->source_file->str); } @@ -2977,7 +3000,11 @@ static EditProfileDialog *edit_profile_dialog_new(CtkAppProfile *ctk_app_profile dialog->settings = json_array(); dialog->settings_store = gtk_list_store_new(SETTING_LIST_STORE_NUM_COLS, G_TYPE_POINTER); - dialog->file_sel = gtk_file_selection_new("Please select a source file for the profile"); + dialog->file_sel = gtk_file_chooser_dialog_new("Please select a source file for the profile", + GTK_WINDOW(NULL), GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); main_vbox = gtk_vbox_new(FALSE, 0); gtk_box_set_spacing(GTK_BOX(main_vbox), 8); @@ -3362,8 +3389,6 @@ static gboolean profiles_tree_view_key_press_event(GtkWidget *widget, static void edit_profile_dialog_load_values(EditProfileDialog *dialog) { - GtkComboBoxEntry *combo_box_entry; - // window title gtk_window_set_title(GTK_WINDOW(dialog->top_window), dialog->new_profile ? "Add new profile" : "Edit existing profile"); @@ -3378,17 +3403,19 @@ static void edit_profile_dialog_load_values(EditProfileDialog *dialog) gtk_entry_set_text(GTK_ENTRY(dialog->name_entry), dialog->name->str); // source file - combo_box_entry = GTK_COMBO_BOX_ENTRY(dialog->source_file_combo); - populate_source_combo_box(CTK_APP_PROFILE(dialog->parent), combo_box_entry); + populate_source_combo_box(CTK_APP_PROFILE(dialog->parent), + GTK_COMBO_BOX(dialog->source_file_combo)); - gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box_entry), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->source_file_combo), 0); if (dialog->new_profile) { g_string_assign(dialog->source_file, - gtk_entry_get_text(GTK_ENTRY(GTK_BIN(combo_box_entry)->child))); + gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child( + GTK_BIN(dialog->source_file_combo))))); } - gtk_entry_set_text(GTK_ENTRY(GTK_BIN(combo_box_entry)->child), + gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child( + GTK_BIN(dialog->source_file_combo))), dialog->source_file->str); // profile settings @@ -4058,7 +4085,7 @@ static SaveAppProfileChangesDialog *save_app_profile_changes_dialog_new(CtkAppPr hbox = gtk_hbox_new(FALSE, 8); - dialog->preview_file_menu = menu = ctk_drop_down_menu_new(CTK_DROP_DOWN_MENU_FLAG_READONLY); + dialog->preview_file_menu = menu = ctk_drop_down_menu_new(CTK_DROP_DOWN_MENU_FLAG_READWRITE); gtk_box_pack_start(GTK_BOX(hbox), menu, TRUE, TRUE, 0); dialog->preview_changed_signal = diff --git a/src/gtk+-2.x/ctkbanner.c b/src/gtk+-2.x/ctkbanner.c index 5919a5e..0ed6678 100644 --- a/src/gtk+-2.x/ctkbanner.c +++ b/src/gtk+-2.x/ctkbanner.c @@ -26,6 +26,7 @@ #include "ctkbanner.h" #include "common-utils.h" +#include "ctkutils.h" /* pixdata headers */ @@ -66,12 +67,22 @@ ctk_banner_class_init (CtkBannerClass *); static void ctk_banner_finalize (GObject *); +#ifdef CTK_GTK3 +static gboolean +ctk_banner_draw_event (GtkWidget *, cairo_t *); + +static void +ctk_banner_get_preferred_width (GtkWidget *, gint *, gint *); +static void +ctk_banner_get_preferred_height(GtkWidget *, gint *, gint *); +#else static gboolean ctk_banner_expose_event (GtkWidget *, GdkEventExpose *); static void ctk_banner_size_request (GtkWidget *, GtkRequisition *); +#endif static gboolean ctk_banner_configure_event (GtkWidget *, GdkEventConfigure *); @@ -128,8 +139,14 @@ static void ctk_banner_class_init( gobject_class->finalize = ctk_banner_finalize; +#ifdef CTK_GTK3 + widget_class->draw = ctk_banner_draw_event; + widget_class->get_preferred_width = ctk_banner_get_preferred_width; + widget_class->get_preferred_height = ctk_banner_get_preferred_height; +#else widget_class->expose_event = ctk_banner_expose_event; widget_class->size_request = ctk_banner_size_request; +#endif widget_class->configure_event = ctk_banner_configure_event; } @@ -152,6 +169,34 @@ static void ctk_banner_finalize( g_object_unref(ctk_banner->background->pixbuf); } +#ifdef CTK_GTK3 +static gboolean ctk_banner_draw_event( + GtkWidget *widget, + cairo_t *cr_i +) +{ + CtkBanner *ctk_banner = CTK_BANNER(widget); + cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); + cairo_rectangle_list_t *rects; + int i; + + /* copy the backing pixbuf into the exposed portion of the window */ + + rects = cairo_copy_clip_rectangle_list(cr); + + for (i = 0; i < rects->num_rectangles; i++) { + gdk_cairo_set_source_pixbuf(cr, ctk_banner->back.pixbuf, + rects->rectangles[i].x, + rects->rectangles[i].y); + cairo_paint(cr); + } + cairo_destroy(cr); + + g_free(rects); + + return FALSE; +} +#else static gboolean ctk_banner_expose_event( GtkWidget *widget, GdkEventExpose *event @@ -180,6 +225,7 @@ static gboolean ctk_banner_expose_event( return FALSE; } +#endif @@ -330,6 +376,30 @@ static void ctk_banner_size_request( requisition->height = ctk_banner->background->h; } +#ifdef CTK_GTK3 +static void ctk_banner_get_preferred_width( + GtkWidget *widget, + gint *minimum_width, + gint *natural_width +) +{ + GtkRequisition requisition; + ctk_banner_size_request(widget, &requisition); + *minimum_width = *natural_width = requisition.width; +} + +static void ctk_banner_get_preferred_height( + GtkWidget *widget, + gint *minimum_height, + gint *natural_height +) +{ + GtkRequisition requisition; + ctk_banner_size_request(widget, &requisition); + *minimum_height = *natural_height = requisition.height; +} +#endif + /* diff --git a/src/gtk+-2.x/ctkclocks.c b/src/gtk+-2.x/ctkclocks.c index 5a3e16b..120b65c 100644 --- a/src/gtk+-2.x/ctkclocks.c +++ b/src/gtk+-2.x/ctkclocks.c @@ -31,6 +31,7 @@ #include "ctkevent.h" #include "ctkconstants.h" #include "ctkdropdownmenu.h" +#include "ctkutils.h" @@ -56,10 +57,10 @@ static void overclocking_state_update_gui(CtkClocks *ctk_object); static void overclocking_state_toggled(GtkWidget *widget, gpointer user_data); -static void overclocking_state_received(GtkObject *object, gpointer arg1, +static void overclocking_state_received(GObject *object, gpointer arg1, gpointer user_data); -static void auto_detection_state_received(GtkObject *object, gpointer arg1, +static void auto_detection_state_received(GObject *object, gpointer arg1, gpointer user_data); static void sync_gui_to_modify_clocks(CtkClocks *ctk_object, int which_clocks); @@ -75,7 +76,7 @@ static void apply_clocks_clicked(GtkWidget *widget, gpointer user_data); static void detect_clocks_clicked(GtkWidget *widget, gpointer user_data); static void reset_clocks_clicked(GtkWidget *widget, gpointer user_data); -static void clocks_received(GtkObject *object, gpointer arg1, +static void clocks_received(GObject *object, gpointer arg1, gpointer user_data); @@ -186,7 +187,7 @@ GtkWidget* ctk_clocks_new(NvCtrlAttributeHandle *handle, { GObject *object; CtkClocks *ctk_object; - GtkObject *adjustment; + GtkAdjustment *adjustment; GtkWidget *alignment; GtkWidget *scale; CtkDropDownMenu *menu; @@ -315,17 +316,17 @@ GtkWidget* ctk_clocks_new(NvCtrlAttributeHandle *handle, if ( can_access_2d_clocks ) { adjustment = - gtk_adjustment_new(GET_GPU_CLOCK(clocks_2D), - GET_GPU_CLOCK(ranges_2D.u.range.min), - GET_GPU_CLOCK(ranges_2D.u.range.max), - 1, 5, 0.0); + GTK_ADJUSTMENT(gtk_adjustment_new(GET_GPU_CLOCK(clocks_2D), + GET_GPU_CLOCK(ranges_2D.u.range.min), + GET_GPU_CLOCK(ranges_2D.u.range.max), + 1, 5, 0.0)); ctk_object->clocks_being_modified = CLOCKS_2D; } else { adjustment = - gtk_adjustment_new(GET_GPU_CLOCK(clocks_3D), - GET_GPU_CLOCK(ranges_3D.u.range.min), - GET_GPU_CLOCK(ranges_3D.u.range.max), - 1, 5, 0.0); + GTK_ADJUSTMENT(gtk_adjustment_new(GET_GPU_CLOCK(clocks_3D), + GET_GPU_CLOCK(ranges_3D.u.range.min), + GET_GPU_CLOCK(ranges_3D.u.range.max), + 1, 5, 0.0)); ctk_object->clocks_being_modified = CLOCKS_3D; } @@ -348,16 +349,16 @@ GtkWidget* ctk_clocks_new(NvCtrlAttributeHandle *handle, if ( can_access_2d_clocks ) { adjustment = - gtk_adjustment_new(GET_MEM_CLOCK(clocks_2D), - GET_MEM_CLOCK(ranges_2D.u.range.min), - GET_MEM_CLOCK(ranges_2D.u.range.max), - 1, 5, 0.0); + GTK_ADJUSTMENT(gtk_adjustment_new(GET_MEM_CLOCK(clocks_2D), + GET_MEM_CLOCK(ranges_2D.u.range.min), + GET_MEM_CLOCK(ranges_2D.u.range.max), + 1, 5, 0.0)); } else { adjustment = - gtk_adjustment_new(GET_MEM_CLOCK(clocks_3D), - GET_MEM_CLOCK(ranges_3D.u.range.min), - GET_MEM_CLOCK(ranges_3D.u.range.max), - 1, 5, 0.0); + GTK_ADJUSTMENT(gtk_adjustment_new(GET_MEM_CLOCK(clocks_3D), + GET_MEM_CLOCK(ranges_3D.u.range.min), + GET_MEM_CLOCK(ranges_3D.u.range.max), + 1, 5, 0.0)); } scale = ctk_scale_new(GTK_ADJUSTMENT(adjustment), "Memory (MHz)", @@ -449,7 +450,7 @@ GtkWidget* ctk_clocks_new(NvCtrlAttributeHandle *handle, ctk_object->detect_dialog = gtk_dialog_new_with_buttons("Auto Detect Optimal 3D Clock Frequencies?", GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(ctk_object))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, @@ -462,7 +463,8 @@ GtkWidget* ctk_clocks_new(NvCtrlAttributeHandle *handle, gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(ctk_object->detect_dialog)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area( + GTK_DIALOG(ctk_object->detect_dialog))), hbox, FALSE, FALSE, 15); /* @@ -807,7 +809,7 @@ static void overclocking_state_toggled(GtkWidget *widget, gpointer user_data) * overclocking state. * */ -static void overclocking_state_received(GtkObject *object, +static void overclocking_state_received(GObject *object, gpointer arg1, gpointer user_data) { CtkClocks *ctk_object = CTK_CLOCKS(user_data); @@ -826,7 +828,7 @@ static void overclocking_state_received(GtkObject *object, * an NV-CONTROL client probing for the optimal clocks. * */ -static void auto_detection_state_received(GtkObject *object, +static void auto_detection_state_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; @@ -941,7 +943,7 @@ static void sync_gui_to_modify_clocks(CtkClocks *ctk_object, int which_clocks) /* Make GPU and Memory clocks reflect the right range/values */ gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->gpu_clk_scale)->gtk_scale); - gtk_adjustment_gpu = GTK_ADJUSTMENT(gtk_range->adjustment); + gtk_adjustment_gpu = gtk_range_get_adjustment(gtk_range); g_signal_handlers_block_by_func(G_OBJECT(gtk_adjustment_gpu), G_CALLBACK(adjustment_value_changed), @@ -955,7 +957,7 @@ static void sync_gui_to_modify_clocks(CtkClocks *ctk_object, int which_clocks) (gpointer) ctk_object); gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->mem_clk_scale)->gtk_scale); - gtk_adjustment_mem = GTK_ADJUSTMENT(gtk_range->adjustment); + gtk_adjustment_mem = gtk_range_get_adjustment(gtk_range); g_signal_handlers_block_by_func(G_OBJECT(gtk_adjustment_mem), G_CALLBACK(adjustment_value_changed), @@ -1251,7 +1253,7 @@ static void detect_clocks_clicked(GtkWidget *widget, gpointer user_data) * being changed. * */ -static void clocks_received(GtkObject *object, gpointer arg1, +static void clocks_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; diff --git a/src/gtk+-2.x/ctkcolorcontrols.c b/src/gtk+-2.x/ctkcolorcontrols.c index 1252889..b3249f8 100644 --- a/src/gtk+-2.x/ctkcolorcontrols.c +++ b/src/gtk+-2.x/ctkcolorcontrols.c @@ -33,6 +33,7 @@ #include "ctkhelp.h" #include "ctkcolorcontrols.h" #include "ctkdropdownmenu.h" +#include "ctkutils.h" /* function prototypes */ static void @@ -56,7 +57,7 @@ static void color_space_menu_changed(GtkWidget *widget, static void color_range_menu_changed(GtkWidget *widget, gpointer user_data); -static void color_control_update_received(GtkObject *object, gpointer arg1, +static void color_control_update_received(GObject *object, gpointer arg1, gpointer user_data); static void setup_color_range_dropdown(CtkColorControls *ctk_color_controls); static @@ -312,7 +313,7 @@ static void setup_reset_button(CtkColorControls *ctk_color_controls) gint val; CtkDropDownMenu *color_space_menu, *color_range_menu; - if (!GTK_WIDGET_SENSITIVE(ctk_color_controls->color_controls_box)) { + if (!ctk_widget_get_sensitive(ctk_color_controls->color_controls_box)) { /* Nothing is available, don't bother enabling the reset button yet. */ return; } @@ -327,7 +328,7 @@ static void setup_reset_button(CtkColorControls *ctk_color_controls) } /* Color range is dependent on the color space */ - if (GTK_WIDGET_SENSITIVE(ctk_color_controls->color_range_menu)) { + if (ctk_widget_get_sensitive(ctk_color_controls->color_range_menu)) { color_range_menu = CTK_DROP_DOWN_MENU(ctk_color_controls->color_range_menu); history = ctk_drop_down_menu_get_current_value(color_range_menu); @@ -362,7 +363,7 @@ void ctk_color_controls_setup(CtkColorControls *ctk_color_controls) /* color space */ if (!update_color_space_menu_info(ctk_color_controls)) { gtk_widget_set_sensitive(ctk_color_controls->color_controls_box, FALSE); - gtk_widget_hide_all(ctk_color_controls->color_controls_box); + gtk_widget_hide(ctk_color_controls->color_controls_box); } setup_reset_button(ctk_color_controls); @@ -535,7 +536,7 @@ void add_color_controls_help(CtkColorControls *ctk_color_controls, * we should update the GUI to reflect the current color range * and color space. */ -static void color_control_update_received(GtkObject *object, gpointer arg1, +static void color_control_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkColorControls *ctk_object = CTK_COLOR_CONTROLS(user_data); diff --git a/src/gtk+-2.x/ctkcolorcorrection.c b/src/gtk+-2.x/ctkcolorcorrection.c index 59f83fa..1ad24cc 100644 --- a/src/gtk+-2.x/ctkcolorcorrection.c +++ b/src/gtk+-2.x/ctkcolorcorrection.c @@ -32,6 +32,7 @@ #include "ctkconfig.h" #include "ctkhelp.h" +#include "ctkutils.h" #include #include @@ -91,7 +92,7 @@ apply_parsed_attribute_list(CtkColorCorrection *, ParsedAttribute *); static gboolean do_confirm_countdown (gpointer); -static void callback_palette_update(GtkObject *object, gpointer arg1, +static void callback_palette_update(GObject *object, gpointer arg1, gpointer user_data); static void @@ -116,18 +117,18 @@ static guint signals[LAST_SIGNAL] = { 0 }; #define DEFAULT_CONFIRM_COLORCORRECTION_TIMEOUT 10 -#define CREATE_COLOR_ADJUSTMENT(adj, attr, min, max) \ -{ \ - gdouble _step_incr, _page_incr, _def; \ - \ - _step_incr = ((gdouble)((max) - (min)))/250.0; \ - _page_incr = ((gdouble)((max) - (min)))/25.0; \ - \ - _def = get_attribute_channel_value(ctk_color_correction, \ - (attr), ALL_CHANNELS); \ - \ - (adj) = gtk_adjustment_new(_def, (min), (max), \ - _step_incr, _page_incr, 0.0); \ +#define CREATE_COLOR_ADJUSTMENT(adj, attr, min, max) \ +{ \ + gdouble _step_incr, _page_incr, _def; \ + \ + _step_incr = ((gdouble)((max) - (min)))/250.0; \ + _page_incr = ((gdouble)((max) - (min)))/25.0; \ + \ + _def = get_attribute_channel_value(ctk_color_correction, \ + (attr), ALL_CHANNELS); \ + \ + (adj) = GTK_ADJUSTMENT(gtk_adjustment_new(_def, (min), (max), \ + _step_incr, _page_incr, 0.0)); \ } GType ctk_color_correction_get_type( @@ -557,8 +558,8 @@ GtkWidget* ctk_color_correction_new(NvCtrlAttributeHandle *handle, * "%d Seconds to Confirm" */ - gtk_widget_size_request(ctk_color_correction->confirm_label, - &requisition); + ctk_widget_get_preferred_size(ctk_color_correction->confirm_label, + &requisition); gtk_widget_set_size_request(ctk_color_correction->confirm_label, requisition.width, -1); @@ -576,7 +577,7 @@ static void color_channel_changed( gpointer user_data ) { - GtkObject *adjustment; + GtkAdjustment *adjustment; gint history, attribute, channel; CtkColorCorrection *ctk_color_correction; gfloat value; @@ -1208,7 +1209,7 @@ void ctk_color_correction_tab_help(GtkTextBuffer *b, GtkTextIter *i, } -static void callback_palette_update(GtkObject *object, gpointer arg1, +static void callback_palette_update(GObject *object, gpointer arg1, gpointer user_data) { gboolean reload_needed; diff --git a/src/gtk+-2.x/ctkcolorcorrection.h b/src/gtk+-2.x/ctkcolorcorrection.h index f32984c..e148cbb 100644 --- a/src/gtk+-2.x/ctkcolorcorrection.h +++ b/src/gtk+-2.x/ctkcolorcorrection.h @@ -57,9 +57,9 @@ struct _CtkColorCorrection CtkConfig *ctk_config; CtkEvent *ctk_event; GtkWidget *color_channel; - GtkObject *brightness_adjustment; - GtkObject *contrast_adjustment; - GtkObject *gamma_adjustment; + GtkAdjustment *brightness_adjustment; + GtkAdjustment *contrast_adjustment; + GtkAdjustment *gamma_adjustment; GtkWidget *curve; GtkWidget *warning_container; GtkWidget *reset_button; diff --git a/src/gtk+-2.x/ctkcolorcorrectionpage.h b/src/gtk+-2.x/ctkcolorcorrectionpage.h index 5a9f5d9..a90e198 100644 --- a/src/gtk+-2.x/ctkcolorcorrectionpage.h +++ b/src/gtk+-2.x/ctkcolorcorrectionpage.h @@ -56,9 +56,9 @@ struct _CtkColorCorrectionPage NvCtrlAttributeHandle *handle; CtkConfig *ctk_config; GtkWidget *option_menu; - GtkObject *brightness_adjustment; - GtkObject *contrast_adjustment; - GtkObject *gamma_adjustment; + GtkAdjustment *brightness_adjustment; + GtkAdjustment *contrast_adjustment; + GtkAdjustment *gamma_adjustment; GtkWidget *confirm_button; GtkWidget *confirm_label; gint confirm_countdown; diff --git a/src/gtk+-2.x/ctkconfig.c b/src/gtk+-2.x/ctkconfig.c index f6a0cbe..5e78021 100644 --- a/src/gtk+-2.x/ctkconfig.c +++ b/src/gtk+-2.x/ctkconfig.c @@ -34,9 +34,11 @@ #include #include +#ifndef CTK_GTK3 static const char *__tooltip_help = "When ToolTips are enabled, descriptions will be displayed next to options " "when the mouse is held over them."; +#endif static const char *__status_bar_help = "The status bar in the bottom " @@ -81,7 +83,9 @@ static const char *__update_rules_on_profile_name_change_help = static void ctk_config_class_init(CtkConfigClass *ctk_config_class); static void display_status_bar_toggled(GtkWidget *, gpointer); +#ifndef CTK_GTK3 static void tooltips_toggled(GtkWidget *, gpointer); +#endif static void slider_text_entries_toggled(GtkWidget *, gpointer); static void display_name_toggled(GtkWidget *widget, gpointer user_data); static void show_quit_dialog_toggled(GtkWidget *widget, gpointer user_data); @@ -144,15 +148,10 @@ void ctk_statusbar_init(CtkStatusBar *status_bar) status_bar->widget = gtk_statusbar_new(); status_bar->prev_message_id = 0; status_bar->enabled = TRUE; - +#ifndef CTK_GTK3 gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR(status_bar->widget), FALSE); - - /* XXX force the status bar window to be vertically centered */ - - gtk_misc_set_alignment - (GTK_MISC(GTK_STATUSBAR(status_bar->widget)->label), - 0.0, 0.5); +#endif } GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles) @@ -176,12 +175,14 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles) const char *help_text; } config_check_button_entries[] = { +#ifndef CTK_GTK3 { "Enable ToolTips", CONFIG_PROPERTIES_TOOLTIPS, G_CALLBACK(tooltips_toggled), __tooltip_help }, +#endif { "Display Status Bar", CONFIG_PROPERTIES_DISPLAY_STATUS_BAR, @@ -227,10 +228,12 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles) /* initialize the statusbar widget */ ctk_statusbar_init(&ctk_config->status_bar); - + +#ifndef CTK_GTK3 /* initialize the tooltips widget */ ctk_config->tooltips.object = gtk_tooltips_new(); +#endif /* banner */ @@ -263,6 +266,7 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles) gtk_container_add(GTK_CONTAINER(check_button), label); b = !!(ctk_config->conf->booleans & config_check_button_entries[i].mask); +#ifndef CTK_GTK3 if (config_check_button_entries[i].mask == CONFIG_PROPERTIES_TOOLTIPS) { if (b) { gtk_tooltips_enable(ctk_config->tooltips.object); @@ -270,6 +274,7 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles) gtk_tooltips_disable(ctk_config->tooltips.object); } } +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), b); gtk_box_pack_start(GTK_BOX(vbox), check_button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(check_button), "toggled", @@ -310,14 +315,19 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles) /* Create the file selector for rc file */ ctk_config->rc_file_selector = - gtk_file_selection_new ("Please select a file to save to"); + gtk_file_chooser_dialog_new("Please select a file to save to", + GTK_WINDOW(ctk_get_parent_window(GTK_WIDGET(ctk_config))), + GTK_FILE_CHOOSER_ACTION_OPEN, + "Cancel", GTK_RESPONSE_CANCEL, + "Open", GTK_RESPONSE_ACCEPT, + NULL); g_signal_connect(G_OBJECT(ctk_config->button_save_rc), "clicked", G_CALLBACK(save_rc_clicked), (gpointer) ctk_config); - gtk_file_selection_set_filename - (GTK_FILE_SELECTION(ctk_config->rc_file_selector), DEFAULT_RC_FILE); + gtk_file_chooser_set_filename + (GTK_FILE_CHOOSER(ctk_config->rc_file_selector), DEFAULT_RC_FILE); ctk_config_set_tooltip(ctk_config, ctk_config->button_save_rc, __save_current_config_help); @@ -346,8 +356,8 @@ static void save_rc_clicked(GtkWidget *widget, gpointer user_data) switch (result) { case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: - rc_filename = gtk_file_selection_get_filename - (GTK_FILE_SELECTION(ctk_config->rc_file_selector)); + rc_filename = gtk_file_chooser_get_filename + (GTK_FILE_CHOOSER(ctk_config->rc_file_selector)); break; default: return; @@ -429,7 +439,11 @@ void ctk_config_set_tooltip(CtkConfig *ctk_config, const gchar *text) { +#ifdef CTK_GTK3 + gtk_widget_set_tooltip_text(widget, text); +#else gtk_tooltips_set_tip(ctk_config->tooltips.object, widget, text, NULL); +#endif } @@ -458,6 +472,7 @@ static void display_status_bar_toggled( } } +#ifndef CTK_GTK3 static void tooltips_toggled(GtkWidget *widget, gpointer user_data) { CtkConfig *ctk_config = CTK_CONFIG(user_data); @@ -474,6 +489,7 @@ static void tooltips_toggled(GtkWidget *widget, gpointer user_data) ctk_config_statusbar_message(ctk_config, "Tooltips %s.", active ? "enabled" : "disabled"); } +#endif static void slider_text_entries_toggled(GtkWidget *widget, gpointer user_data) diff --git a/src/gtk+-2.x/ctkconfig.h b/src/gtk+-2.x/ctkconfig.h index ab6a352..c631bbc 100644 --- a/src/gtk+-2.x/ctkconfig.h +++ b/src/gtk+-2.x/ctkconfig.h @@ -28,6 +28,10 @@ #include +#if GTK_MAJOR_VERSION >= 3 +#define CTK_GTK3 +#endif + #include "config-file.h" G_BEGIN_DECLS @@ -65,17 +69,21 @@ struct _CtkStatusBar gboolean enabled; }; +#ifndef CTK_GTK3 struct _CtkToolTips { GtkTooltips *object; }; +#endif struct _CtkConfig { GtkVBox parent; CtkStatusBar status_bar; +#ifndef CTK_GTK3 CtkToolTips tooltips; +#endif GtkListStore *list_store; ConfigProperties *conf; GtkWidget *timer_list; diff --git a/src/gtk+-2.x/ctkcurve.c b/src/gtk+-2.x/ctkcurve.c index 0d1b8fd..e843ac6 100644 --- a/src/gtk+-2.x/ctkcurve.c +++ b/src/gtk+-2.x/ctkcurve.c @@ -33,18 +33,34 @@ ctk_curve_class_init (CtkCurveClass *); static void ctk_curve_finalize (GObject *); +#ifdef CTK_GTK3 +static gboolean +ctk_curve_draw_event (GtkWidget *, cairo_t *); + +static void +ctk_curve_get_preferred_width(GtkWidget *, gint *, gint *); + +static void +ctk_curve_get_preferred_height(GtkWidget *, gint *, gint *); +#else static gboolean ctk_curve_expose_event (GtkWidget *, GdkEventExpose *); static void ctk_curve_size_request (GtkWidget *, GtkRequisition *); +#endif static gboolean ctk_curve_configure_event(GtkWidget *, GdkEventConfigure *); static void +#ifdef CTK_GTK3 +plot_color_ramp (cairo_t *, gushort *, gint, gint, gint); +#else plot_color_ramp (GdkPixmap *, GdkGC *, gushort *, gint, gint, gint); +#endif + static void draw(CtkCurve *ctk_curve); @@ -92,8 +108,14 @@ static void ctk_curve_class_init( gobject_class->finalize = ctk_curve_finalize; +#ifdef CTK_GTK3 + widget_class->draw = ctk_curve_draw_event; + widget_class->get_preferred_width = ctk_curve_get_preferred_width; + widget_class->get_preferred_height = ctk_curve_get_preferred_height; +#else widget_class->expose_event = ctk_curve_expose_event; widget_class->size_request = ctk_curve_size_request; +#endif widget_class->configure_event = ctk_curve_configure_event; } @@ -103,6 +125,7 @@ static void ctk_curve_finalize( GObject *object ) { +#ifndef CTK_GTK3 CtkCurve *ctk_curve; GdkColormap *gdk_colormap; GdkColor *gdk_color; @@ -121,32 +144,52 @@ static void ctk_curve_finalize( gdk_colormap_free_colors(gdk_colormap, gdk_color, 1); g_object_unref(gdk_colormap); +#endif } +#ifdef CTK_GTK3 +static gboolean ctk_curve_draw_event( + GtkWidget *widget, + cairo_t *cr +) +#else static gboolean ctk_curve_expose_event( GtkWidget *widget, GdkEventExpose *event ) +#endif { gint width, height; CtkCurve *ctk_curve; + GtkAllocation allocation; ctk_curve = CTK_CURVE(widget); - width = widget->allocation.width - 2 * widget->style->xthickness; - height = widget->allocation.height - 2 * widget->style->ythickness; + ctk_widget_get_allocation(widget, &allocation); + + width = allocation.width - 2 * gtk_widget_get_style(widget)->xthickness; + height = allocation.height - 2 * gtk_widget_get_style(widget)->ythickness; +#ifdef CTK_GTK3 + gtk_render_frame(gtk_widget_get_style_context(widget), + cr, 0, 0, allocation.width, allocation.height); + + cairo_set_operator(ctk_curve->c_context, CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(cr, ctk_curve->c_surface, 0, 0); + cairo_paint(cr); +#else gtk_paint_shadow(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, &event->area, widget, "ctk_curve", 0, 0, - widget->allocation.width, widget->allocation.height); + allocation.width, allocation.height); gdk_gc_set_function(ctk_curve->gdk_gc, GDK_COPY); - + gdk_draw_drawable(widget->window, ctk_curve->gdk_gc, ctk_curve->gdk_pixmap, 0, 0, widget->style->xthickness, widget->style->ythickness, width, height); +#endif return FALSE; } @@ -161,12 +204,27 @@ static gboolean ctk_curve_configure_event ctk_curve->width = event->width; ctk_curve->height = event->height; +#ifdef CTK_GTK3 + if (ctk_curve->c_context) { + cairo_destroy(ctk_curve->c_context); + } + if (ctk_curve->c_surface) { + cairo_surface_destroy(ctk_curve->c_surface); + } + + ctk_curve->c_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + ctk_curve->width, + ctk_curve->height); + ctk_curve->c_context = cairo_create(ctk_curve->c_surface); + +#else if (ctk_curve->gdk_pixmap) g_object_unref(ctk_curve->gdk_pixmap); if (ctk_curve->gdk_gc) g_object_unref(ctk_curve->gdk_gc); ctk_curve->gdk_pixmap = gdk_pixmap_new(widget->window, ctk_curve->width, ctk_curve->height, -1); ctk_curve->gdk_gc = gdk_gc_new(ctk_curve->gdk_pixmap); +#endif draw(ctk_curve); @@ -175,8 +233,12 @@ static gboolean ctk_curve_configure_event static void plot_color_ramp( +#ifdef CTK_GTK3 + cairo_t *cr, +#else GdkPixmap *gdk_pixmap, GdkGC *gdk_gc, +#endif gushort *color_ramp, gint n_color_ramp_entries, gint width, @@ -198,11 +260,40 @@ static void plot_color_ramp( gdk_points[i].y = height - ((height - 1) * (y / 65535) + 0.5); } +#ifdef CTK_GTK3 + cairo_set_line_width(cr, 1.0); + cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT); + + cairo_move_to(cr, gdk_points[0].x, gdk_points[0].y); + for (i = 1; i < width; i++) { + cairo_line_to(cr, gdk_points[i].x, gdk_points[i].y); + } + cairo_stroke(cr); +#else gdk_draw_lines(gdk_pixmap, gdk_gc, gdk_points, width); +#endif g_free(gdk_points); } +#ifdef CTK_GTK3 +static void ctk_curve_get_preferred_height( + GtkWidget *widget, + gint *minimum_height, + gint *natural_height +) +{ + *minimum_height = *natural_height = REQUESTED_WIDTH; +} +static void ctk_curve_get_preferred_width( + GtkWidget *widget, + gint *minimum_width, + gint *natural_width +) +{ + *minimum_width = *natural_width = REQUESTED_WIDTH; +} +#else static void ctk_curve_size_request( GtkWidget *widget, GtkRequisition *requisition @@ -211,20 +302,25 @@ static void ctk_curve_size_request( requisition->width = REQUESTED_WIDTH; requisition->height = REQUESTED_HEIGHT; } +#endif void ctk_curve_color_changed(GtkWidget *widget) { GdkRectangle rectangle; + GtkAllocation allocation; - rectangle.x = widget->style->xthickness; - rectangle.y = widget->style->ythickness; + ctk_widget_get_allocation(widget, &allocation); - rectangle.width = widget->allocation.width - 2 * rectangle.x; - rectangle.height = widget->allocation.height - 2 * rectangle.y; + rectangle.x = gtk_widget_get_style(widget)->xthickness; + rectangle.y = gtk_widget_get_style(widget)->ythickness; - if (GTK_WIDGET_DRAWABLE(widget)) { + rectangle.width = allocation.width - 2 * rectangle.x; + rectangle.height = allocation.height - 2 * rectangle.y; + + if (ctk_widget_is_drawable(widget)) { draw(CTK_CURVE(widget)); /* only draw when visible */ - gdk_window_invalidate_rect(widget->window, &rectangle, FALSE); + gdk_window_invalidate_rect(ctk_widget_get_window(widget), + &rectangle, FALSE); } } @@ -232,8 +328,10 @@ GtkWidget* ctk_curve_new(NvCtrlAttributeHandle *handle, GtkWidget *color) { GObject *object; CtkCurve *ctk_curve; +#ifndef CTK_GTK3 GdkColormap *gdk_colormap; GdkColor *gdk_color; +#endif object = g_object_new(CTK_TYPE_CURVE, NULL); @@ -242,6 +340,10 @@ GtkWidget* ctk_curve_new(NvCtrlAttributeHandle *handle, GtkWidget *color) ctk_curve->handle = handle; ctk_curve->color = color; +#ifdef CTK_GTK3 + ctk_curve->c_context = NULL; + ctk_curve->c_surface = NULL; +#else ctk_curve->gdk_pixmap = NULL; ctk_curve->gdk_gc = NULL; @@ -263,7 +365,7 @@ GtkWidget* ctk_curve_new(NvCtrlAttributeHandle *handle, GtkWidget *color) memset(gdk_color, 0, sizeof(GdkColor)); gdk_color->blue = 65535; gdk_colormap_alloc_color(gdk_colormap, gdk_color, FALSE, TRUE); - +#endif g_signal_connect_swapped(G_OBJECT(ctk_curve->color), "changed", G_CALLBACK(ctk_curve_color_changed), @@ -276,11 +378,38 @@ GtkWidget* ctk_curve_new(NvCtrlAttributeHandle *handle, GtkWidget *color) static void draw(CtkCurve *ctk_curve) { - GtkWidget *widget = GTK_WIDGET(ctk_curve); - gushort *lut; gint n_lut_entries; +#ifdef CTK_GTK3 + /* Fill Curve surface with black background */ + cairo_set_operator(ctk_curve->c_context, CAIRO_OPERATOR_SOURCE); + + cairo_set_source_rgba(ctk_curve->c_context, 0.0, 0.0, 0.0, 1.0); + cairo_rectangle(ctk_curve->c_context, 0, 0, + ctk_curve->width, ctk_curve->height); + cairo_fill(ctk_curve->c_context); + + /* Add the Color LUT ramp lines */ + cairo_set_operator(ctk_curve->c_context, CAIRO_OPERATOR_ADD); + + cairo_set_source_rgba(ctk_curve->c_context, 1.0, 0.0, 0.0, 1.0); + NvCtrlGetColorRamp(ctk_curve->handle, RED_CHANNEL, &lut, &n_lut_entries); + plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries, + ctk_curve->width, ctk_curve->height); + + cairo_set_source_rgba(ctk_curve->c_context, 0.0, 1.0, 0.0, 1.0); + NvCtrlGetColorRamp(ctk_curve->handle, GREEN_CHANNEL, &lut, &n_lut_entries); + plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries, + ctk_curve->width, ctk_curve->height); + + cairo_set_source_rgba(ctk_curve->c_context, 0.0, 0.0, 1.0, 1.0); + NvCtrlGetColorRamp(ctk_curve->handle, BLUE_CHANNEL, &lut, &n_lut_entries); + plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries, + ctk_curve->width, ctk_curve->height); +#else + GtkWidget *widget = GTK_WIDGET(ctk_curve); + gdk_gc_set_function(ctk_curve->gdk_gc, GDK_COPY); gdk_draw_rectangle(ctk_curve->gdk_pixmap, widget->style->black_gc, @@ -302,5 +431,5 @@ static void draw(CtkCurve *ctk_curve) NvCtrlGetColorRamp(ctk_curve->handle, BLUE_CHANNEL, &lut, &n_lut_entries); plot_color_ramp(ctk_curve->gdk_pixmap, ctk_curve->gdk_gc, lut, n_lut_entries, ctk_curve->width, ctk_curve->height); - +#endif } diff --git a/src/gtk+-2.x/ctkcurve.h b/src/gtk+-2.x/ctkcurve.h index 04c2a9f..3bb8875 100644 --- a/src/gtk+-2.x/ctkcurve.h +++ b/src/gtk+-2.x/ctkcurve.h @@ -20,6 +20,8 @@ #ifndef __CTK_CURVE_H__ #define __CTK_CURVE_H__ +#include "ctkutils.h" + G_BEGIN_DECLS #define CTK_TYPE_CURVE (ctk_curve_get_type()) @@ -50,6 +52,10 @@ struct _CtkCurve NvCtrlAttributeHandle *handle; GtkWidget *color; +#ifdef CTK_GTK3 + cairo_surface_t *c_surface; + cairo_t *c_context; +#else GdkColor gdk_color_red; GdkColor gdk_color_green; GdkColor gdk_color_blue; @@ -58,6 +64,7 @@ struct _CtkCurve GdkPixmap *gdk_pixmap; GdkGC *gdk_gc; +#endif gint width; gint height; }; diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c index 27e5e03..48ab4ae 100644 --- a/src/gtk+-2.x/ctkdisplayconfig-utils.c +++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c @@ -4313,7 +4313,7 @@ static void update_xconfig_save_buffer(SaveXConfDlg *dlg) static void xconfig_preview_clicked(GtkWidget *widget, gpointer user_data) { SaveXConfDlg *dlg = (SaveXConfDlg *)user_data; - gboolean show = !GTK_WIDGET_VISIBLE(dlg->box_xconfig_save); + gboolean show = !ctk_widget_get_visible(dlg->box_xconfig_save); if (show) { gtk_widget_show_all(dlg->box_xconfig_save); @@ -4369,8 +4369,8 @@ static void xconfig_file_clicked(GtkWidget *widget, gpointer user_data) (GTK_WINDOW(dlg->dlg_xconfig_file), GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(dlg->parent)))); - gtk_file_selection_set_filename - (GTK_FILE_SELECTION(dlg->dlg_xconfig_file), filename); + gtk_file_chooser_set_filename + (GTK_FILE_CHOOSER(dlg->dlg_xconfig_file), filename); result = gtk_dialog_run(GTK_DIALOG(dlg->dlg_xconfig_file)); gtk_widget_hide(dlg->dlg_xconfig_file); @@ -4378,8 +4378,8 @@ static void xconfig_file_clicked(GtkWidget *widget, gpointer user_data) switch (result) { case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: - filename = gtk_file_selection_get_filename - (GTK_FILE_SELECTION(dlg->dlg_xconfig_file)); + filename = gtk_file_chooser_get_filename + (GTK_FILE_CHOOSER(dlg->dlg_xconfig_file)); gtk_entry_set_text(GTK_ENTRY(dlg->txt_xconfig_file), filename); @@ -4532,8 +4532,7 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, dlg->dlg_xconfig_save = gtk_dialog_new_with_buttons ("Save X Configuration", GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(parent))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, @@ -4543,8 +4542,6 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, gtk_dialog_set_default_response(GTK_DIALOG(dlg->dlg_xconfig_save), GTK_RESPONSE_REJECT); - gtk_dialog_set_has_separator(GTK_DIALOG(dlg->dlg_xconfig_save), TRUE); - /* Create the preview button */ dlg->btn_xconfig_preview = gtk_button_new(); g_signal_connect(G_OBJECT(dlg->btn_xconfig_preview), "clicked", @@ -4578,7 +4575,11 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, G_CALLBACK(xconfig_file_clicked), (gpointer) dlg); dlg->dlg_xconfig_file = - gtk_file_selection_new("Please select the X configuration file"); + gtk_file_chooser_dialog_new("Please select the X configuration file", + NULL, GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); /* Create the merge checkbox */ dlg->btn_xconfig_merge = @@ -4597,7 +4598,7 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, gtk_box_pack_start(GTK_BOX(hbox), dlg->btn_xconfig_preview, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg->dlg_xconfig_save)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_xconfig_save))), hbox, FALSE, FALSE, 5); /* Pack the preview window */ @@ -4607,7 +4608,7 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, dlg->txt_xconfig_save); gtk_box_pack_start(GTK_BOX(hbox), dlg->scr_xconfig_save, TRUE, TRUE, 5); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(dlg->dlg_xconfig_save)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_xconfig_save))), hbox, TRUE, TRUE, 0); dlg->box_xconfig_save = hbox; @@ -4619,16 +4620,16 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, gtk_box_pack_end(GTK_BOX(hbox2), dlg->btn_xconfig_file, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox2), dlg->txt_xconfig_file, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(hbox), hbox2, TRUE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg->dlg_xconfig_save)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_xconfig_save))), hbox, FALSE, FALSE, 5); /* Pack the merge checkbox */ - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg->dlg_xconfig_save)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_xconfig_save))), dlg->btn_xconfig_merge, FALSE, FALSE, 5); - gtk_widget_show_all(GTK_DIALOG(dlg->dlg_xconfig_save)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_xconfig_save))); return dlg; diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c index 1ce5b6e..4ecc105 100644 --- a/src/gtk+-2.x/ctkdisplayconfig.c +++ b/src/gtk+-2.x/ctkdisplayconfig.c @@ -108,7 +108,7 @@ static void advanced_clicked(GtkWidget *widget, gpointer user_data); static void reset_clicked(GtkWidget *widget, gpointer user_data); static void validation_details_clicked(GtkWidget *widget, gpointer user_data); -static void display_config_attribute_changed(GtkObject *object, gpointer arg1, +static void display_config_attribute_changed(GtkWidget *object, gpointer arg1, gpointer user_data); static void reset_layout(CtkDisplayConfig *ctk_object); static gboolean force_layout_reset(gpointer user_data); @@ -911,12 +911,11 @@ static GtkWidget * create_validation_dialog(CtkDisplayConfig *ctk_object) dialog = gtk_dialog_new_with_buttons ("Layout Inconsistencie(s)", GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(ctk_object))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - NULL); + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, NULL); /* Main horizontal box */ hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, TRUE, TRUE, 5); /* Pack the information icon */ @@ -977,7 +976,7 @@ static GtkWidget * create_validation_dialog(CtkDisplayConfig *ctk_object) GTK_RESPONSE_REJECT); ctk_object->btn_validation_override_cancel = button; - gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dialog))); return dialog; @@ -1018,7 +1017,7 @@ static GtkWidget * create_validation_apply_dialog(CtkDisplayConfig *ctk_object) /* Main horizontal box */ hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, TRUE, TRUE, 5); /* Pack the information icon */ @@ -1055,7 +1054,7 @@ static GtkWidget * create_validation_apply_dialog(CtkDisplayConfig *ctk_object) GTK_RESPONSE_ACCEPT); gtk_dialog_add_button(GTK_DIALOG(dialog), "Cancel", GTK_RESPONSE_REJECT); - gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dialog))); return dialog; @@ -1120,7 +1119,7 @@ static void screen_size_changed(GdkScreen *screen, gint h = gdk_screen_get_height(screen); if ( h < MIN_LAYOUT_SCREENSIZE ) { - gtk_widget_hide_all(ctk_object->obj_layout); + gtk_widget_hide(ctk_object->obj_layout); gtk_widget_show(ctk_object->label_layout); return; } @@ -1316,7 +1315,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); /* Selected display/X screen dropdown */ - ctk_object->mnu_selected_item = gtk_combo_box_new_text(); + ctk_object->mnu_selected_item = ctk_combo_box_text_new(); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_selected_item, __selected_item_help); g_signal_connect(G_OBJECT(ctk_object->mnu_selected_item), "changed", @@ -1324,7 +1323,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); /* Display configuration (Disabled, TwinView, Separate X screen) */ - ctk_object->mnu_display_config = gtk_combo_box_new_text(); + ctk_object->mnu_display_config = ctk_combo_box_text_new(); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_config, __dpy_configuration_mnu_help); g_signal_connect(G_OBJECT(ctk_object->mnu_display_config), "changed", @@ -1336,9 +1335,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, ctk_object->dlg_display_disable = gtk_dialog_new_with_buttons ("Disable Display Device", GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(ctk_object))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT - | GTK_DIALOG_NO_SEPARATOR, - NULL); + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, NULL); ctk_object->btn_display_disable_off = gtk_dialog_add_button(GTK_DIALOG(ctk_object->dlg_display_disable), "Remove", @@ -1352,7 +1349,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, /* Display resolution */ - ctk_object->mnu_display_resolution = gtk_combo_box_new_text(); + ctk_object->mnu_display_resolution = ctk_combo_box_text_new(); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_resolution, __dpy_resolution_mnu_help); g_signal_connect(G_OBJECT(ctk_object->mnu_display_resolution), "changed", @@ -1361,7 +1358,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, /* Display refresh */ - ctk_object->mnu_display_refresh = gtk_combo_box_new_text(); + ctk_object->mnu_display_refresh = ctk_combo_box_text_new(); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_refresh, __dpy_refresh_mnu_help); g_signal_connect(G_OBJECT(ctk_object->mnu_display_refresh), "changed", @@ -1373,13 +1370,13 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, gtk_label_set_selectable(GTK_LABEL(ctk_object->txt_display_modename), TRUE); /* Display passive stereo eye dropdown */ - ctk_object->mnu_display_stereo = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_stereo), - "None"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_stereo), - "Left"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_stereo), - "Right"); + ctk_object->mnu_display_stereo = ctk_combo_box_text_new(); + ctk_combo_box_text_append_text(ctk_object->mnu_display_stereo, + "None"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_stereo, + "Left"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_stereo, + "Right"); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_stereo, __dpy_stereo_help); g_signal_connect(G_OBJECT(ctk_object->mnu_display_stereo), @@ -1387,15 +1384,15 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); /* Display rotation dropdown */ - ctk_object->mnu_display_rotation = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_rotation), - "No Rotation"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_rotation), - "Rotate Left"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_rotation), - "Invert"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_rotation), - "Rotate Right"); + ctk_object->mnu_display_rotation = ctk_combo_box_text_new(); + ctk_combo_box_text_append_text(ctk_object->mnu_display_rotation, + "No Rotation"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_rotation, + "Rotate Left"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_rotation, + "Invert"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_rotation, + "Rotate Right"); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_rotation, __dpy_rotation_help); g_signal_connect(G_OBJECT(ctk_object->mnu_display_rotation), @@ -1403,15 +1400,15 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); /* Display reflection dropdown */ - ctk_object->mnu_display_reflection = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_reflection), - "No Reflection"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_reflection), - "Reflect along X"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_reflection), - "Reflect along Y"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_reflection), - "Reflect along XY"); + ctk_object->mnu_display_reflection = ctk_combo_box_text_new(); + ctk_combo_box_text_append_text(ctk_object->mnu_display_reflection, + "No Reflection"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_reflection, + "Reflect along X"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_reflection, + "Reflect along Y"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_reflection, + "Reflect along XY"); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_reflection, __dpy_reflection_help); g_signal_connect(G_OBJECT(ctk_object->mnu_display_reflection), @@ -1430,10 +1427,10 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); ctk_object->adj_display_underscan = - gtk_adjustment_new(0, - UNDERSCAN_MIN_PERCENT, - UNDERSCAN_MAX_PERCENT, - 1, 1, 0.0); + GTK_ADJUSTMENT(gtk_adjustment_new(0, + UNDERSCAN_MIN_PERCENT, + UNDERSCAN_MAX_PERCENT, + 1, 1, 0.0)); ctk_object->sld_display_underscan = gtk_hscale_new(GTK_ADJUSTMENT(ctk_object->adj_display_underscan)); gtk_scale_set_draw_value(GTK_SCALE(ctk_object->sld_display_underscan), @@ -1445,19 +1442,19 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); /* Display Position Type (Absolute/Relative Menu) */ - ctk_object->mnu_display_position_type = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_position_type), - "Absolute"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_position_type), - "Right of"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_position_type), - "Left of"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_position_type), - "Above"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_position_type), - "Below"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_display_position_type), - "Same as"); + ctk_object->mnu_display_position_type = ctk_combo_box_text_new(); + ctk_combo_box_text_append_text(ctk_object->mnu_display_position_type, + "Absolute"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_position_type, + "Right of"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_position_type, + "Left of"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_position_type, + "Above"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_position_type, + "Below"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_position_type, + "Same as"); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_position_type, __dpy_position_type_help); g_signal_connect(G_OBJECT(ctk_object->mnu_display_position_type), @@ -1465,7 +1462,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); /* Display Position Relative (Display device to be relative to) */ - ctk_object->mnu_display_position_relative = gtk_combo_box_new_text(); + ctk_object->mnu_display_position_relative = ctk_combo_box_text_new(); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_position_relative, __dpy_position_relative_help); @@ -1528,7 +1525,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); /* X screen depth */ - ctk_object->mnu_screen_depth = gtk_combo_box_new_text(); + ctk_object->mnu_screen_depth = ctk_combo_box_text_new(); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_screen_depth, __screen_depth_help); g_signal_connect(G_OBJECT(ctk_object->mnu_screen_depth), "changed", @@ -1540,7 +1537,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, if (ret == NvCtrlSuccess) { - ctk_object->mnu_screen_stereo = gtk_combo_box_new_text(); + ctk_object->mnu_screen_stereo = ctk_combo_box_text_new(); ctk_object->stereo_table_size = 0; memset(ctk_object->stereo_table, 0, @@ -1571,8 +1568,8 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, valid.u.bits.ints & (1 << stereo_mode)))) { ctk_object->stereo_table[ctk_object->stereo_table_size++] = stereo_mode; - gtk_combo_box_append_text( - GTK_COMBO_BOX(ctk_object->mnu_screen_stereo), + ctk_combo_box_text_append_text( + ctk_object->mnu_screen_stereo, stereo_mode_str); } } @@ -1587,20 +1584,20 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, } /* Screen Position Type (Absolute/Relative Menu) */ - ctk_object->mnu_screen_position_type = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_position_type), - "Absolute"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_position_type), - "Right of"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_position_type), - "Left of"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_position_type), - "Above"); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_position_type), - "Below"); + ctk_object->mnu_screen_position_type = ctk_combo_box_text_new(); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_position_type, + "Absolute"); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_position_type, + "Right of"); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_position_type, + "Left of"); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_position_type, + "Above"); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_position_type, + "Below"); // XXX Add better support for this later. - //gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_position_type), - // "Relative to"); + //ctk_combo_box_text_append_text(ctk_object->mnu_screen_position_type, + // "Relative to"); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_screen_position_type, __screen_position_type_help); g_signal_connect(G_OBJECT(ctk_object->mnu_screen_position_type), @@ -1608,7 +1605,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_object); /* Screen Position Relative (Screen to be relative to) */ - ctk_object->mnu_screen_position_relative = gtk_combo_box_new_text(); + ctk_object->mnu_screen_position_relative = ctk_combo_box_text_new(); ctk_config_set_tooltip(ctk_config, ctk_object->mnu_screen_position_relative, __screen_position_relative_help); @@ -1665,8 +1662,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, ctk_object->dlg_reset_confirm = gtk_dialog_new_with_buttons ("Confirm Reset", GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(ctk_object))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT - | GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); @@ -1682,8 +1678,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, ctk_object->dlg_display_confirm = gtk_dialog_new_with_buttons ("Confirm ModeSwitch", GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(ctk_object))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT - | GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); @@ -2071,7 +2066,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, for (slitem = labels; slitem; slitem = slitem->next) { label = slitem->data; gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_widget_size_request(label, &req); + ctk_widget_get_preferred_size(label, &req); if (req.width > max_width) { max_width = req.width; } @@ -2114,9 +2109,9 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, gtk_box_pack_start(GTK_BOX(hbox), ctk_object->txt_display_disable, FALSE, FALSE, 20); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(ctk_object->dlg_display_disable)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(ctk_object->dlg_display_disable))), hbox, TRUE, TRUE, 20); - gtk_widget_show_all(GTK_DIALOG(ctk_object->dlg_display_disable)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(ctk_object->dlg_display_disable))); /* Reset Confirm Dialog */ label = gtk_label_new("Do you really want to reset the " @@ -2124,18 +2119,18 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, hbox = gtk_hbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 20); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(ctk_object->dlg_reset_confirm)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(ctk_object->dlg_reset_confirm))), hbox, TRUE, TRUE, 20); - gtk_widget_show_all(GTK_DIALOG(ctk_object->dlg_reset_confirm)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(ctk_object->dlg_reset_confirm))); /* Apply Confirm Dialog */ hbox = gtk_hbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), ctk_object->txt_display_confirm, TRUE, TRUE, 20); gtk_box_pack_start - (GTK_BOX(GTK_DIALOG(ctk_object->dlg_display_confirm)->vbox), + (GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(ctk_object->dlg_display_confirm))), hbox, TRUE, TRUE, 20); - gtk_widget_show_all(GTK_DIALOG(ctk_object->dlg_display_confirm)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(ctk_object->dlg_display_confirm))); } @@ -2530,8 +2525,7 @@ static void generate_selected_item_dropdown(CtkDisplayConfig *ctk_object, str = g_strdup_printf("X screen %d", screen->scrnum); - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_selected_item), - str); + ctk_combo_box_text_append_text(ctk_object->mnu_selected_item, str); g_free(str); ctk_object->selected_item_table[idx].type = SELECTABLE_ITEM_SCREEN; @@ -2559,8 +2553,7 @@ static void generate_selected_item_dropdown(CtkDisplayConfig *ctk_object, str = g_strdup_printf("%s)", tmp); g_free(tmp); - gtk_combo_box_append_text( - GTK_COMBO_BOX(ctk_object->mnu_selected_item), str); + ctk_combo_box_text_append_text(ctk_object->mnu_selected_item, str); g_free(str); ctk_object->selected_item_table[idx].type = SELECTABLE_ITEM_DISPLAY; @@ -2742,19 +2735,19 @@ static void setup_display_config(CtkDisplayConfig *ctk_object) switch (options[i].config) { case DPY_CFG_DISABLED: - gtk_combo_box_append_text( - GTK_COMBO_BOX(ctk_object->mnu_display_config), "Disabled"); + ctk_combo_box_text_append_text(ctk_object->mnu_display_config, + "Disabled"); break; case DPY_CFG_NEW_X_SCREEN: - gtk_combo_box_append_text( - GTK_COMBO_BOX(ctk_object->mnu_display_config), + ctk_combo_box_text_append_text( + ctk_object->mnu_display_config, "New X screen (requires X restart)"); break; case DPY_CFG_X_SCREEN: label = g_strdup_printf("X screen %d", options[i].screen->scrnum); - gtk_combo_box_append_text( - GTK_COMBO_BOX(ctk_object->mnu_display_config), label); + ctk_combo_box_text_append_text(ctk_object->mnu_display_config, + label); g_free(label); break; } @@ -2782,7 +2775,7 @@ static void setup_display_config(CtkDisplayConfig *ctk_object) static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) { - GtkComboBox *combo_box = GTK_COMBO_BOX(ctk_object->mnu_display_refresh); + GtkWidget *combo_box = ctk_object->mnu_display_refresh; nvModeLinePtr modeline; nvModeLinePtr auto_modeline; nvModeLinePtr modelines; @@ -2830,7 +2823,7 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) /* Special case the 'nvidia-auto-select' mode. */ if (IS_NVIDIA_DEFAULT_MODE(cur_modeline)) { - gtk_combo_box_append_text(combo_box, "Auto"); + ctk_combo_box_text_append_text(combo_box, "Auto"); ctk_object->refresh_table[ctk_object->refresh_table_len++] = cur_modeline; modelines = NULL; /* Skip building rest of refresh dropdown */ @@ -2958,7 +2951,7 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) /* Add the modeline entry to the dropdown */ - gtk_combo_box_append_text(combo_box, name); + ctk_combo_box_text_append_text(combo_box, name); g_free(name); ctk_object->refresh_table[ctk_object->refresh_table_len++] = modeline; } @@ -3041,7 +3034,7 @@ allocate_selected_mode(char *name, selected_mode = (nvSelectedModePtr)nvalloc(sizeof(nvSelectedMode)); - selected_mode->label = gtk_menu_item_new_with_label(name); + selected_mode->text = g_strdup(name); selected_mode->modeline = modeline; selected_mode->isSpecial = isSpecial; @@ -3075,6 +3068,7 @@ free_selected_modes(nvSelectedModePtr selected_mode) { if (selected_mode) { free_selected_modes(selected_mode->next); + g_free(selected_mode->text); free(selected_mode); } } @@ -3237,20 +3231,26 @@ static void generate_selected_modes(const nvDisplayPtr display) nvSelectedModePtr selected_mode = NULL; nvModeLinePtr modeline; - /* Add the off item */ - selected_mode = allocate_selected_mode("Off", - NULL /* modeline */, - TRUE /* isSpecial */, - NULL /* viewPortIn */, - NULL /* viewPortOut */); + display->num_selected_modes = 0; + display->selected_modes = NULL; - display->num_selected_modes = 1; - display->selected_modes = selected_mode; + /* Add the off item if we have more than one display */ + if (display->screen->num_displays > 1) { + selected_mode = allocate_selected_mode("Off", + NULL /* modeline */, + TRUE /* isSpecial */, + NULL /* viewPortIn */, + NULL /* viewPortOut */); + + display->num_selected_modes = 1; + display->selected_modes = selected_mode; + } modeline = display->modelines; while (modeline) { gchar *name; Bool isSpecial; + Bool mode_added; if (IS_NVIDIA_DEFAULT_MODE(modeline)) { name = g_strdup_printf("Auto"); @@ -3267,8 +3267,15 @@ static void generate_selected_modes(const nvDisplayPtr display) NULL /* viewPortOut */); g_free(name); - if (append_unique_selected_mode(display->selected_modes, - selected_mode)) { + if (!display->selected_modes) { + display->selected_modes = selected_mode; + mode_added = TRUE; + } else { + mode_added = append_unique_selected_mode(display->selected_modes, + selected_mode); + } + + if (mode_added) { display->num_selected_modes++; if (matches_current_selected_mode(display, selected_mode, @@ -3401,10 +3408,18 @@ static void setup_display_resolution_dropdown(CtkDisplayConfig *ctk_object) } - if (display->cur_mode->modeline) { - cur_idx = 1; /* Modeline is set, start off as 'nvidia-auto-select' */ + if (display->cur_mode->modeline && display->screen->num_displays > 1) { + /* + * Modeline is set and we have more than 1 display, start off as + * 'nvidia-auto-select' + */ + cur_idx = 1; } else { - cur_idx = 0; /* Modeline not set, start off as 'off'. */ + /* + * Modeline not set, start off as 'off'. If we do not have more than + * 1 display, 'auto' will be at index 0. + */ + cur_idx = 0; } /* Setup the menu */ @@ -3418,12 +3433,9 @@ static void setup_display_resolution_dropdown(CtkDisplayConfig *ctk_object) /* Fill dropdown menu */ selected_mode = display->selected_modes; while (selected_mode) { - GtkWidget *menu_item = selected_mode->label; - const gchar *label_text = gtk_label_get_text( - GTK_LABEL(gtk_bin_get_child(GTK_BIN(selected_mode->label)))); - gtk_combo_box_append_text( - GTK_COMBO_BOX(ctk_object->mnu_display_resolution), label_text); + ctk_combo_box_text_append_text(ctk_object->mnu_display_resolution, + selected_mode->text); ctk_object->resolution_table[ctk_object->resolution_table_len] = selected_mode; @@ -3432,12 +3444,6 @@ static void setup_display_resolution_dropdown(CtkDisplayConfig *ctk_object) cur_idx = ctk_object->resolution_table_len; } - if (selected_mode->isSpecial && - !selected_mode->modeline && - display->screen->num_displays <= 1) { - gtk_widget_set_sensitive(menu_item, FALSE); - } - ctk_object->resolution_table_len++; selected_mode = selected_mode->next; } @@ -3970,9 +3976,9 @@ static void setup_display_position_relative(CtkDisplayConfig *ctk_object) ctk_object->display_position_table[idx] = relative_to; - gtk_combo_box_append_text - (GTK_COMBO_BOX(ctk_object->mnu_display_position_relative), - relative_to->logName); + ctk_combo_box_text_append_text( + ctk_object->mnu_display_position_relative, + relative_to->logName); idx++; } @@ -4334,34 +4340,34 @@ static void setup_screen_depth_dropdown(CtkDisplayConfig *ctk_object) if (add_depth_30_option) { if (grow_screen_depth_table(ctk_object)) { - gtk_combo_box_append_text - (GTK_COMBO_BOX(ctk_object->mnu_screen_depth), + ctk_combo_box_text_append_text + (ctk_object->mnu_screen_depth, "1.1 Billion Colors (Depth 30) - Experimental"); ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 30; } } if (grow_screen_depth_table(ctk_object)) { - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_depth), - "16.7 Million Colors (Depth 24)"); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_depth, + "16.7 Million Colors (Depth 24)"); ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 24; } if (grow_screen_depth_table(ctk_object)) { - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_depth), - "65,536 Colors (Depth 16)"); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_depth, + "65,536 Colors (Depth 16)"); ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 16; } if (grow_screen_depth_table(ctk_object)) { - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_depth), - "32,768 Colors (Depth 15)"); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_depth, + "32,768 Colors (Depth 15)"); ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 15; } if (grow_screen_depth_table(ctk_object)) { - gtk_combo_box_append_text(GTK_COMBO_BOX(ctk_object->mnu_screen_depth), - "256 Colors (Depth 8)"); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_depth, + "256 Colors (Depth 8)"); ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 8; } @@ -4539,8 +4545,8 @@ static void setup_screen_position_relative(CtkDisplayConfig *ctk_object) tmp_str = g_strdup_printf("X screen %d", relative_to->scrnum); - gtk_combo_box_append_text - (GTK_COMBO_BOX(ctk_object->mnu_screen_position_relative), tmp_str); + ctk_combo_box_text_append_text(ctk_object->mnu_screen_position_relative, + tmp_str); g_free(tmp_str); idx++; } @@ -9177,7 +9183,7 @@ done: * **/ -static void display_config_attribute_changed(GtkObject *object, gpointer arg1, +static void display_config_attribute_changed(GtkWidget *object, gpointer arg1, gpointer user_data) { CtkDisplayConfig *ctk_object = (CtkDisplayConfig *) user_data; @@ -9244,7 +9250,7 @@ static void validation_details_clicked(GtkWidget *widget, gpointer user_data) { CtkDisplayConfig *ctk_object = CTK_DISPLAY_CONFIG(user_data); gboolean show = - !(GTK_WIDGET_VISIBLE(ctk_object->box_validation_override_details)); + !(ctk_widget_get_visible(ctk_object->box_validation_override_details)); if (show) { gtk_widget_show_all(ctk_object->box_validation_override_details); diff --git a/src/gtk+-2.x/ctkdisplayconfig.h b/src/gtk+-2.x/ctkdisplayconfig.h index b0d47a8..73b411f 100644 --- a/src/gtk+-2.x/ctkdisplayconfig.h +++ b/src/gtk+-2.x/ctkdisplayconfig.h @@ -136,7 +136,7 @@ typedef struct _CtkDisplayConfig GtkWidget *box_display_underscan; GtkWidget *txt_display_underscan; GtkWidget *sld_display_underscan; - GtkObject *adj_display_underscan; + GtkAdjustment *adj_display_underscan; GtkWidget *box_display_viewport; diff --git a/src/gtk+-2.x/ctkdisplaydevice.c b/src/gtk+-2.x/ctkdisplaydevice.c index 4184ba0..80bbbde 100644 --- a/src/gtk+-2.x/ctkdisplaydevice.c +++ b/src/gtk+-2.x/ctkdisplaydevice.c @@ -45,13 +45,13 @@ static void update_device_info(CtkDisplayDevice *ctk_object); static void display_device_setup(CtkDisplayDevice *ctk_object); -static void enabled_displays_received(GtkObject *object, gpointer arg1, +static void enabled_displays_received(GObject *object, gpointer arg1, gpointer user_data); -static void callback_link_changed(GtkObject *object, gpointer arg1, +static void callback_link_changed(GObject *object, gpointer arg1, gpointer user_data); -static void callback_refresh_rate_changed(GtkObject *object, gpointer arg1, +static void callback_refresh_rate_changed(GObject *object, gpointer arg1, gpointer user_data); static gboolean update_guid_info(InfoEntry *entry); @@ -501,7 +501,7 @@ GtkTextBuffer *ctk_display_device_create_help(GtkTextTagTable *table, { GtkTextIter i; GtkTextBuffer *b; - GtkTooltipsData *td; + gchar *tip_text; int j; b = gtk_text_buffer_new(table); @@ -538,8 +538,9 @@ GtkTextBuffer *ctk_display_device_create_help(GtkTextTagTable *table, ctk_color_correction_tab_help(b, &i, "X Server Color Correction", TRUE); } - td = gtk_tooltips_data_get(GTK_WIDGET(ctk_object->reset_button)); - ctk_help_reset_hardware_defaults(b, &i, td->tip_text); + tip_text = ctk_widget_get_tooltip_text(GTK_WIDGET(ctk_object->reset_button)); + ctk_help_reset_hardware_defaults(b, &i, tip_text); + g_free(tip_text); ctk_help_finish(b); @@ -775,7 +776,7 @@ static void update_device_info(CtkDisplayDevice *ctk_object) if (entry->present) { gtk_widget_show(entry->hbox); - gtk_widget_size_request(entry->label, &req); + ctk_widget_get_preferred_size(entry->label, &req); if (max_width < req.width) { max_width = req.width; } @@ -891,7 +892,7 @@ static gboolean unregister_refresh_rate_events(InfoEntry *entry) * this page should disable/enable access based on whether * or not the display device is enabled. */ -static void enabled_displays_received(GtkObject *object, gpointer arg1, +static void enabled_displays_received(GObject *object, gpointer arg1, gpointer user_data) { CtkDisplayDevice *ctk_object = CTK_DISPLAY_DEVICE(user_data); @@ -903,7 +904,7 @@ static void enabled_displays_received(GtkObject *object, gpointer arg1, } /* enabled_displays_received() */ -static void callback_link_changed(GtkObject *object, gpointer arg1, +static void callback_link_changed(GObject *object, gpointer arg1, gpointer user_data) { InfoEntry *entry = (InfoEntry *)user_data; @@ -912,7 +913,7 @@ static void callback_link_changed(GtkObject *object, gpointer arg1, } -static void callback_refresh_rate_changed(GtkObject *object, gpointer arg1, +static void callback_refresh_rate_changed(GObject *object, gpointer arg1, gpointer user_data) { InfoEntry *entry = (InfoEntry *)user_data; diff --git a/src/gtk+-2.x/ctkdisplaylayout.c b/src/gtk+-2.x/ctkdisplaylayout.c index 1913776..9161cdc 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.c +++ b/src/gtk+-2.x/ctkdisplaylayout.c @@ -49,6 +49,10 @@ #define LAYOUT_IMG_BG_COLOR "#AAAAAA" #define LAYOUT_IMG_SELECT_COLOR "#FF8888" +#ifdef CTK_GTK3 +#define LENGTH_DASH_ARRAY 2 +static const double dashes[] = {4.0, 4.0}; +#endif /* Device (GPU) Coloring */ @@ -144,9 +148,15 @@ int __palettes_color_names[NUM_COLORS] = { /*** P R O T O T Y P E S *****************************************************/ +#ifdef CTK_GTK3 +static gboolean draw_event_callback (GtkWidget *widget, + cairo_t *cr, + gpointer data); +#else static gboolean expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data); +#endif static gboolean configure_event_callback (GtkWidget *widget, GdkEventConfigure *event, @@ -184,21 +194,23 @@ static Bool sync_layout(CtkDisplayLayout *ctk_object); static void queue_layout_redraw(CtkDisplayLayout *ctk_object) { GtkWidget *drawing_area = ctk_object->drawing_area; - GtkAllocation *allocation = &(drawing_area->allocation); + GdkWindow *window = ctk_widget_get_window(drawing_area); + GtkAllocation allocation; GdkRectangle rect; - - if (!drawing_area->window) { + if (!window) { return; } + ctk_widget_get_allocation(drawing_area, &allocation); + /* Queue an expose event */ - rect.x = allocation->x; - rect.y = allocation->x; - rect.width = allocation->width; - rect.height = allocation->height; + rect.x = allocation.x; + rect.y = allocation.x; + rect.width = allocation.width; + rect.height = allocation.height; - gdk_window_invalidate_rect(drawing_area->window, &rect, TRUE); + gdk_window_invalidate_rect(window, &rect, TRUE); } /* queue_layout_redraw() */ @@ -2482,7 +2494,8 @@ static char *get_tooltip_under_mouse(CtkDisplayLayout *ctk_object, * **/ -static int click_layout(CtkDisplayLayout *ctk_object, int x, int y) +static int click_layout(CtkDisplayLayout *ctk_object, + GdkDevice *device, int x, int y) { int i; nvDisplayPtr cur_selected_display = ctk_object->selected_display; @@ -2497,9 +2510,16 @@ static int click_layout(CtkDisplayLayout *ctk_object, int x, int y) ctk_object->selected_display = NULL; ctk_object->selected_screen = NULL; +#ifdef CTK_GTK3 + gdk_window_get_device_position + (ctk_widget_get_window( + GTK_WIDGET(ctk_get_parent_window(ctk_object->drawing_area))), + device, NULL, NULL, &state); +#else gdk_window_get_pointer (GTK_WIDGET(ctk_get_parent_window(ctk_object->drawing_area))->window, NULL, NULL, &state); +#endif /* Look through the Z-order for the next element */ for (i = 0; i < ctk_object->Zcount; i++) { @@ -2674,27 +2694,33 @@ GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); - g_signal_connect (G_OBJECT (tmp), "expose_event", +#ifdef CTK_GTK3 + g_signal_connect (G_OBJECT (tmp), "draw", + G_CALLBACK (draw_event_callback), + (gpointer)(ctk_object)); +#else + g_signal_connect (G_OBJECT (tmp), "expose_event", G_CALLBACK (expose_event_callback), (gpointer)(ctk_object)); +#endif - g_signal_connect (G_OBJECT (tmp), "configure_event", + g_signal_connect (G_OBJECT (tmp), "configure_event", G_CALLBACK (configure_event_callback), (gpointer)(ctk_object)); - g_signal_connect (G_OBJECT (tmp), "motion_notify_event", + g_signal_connect (G_OBJECT (tmp), "motion_notify_event", G_CALLBACK (motion_event_callback), (gpointer)(ctk_object)); - g_signal_connect (G_OBJECT (tmp), "button_press_event", + g_signal_connect (G_OBJECT (tmp), "button_press_event", G_CALLBACK (button_press_event_callback), (gpointer)(ctk_object)); - g_signal_connect (G_OBJECT (tmp), "button_release_event", + g_signal_connect (G_OBJECT (tmp), "button_release_event", G_CALLBACK (button_release_event_callback), (gpointer)(ctk_object)); - GTK_WIDGET_SET_FLAGS(tmp, GTK_DOUBLE_BUFFERED); + gtk_widget_set_double_buffered(tmp, TRUE); ctk_object->drawing_area = tmp; gtk_widget_set_size_request(tmp, width, height); @@ -2704,12 +2730,17 @@ GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle, gtk_box_set_spacing(GTK_BOX(ctk_object), 0); ctk_object->tooltip_area = gtk_event_box_new(); + +#ifdef CTK_GTK3 + gtk_widget_set_tooltip_text(ctk_object->tooltip_area, "*** No Display ***"); +#else ctk_object->tooltip_group = gtk_tooltips_new(); gtk_tooltips_enable(ctk_object->tooltip_group); gtk_tooltips_set_tip(ctk_object->tooltip_group, ctk_object->tooltip_area, "*** No Display ***", NULL); +#endif gtk_container_add(GTK_CONTAINER(ctk_object->tooltip_area), tmp); gtk_box_pack_start(GTK_BOX(object), ctk_object->tooltip_area, @@ -2721,7 +2752,32 @@ GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle, -/** get_widget_fg_gc() *********************************************** +/** set_drawing_color() ************************************************* + * + * Sets the color passed in to the context given. This function + * hides the implementation differences between GTK 2 and 3 from + * the callers. + * + **/ +#ifdef CTK_GTK3 +static void set_drawing_color(cairo_t *cr, GdkColor *c) +{ + cairo_set_source_rgba(cr, + c->red / 65535.0, + c->green / 65535.0, + c->blue / 65535.0, + 1.0); +} +#else +static void set_drawing_color(GdkGC *gc, GdkColor *c) +{ + gdk_gc_set_rgb_fg_color(gc, c); +} +#endif + + + +/** get_drawing_context() *********************************************** * * Returns the foreground graphics context of the given widget. If * this function returns NULL, then drawing on this widget is not @@ -2729,15 +2785,22 @@ GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle, * **/ -static GdkGC *get_widget_fg_gc(GtkWidget *widget) +#ifdef CTK_GTK3 +static cairo_t *get_drawing_context(CtkDisplayLayout *ctk_object) { - GtkStyle *style = gtk_widget_get_style(widget); + return ctk_object->c_context; +} +#else +static GdkGC *get_drawing_context(CtkDisplayLayout *ctk_object) +{ + GtkStyle *style = gtk_widget_get_style(ctk_object->drawing_area); if (!style) return NULL; - return style->fg_gc[GTK_WIDGET_STATE(widget)]; + return style->fg_gc[GTK_WIDGET_STATE(ctk_object->drawing_area)]; -} /* get_widget_fg_gc() */ +} +#endif @@ -2753,13 +2816,33 @@ static void draw_rect(CtkDisplayLayout *ctk_object, GdkColor *color, int fill) { - GtkWidget *drawing_area = ctk_object->drawing_area; - GdkGC *fg_gc = get_widget_fg_gc(drawing_area); +#ifdef CTK_GTK3 + cairo_t *fg_gc; +#else + GdkGC *fg_gc; +#endif + + fg_gc = get_drawing_context(ctk_object); /* Setup color to use */ - gdk_gc_set_rgb_fg_color(fg_gc, color); + set_drawing_color(fg_gc, color); /* Draw the rectangle */ +#ifdef CTK_GTK3 + cairo_set_antialias(fg_gc, CAIRO_ANTIALIAS_NONE); + cairo_rectangle(fg_gc, + ctk_object->img_dim.x + ctk_object->scale * rect->x, + ctk_object->img_dim.y + ctk_object->scale * rect->y, + ctk_object->scale * rect->width, + ctk_object->scale * rect->height); + + if (fill) { + cairo_fill(fg_gc); + } else { + cairo_stroke(fg_gc); + } + +#else gdk_draw_rectangle(ctk_object->pixmap, fg_gc, fill, @@ -2767,7 +2850,7 @@ static void draw_rect(CtkDisplayLayout *ctk_object, ctk_object->img_dim.y + ctk_object->scale * rect->y, ctk_object->scale * rect->width, ctk_object->scale * rect->height); - +#endif } /* draw_rect() */ @@ -2785,8 +2868,11 @@ static void draw_rect_strs(CtkDisplayLayout *ctk_object, const char *str_1, const char *str_2) { - GtkWidget *drawing_area = ctk_object->drawing_area; - GdkGC *fg_gc = get_widget_fg_gc(drawing_area); +#ifdef CTK_GTK3 + cairo_t *fg_gc; +#else + GdkGC *fg_gc; +#endif char *str; int txt_w; @@ -2797,6 +2883,8 @@ static void draw_rect_strs(CtkDisplayLayout *ctk_object, int draw_1 = 0; int draw_2 = 0; + fg_gc = get_drawing_context(ctk_object); + if (str_1) { pango_layout_set_text(ctk_object->pango_layout, str_1, -1); pango_layout_get_pixel_size(ctk_object->pango_layout, &txt_w, &txt_h); @@ -2837,13 +2925,20 @@ static void draw_rect_strs(CtkDisplayLayout *ctk_object, txt_y1 = ctk_object->scale*(rect->y + rect->height / 2) - (txt_h / 2); /* Write name */ - gdk_gc_set_rgb_fg_color(fg_gc, color); - + set_drawing_color(fg_gc, color); + +#ifdef CTK_GTK3 + cairo_move_to(fg_gc, + ctk_object->img_dim.x + txt_x1, + ctk_object->img_dim.y + txt_y1); + pango_cairo_show_layout(fg_gc, ctk_object->pango_layout); +#else gdk_draw_layout(ctk_object->pixmap, fg_gc, ctk_object->img_dim.x + txt_x1, ctk_object->img_dim.y + txt_y1, ctk_object->pango_layout); +#endif } else if (!draw_1 && draw_2) { @@ -2854,13 +2949,20 @@ static void draw_rect_strs(CtkDisplayLayout *ctk_object, txt_y2 = ctk_object->scale*(rect->y + rect->height / 2) - (txt_h / 2); /* Write dimensions */ - gdk_gc_set_rgb_fg_color(fg_gc, color); - + set_drawing_color(fg_gc, color); + +#ifdef CTK_GTK3 + cairo_move_to(fg_gc, + ctk_object->img_dim.x + txt_x2, + ctk_object->img_dim.y + txt_y2); + pango_cairo_show_layout(fg_gc, ctk_object->pango_layout); +#else gdk_draw_layout(ctk_object->pixmap, fg_gc, ctk_object->img_dim.x + txt_x2, ctk_object->img_dim.y + txt_y2, ctk_object->pango_layout); +#endif } else if (draw_1 && draw_2) { @@ -2873,13 +2975,20 @@ static void draw_rect_strs(CtkDisplayLayout *ctk_object, txt_y = ctk_object->scale*(rect->y + rect->height / 2) - (txt_h / 2); /* Write both */ - gdk_gc_set_rgb_fg_color(fg_gc, color); - + set_drawing_color(fg_gc, color); + +#ifdef CTK_GTK3 + cairo_move_to(fg_gc, + ctk_object->img_dim.x + txt_x, + ctk_object->img_dim.y + txt_y); + pango_cairo_show_layout(fg_gc, ctk_object->pango_layout); +#else gdk_draw_layout(ctk_object->pixmap, fg_gc, ctk_object->img_dim.x + txt_x, ctk_object->img_dim.y + txt_y, ctk_object->pango_layout); +#endif g_free(str); } @@ -2955,8 +3064,11 @@ static void draw_display(CtkDisplayLayout *ctk_object, static void draw_screen(CtkDisplayLayout *ctk_object, nvScreenPtr screen) { - GtkWidget *drawing_area = ctk_object->drawing_area; - GdkGC *fg_gc = get_widget_fg_gc(drawing_area); +#ifdef CTK_GTK3 + cairo_t *fg_gc; +#else + GdkGC *fg_gc; +#endif GdkRectangle *sdim; /* Screen dimensions */ GdkColor bg_color; /* Background color */ @@ -2967,6 +3079,8 @@ static void draw_screen(CtkDisplayLayout *ctk_object, if (!screen) return; + fg_gc = get_drawing_context(ctk_object); + /* Draw the screen effective size */ gdk_color_parse("#888888", &bg_color); gdk_color_parse("#777777", &bd_color); @@ -2977,13 +3091,25 @@ static void draw_screen(CtkDisplayLayout *ctk_object, draw_rect(ctk_object, sdim, &bg_color, 1); /* Draw the screen border with dashed lines */ + +#ifdef CTK_GTK3 + cairo_set_line_width(fg_gc, 1); + cairo_set_line_cap(fg_gc, CAIRO_LINE_CAP_BUTT); + cairo_set_line_join(fg_gc, CAIRO_LINE_JOIN_MITER); + cairo_set_dash(fg_gc, dashes, LENGTH_DASH_ARRAY, 0); +#else gdk_gc_set_line_attributes(fg_gc, 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND); +#endif draw_rect(ctk_object, sdim, &(ctk_object->fg_color), 0); +#ifdef CTK_GTK3 + cairo_set_dash(fg_gc, NULL, 0, 0); +#else gdk_gc_set_line_attributes(fg_gc, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND); +#endif /* Show the name of the screen if no-scanout is selected */ if (screen->no_scanout) { @@ -3009,13 +3135,17 @@ static void draw_screen(CtkDisplayLayout *ctk_object, static void draw_layout(CtkDisplayLayout *ctk_object) { - GtkWidget *drawing_area = ctk_object->drawing_area; - GdkGC *fg_gc = get_widget_fg_gc(drawing_area); +#ifdef CTK_GTK3 + cairo_t *fg_gc; +#else + GdkGC *fg_gc; +#endif GdkColor bg_color; /* Background color */ GdkColor bd_color; /* Border color */ int i; + fg_gc = get_drawing_context(ctk_object); gdk_color_parse("#888888", &bg_color); gdk_color_parse("#777777", &bd_color); @@ -3052,7 +3182,7 @@ static void draw_layout(CtkDisplayLayout *ctk_object) h = (int)(ctk_object->scale * rect->height); /* Setup color to use */ - gdk_gc_set_rgb_fg_color(fg_gc, &(ctk_object->select_color)); + set_drawing_color(fg_gc, &(ctk_object->select_color)); /* If dislay is too small, just color the whole thing */ size = 3; @@ -3063,6 +3193,22 @@ static void draw_layout(CtkDisplayLayout *ctk_object) draw_rect(ctk_object, rect, &(ctk_object->fg_color), 0); } else { +#ifdef CTK_GTK3 + double line_width = cairo_get_line_width(fg_gc); + cairo_set_line_width(fg_gc, size); + cairo_set_line_cap(fg_gc, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(fg_gc, CAIRO_LINE_JOIN_MITER); + cairo_set_antialias(fg_gc, CAIRO_ANTIALIAS_NONE); + + cairo_rectangle(fg_gc, + ctk_object->img_dim.x + (ctk_object->scale * rect->x) + offset, + ctk_object->img_dim.y + (ctk_object->scale * rect->y) + offset, + (ctk_object->scale * rect->width) - (2 * offset), + (ctk_object->scale * rect->height) - (2 * offset)); + cairo_stroke(fg_gc); + + cairo_set_line_width(fg_gc, line_width); +#else gdk_gc_set_line_attributes(fg_gc, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND); @@ -3076,6 +3222,8 @@ static void draw_layout(CtkDisplayLayout *ctk_object) gdk_gc_set_line_attributes(fg_gc, 1, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND); +#endif + } @@ -3136,45 +3284,84 @@ static void draw_layout(CtkDisplayLayout *ctk_object) static void clear_layout(CtkDisplayLayout *ctk_object) { - GtkWidget *drawing_area = ctk_object->drawing_area; - GtkAllocation *allocation = &(drawing_area->allocation); - GdkGC *fg_gc = get_widget_fg_gc(drawing_area); + GtkAllocation allocation; GdkColor color; +#ifdef CTK_GTK3 + cairo_t *fg_gc; +#else + GdkGC *fg_gc; +#endif + fg_gc = get_drawing_context(ctk_object); + + ctk_widget_get_allocation(GTK_WIDGET(ctk_object->drawing_area), + &allocation); - /* Clear to background color */ - gdk_gc_set_rgb_fg_color(fg_gc, &(ctk_object->bg_color)); + /* Clear to background color */ + set_drawing_color(fg_gc, &(ctk_object->bg_color)); + +#ifdef CTK_GTK3 + cairo_set_antialias(fg_gc, CAIRO_ANTIALIAS_NONE); + + cairo_rectangle(fg_gc, + 2, + 2, + allocation.width - 4, + allocation.height - 4); + cairo_fill(fg_gc); +#else gdk_draw_rectangle(ctk_object->pixmap, fg_gc, TRUE, 2, 2, - allocation->width -4, - allocation->height -4); + allocation.width - 4, + allocation.height - 4); +#endif /* Add white trim */ gdk_color_parse("white", &color); - gdk_gc_set_rgb_fg_color(fg_gc, &color); + set_drawing_color(fg_gc, &color); + +#ifdef CTK_GTK3 + cairo_rectangle(fg_gc, + 1, + 1, + allocation.width - 3, + allocation.height - 3); + cairo_stroke(fg_gc); +#else gdk_draw_rectangle(ctk_object->pixmap, fg_gc, FALSE, 1, 1, - allocation->width -3, - allocation->height -3); + allocation.width - 3, + allocation.height - 3); +#endif /* Add layout border */ - gdk_gc_set_rgb_fg_color(fg_gc, &(ctk_object->fg_color)); + set_drawing_color(fg_gc, &(ctk_object->fg_color)); + +#ifdef CTK_GTK3 + cairo_rectangle(fg_gc, + 0, + 0, + allocation.width - 1, + allocation.height - 1); + cairo_stroke(fg_gc); +#else gdk_draw_rectangle(ctk_object->pixmap, fg_gc, FALSE, 0, 0, - allocation->width -1, - allocation->height -1); + allocation.width - 1, + allocation.height - 1); +#endif } /* clear_layout() */ @@ -4223,6 +4410,28 @@ void ctk_display_layout_register_callbacks(CtkDisplayLayout *ctk_object, +#ifdef CTK_GTK3 +/** draw_event_callback() ****************************************** + * + * Handles GTK 3 draw events. + * + **/ + +static gboolean +draw_event_callback(GtkWidget *widget, cairo_t *cr, gpointer data) +{ + CtkDisplayLayout *ctk_object = CTK_DISPLAY_LAYOUT(data); + + ctk_object->c_context = cr; + clear_layout(ctk_object); + draw_layout(ctk_object); + ctk_object->c_context = NULL; + + return TRUE; + +} /* draw_event_callback() */ + +#else /** expose_event_callback() ****************************************** * * Handles expose events. @@ -4233,16 +4442,16 @@ static gboolean expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { CtkDisplayLayout *ctk_object = CTK_DISPLAY_LAYOUT(data); - GdkGC *fg_gc = get_widget_fg_gc(widget); + GdkGC *fg_gc = get_drawing_context(ctk_object); GdkGCValues old_gc_values; - if (event->count || !widget->window || !fg_gc) { + if (event->count || !ctk_widget_get_window(widget) || !fg_gc) { return TRUE; } /* Redraw the layout */ - gdk_window_begin_paint_rect(widget->window, &event->area); + gdk_window_begin_paint_rect(ctk_widget_get_window(widget), &event->area); gdk_gc_get_values(fg_gc, &old_gc_values); @@ -4259,11 +4468,12 @@ expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) event->area.x, event->area.y, event->area.width, event->area.height); - gdk_window_end_paint(widget->window); + gdk_window_end_paint(ctk_widget_get_window(widget)); return TRUE; } /* expose_event_callback() */ +#endif @@ -4278,8 +4488,13 @@ configure_event_callback(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { CtkDisplayLayout *ctk_object = CTK_DISPLAY_LAYOUT(data); - int width = widget->allocation.width; - int height = widget->allocation.height; + GtkAllocation allocation; + int width, height; + + ctk_widget_get_allocation(widget, &allocation); + + width = allocation.width; + height = allocation.height; ctk_object->img_dim.x = LAYOUT_IMG_OFFSET + LAYOUT_IMG_BORDER_PADDING; ctk_object->img_dim.y = LAYOUT_IMG_OFFSET + LAYOUT_IMG_BORDER_PADDING; @@ -4288,7 +4503,9 @@ configure_event_callback(GtkWidget *widget, GdkEventConfigure *event, sync_scaling(ctk_object); +#ifndef CTK_GTK3 ctk_object->pixmap = gdk_pixmap_new(widget->window, width, height, -1); +#endif return TRUE; @@ -4315,7 +4532,11 @@ motion_event_callback(GtkWidget *widget, GdkEventMotion *event, gpointer data) /* Handle hints so we don't get overwhelmed with motion events */ if (event->is_hint) { +#ifdef CTK_GTK3 + gdk_window_get_device_position(event->window, event->device, &x, &y, &state); +#else gdk_window_get_pointer(event->window, &x, &y, &state); +#endif } else { x = event->x; y = event->y; @@ -4366,17 +4587,21 @@ motion_event_callback(GtkWidget *widget, GdkEventMotion *event, gpointer data) /* Queue and process expose event so we redraw ASAP */ queue_layout_redraw(ctk_object); - gdk_window_process_updates(drawing_area->window, TRUE); + gdk_window_process_updates(ctk_widget_get_window(drawing_area), TRUE); } /* Update the tooltip under the mouse */ } else { char *tip = get_tooltip_under_mouse(ctk_object, x, y); if (tip) { +#ifdef CTK_GTK3 + gtk_widget_set_tooltip_text(ctk_object->tooltip_area, tip); +#else gtk_tooltips_set_tip(ctk_object->tooltip_group, ctk_object->tooltip_area, tip, NULL); gtk_tooltips_force_window(ctk_object->tooltip_group); +#endif g_free(tip); } } @@ -4440,7 +4665,7 @@ button_press_event_callback(GtkWidget *widget, GdkEventButton *event, /* Handle selection of displays/X screens */ case Button1: ctk_object->button1 = 1; - click_layout(ctk_object, x, y); + click_layout(ctk_object, event->device, x, y); /* Report back selection event */ if (ctk_object->selected_callback) { diff --git a/src/gtk+-2.x/ctkdisplaylayout.h b/src/gtk+-2.x/ctkdisplaylayout.h index 34a7b44..bcfd1b0 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.h +++ b/src/gtk+-2.x/ctkdisplaylayout.h @@ -166,7 +166,7 @@ typedef struct nvModeLineRec { typedef struct nvSelectedModeRec { struct nvSelectedModeRec *next; - GtkWidget *label; /* Label shown in dropdown menu */ + gchar *text; /* Text shown in dropdown menu */ nvModeLinePtr modeline; /* Modeline this mode references */ @@ -474,13 +474,19 @@ typedef struct _CtkDisplayLayout GtkWidget *drawing_area; /* Drawing area */ GtkWidget *tooltip_area; /* Tooltip area */ +#ifndef CTK_GTK3 GtkTooltips *tooltip_group; /* Tooltip group */ +#endif /* Layout configuration */ nvLayoutPtr layout; /* Double buffering of layout image */ +#ifdef CTK_GTK3 + cairo_t *c_context; +#else GdkPixmap *pixmap; +#endif /* Image information */ GdkRectangle img_dim; diff --git a/src/gtk+-2.x/ctkditheringcontrols.c b/src/gtk+-2.x/ctkditheringcontrols.c index 97d4a15..dee39dd 100644 --- a/src/gtk+-2.x/ctkditheringcontrols.c +++ b/src/gtk+-2.x/ctkditheringcontrols.c @@ -33,6 +33,7 @@ #include "ctkhelp.h" #include "ctkditheringcontrols.h" #include "ctkdropdownmenu.h" +#include "ctkutils.h" /* function prototypes */ static void @@ -64,7 +65,7 @@ static void dithering_mode_menu_changed(GtkWidget *dithering_mode_menu, static void dithering_config_menu_changed(GtkWidget *dithering_config_menu, gpointer user_data); -static void dithering_update_received(GtkObject *object, gpointer arg1, +static void dithering_update_received(GObject *object, gpointer arg1, gpointer user_data); static @@ -406,7 +407,7 @@ static void setup_reset_button(CtkDitheringControls *ctk_dithering_controls) CtkDropDownMenu *dithering_mode_menu; CtkDropDownMenu *dithering_depth_menu; - if (!GTK_WIDGET_SENSITIVE(ctk_dithering_controls->dithering_controls_box)) { + if (!ctk_widget_get_sensitive(ctk_dithering_controls->dithering_controls_box)) { /* Nothing is available, don't bother enabling the reset button yet. */ return; } @@ -420,7 +421,7 @@ static void setup_reset_button(CtkDitheringControls *ctk_dithering_controls) goto enable; } - if (GTK_WIDGET_SENSITIVE(ctk_dithering_controls->dithering_mode_box)) { + if (ctk_widget_get_sensitive(ctk_dithering_controls->dithering_mode_box)) { dithering_mode_menu = CTK_DROP_DOWN_MENU(ctk_dithering_controls->dithering_mode_menu); history = ctk_drop_down_menu_get_current_value(dithering_mode_menu); @@ -430,7 +431,7 @@ static void setup_reset_button(CtkDitheringControls *ctk_dithering_controls) } } - if (GTK_WIDGET_SENSITIVE(ctk_dithering_controls->dithering_depth_box)) { + if (ctk_widget_get_sensitive(ctk_dithering_controls->dithering_depth_box)) { dithering_depth_menu = CTK_DROP_DOWN_MENU(ctk_dithering_controls->dithering_depth_menu); history = ctk_drop_down_menu_get_current_value(dithering_depth_menu); @@ -896,7 +897,7 @@ void add_dithering_controls_help(CtkDitheringControls *ctk_dithering_controls, * When dithering configuration is enabled/disabled, * we should update the GUI to reflect the current state & mode. */ -static void dithering_update_received(GtkObject *object, gpointer arg1, +static void dithering_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkDitheringControls *ctk_object = CTK_DITHERING_CONTROLS(user_data); diff --git a/src/gtk+-2.x/ctkdropdownmenu.c b/src/gtk+-2.x/ctkdropdownmenu.c index 0ef6e28..f1b33be 100644 --- a/src/gtk+-2.x/ctkdropdownmenu.c +++ b/src/gtk+-2.x/ctkdropdownmenu.c @@ -22,6 +22,7 @@ #include #include "ctkdropdownmenu.h" +#include "ctkutils.h" enum { DROP_DOWN_MENU_CHANGED_SIGNAL, @@ -128,7 +129,7 @@ GObject *ctk_drop_down_menu_change_object(GtkWidget* widget) CtkDropDownMenu *d = CTK_DROP_DOWN_MENU(widget); if (d->flags & CTK_DROP_DOWN_MENU_FLAG_READWRITE) { - return G_OBJECT(GTK_EDITABLE(GTK_BIN(d->combo_box)->child)); + return G_OBJECT(gtk_bin_get_child(GTK_BIN(d->combo_box))); } else { return G_OBJECT(d->combo_box); } @@ -177,13 +178,13 @@ GtkWidget* ctk_drop_down_menu_new(guint flags) d->current_selected_item = -1; if (flags & CTK_DROP_DOWN_MENU_FLAG_READWRITE) { - d->combo_box = gtk_combo_box_entry_new_text(); - g_signal_connect(G_OBJECT(GTK_EDITABLE(GTK_BIN(d->combo_box)->child)), + d->combo_box = ctk_combo_box_text_new_with_entry(); + g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(d->combo_box))), "changed", G_CALLBACK(ctk_drop_down_menu_changed), (gpointer) d); } else { - d->combo_box = gtk_combo_box_new_text(); + d->combo_box = ctk_combo_box_text_new(); g_signal_connect(G_OBJECT(d->combo_box), "changed", G_CALLBACK(changed), (gpointer) d); @@ -233,7 +234,7 @@ GtkWidget *ctk_drop_down_menu_append_item(CtkDropDownMenu *d, d->values = g_realloc(d->values, sizeof(CtkDropDownMenuValue) * (d->num_entries + 1)); - gtk_combo_box_append_text(GTK_COMBO_BOX(d->combo_box), name); + ctk_combo_box_text_append_text(d->combo_box, name); d->values[d->num_entries].glist_item = g_strdup(name); d->values[d->num_entries].value = value; @@ -348,7 +349,7 @@ void ctk_drop_down_menu_set_current_index(CtkDropDownMenu *d, gint index) if (d->flags & CTK_DROP_DOWN_MENU_FLAG_READWRITE) { gtk_entry_set_text - (GTK_ENTRY(GTK_BIN(d->combo_box)->child), + (GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->combo_box))), d->values[index].glist_item); d->current_selected_item = index; } else { @@ -369,7 +370,7 @@ void ctk_drop_down_menu_set_value_sensitive(CtkDropDownMenu *d, if (d->flags & CTK_DROP_DOWN_MENU_FLAG_READWRITE) { ctk_drop_down_menu_set_current_value(d, value); - gtk_widget_set_sensitive(GTK_WIDGET(GTK_BIN(d->combo_box)->child), + gtk_widget_set_sensitive(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->combo_box))), sensitive); } else { gint i; diff --git a/src/gtk+-2.x/ctkecc.c b/src/gtk+-2.x/ctkecc.c index b15797f..21f9f00 100644 --- a/src/gtk+-2.x/ctkecc.c +++ b/src/gtk+-2.x/ctkecc.c @@ -67,7 +67,7 @@ static const char *__reset_default_config_button_help = static void ecc_config_button_toggled(GtkWidget *, gpointer); static void show_ecc_toggle_warning_dlg(CtkEcc *); static void ecc_set_config_status(CtkEcc *); -static void ecc_configuration_update_received(GtkObject *, gpointer, gpointer); +static void ecc_configuration_update_received(GObject *, gpointer, gpointer); static void post_ecc_configuration_update(CtkEcc *); GType ctk_ecc_get_type(void) @@ -238,7 +238,7 @@ static void ecc_set_config_status(CtkEcc *ctk_ecc) * NV-CONTROL client. */ -static void ecc_configuration_update_received(GtkObject *object, +static void ecc_configuration_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; diff --git a/src/gtk+-2.x/ctkedid.c b/src/gtk+-2.x/ctkedid.c index 1e2cf9a..edf9049 100644 --- a/src/gtk+-2.x/ctkedid.c +++ b/src/gtk+-2.x/ctkedid.c @@ -119,13 +119,15 @@ GtkWidget* ctk_edid_new(NvCtrlAttributeHandle *handle, ctk_edid->name = name; ctk_edid->filename = DEFAULT_EDID_FILENAME_BINARY; ctk_edid->file_format = FILE_FORMAT_BINARY; - ctk_edid->file_selector = gtk_file_selection_new("Please select file where " - "EDID data will be " - "saved."); - - gtk_file_selection_set_select_multiple - (GTK_FILE_SELECTION(ctk_edid->file_selector), - FALSE); + ctk_edid->file_selector = + gtk_file_chooser_dialog_new("Please select file where " + "EDID data will be saved.", + NULL, GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ctk_edid->file_selector), + ctk_edid->filename); /* create the frame and vbox */ @@ -160,12 +162,6 @@ GtkWidget* ctk_edid_new(NvCtrlAttributeHandle *handle, /* adding file format selection option to file selector dialog */ frame = gtk_frame_new(NULL); - gtk_box_pack_start - (GTK_BOX(GTK_FILE_SELECTION(ctk_edid->file_selector)->main_vbox), - frame, FALSE, FALSE, 15); - gtk_box_reorder_child - (GTK_BOX(GTK_FILE_SELECTION(ctk_edid->file_selector)->main_vbox), - frame, 0); hbox = gtk_hbox_new(FALSE, 10); gtk_container_set_border_width(GTK_CONTAINER(hbox), FRAME_PADDING); @@ -192,11 +188,11 @@ GtkWidget* ctk_edid_new(NvCtrlAttributeHandle *handle, "toggled", G_CALLBACK(file_format_changed), (gpointer) ctk_edid); - gtk_window_set_resizable(GTK_WINDOW(ctk_edid->file_selector), - FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ctk_edid->file_format_binary_radio_button), TRUE); - gtk_widget_show_all(GTK_FILE_SELECTION(ctk_edid->file_selector)->main_vbox); + gtk_widget_show_all(frame); + gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(ctk_edid->file_selector), + frame); gtk_widget_show_all(GTK_WIDGET(object)); @@ -214,8 +210,11 @@ static void normalize_filename(CtkEdid *ctk_edid) int len = 0, n; ctk_edid->filename = - gtk_file_selection_get_filename(GTK_FILE_SELECTION(ctk_edid->file_selector)); + gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctk_edid->file_selector)); + if (!ctk_edid->filename) { + goto done; + } len = strlen(ctk_edid->filename); filename = malloc(len + 1); if (!filename) { @@ -270,9 +269,17 @@ static void normalize_filename(CtkEdid *ctk_edid) snprintf(buffer + n, 5, ".txt"); } + /* find the last forward slash (or the start of the filename) */ + slash = strrchr(buffer, '/'); + if (!slash) { + slash = filename; + } else { + slash++; + } + /* modify the file name as per the format selected */ - gtk_file_selection_set_filename(GTK_FILE_SELECTION(ctk_edid->file_selector), - buffer); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ctk_edid->file_selector), + slash); done: free(filename); free(buffer); @@ -306,8 +313,8 @@ static void button_clicked(GtkButton *button, gpointer user_data) /* Ask user for filename */ - gtk_file_selection_set_filename(GTK_FILE_SELECTION(ctk_edid->file_selector), - ctk_edid->filename); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(ctk_edid->file_selector), + ctk_edid->filename); result = gtk_dialog_run(GTK_DIALOG(ctk_edid->file_selector)); gtk_widget_hide(ctk_edid->file_selector); @@ -318,7 +325,7 @@ static void button_clicked(GtkButton *button, gpointer user_data) normalize_filename(ctk_edid); ctk_edid->filename = - gtk_file_selection_get_filename(GTK_FILE_SELECTION(ctk_edid->file_selector)); + gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctk_edid->file_selector)); write_edid_to_file(ctk_edid->ctk_config, ctk_edid->filename, ctk_edid->file_format, data, len); diff --git a/src/gtk+-2.x/ctkevent.c b/src/gtk+-2.x/ctkevent.c index 9e677e8..2465b2b 100644 --- a/src/gtk+-2.x/ctkevent.c +++ b/src/gtk+-2.x/ctkevent.c @@ -95,7 +95,7 @@ GType ctk_event_get_type(void) }; ctk_event_type = g_type_register_static - (GTK_TYPE_OBJECT, "CtkEvent", &ctk_event_info, 0); + (G_TYPE_OBJECT, "CtkEvent", &ctk_event_info, 0); } return ctk_event_type; @@ -337,6 +337,7 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_SIGNAL(NV_CTRL_GSYNC_ALLOWED); MAKE_SIGNAL(NV_CTRL_GPU_NVCLOCK_OFFSET); MAKE_SIGNAL(NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET); + MAKE_SIGNAL(NV_CTRL_VIDEO_DECODER_UTILIZATION); #undef MAKE_SIGNAL /* @@ -346,7 +347,7 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) * knows about. */ -#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET +#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_VIDEO_DECODER_UTILIZATION #warning "There are attributes that do not emit signals!" #endif @@ -552,7 +553,7 @@ static void ctk_event_register_source(CtkEvent *ctk_event) -GtkObject *ctk_event_new(NvCtrlAttributeHandle *handle) +GObject *ctk_event_new(NvCtrlAttributeHandle *handle) { GObject *object; CtkEvent *ctk_event; @@ -568,7 +569,7 @@ GtkObject *ctk_event_new(NvCtrlAttributeHandle *handle) ctk_event_register_source(ctk_event); - return GTK_OBJECT(ctk_event); + return G_OBJECT(ctk_event); } /* ctk_event_new() */ diff --git a/src/gtk+-2.x/ctkevent.h b/src/gtk+-2.x/ctkevent.h index 2943baa..6090fba 100644 --- a/src/gtk+-2.x/ctkevent.h +++ b/src/gtk+-2.x/ctkevent.h @@ -50,13 +50,13 @@ typedef struct _CtkEventStruct CtkEventStruct; struct _CtkEvent { - GtkObject parent; + GObject parent; NvCtrlAttributeHandle *handle; }; struct _CtkEventClass { - GtkObjectClass parent_class; + GtkWidgetClass parent_class; }; struct _CtkEventStruct @@ -69,7 +69,7 @@ struct _CtkEventStruct }; GType ctk_event_get_type (void) G_GNUC_CONST; -GtkObject* ctk_event_new (NvCtrlAttributeHandle*); +GObject* ctk_event_new (NvCtrlAttributeHandle*); void ctk_event_emit(CtkEvent *ctk_event, unsigned int mask, int attrib, int value); diff --git a/src/gtk+-2.x/ctkframelock.c b/src/gtk+-2.x/ctkframelock.c index 688ffe2..d9a282e 100644 --- a/src/gtk+-2.x/ctkframelock.c +++ b/src/gtk+-2.x/ctkframelock.c @@ -372,17 +372,24 @@ static void update_expand_all_button_status(CtkFramelock *); static void apply_parsed_attribute_list(CtkFramelock *ctk_framelock, ParsedAttribute *list); -static void gpu_state_received(GtkObject *object, +static void gpu_state_received(GObject *object, gpointer arg1, gpointer user_data); -static void framelock_state_received(GtkObject *object, +static void framelock_state_received(GObject *object, gpointer arg1, gpointer user_data); -#define SELECT_WIDGET(W, S) \ - gtk_widget_modify_fg(GTK_WIDGET(W), GTK_STATE_NORMAL, \ - &((GTK_WIDGET(W))->style->text[S])); \ - gtk_widget_modify_bg(GTK_WIDGET(W), GTK_STATE_NORMAL, \ - &((GTK_WIDGET(W))->style->base[S])); +/** select_widget() ********************************************* + * + * Get and set the foreground and background style colors based + * on the state passed in. + * + */ +static void select_widget(GtkWidget *widget, gint state) +{ + GtkStyle *style = gtk_widget_get_style(widget); + gtk_widget_modify_fg(widget, GTK_STATE_NORMAL, &(style->text[state])); + gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &(style->base[state])); +} @@ -411,8 +418,7 @@ static GtkWidget *create_error_msg_dialog(CtkFramelock *ctk_framelock) dialog = gtk_dialog_new_with_buttons("Error", ctk_framelock->parent_window, GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -422,16 +428,17 @@ static GtkWidget *create_error_msg_dialog(CtkFramelock *ctk_framelock) G_CALLBACK(gtk_widget_hide_on_delete), (gpointer) dialog); - g_signal_connect_swapped(GTK_OBJECT(dialog), "response", - G_CALLBACK(gtk_widget_hide_all), - GTK_OBJECT(dialog)); + g_signal_connect_swapped(G_OBJECT(dialog), "response", + G_CALLBACK(gtk_widget_hide), + G_OBJECT(dialog)); gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); hbox = gtk_hbox_new(FALSE, 12); gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); + gtk_container_add(GTK_CONTAINER( + ctk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox); pixbuf = gtk_widget_render_icon(dialog, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG, NULL); @@ -495,7 +502,7 @@ static GtkWidget *create_sync_state_button(CtkFramelock *ctk_framelock) * gtk_container_remove() later, it doesn't get destroyed */ - g_object_ref(GTK_OBJECT(hbox2)); + g_object_ref(G_OBJECT(hbox2)); ctk_framelock->enable_syncing_label = hbox2; @@ -524,7 +531,7 @@ static GtkWidget *create_sync_state_button(CtkFramelock *ctk_framelock) * gtk_container_remove() later, it doesn't get destroyed */ - g_object_ref(GTK_OBJECT(hbox2)); + g_object_ref(G_OBJECT(hbox2)); ctk_framelock->disable_syncing_label = hbox2; @@ -560,8 +567,7 @@ static GtkWidget *create_add_devices_dialog(CtkFramelock *ctk_framelock) dialog = gtk_dialog_new_with_buttons("Add X Screen", ctk_framelock->parent_window, GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, @@ -573,16 +579,17 @@ static GtkWidget *create_add_devices_dialog(CtkFramelock *ctk_framelock) G_CALLBACK(gtk_widget_hide_on_delete), (gpointer) dialog); - g_signal_connect (GTK_OBJECT(dialog), "response", + g_signal_connect (G_OBJECT(dialog), "response", G_CALLBACK(add_devices_response), - GTK_OBJECT(ctk_framelock)); + G_OBJECT(ctk_framelock)); gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); hbox = gtk_hbox_new(FALSE, 12); gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); + gtk_container_add(GTK_CONTAINER(ctk_dialog_get_content_area(GTK_DIALOG(dialog))), + hbox); pixbuf = gtk_widget_render_icon(dialog, GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG, NULL); @@ -648,8 +655,7 @@ static GtkWidget *create_remove_devices_dialog(CtkFramelock *ctk_framelock) dialog = gtk_dialog_new_with_buttons("Remove Device(s)", ctk_framelock->parent_window, GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, @@ -661,16 +667,17 @@ static GtkWidget *create_remove_devices_dialog(CtkFramelock *ctk_framelock) G_CALLBACK(gtk_widget_hide_on_delete), (gpointer) dialog); - g_signal_connect(GTK_OBJECT(dialog), "response", + g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(remove_devices_response), - GTK_OBJECT(ctk_framelock)); + G_OBJECT(ctk_framelock)); gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); hbox = gtk_hbox_new(FALSE, 12); gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); + gtk_container_add(GTK_CONTAINER(ctk_dialog_get_content_area(GTK_DIALOG(dialog))), + hbox); pixbuf = gtk_widget_render_icon(dialog, GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG, NULL); @@ -708,8 +715,7 @@ static GtkWidget *create_enable_confirm_dialog(CtkFramelock *ctk_framelock) dialog = gtk_dialog_new_with_buttons ("Confirm ModeSwitch", GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(ctk_framelock))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT - | GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_YES, GTK_RESPONSE_ACCEPT, NULL); @@ -728,9 +734,9 @@ static GtkWidget *create_enable_confirm_dialog(CtkFramelock *ctk_framelock) hbox = gtk_hbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), ctk_framelock->enable_confirm_text, TRUE, TRUE, 20); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, - TRUE, TRUE, 20); - gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dialog))), + hbox, TRUE, TRUE, 20); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dialog))); return dialog; } @@ -1523,15 +1529,15 @@ static void do_select_framelock_data(nvFrameLockDataPtr data, gint select) if (!data) { return; } - SELECT_WIDGET(data->label, select); - SELECT_WIDGET(data->receiving_label, select); - SELECT_WIDGET(data->rate_label, select); - SELECT_WIDGET(data->rate_text, select); - SELECT_WIDGET(data->delay_label, select); - SELECT_WIDGET(data->delay_text, select); - SELECT_WIDGET(data->house_label, select); - SELECT_WIDGET(data->port0_label, select); - SELECT_WIDGET(data->port1_label, select); + select_widget(data->label, select); + select_widget(data->receiving_label, select); + select_widget(data->rate_label, select); + select_widget(data->rate_text, select); + select_widget(data->delay_label, select); + select_widget(data->delay_text, select); + select_widget(data->house_label, select); + select_widget(data->port0_label, select); + select_widget(data->port1_label, select); } @@ -1547,8 +1553,8 @@ static void do_select_gpu_data(nvGPUDataPtr data, gint select) if (!data) { return; } - SELECT_WIDGET(data->label, select); - SELECT_WIDGET(data->timing_label, select); + select_widget(data->label, select); + select_widget(data->timing_label, select); } @@ -1564,12 +1570,12 @@ static void do_select_display_data(nvDisplayDataPtr data, gint select) if (!data) { return; } - SELECT_WIDGET(data->label, select); - SELECT_WIDGET(data->server_label, select); - SELECT_WIDGET(data->client_label, select); - SELECT_WIDGET(data->rate_label, select); - SELECT_WIDGET(data->rate_text, select); - SELECT_WIDGET(data->stereo_label, select); + select_widget(data->label, select); + select_widget(data->server_label, select); + select_widget(data->client_label, select); + select_widget(data->rate_label, select); + select_widget(data->rate_text, select); + select_widget(data->stereo_label, select); } @@ -1607,7 +1613,7 @@ static void list_entry_set_select(nvListEntryPtr entry, gint selected) /* Update the state of the entry's widgets */ - SELECT_WIDGET(entry->ebox, state); + select_widget(entry->ebox, state); if (!entry->data) { return; @@ -1802,7 +1808,7 @@ static nvListEntryPtr list_entry_new(nvListTreePtr tree) gtk_container_add(GTK_CONTAINER(entry->ebox), GTK_WIDGET(entry->hbox)); gtk_box_pack_start(GTK_BOX(entry->vbox), entry->ebox, TRUE, TRUE, 0); - SELECT_WIDGET(entry->ebox, GTK_STATE_NORMAL); + select_widget(entry->ebox, GTK_STATE_NORMAL); gtk_widget_set_events(entry->ebox, GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(entry->ebox), "button_press_event", G_CALLBACK(list_entry_clicked), @@ -3214,7 +3220,8 @@ static gint test_link_done(gpointer data) gtk_grab_remove(ctk_framelock->test_link_button); - gdk_window_set_cursor((GTK_WIDGET(ctk_framelock->parent_window))->window, + gdk_window_set_cursor(ctk_widget_get_window( + GTK_WIDGET(ctk_framelock->parent_window)), NULL); /* un-press the test link button */ @@ -3280,7 +3287,7 @@ static void toggle_test_link(GtkWidget *button, gpointer data) ctk_framelock->test_link_enabled = TRUE; gdk_window_set_cursor - ((GTK_WIDGET(ctk_framelock->parent_window))->window, + (ctk_widget_get_window(GTK_WIDGET(ctk_framelock->parent_window)), ctk_framelock->wait_cursor); gtk_grab_add(button); @@ -3705,8 +3712,12 @@ static void list_entry_update_gpu_status(CtkFramelock *ctk_framelock, &house); } - has_client = has_client_selected(entry); - has_server = has_server_selected(entry); + /* + * Iterate over this GPU's children (list of displays) to determine + * if any child is selected as a framelock client or server. + */ + has_client = has_client_selected(entry->children); + has_server = has_server_selected(entry->children); /* Update the Timing LED: * @@ -4253,7 +4264,7 @@ static void update_display_config(nvListEntryPtr display_entry, int config) * Signal handler for display target events. * */ -static void display_state_received(GtkObject *object, +static void display_state_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event = (CtkEventStruct *) arg1; @@ -4306,7 +4317,7 @@ static void display_state_received(GtkObject *object, * Signal handler for gpu target events. * */ -static void gpu_state_received(GtkObject *object, +static void gpu_state_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event = (CtkEventStruct *) arg1; @@ -4357,7 +4368,7 @@ static void gpu_state_received(GtkObject *object, case NV_CTRL_FRAMELOCK_TEST_SIGNAL_ENABLE: ctk_framelock->test_link_enabled = TRUE; gdk_window_set_cursor - ((GTK_WIDGET(ctk_framelock->parent_window))->window, + (ctk_widget_get_window(GTK_WIDGET(ctk_framelock->parent_window)), ctk_framelock->wait_cursor); gtk_grab_add(ctk_framelock->test_link_button); break; @@ -4365,7 +4376,7 @@ static void gpu_state_received(GtkObject *object, ctk_framelock->test_link_enabled = FALSE; gtk_grab_remove(ctk_framelock->test_link_button); gdk_window_set_cursor - ((GTK_WIDGET(ctk_framelock->parent_window))->window, + (ctk_widget_get_window(GTK_WIDGET(ctk_framelock->parent_window)), NULL); break; default: @@ -4407,7 +4418,7 @@ static void gpu_state_received(GtkObject *object, * Signal handler for frame lock target events. * */ -static void framelock_state_received(GtkObject *object, +static void framelock_state_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event = (CtkEventStruct *) arg1; @@ -4603,7 +4614,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, GtkWidget *sw; /* Scrollable window */ GtkWidget *vp; /* Viewport */ GtkWidget *scale; - GtkObject *adjustment; + GtkAdjustment *adjustment; GtkWidget *hbox; GtkWidget *vbox; @@ -4679,7 +4690,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, button = my_button_new_with_label("Remove Devices...", 15, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(show_remove_devices_dialog), - GTK_OBJECT(ctk_framelock)); + G_OBJECT(ctk_framelock)); ctk_config_set_tooltip(ctk_config, button, __remove_devices_button_help); ctk_framelock->remove_devices_button = button; @@ -4687,7 +4698,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, button = my_toggle_button_new_with_label("Short Names", 15, 0); // g_signal_connect(G_OBJECT(button), // "toggled", G_CALLBACK(toggle_short_names), - // GTK_OBJECT(ctk_framelock)); + // G_OBJECT(ctk_framelock)); ctk_framelock->short_labels_button = button; button = my_toggle_button_new_with_label("Show Extra Info", 15, 0); @@ -4720,7 +4731,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, button = my_toggle_button_new_with_label("Detect", 15, 0); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(toggle_detect_video_mode), - GTK_OBJECT(ctk_framelock)); + G_OBJECT(ctk_framelock)); ctk_config_set_tooltip(ctk_config, button, __detect_video_mode_button_help); ctk_framelock->video_mode_detect = button; @@ -4730,7 +4741,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, gtk_widget_set_sensitive(button, FALSE); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(toggle_test_link), - GTK_OBJECT(ctk_framelock)); + G_OBJECT(ctk_framelock)); ctk_config_set_tooltip(ctk_config, button, __test_link_button_help); ctk_framelock->test_link_button = button; @@ -4740,7 +4751,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, gtk_widget_set_sensitive(button, FALSE); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(toggle_sync_enable), - GTK_OBJECT(ctk_framelock)); + G_OBJECT(ctk_framelock)); ctk_config_set_tooltip(ctk_config, button, __sync_enable_button_help); ctk_framelock->sync_state_button = button; @@ -4757,14 +4768,14 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, } if (!ctk_framelock->video_mode_read_only) { - combo_box = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), + combo_box = ctk_combo_box_text_new(); + ctk_combo_box_text_append_text(combo_box, houseFormatStrings[NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_AUTO]); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), + ctk_combo_box_text_append_text(combo_box, houseFormatStrings[NV_CTRL_FRAMELOCK_VIDEO_MODE_TTL]); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), + ctk_combo_box_text_append_text(combo_box, houseFormatStrings[NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_BI_LEVEL]); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), + ctk_combo_box_text_append_text(combo_box, houseFormatStrings[NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_TRI_LEVEL]); gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), 0); @@ -4780,12 +4791,12 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, __video_mode_help); - combo_box = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), + combo_box = ctk_combo_box_text_new(); + ctk_combo_box_text_append_text(combo_box, syncEdgeStrings[NV_CTRL_FRAMELOCK_POLARITY_RISING_EDGE]); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), + ctk_combo_box_text_append_text(combo_box, syncEdgeStrings[NV_CTRL_FRAMELOCK_POLARITY_FALLING_EDGE]); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), + ctk_combo_box_text_append_text(combo_box, syncEdgeStrings[NV_CTRL_FRAMELOCK_POLARITY_BOTH_EDGES]); gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), 0); @@ -4856,7 +4867,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, /* create a viewport so we can have a white background */ vp = gtk_viewport_new(NULL, NULL); - SELECT_WIDGET(vp, GTK_STATE_NORMAL); + select_widget(vp, GTK_STATE_NORMAL); gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(vp)); /** XXX **/gtk_widget_set_size_request(sw, -1, 200);/** XXX **/ @@ -4941,8 +4952,9 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, hbox = gtk_hbox_new(FALSE, 5); label = gtk_label_new("Sync Interval:"); - adjustment = gtk_adjustment_new(val, valid.u.range.min, - valid.u.range.max, 1, 1, 0); + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(val, valid.u.range.min, + valid.u.range.max, + 1, 1, 0)); scale = gtk_hscale_new(GTK_ADJUSTMENT(adjustment)); gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustment), val); @@ -5088,7 +5100,7 @@ static void add_devices_response(GtkWidget *button, gint response, /* hide the dialog box */ - gtk_widget_hide_all(ctk_framelock->add_devices_dialog); + gtk_widget_hide(ctk_framelock->add_devices_dialog); /* set the focus back to the text entry */ @@ -5142,7 +5154,7 @@ static void remove_devices_response(GtkWidget *button, gint response, nvListEntryPtr entry = tree->selected_entry; gchar *name; - gtk_widget_hide_all(ctk_framelock->remove_devices_dialog); + gtk_widget_hide(ctk_framelock->remove_devices_dialog); if (response != GTK_RESPONSE_OK) return; diff --git a/src/gtk+-2.x/ctkgauge.c b/src/gtk+-2.x/ctkgauge.c index e63bb4e..488056a 100644 --- a/src/gtk+-2.x/ctkgauge.c +++ b/src/gtk+-2.x/ctkgauge.c @@ -21,6 +21,7 @@ #include #include "ctkgauge.h" +#include "ctkutils.h" #define REQUESTED_WIDTH 116 #define REQUESTED_HEIGHT 86 @@ -31,19 +32,37 @@ ctk_gauge_class_init (CtkGaugeClass *); static void ctk_gauge_finalize (GObject *); +#ifdef CTK_GTK3 +static gboolean +ctk_gauge_draw_event (GtkWidget *, cairo_t *); + +static void +ctk_gauge_get_preferred_width(GtkWidget *, gint *, gint *); + +static void +ctk_gauge_get_preferred_height(GtkWidget *, gint *, gint *); +#else + static gboolean ctk_gauge_expose_event (GtkWidget *, GdkEventExpose *); static void ctk_gauge_size_request (GtkWidget *, GtkRequisition *); +#endif + static gboolean ctk_gauge_configure_event (GtkWidget *, GdkEventConfigure *); static void draw (CtkGauge *); +#ifdef CTK_GTK3 +static void +set_foreground_color (cairo_t *, gint); +#else static GdkColor* get_foreground_color (CtkGauge *, gint); +#endif static GObjectClass *parent_class; @@ -89,8 +108,14 @@ static void ctk_gauge_class_init( gobject_class->finalize = ctk_gauge_finalize; +#ifdef CTK_GTK3 + widget_class->draw = ctk_gauge_draw_event; + widget_class->get_preferred_width = ctk_gauge_get_preferred_width; + widget_class->get_preferred_height = ctk_gauge_get_preferred_height; +#else widget_class->expose_event = ctk_gauge_expose_event; widget_class->size_request = ctk_gauge_size_request; +#endif widget_class->configure_event = ctk_gauge_configure_event; } @@ -98,6 +123,7 @@ static void ctk_gauge_finalize( GObject *object ) { +#ifndef CTK_GTK3 CtkGauge *ctk_gauge; GdkColormap *gdk_colormap; GdkColor *gdk_color; @@ -119,32 +145,53 @@ static void ctk_gauge_finalize( gdk_colormap_free_colors(gdk_colormap, gdk_color, 1); g_object_unref(gdk_colormap); +#endif } +#ifdef CTK_GTK3 +static gboolean ctk_gauge_draw_event( + GtkWidget *widget, + cairo_t *cr +) +#else static gboolean ctk_gauge_expose_event( GtkWidget *widget, GdkEventExpose *event ) +#endif { gint width, height; CtkGauge *ctk_gauge; + GtkAllocation allocation; ctk_gauge = CTK_GAUGE(widget); - width = widget->allocation.width - 2 * widget->style->xthickness; - height = widget->allocation.height - 2 * widget->style->ythickness; + ctk_widget_get_allocation(widget, &allocation); + width = allocation.width - 2 * gtk_widget_get_style(widget)->xthickness; + height = allocation.height - 2 * gtk_widget_get_style(widget)->ythickness; + +#ifdef CTK_GTK3 + gtk_render_frame(gtk_widget_get_style_context(widget), + cr, 0, 0, allocation.width, allocation.height); + + cairo_set_operator(ctk_gauge->c_context, CAIRO_OPERATOR_SOURCE); + + cairo_set_source_surface(cr, ctk_gauge->c_surface, 0, 0); + cairo_paint(cr); +#else gtk_paint_shadow(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, &event->area, widget, "ctk_gauge", 0, 0, widget->allocation.width, widget->allocation.height); gdk_gc_set_function(ctk_gauge->gdk_gc, GDK_COPY); - + gdk_draw_drawable(widget->window, ctk_gauge->gdk_gc, ctk_gauge->gdk_pixmap, 0, 0, widget->style->xthickness, widget->style->ythickness, width, height); +#endif return FALSE; } @@ -158,7 +205,16 @@ static gboolean ctk_gauge_configure_event ctk_gauge->width = event->width; ctk_gauge->height = event->height; - + +#ifdef CTK_GTK3 + if (ctk_gauge->c_context) cairo_destroy(ctk_gauge->c_context); + if (ctk_gauge->c_surface) cairo_surface_destroy(ctk_gauge->c_surface); + + ctk_gauge->c_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + ctk_gauge->width, + ctk_gauge->height); + ctk_gauge->c_context = cairo_create(ctk_gauge->c_surface); +#else if (ctk_gauge->gdk_pixmap) g_object_unref(ctk_gauge->gdk_pixmap); if (ctk_gauge->gdk_gc) g_object_unref(ctk_gauge->gdk_gc); @@ -166,12 +222,32 @@ static gboolean ctk_gauge_configure_event gdk_pixmap_new(widget->window, ctk_gauge->width, ctk_gauge->height, -1); ctk_gauge->gdk_gc = gdk_gc_new(ctk_gauge->gdk_pixmap); +#endif draw(ctk_gauge); return FALSE; } +#ifdef CTK_GTK3 +static void ctk_gauge_get_preferred_height( + GtkWidget *widget, + gint *minimum_height, + gint *natural_height +) +{ + *minimum_height = *natural_height = REQUESTED_HEIGHT; +} + +static void ctk_gauge_get_preferred_width( + GtkWidget *widget, + gint *minimum_width, + gint *natural_width +) +{ + *minimum_width = *natural_width = REQUESTED_WIDTH; +} +#else static void ctk_gauge_size_request( GtkWidget *widget, GtkRequisition *requisition @@ -180,13 +256,16 @@ static void ctk_gauge_size_request( requisition->width = REQUESTED_WIDTH; requisition->height = REQUESTED_HEIGHT; } +#endif GtkWidget* ctk_gauge_new(gint lower, gint upper) { GObject *object; CtkGauge *ctk_gauge; +#ifndef CTK_GTK3 GdkColormap *gdk_colormap; GdkColor *gdk_color; +#endif object = g_object_new(CTK_TYPE_GAUGE, NULL); @@ -195,12 +274,18 @@ GtkWidget* ctk_gauge_new(gint lower, gint upper) ctk_gauge->lower = lower; ctk_gauge->upper = upper; +#ifdef CTK_GTK3 + ctk_gauge->c_surface = NULL; + ctk_gauge->c_context = NULL; +#else ctk_gauge->gdk_pixmap = NULL; ctk_gauge->gdk_gc = NULL; - - ctk_gauge->pango_layout = +#endif + + ctk_gauge->pango_layout = gtk_widget_create_pango_layout(GTK_WIDGET(ctk_gauge), NULL); +#ifndef CTK_GTK3 ctk_gauge->gdk_colormap = gdk_colormap = gdk_colormap_get_system(); g_object_ref(gdk_colormap); @@ -227,7 +312,7 @@ GtkWidget* ctk_gauge_new(gint lower, gint upper) memset(gdk_color, 0, sizeof(GdkColor)); gdk_color->green = 65535; gdk_colormap_alloc_color(gdk_colormap, gdk_color, FALSE, TRUE); - +#endif return GTK_WIDGET(object); } @@ -246,32 +331,58 @@ void ctk_gauge_set_current(CtkGauge *ctk_gauge, gint current) g_free(ts); } -static GdkColor* get_foreground_color(CtkGauge *ctk_gauge, gint i) +#ifdef CTK_GTK3 +static void set_foreground_color(cairo_t *cr, gint i) +{ + if (i >= 7) { + cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 1.0); + } else if (i > 3) { + cairo_set_source_rgba(cr, 1.0, 1.0, 0.0, 1.0); + } else { + cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0); + } +} +#else +static GdkColor *get_foreground_color(CtkGauge *ctk_gauge, gint i) { - if (i >= 7) + if (i >= 7) { return &ctk_gauge->gdk_color_red; - else if (i > 3) + } else if (i > 3) { return &ctk_gauge->gdk_color_yellow; - else + } else { return &ctk_gauge->gdk_color_green; + } } +#endif + static void draw(CtkGauge *ctk_gauge) { GtkWidget *widget; gint x1, x2, y, width, i, percent, pos; gint upper, lower, range, current; - + lower = ctk_gauge->lower; upper = ctk_gauge->upper; range = upper - lower; current = ctk_gauge->current; - gdk_gc_set_function(ctk_gauge->gdk_gc, GDK_COPY); - widget = GTK_WIDGET(ctk_gauge); + +#ifdef CTK_GTK3 + /* Fill Curve surface with black background */ + cairo_set_operator(ctk_gauge->c_context, CAIRO_OPERATOR_SOURCE); + + cairo_set_source_rgba(ctk_gauge->c_context, 0.0, 0.0, 0.0, 1.0); + cairo_rectangle(ctk_gauge->c_context, 0, 0, + ctk_gauge->width, ctk_gauge->height); + cairo_fill(ctk_gauge->c_context); +#else + gdk_gc_set_function(ctk_gauge->gdk_gc, GDK_COPY); + gdk_draw_rectangle(ctk_gauge->gdk_pixmap, widget->style->black_gc, TRUE, 0, 0, ctk_gauge->width, ctk_gauge->height); +#endif width = ctk_gauge->width / 5; y = ctk_gauge->height / 5; @@ -281,48 +392,77 @@ static void draw(CtkGauge *ctk_gauge) x1 = (ctk_gauge->width / 2) - width - 4; x2 = x1 + width + 2; +#ifdef CTK_GTK3 + cairo_set_source_rgba(ctk_gauge->c_context, 0.5, 0.5, 0.5, 1.0); +#else gdk_gc_set_foreground(ctk_gauge->gdk_gc, &ctk_gauge->gdk_color_gray); +#endif for (i = 10; i > pos; i--) { +#ifdef CTK_GTK3 + cairo_rectangle(ctk_gauge->c_context, x1, y, width, 2); + cairo_fill(ctk_gauge->c_context); + cairo_rectangle(ctk_gauge->c_context, x2, y, width, 2); + cairo_fill(ctk_gauge->c_context); +#else gdk_draw_rectangle(ctk_gauge->gdk_pixmap, ctk_gauge->gdk_gc, TRUE, x1, y, width, 2); gdk_draw_rectangle(ctk_gauge->gdk_pixmap, ctk_gauge->gdk_gc, TRUE, x2, y, width, 2); +#endif y += 2 * 2; } for (i = i; i > 0; i--) { +#ifdef CTK_GTK3 + set_foreground_color(ctk_gauge->c_context, i); + cairo_rectangle(ctk_gauge->c_context, x1, y, width, 2); + cairo_fill(ctk_gauge->c_context); + cairo_rectangle(ctk_gauge->c_context, x2, y, width, 2); + cairo_fill(ctk_gauge->c_context); +#else gdk_gc_set_foreground(ctk_gauge->gdk_gc, get_foreground_color(ctk_gauge, i)); gdk_draw_rectangle(ctk_gauge->gdk_pixmap, ctk_gauge->gdk_gc, TRUE, x1, y, width, 2); gdk_draw_rectangle(ctk_gauge->gdk_pixmap, ctk_gauge->gdk_gc, TRUE, x2, y, width, 2); +#endif y += 2 * 2; } +#ifdef CTK_GTK3 + cairo_set_source_rgba(ctk_gauge->c_context, 0.5, 0.5, 0.5, 1.0); + cairo_move_to(ctk_gauge->c_context, x1, y); + pango_cairo_show_layout(ctk_gauge->c_context, ctk_gauge->pango_layout); +#else gdk_gc_set_foreground(ctk_gauge->gdk_gc, &ctk_gauge->gdk_color_gray); gdk_draw_layout(ctk_gauge->gdk_pixmap, ctk_gauge->gdk_gc, x1, y, ctk_gauge->pango_layout); +#endif } void ctk_gauge_draw(CtkGauge *ctk_gauge) { GtkWidget *widget; GdkRectangle rectangle; - + GtkAllocation allocation; + g_return_if_fail(CTK_IS_GAUGE(ctk_gauge)); widget = GTK_WIDGET(ctk_gauge); - rectangle.x = widget->style->xthickness; - rectangle.y = widget->style->ythickness; + ctk_widget_get_allocation(widget, &allocation); + + rectangle.x = gtk_widget_get_style(widget)->xthickness; + rectangle.y = gtk_widget_get_style(widget)->ythickness; - rectangle.width = widget->allocation.width - 2 * rectangle.x; - rectangle.height = widget->allocation.height - 2 * rectangle.y; + rectangle.width = allocation.width - 2 * rectangle.x; + rectangle.height = allocation.height - 2 * rectangle.y; - if (GTK_WIDGET_DRAWABLE(widget)) { + if (ctk_widget_is_drawable(widget)) { draw(ctk_gauge); /* only draw when visible */ - gdk_window_invalidate_rect(widget->window, &rectangle, FALSE); + gdk_window_invalidate_rect(ctk_widget_get_window(widget), + &rectangle, FALSE); } } diff --git a/src/gtk+-2.x/ctkgauge.h b/src/gtk+-2.x/ctkgauge.h index acdd36e..577c1ef 100644 --- a/src/gtk+-2.x/ctkgauge.h +++ b/src/gtk+-2.x/ctkgauge.h @@ -20,6 +20,8 @@ #ifndef __CTK_GAUGE_H__ #define __CTK_GAUGE_H__ +#include "ctkconfig.h" + G_BEGIN_DECLS #define CTK_TYPE_GAUGE (ctk_gauge_get_type()) @@ -50,15 +52,21 @@ struct _CtkGauge gint lower, upper; gint current; - GdkColormap *gdk_colormap; GdkColor gdk_color_gray; GdkColor gdk_color_red; GdkColor gdk_color_yellow; GdkColor gdk_color_green; +#ifdef CTK_GTK3 + cairo_surface_t *c_surface; + cairo_t *c_context; +#else + GdkColormap *gdk_colormap; + GdkPixmap *gdk_pixmap; GdkGC *gdk_gc; +#endif PangoLayout *pango_layout; diff --git a/src/gtk+-2.x/ctkglx.c b/src/gtk+-2.x/ctkglx.c index 34b68f0..feec275 100644 --- a/src/gtk+-2.x/ctkglx.c +++ b/src/gtk+-2.x/ctkglx.c @@ -398,7 +398,7 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0); fbconfig_header_sizes[i].widget = btn; - gtk_widget_size_request(btn, &req); + ctk_widget_get_preferred_size(btn, &req); fbconfig_header_sizes[i].width = req.width; } @@ -548,7 +548,7 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle, /* Make sure the table headers are the same width * as their table data column */ - gtk_widget_size_request(label, &req); + ctk_widget_get_preferred_size(label, &req); if ( fbconfig_header_sizes[cell].width > req.width ) { gtk_widget_set_size_request(label, diff --git a/src/gtk+-2.x/ctkgpu.c b/src/gtk+-2.x/ctkgpu.c index c2d1b65..99ba6e5 100644 --- a/src/gtk+-2.x/ctkgpu.c +++ b/src/gtk+-2.x/ctkgpu.c @@ -35,7 +35,7 @@ #include "XF86Config-parser/xf86Parser.h" -static void probe_displays_received(GtkObject *object, gpointer arg1, +static void probe_displays_received(GObject *object, gpointer arg1, gpointer user_data); static gboolean update_gpu_usage(gpointer); @@ -754,7 +754,7 @@ GtkTextBuffer *ctk_gpu_create_help(GtkTextTagTable *table, -static void probe_displays_received(GtkObject *object, gpointer arg1, +static void probe_displays_received(GObject *object, gpointer arg1, gpointer user_data) { CtkGpu *ctk_object = CTK_GPU(user_data); diff --git a/src/gtk+-2.x/ctkgvi.c b/src/gtk+-2.x/ctkgvi.c index 08628ff..65d5691 100644 --- a/src/gtk+-2.x/ctkgvi.c +++ b/src/gtk+-2.x/ctkgvi.c @@ -450,7 +450,7 @@ static gboolean update_sdi_input_info(gpointer user_data) ctk_empty_container(ctk_gvi->input_info_vbox); if (!show_detailed_info) { - gtk_widget_hide_all(GTK_WIDGET(ctk_gvi->jack_channel_omenu)); + gtk_widget_hide(GTK_WIDGET(ctk_gvi->jack_channel_omenu)); update_sdi_input_info_simple(ctk_gvi); } else { gtk_widget_show_all(GTK_WIDGET(ctk_gvi->jack_channel_omenu)); @@ -492,7 +492,7 @@ static gchar* gpu_name_string(gint gpu, CtrlHandles *handle) return gpu_name; } -static void bound_gpu_changed(GtkObject *object, gpointer arg1, +static void bound_gpu_changed(GObject *object, gpointer arg1, gpointer user_data) { CtkGvi *ctk_gvi = (CtkGvi *) user_data; @@ -695,7 +695,7 @@ GtkWidget* ctk_gvi_new(NvCtrlAttributeHandle *handle, g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(show_detailed_info_button_toggled), - GTK_OBJECT(ctk_gvi)); + G_OBJECT(ctk_gvi)); g_signal_connect(G_OBJECT(ctk_event), CTK_EVENT_NAME(NV_CTRL_GVI_BOUND_GPU), diff --git a/src/gtk+-2.x/ctkgvo-banner.c b/src/gtk+-2.x/ctkgvo-banner.c index 8ffd798..c75a538 100644 --- a/src/gtk+-2.x/ctkgvo-banner.c +++ b/src/gtk+-2.x/ctkgvo-banner.c @@ -84,7 +84,7 @@ static gboolean update_gvo_banner_led_images_shared_sync_bnc(gpointer data); static void update_gvo_banner_led_state(CtkGvoBanner *ctk_gvo_banner); -static void gvo_event_received(GtkObject *object, +static void gvo_event_received(GObject *object, gpointer arg1, gpointer user_data); @@ -400,13 +400,13 @@ static void update_led_image(CtkGvoBanner *banner, int led, int color) banner->img[led] = color; /* Draw the LED and tell gdk to draw it to the window */ - if (ctk_banner && ctk_banner->window) { + if (ctk_banner && ctk_widget_get_window(ctk_banner)) { draw_led(CTK_BANNER(ctk_banner), led, color); rec.x = CTK_BANNER(ctk_banner)->artwork_x + __led_pos_x[led]; rec.y = CTK_BANNER(ctk_banner)->artwork_y + __led_pos_y; - gdk_window_invalidate_rect(ctk_banner->window, &rec, TRUE); + gdk_window_invalidate_rect(ctk_widget_get_window(ctk_banner), &rec, TRUE); } } /* update_led_image() */ @@ -817,7 +817,7 @@ gint ctk_gvo_banner_probe(gpointer data) * for event-driven NV-CONTROL attributes. */ -static void gvo_event_received(GtkObject *object, +static void gvo_event_received(GObject *object, gpointer arg1, gpointer user_data) { diff --git a/src/gtk+-2.x/ctkgvo-csc.c b/src/gtk+-2.x/ctkgvo-csc.c index 004457f..59779ca 100644 --- a/src/gtk+-2.x/ctkgvo-csc.c +++ b/src/gtk+-2.x/ctkgvo-csc.c @@ -105,7 +105,7 @@ static void set_apply_button_sensitive (CtkGvoCsc *ctk_gvo_csc); static void apply_csc_values (CtkGvoCsc *ctk_gvo_csc); -static void gvo_csc_event_received (GtkObject *object, +static void gvo_csc_event_received (GObject *object, gpointer arg1, gpointer user_data); @@ -258,7 +258,7 @@ GtkWidget* ctk_gvo_csc_new(NvCtrlAttributeHandle *handle, ctk_config_set_tooltip(ctk_config, ctk_gvo_csc->overrideButton, __override_help); - g_signal_connect(GTK_OBJECT(ctk_gvo_csc->overrideButton), "toggled", + g_signal_connect(G_OBJECT(ctk_gvo_csc->overrideButton), "toggled", G_CALLBACK(override_button_toggled), ctk_gvo_csc); frame = gtk_frame_new(NULL); @@ -535,7 +535,7 @@ GtkWidget* ctk_gvo_csc_new(NvCtrlAttributeHandle *handle, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ctk_gvo_csc->applyImmediateButton), FALSE); - g_signal_connect(GTK_OBJECT(ctk_gvo_csc->applyImmediateButton), + g_signal_connect(G_OBJECT(ctk_gvo_csc->applyImmediateButton), "toggled", G_CALLBACK(apply_immediate_button_toggled), ctk_gvo_csc); @@ -556,7 +556,7 @@ GtkWidget* ctk_gvo_csc_new(NvCtrlAttributeHandle *handle, ctk_config_set_tooltip(ctk_config, ctk_gvo_csc->applyButton, __apply_help); - g_signal_connect(GTK_OBJECT(ctk_gvo_csc->applyButton), + g_signal_connect(G_OBJECT(ctk_gvo_csc->applyButton), "clicked", G_CALLBACK(apply_button_clicked), ctk_gvo_csc); @@ -1017,7 +1017,7 @@ static void apply_csc_values(CtkGvoCsc *ctk_gvo_csc) * GVO CSC event handler. */ -static void gvo_csc_event_received(GtkObject *object, +static void gvo_csc_event_received(GObject *object, gpointer arg1, gpointer user_data) { diff --git a/src/gtk+-2.x/ctkgvo-sync.c b/src/gtk+-2.x/ctkgvo-sync.c index 6643f64..6a6609d 100644 --- a/src/gtk+-2.x/ctkgvo-sync.c +++ b/src/gtk+-2.x/ctkgvo-sync.c @@ -29,6 +29,7 @@ #include "ctkconfig.h" #include "ctkhelp.h" +#include "ctkutils.h" #include "ctkdropdownmenu.h" @@ -92,7 +93,7 @@ static void hsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data); static void vsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data); -static void gvo_sync_event_received(GtkObject *object, +static void gvo_sync_event_received(GObject *object, gpointer arg1, gpointer user_data); static gint gvo_sync_probe_callback(gpointer data); @@ -358,7 +359,7 @@ GtkWidget* ctk_gvo_sync_new(NvCtrlAttributeHandle *handle, if ( !query_init_gvo_sync_state(ctk_gvo_sync) ) { // Free the object g_object_ref(object); - gtk_object_sink(GTK_OBJECT(object)); + ctk_g_object_ref_sink(G_OBJECT(object)); g_object_unref(object); return NULL; } @@ -1062,7 +1063,7 @@ static void detect_input_toggled(GtkToggleButton *togglebutton, /* change the cursor */ gdk_window_set_cursor - ((GTK_WIDGET(ctk_gvo_sync->parent_window))->window, + (ctk_widget_get_window(GTK_WIDGET(ctk_gvo_sync->parent_window)), ctk_gvo_sync->wait_cursor); /* make all other widgets insensitive */ @@ -1134,7 +1135,7 @@ static gint detect_input_done(gpointer data) /* restore the cursor */ - gdk_window_set_cursor((GTK_WIDGET(ctk_gvo_sync->parent_window))->window, + gdk_window_set_cursor(ctk_widget_get_window(GTK_WIDGET(ctk_gvo_sync->parent_window)), NULL); /* ungrab the server */ @@ -1292,7 +1293,7 @@ static void vsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data) * NV-CONTROL events. */ -static void gvo_sync_event_received(GtkObject *object, +static void gvo_sync_event_received(GObject *object, gpointer arg1, gpointer user_data) { diff --git a/src/gtk+-2.x/ctkgvo.c b/src/gtk+-2.x/ctkgvo.c index 3bf36c5..239a38f 100644 --- a/src/gtk+-2.x/ctkgvo.c +++ b/src/gtk+-2.x/ctkgvo.c @@ -69,7 +69,7 @@ static void register_for_gvo_events(CtkGvo *ctk_gvo, CtkEvent *ctk_event); static void update_gvo_current_info(CtkGvo *ctk_gvo); -static void gvo_event_received(GtkObject *object, +static void gvo_event_received(GObject *object, gpointer arg1, gpointer user_data); @@ -713,7 +713,7 @@ static void update_gvo_current_info(CtkGvo *ctk_gvo) * gvo_event_received() - Handles GVO NV-CONTROL events. */ -static void gvo_event_received(GtkObject *object, +static void gvo_event_received(GObject *object, gpointer arg1, gpointer user_data) { diff --git a/src/gtk+-2.x/ctkimagesliders.c b/src/gtk+-2.x/ctkimagesliders.c index f5e417b..85dfe75 100644 --- a/src/gtk+-2.x/ctkimagesliders.c +++ b/src/gtk+-2.x/ctkimagesliders.c @@ -25,6 +25,7 @@ #include "ctkscale.h" #include "ctkconfig.h" #include "ctkhelp.h" +#include "ctkutils.h" #define FRAME_PADDING 5 @@ -55,7 +56,7 @@ static void setup_reset_button(CtkImageSliders *ctk_image_sliders); static void scale_value_changed(GtkAdjustment *adjustment, gpointer user_data); -static void scale_value_received(GtkObject *, gpointer arg1, gpointer); +static void scale_value_received(GObject *, gpointer arg1, gpointer); GType ctk_image_sliders_get_type(void) @@ -210,11 +211,11 @@ static GtkWidget * add_scale(CtkConfig *ctk_config, gint default_value, gpointer callback_data) { - GtkObject *adj; + GtkAdjustment *adj; GtkWidget *scale; - adj = gtk_adjustment_new(0, 0, 10, 1, 1, 0); + adj = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 10, 1, 1, 0)); g_object_set_data(G_OBJECT(adj), "attribute", GINT_TO_POINTER(attribute)); @@ -302,7 +303,7 @@ void ctk_image_sliders_reset(CtkImageSliders *ctk_image_sliders) if (!ctk_image_sliders) return; - if (GTK_WIDGET_SENSITIVE(ctk_image_sliders->digital_vibrance)) { + if (ctk_widget_get_sensitive(ctk_image_sliders->digital_vibrance)) { adj = CTK_SCALE(ctk_image_sliders->digital_vibrance)->gtk_adjustment; val = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(adj), "attribute default value")); @@ -312,7 +313,7 @@ void ctk_image_sliders_reset(CtkImageSliders *ctk_image_sliders) val); } - if (GTK_WIDGET_SENSITIVE(ctk_image_sliders->image_sharpening)) { + if (ctk_widget_get_sensitive(ctk_image_sliders->image_sharpening)) { adj = CTK_SCALE(ctk_image_sliders->image_sharpening)->gtk_adjustment; val = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(adj), "attribute default value")); @@ -353,7 +354,7 @@ void ctk_image_sliders_reset(CtkImageSliders *ctk_image_sliders) * NV-CONTROL client changed any of the settings that we care about. */ -static void scale_value_received(GtkObject *object, gpointer arg1, +static void scale_value_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct; @@ -454,8 +455,8 @@ static void setup_scale(CtkImageSliders *ctk_image_sliders, g_signal_handlers_block_by_func(adj, scale_value_changed, ctk_image_sliders); - adj->lower = valid.u.range.min; - adj->upper = valid.u.range.max; + ctk_adjustment_set_lower(adj, valid.u.range.min); + ctk_adjustment_set_upper(adj, valid.u.range.max); gtk_adjustment_changed(GTK_ADJUSTMENT(adj)); gtk_adjustment_set_value(GTK_ADJUSTMENT(adj), val); @@ -485,7 +486,7 @@ static void setup_reset_button(CtkImageSliders *ctk_image_sliders) */ scale = ctk_image_sliders->digital_vibrance; - if (GTK_WIDGET_SENSITIVE(scale)) { + if (ctk_widget_get_sensitive(scale)) { adj = CTK_SCALE(scale)->gtk_adjustment; current_val = (gint) gtk_adjustment_get_value(adj); default_val = @@ -497,7 +498,7 @@ static void setup_reset_button(CtkImageSliders *ctk_image_sliders) } scale = ctk_image_sliders->image_sharpening; - if (GTK_WIDGET_SENSITIVE(scale)) { + if (ctk_widget_get_sensitive(scale)) { adj = CTK_SCALE(scale)->gtk_adjustment; current_val = (gint) gtk_adjustment_get_value(adj); default_val = diff --git a/src/gtk+-2.x/ctkmultisample.c b/src/gtk+-2.x/ctkmultisample.c index ffb0d55..a5ee7d6 100644 --- a/src/gtk+-2.x/ctkmultisample.c +++ b/src/gtk+-2.x/ctkmultisample.c @@ -49,9 +49,9 @@ static GtkWidget *create_fsaa_setting_menu(CtkMultisample *ctk_multisample, static void fsaa_setting_checkbox_toggled(GtkWidget *widget, gpointer user_data); -static void fsaa_setting_menu_changed(GtkObject *object, gpointer user_data); +static void fsaa_setting_menu_changed(GObject *object, gpointer user_data); -static void fsaa_setting_update_received(GtkObject *object, +static void fsaa_setting_update_received(GObject *object, gpointer arg1, gpointer user_data); @@ -59,13 +59,13 @@ static void post_fsaa_value_changed(CtkMultisample *ctk_multisample, gint val); static void fsaa_value_changed(GtkRange *range, gpointer user_data); -static void fsaa_update_received(GtkObject *object, +static void fsaa_update_received(GObject *object, gpointer arg1, gpointer user_data); static void fxaa_checkbox_toggled(GtkWidget *widget, gpointer user_data); -static void fxaa_update_received(GtkObject *object, +static void fxaa_update_received(GObject *object, gpointer arg1, gpointer user_data); static void post_fxaa_toggled(CtkMultisample *ctk_multisample, @@ -78,7 +78,7 @@ post_log_aniso_app_override_toggled(CtkMultisample *ctk_multisample, static void log_aniso_app_override_toggled(GtkWidget *widget, gpointer user_data); -static void log_app_override_update_received(GtkObject *object, +static void log_app_override_update_received(GObject *object, gpointer arg1, gpointer user_data); @@ -92,7 +92,7 @@ static void post_log_aniso_value_changed(CtkMultisample *ctk_multisample, static void log_aniso_value_changed(GtkRange *range, gpointer user_data); -static void log_aniso_range_update_received(GtkObject *object, +static void log_aniso_range_update_received(GObject *object, gpointer arg1, gpointer user_data); @@ -101,7 +101,7 @@ static void post_texture_sharpening_toggled(CtkMultisample *ctk_multisample, static void texture_sharpening_toggled(GtkWidget *widget, gpointer user_data); -static void texture_sharpening_update_received(GtkObject *object, +static void texture_sharpening_update_received(GObject *object, gpointer arg1, gpointer user_data); @@ -227,7 +227,7 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle, GtkWidget *check_button; GtkWidget *menu; GtkWidget *scale; - GtkObject *adjustment; + GtkAdjustment *adjustment; gint min, max; gint val, app_control, override, enhance, mode, i; @@ -347,7 +347,8 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle, max = ctk_multisample->fsaa_translation_table_size - 1; /* create the slider */ - adjustment = gtk_adjustment_new(val, min, max, 1, 1, 0.0); + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(val, min, max, + 1, 1, 0.0)); scale = gtk_hscale_new(GTK_ADJUSTMENT(adjustment)); gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustment), val); @@ -482,7 +483,8 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle, max = valid.u.range.max; /* create the slider */ - adjustment = gtk_adjustment_new(val, min, max, 1, 1, 0.0); + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(val, min, max, + 1, 1, 0.0)); scale = gtk_hscale_new(GTK_ADJUSTMENT(adjustment)); gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustment), val); @@ -842,7 +844,7 @@ static void fsaa_setting_checkbox_toggled(GtkWidget *widget, * the fsaa slider. */ -static void fsaa_setting_menu_changed(GtkObject *object, gpointer user_data) +static void fsaa_setting_menu_changed(GObject *object, gpointer user_data) { CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data); gint idx; @@ -874,7 +876,7 @@ static void fsaa_setting_menu_changed(GtkObject *object, gpointer user_data) * NV-CONTROL client. */ -static void fsaa_setting_update_received(GtkObject *object, +static void fsaa_setting_update_received(GObject *object, gpointer arg1, gpointer user_data) { @@ -1125,7 +1127,7 @@ static void fxaa_checkbox_toggled(GtkWidget *widget, * client. */ -static void fxaa_update_received(GtkObject *object, +static void fxaa_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; @@ -1172,7 +1174,7 @@ post_fxaa_toggled(CtkMultisample *ctk_multisample, gboolean enable) * client. */ -static void fsaa_update_received(GtkObject *object, +static void fsaa_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct; @@ -1274,7 +1276,7 @@ static void log_aniso_app_override_toggled(GtkWidget *widget, * another NV-CONTROL client. */ -static void log_app_override_update_received(GtkObject *object, +static void log_app_override_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; @@ -1378,7 +1380,7 @@ static void log_aniso_value_changed(GtkRange *range, gpointer user_data) * client. */ -static void log_aniso_range_update_received(GtkObject *object, +static void log_aniso_range_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct; @@ -1453,7 +1455,7 @@ static void texture_sharpening_toggled(GtkWidget *widget, gpointer user_data) * NV-CONTROL client. */ -static void texture_sharpening_update_received(GtkObject *object, +static void texture_sharpening_update_received(GObject *object, gpointer arg1, gpointer user_data) { diff --git a/src/gtk+-2.x/ctkopengl.c b/src/gtk+-2.x/ctkopengl.c index f251737..bfce5bf 100644 --- a/src/gtk+-2.x/ctkopengl.c +++ b/src/gtk+-2.x/ctkopengl.c @@ -70,7 +70,7 @@ static void show_sli_visual_indicator_button_toggled (GtkWidget *, gpointer); static void show_multigpu_visual_indicator_button_toggled (GtkWidget *, gpointer); -static void value_changed (GtkObject *, gpointer, gpointer); +static void value_changed (GObject *, gpointer, gpointer); static const gchar *get_image_settings_string(gint val); @@ -79,14 +79,14 @@ static gchar *format_image_settings_value(GtkScale *scale, gdouble arg1, static void post_slider_value_changed(CtkOpenGL *ctk_opengl, gint val); -static void aa_line_gamma_update_received(GtkObject *object, +static void aa_line_gamma_update_received(GObject *object, gpointer arg1, gpointer user_data); static void post_image_settings_value_changed(CtkOpenGL *ctk_opengl, gint val); static void image_settings_value_changed(GtkRange *range, gpointer user_data); -static void image_settings_update_received(GtkObject *object, +static void image_settings_update_received(GObject *object, gpointer arg1, gpointer user_data); static GtkWidget *create_slider(CtkOpenGL *ctk_opengl, @@ -213,7 +213,7 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle, GtkWidget *vbox; GtkWidget *check_button; GtkWidget *scale; - GtkObject *adjustment; + GtkAdjustment *adjustment; gint sync_to_vblank; gint flipping_allowed; @@ -537,10 +537,11 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle, gtk_container_add(GTK_CONTAINER(frame), hbox); /* create the slider */ - adjustment = gtk_adjustment_new(image_settings_value, - image_settings_valid.u.range.min, - image_settings_valid.u.range.max, - 1, 1, 0.0); + adjustment = GTK_ADJUSTMENT( + gtk_adjustment_new(image_settings_value, + image_settings_valid.u.range.min, + image_settings_valid.u.range.max, + 1, 1, 0.0)); scale = gtk_hscale_new(GTK_ADJUSTMENT(adjustment)); gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustment), image_settings_value); @@ -986,7 +987,7 @@ static void use_conformant_clamping_button_toggled(GtkWidget *widget, * value_changed() - callback function for changed OpenGL settings. */ -static void value_changed(GtkObject *object, gpointer arg1, gpointer user_data) +static void value_changed(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct; CtkOpenGL *ctk_opengl; @@ -1146,7 +1147,7 @@ static void image_settings_value_changed(GtkRange *range, gpointer user_data) * NV_CTRL_IMAGE_SETTINGS atribute is changed by another NV-CONTROL client. */ -static void image_settings_update_received(GtkObject *object, +static void image_settings_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; @@ -1193,7 +1194,7 @@ static void slider_changed(GtkAdjustment *adjustment, gpointer user_data) gint attribute, value; user_data = g_object_get_data(G_OBJECT(adjustment), "opengl_attribute"); attribute = GPOINTER_TO_INT(user_data); - value = (gint) adjustment->value; + value = (gint) gtk_adjustment_get_value(adjustment); NvCtrlSetAttribute(ctk_opengl->handle, attribute, value); post_slider_value_changed(ctk_opengl, value); } /* slider_changed() */ @@ -1205,7 +1206,7 @@ static void slider_changed(GtkAdjustment *adjustment, gpointer user_data) * client. */ -static void aa_line_gamma_update_received(GtkObject *object, +static void aa_line_gamma_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; @@ -1236,7 +1237,7 @@ static GtkWidget *create_slider(CtkOpenGL *ctk_opengl, gint attribute, unsigned int bit) { - GtkObject *adjustment; + GtkAdjustment *adjustment; GtkWidget *scale, *widget; gint min, max, val, step_incr, page_incr; NVCTRLAttributeValidValuesRec range; @@ -1259,8 +1260,8 @@ static GtkWidget *create_slider(CtkOpenGL *ctk_opengl, if (page_incr <= 0) page_incr = 1; /* create the slider */ - adjustment = gtk_adjustment_new(val, min, max, - step_incr, page_incr, 0.0); + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(val, min, max, + step_incr, page_incr, 0.0)); g_object_set_data(G_OBJECT(adjustment), "opengl_attribute", GINT_TO_POINTER(attribute)); diff --git a/src/gtk+-2.x/ctkpowermizer.c b/src/gtk+-2.x/ctkpowermizer.c index 42c8a94..e1bdc69 100644 --- a/src/gtk+-2.x/ctkpowermizer.c +++ b/src/gtk+-2.x/ctkpowermizer.c @@ -41,13 +41,13 @@ static void update_powermizer_menu_info(CtkPowermizer *ctk_powermizer); static void set_powermizer_menu_label_txt(CtkPowermizer *ctk_powermizer, gint powerMizerMode); static void powermizer_menu_changed(GtkWidget*, gpointer); -static void update_powermizer_menu_event(GtkObject *object, +static void update_powermizer_menu_event(GObject *object, gpointer arg1, gpointer user_data); static void dp_config_button_toggled(GtkWidget *, gpointer); static void dp_set_config_status(CtkPowermizer *); static void dp_update_config_status(CtkPowermizer *, gboolean); -static void dp_configuration_update_received(GtkObject *, gpointer, gpointer); +static void dp_configuration_update_received(GObject *, gpointer, gpointer); static void post_dp_configuration_update(CtkPowermizer *); static void show_dp_toggle_warning_dlg(CtkPowermizer *ctk_powermizer); static void post_set_attribute_offset_value(CtkPowermizer *ctk_powermizer, @@ -57,7 +57,7 @@ static void offset_entry_set_value(CtkPowermizer *ctk_powermizer, GtkWidget *widget, gint offset); -static void offset_value_changed_event_received(GtkObject *object, +static void offset_value_changed_event_received(GObject *object, gpointer arg1, gpointer user_data); @@ -239,7 +239,7 @@ static void apply_perf_mode_token(char *token, char *value, void *data) -static void offset_value_changed_event_received(GtkObject *object, +static void offset_value_changed_event_received(GObject *object, gpointer arg1, gpointer user_data) { @@ -1696,7 +1696,7 @@ static void post_powermizer_menu_update(CtkPowermizer *ctk_powermizer) -static void update_powermizer_menu_event(GtkObject *object, +static void update_powermizer_menu_event(GObject *object, gpointer arg1, gpointer user_data) { @@ -1899,7 +1899,7 @@ static void dp_update_config_status(CtkPowermizer *ctk_powermizer, gboolean val) * NV-CONTROL client. */ -static void dp_configuration_update_received(GtkObject *object, +static void dp_configuration_update_received(GObject *object, gpointer arg1, gpointer user_data) { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; diff --git a/src/gtk+-2.x/ctkscale.c b/src/gtk+-2.x/ctkscale.c index 40d0c25..5ba439d 100644 --- a/src/gtk+-2.x/ctkscale.c +++ b/src/gtk+-2.x/ctkscale.c @@ -21,8 +21,13 @@ #include #include "ctkscale.h" +#include "ctkutils.h" #include +#ifdef CTK_GTK3 +#include +#endif + static void ctk_scale_finalize(GObject *object); static void ctk_scale_init(CtkScaleClass *ctk_object_class); @@ -95,6 +100,9 @@ static gboolean ctk_scale_key_event(GtkWidget *widget, GdkEvent *event, GdkEventKey *key_event = (GdkEventKey *) event; GtkAdjustment *adjustment = GTK_ADJUSTMENT(ctk_scale->gtk_adjustment); gdouble newval; + gdouble value = gtk_adjustment_get_value(adjustment); + gdouble step_increment = ctk_adjustment_get_step_increment(adjustment); + gdouble page_increment = ctk_adjustment_get_page_increment(adjustment); switch (key_event->keyval) { @@ -102,24 +110,24 @@ static gboolean ctk_scale_key_event(GtkWidget *widget, GdkEvent *event, case GDK_KP_Left: case GDK_Down: case GDK_KP_Down: - newval = adjustment->value - adjustment->step_increment; + newval = value - step_increment; break; - + case GDK_Right: case GDK_KP_Right: case GDK_Up: case GDK_KP_Up: - newval = adjustment->value + adjustment->step_increment; + newval = value + step_increment; break; case GDK_Page_Down: case GDK_KP_Page_Down: - newval = adjustment->value - adjustment->page_increment; + newval = value - page_increment; break; case GDK_Page_Up: case GDK_KP_Page_Up: - newval = adjustment->value + adjustment->page_increment; + newval = value + page_increment; break; default: @@ -142,11 +150,11 @@ static void adjustment_value_changed( switch (ctk_scale->value_type) { case G_TYPE_INT: - g_snprintf(text, 6, "%d", (gint) adjustment->value); + g_snprintf(text, 6, "%d", (gint) gtk_adjustment_get_value(adjustment)); break; case G_TYPE_DOUBLE: default: - g_snprintf(text, 6, "%2.3f", adjustment->value); + g_snprintf(text, 6, "%2.3f", gtk_adjustment_get_value(adjustment)); break; } diff --git a/src/gtk+-2.x/ctkscreen.c b/src/gtk+-2.x/ctkscreen.c index 4d22a03..6c384a3 100644 --- a/src/gtk+-2.x/ctkscreen.c +++ b/src/gtk+-2.x/ctkscreen.c @@ -38,7 +38,7 @@ void ctk_screen_event_handler(GtkWidget *widget, XRRScreenChangeNotifyEvent *ev, gpointer data); -static void info_update_gpu_error(GtkObject *object, gpointer arg1, +static void info_update_gpu_error(GObject *object, gpointer arg1, gpointer user_data); GType ctk_screen_get_type( @@ -433,7 +433,7 @@ void ctk_screen_event_handler(GtkWidget *widget, * update the count showed on the page. */ -static void info_update_gpu_error(GtkObject *object, gpointer arg1, +static void info_update_gpu_error(GObject *object, gpointer arg1, gpointer data) { CtkScreen *ctk_screen = (CtkScreen *) data; diff --git a/src/gtk+-2.x/ctkslimm.c b/src/gtk+-2.x/ctkslimm.c index 9717105..3d2529e 100644 --- a/src/gtk+-2.x/ctkslimm.c +++ b/src/gtk+-2.x/ctkslimm.c @@ -499,7 +499,7 @@ static void slimm_checkbox_toggled(GtkWidget *widget, gpointer user_data) gtk_widget_set_sensitive(ctk_object->box_total_size, True); set_overlap_controls_status(ctk_object); } else { - if (GTK_WIDGET_SENSITIVE(ctk_object->mnu_display_refresh)) { + if (ctk_widget_get_sensitive(ctk_object->mnu_display_refresh)) { ctk_object->mnu_refresh_disabled = True; gtk_widget_set_sensitive(ctk_object->mnu_display_refresh, False); } diff --git a/src/gtk+-2.x/ctkthermal.c b/src/gtk+-2.x/ctkthermal.c index db4d044..cf47e4d 100644 --- a/src/gtk+-2.x/ctkthermal.c +++ b/src/gtk+-2.x/ctkthermal.c @@ -37,7 +37,7 @@ static void sync_gui_sensitivity(CtkThermal *ctk_thermal); static void sync_gui_to_modify_cooler_level(CtkThermal *ctk_thermal); static gboolean sync_gui_to_update_cooler_event(gpointer user_data); static void cooler_control_checkbox_toggled(GtkWidget *widget, gpointer user_data); -static void cooler_operating_level_changed(GtkObject *object, gpointer arg1, +static void cooler_operating_level_changed(GObject *object, gpointer arg1, gpointer user_data); static void apply_button_clicked(GtkWidget *widget, gpointer user_data); static void reset_button_clicked(GtkWidget *widget, gpointer user_data); @@ -479,7 +479,7 @@ static void cooler_control_state_toggled(GtkWidget *widget, gpointer user_data) * cooler control state. * */ -static void cooler_control_state_received(GtkObject *object, +static void cooler_control_state_received(GObject *object, gpointer arg1, gpointer user_data) { CtkThermal *ctk_thermal = CTK_THERMAL(user_data); @@ -808,7 +808,7 @@ static gboolean sync_gui_to_update_cooler_event(gpointer user_data) * Callback function when another NV_CONTROL client changed cooler level. * */ -static void cooler_operating_level_changed(GtkObject *object, gpointer arg1, +static void cooler_operating_level_changed(GObject *object, gpointer arg1, gpointer user_data) { /* sync_gui_to_modify_cooler_level() to be called once when all other @@ -1043,7 +1043,7 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle, GObject *object; CtkThermal *ctk_thermal; CtrlHandles *h; - GtkObject *adjustment; + GtkAdjustment *adjustment; GtkWidget *hbox = NULL, *hbox1, *hbox2, *table, *vbox; GtkWidget *frame, *banner, *label; GtkWidget *vbox1; @@ -1424,10 +1424,10 @@ sensor_end: NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_VARIABLE)) { adjustment = - gtk_adjustment_new(cooler_level, - cooler_range.u.range.min, - cooler_range.u.range.max, - 1, 5, 0.0); + GTK_ADJUSTMENT(gtk_adjustment_new(cooler_level, + cooler_range.u.range.min, + cooler_range.u.range.max, + 1, 5, 0.0)); name = g_strdup_printf("Fan %d Speed", cur_cooler_idx); scale = ctk_scale_new(GTK_ADJUSTMENT(adjustment), name, ctk_config, G_TYPE_INT); diff --git a/src/gtk+-2.x/ctkutils.c b/src/gtk+-2.x/ctkutils.c index 9e9fc6c..db88640 100644 --- a/src/gtk+-2.x/ctkutils.c +++ b/src/gtk+-2.x/ctkutils.c @@ -23,6 +23,252 @@ #include "ctkutils.h" #include "msg.h" +/* + * GTK 2/3 util functions - These functions are used in nvidia-settings to hide + * function calls that differ between GTK 2 and GTK 3. The naming convention + * used is the name of the GTK 3 function, if applicable, with a ctk_ prefix + * instead of gtk_. + */ + +gboolean ctk_widget_is_sensitive(GtkWidget *w) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.18 */ + return gtk_widget_is_sensitive(w); +#else + /* deprecated in 2.20, removed in 3.0 */ + return GTK_WIDGET_IS_SENSITIVE(w); +#endif +} + +gboolean ctk_widget_get_sensitive(GtkWidget *w) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.18 */ + return gtk_widget_get_sensitive(w); +#else + /* deprecated in 2.20, removed in 3.0 */ + return GTK_WIDGET_SENSITIVE(w); +#endif +} + +gboolean ctk_widget_get_visible(GtkWidget *w) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.18 */ + return gtk_widget_get_visible(w); +#else + /* deprecated in 2.20, removed in 3.0 */ + return GTK_WIDGET_VISIBLE(w); +#endif +} + +gboolean ctk_widget_is_drawable(GtkWidget *w) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.18 */ + return gtk_widget_is_drawable(w); +#else + /* deprecated in 2.20, removed in 3.0 */ + return GTK_WIDGET_DRAWABLE(w); +#endif +} + +GdkWindow *ctk_widget_get_window(GtkWidget *w) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + return gtk_widget_get_window(w); +#else + /* direct access removed in 3.0 */ + return w->window; +#endif +} + +void ctk_widget_get_allocation(GtkWidget *w, GtkAllocation *a) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + gtk_widget_get_allocation(w, a); +#else + /* direct access removed in 3.0 */ + a->x = w->allocation.x; + a->y = w->allocation.y; + a->width = w->allocation.width; + a->height = w->allocation.height; +#endif +} + +void ctk_widget_get_preferred_size(GtkWidget *w, GtkRequisition *r) +{ +#ifdef CTK_GTK3 + /* GTK function added in 3.0 */ + GtkRequisition min_req; + gtk_widget_get_preferred_size(w, &min_req, r); +#else + /* deprecated in 3.0 */ + gtk_widget_size_request(w, r); +#endif +} + +gchar *ctk_widget_get_tooltip_text(GtkWidget *w) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.12 */ + return gtk_widget_get_tooltip_text(w); +#else + /* direct access removed in 3.0 */ + GtkTooltipsData *td = gtk_tooltips_data_get(GTK_WIDGET(w)); + return g_strdup(td->tip_text); +#endif +} + +GtkWidget *ctk_dialog_get_content_area(GtkDialog *d) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + return gtk_dialog_get_content_area(d); +#else + /* direct access removed in 3.0 */ + return d->vbox; +#endif +} + +gdouble ctk_adjustment_get_page_increment(GtkAdjustment *a) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + return gtk_adjustment_get_page_increment(a); +#else + /* direct access removed in 3.0 */ + return a->page_increment; +#endif +} + +gdouble ctk_adjustment_get_step_increment(GtkAdjustment *a) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + return gtk_adjustment_get_step_increment(a); +#else + /* direct access removed in 3.0 */ + return a->step_increment; +#endif +} + +gdouble ctk_adjustment_get_page_size(GtkAdjustment *a) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + return gtk_adjustment_get_page_size(a); +#else + /* direct access removed in 3.0 */ + return a->page_size; +#endif +} + +gdouble ctk_adjustment_get_upper(GtkAdjustment *a) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + return gtk_adjustment_get_upper(a); +#else + /* direct access removed in 3.0 */ + return a->upper; +#endif +} + +void ctk_adjustment_set_upper(GtkAdjustment *a, gdouble x) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + gtk_adjustment_set_upper(a, x); +#else + /* direct access removed in 3.0 */ + a->upper = x; +#endif +} + +void ctk_adjustment_set_lower(GtkAdjustment *a, gdouble x) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.14 */ + gtk_adjustment_set_lower(a, x); +#else + /* direct access removed in 3.0 */ + a->lower = x; +#endif +} + +GtkWidget *ctk_scrolled_window_get_vscrollbar(GtkScrolledWindow *sw) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.8 */ + return gtk_scrolled_window_get_vscrollbar(sw); +#else + /* direct access removed in 3.0 */ + return sw->vscrollbar; +#endif +} + +GtkWidget *ctk_statusbar_get_message_area(GtkStatusbar *statusbar) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.20 */ + return gtk_statusbar_get_message_area(statusbar); +#else + /* direct access removed in 3.0 */ + return statusbar->label; +#endif +} + +void ctk_g_object_ref_sink(gpointer obj) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.10 */ + g_object_ref_sink(obj); +#else + /* function removed in 2.10 */ + gtk_object_sink(GTK_OBJECT(obj)); +#endif +} + +GtkWidget *ctk_combo_box_text_new(void) +{ +#ifdef CTK_GTK3 + /* added in 2.24 */ + return gtk_combo_box_text_new(); +#else + /* added in 2.4, deprecated in 2.24, removed in 3.0 */ + return gtk_combo_box_new_text(); +#endif +} + +GtkWidget *ctk_combo_box_text_new_with_entry() +{ +#ifdef CTK_GTK3 + /* added in 2.24 */ + return gtk_combo_box_text_new_with_entry(); +#else + /* added in 2.4, deprecated in 2.24, removed in 3.0 */ + return gtk_combo_box_entry_new_text(); +#endif +} + +void ctk_combo_box_text_append_text(GtkWidget *widget, const gchar *text) +{ +#ifdef CTK_GTK3 + /* added in 2.24 */ + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), text); +#else + /* added in 2.4, deprecated in 2.24, removed in 3.0 */ + gtk_combo_box_append_text(GTK_COMBO_BOX(widget), text); +#endif +} + +/* end of GTK2/3 util functions */ + + /* * This function checks that the GTK+ library in use is at least as new as the * given version number. Note this differs from gtk_check_version(), which @@ -394,8 +640,10 @@ void ctk_empty_container(GtkWidget *container) static void widget_use_text_colors_for_state(GtkWidget *widget, GtkStateType state) { - gtk_widget_modify_fg(widget, state, &(widget->style->text[state])); - gtk_widget_modify_bg(widget, state, &(widget->style->base[state])); + GtkStyle *style = gtk_widget_get_style(widget); + + gtk_widget_modify_fg(widget, state, &(style->text[state])); + gtk_widget_modify_bg(widget, state, &(style->base[state])); } @@ -428,9 +676,13 @@ void ctk_force_text_colors_on_widget(GtkWidget *widget) /* Set the intial state */ force_text_colors_handler(widget, NULL, NULL); +#ifndef CTK_GTK3 + /* This behavior is not properly supported in GTK 3 */ + /* Ensure state is updated when style changes */ g_signal_connect(G_OBJECT(widget), "style-set", G_CALLBACK(force_text_colors_handler), (gpointer) NULL); +#endif } diff --git a/src/gtk+-2.x/ctkutils.h b/src/gtk+-2.x/ctkutils.h index 40d055b..d5ae1a9 100644 --- a/src/gtk+-2.x/ctkutils.h +++ b/src/gtk+-2.x/ctkutils.h @@ -33,6 +33,39 @@ G_BEGIN_DECLS # define G_VALUE_INIT { 0, { { 0 } } } #endif +/* + * GTK 2/3 util functions + */ + +gboolean ctk_widget_is_sensitive(GtkWidget *w); +gboolean ctk_widget_get_sensitive(GtkWidget *w); +gboolean ctk_widget_get_visible(GtkWidget *w); +gboolean ctk_widget_is_drawable(GtkWidget *w); +GdkWindow *ctk_widget_get_window(GtkWidget *w); +void ctk_widget_get_allocation(GtkWidget *w, GtkAllocation *a); +gchar *ctk_widget_get_tooltip_text(GtkWidget *w); + +void ctk_widget_get_preferred_size(GtkWidget *w, GtkRequisition *r); +GtkWidget *ctk_dialog_get_content_area(GtkDialog *d); + +gdouble ctk_adjustment_get_page_increment(GtkAdjustment *a); +gdouble ctk_adjustment_get_step_increment(GtkAdjustment *a); +gdouble ctk_adjustment_get_page_size(GtkAdjustment *a); +gdouble ctk_adjustment_get_upper(GtkAdjustment *a); +void ctk_adjustment_set_upper(GtkAdjustment *a, gdouble x); +void ctk_adjustment_set_lower(GtkAdjustment *a, gdouble x); + +GtkWidget *ctk_scrolled_window_get_vscrollbar(GtkScrolledWindow *sw); +GtkWidget *ctk_statusbar_get_message_area(GtkStatusbar *statusbar); + +GtkWidget *ctk_combo_box_text_new(void); +GtkWidget *ctk_combo_box_text_new_with_entry(void); +void ctk_combo_box_text_append_text(GtkWidget *widget, const gchar *text); + +void ctk_g_object_ref_sink(gpointer obj); + +/* end of GTK 2/3 util functions */ + gchar *get_pcie_generation_string(NvCtrlAttributeHandle *handle); gchar *get_pcie_link_width_string(NvCtrlAttributeHandle *handle, diff --git a/src/gtk+-2.x/ctkvcs.c b/src/gtk+-2.x/ctkvcs.c index 77bc7e4..a663887 100644 --- a/src/gtk+-2.x/ctkvcs.c +++ b/src/gtk+-2.x/ctkvcs.c @@ -241,7 +241,7 @@ static GtkWidget * create_error_dialog(CtkVcs *ctk_object) /* Main horizontal box */ hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, TRUE, TRUE, 5); /* Pack the information icon */ @@ -264,7 +264,7 @@ static GtkWidget * create_error_dialog(CtkVcs *ctk_object) gtk_dialog_add_button(GTK_DIALOG(dialog), "OK", GTK_RESPONSE_ACCEPT); - gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); + gtk_widget_show_all(ctk_dialog_get_content_area(GTK_DIALOG(dialog))); return dialog; @@ -648,7 +648,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle, label = gtk_label_new("Exhaust Temperature:"); /* This is the current largest label. Get its size */ - gtk_widget_size_request(label, &ctk_object->req); + ctk_widget_get_preferred_size(label, &ctk_object->req); gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, diff --git a/src/gtk+-2.x/ctkwindow.c b/src/gtk+-2.x/ctkwindow.c index 03a37f6..61e7959 100644 --- a/src/gtk+-2.x/ctkwindow.c +++ b/src/gtk+-2.x/ctkwindow.c @@ -106,7 +106,11 @@ typedef void (*unselect_widget_func_t)(GtkWidget *); static void ctk_window_class_init(CtkWindowClass *); +#ifdef CTK_GTK3 +static void ctk_window_real_destroy(GtkWidget *); +#else static void ctk_window_real_destroy(GtkObject *); +#endif static void add_page(GtkWidget *, GtkTextBuffer *, CtkWindow *, GtkTreeIter *, GtkTreeIter *, const gchar *, @@ -126,12 +130,9 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, UpdateDisplaysData *data, ParsedAttribute *p); -static void update_display_devices(GtkObject *object, gpointer arg1, +static void update_display_devices(GtkWidget *object, gpointer arg1, gpointer user_data); -static void ctk_window_destroyed(GtkObject *object, gpointer arg1, - gpointer user_data); - static GObjectClass *parent_class; @@ -177,6 +178,15 @@ GType ctk_window_get_type(void) static void ctk_window_class_init(CtkWindowClass *ctk_window_class) { +#ifdef CTK_GTK3 + GtkWidgetClass *widget_class; + + widget_class = (GtkWidgetClass *) ctk_window_class; + + parent_class = g_type_class_peek_parent(ctk_window_class); + + widget_class->destroy = ctk_window_real_destroy; +#else GtkObjectClass *object_class; object_class = (GtkObjectClass *) ctk_window_class; @@ -184,7 +194,7 @@ static void ctk_window_class_init(CtkWindowClass *ctk_window_class) parent_class = g_type_class_peek_parent(ctk_window_class); object_class->destroy = ctk_window_real_destroy; - +#endif } /* ctk_window_class_init() */ @@ -194,25 +204,41 @@ static void ctk_window_class_init(CtkWindowClass *ctk_window_class) * the configuration file here? */ +#ifdef CTK_GTK3 +static void ctk_window_real_destroy(GtkWidget *object) +{ + GTK_WIDGET_CLASS(parent_class)->destroy(object); + gtk_main_quit(); + +} /* ctk_window_real_destroy() */ +#else static void ctk_window_real_destroy(GtkObject *object) { GTK_OBJECT_CLASS(parent_class)->destroy(object); gtk_main_quit(); } /* ctk_window_real_destroy() */ +#endif -/* - * ctk_window_destroyed() - called when ctk_window destroyed. +/* + * confirm_quit_and_save() - Shows the user the quit dialog and + * saves configuration information before exiting. */ -static void ctk_window_destroyed(GtkObject *object, gpointer arg1, - gpointer user_data) +static void confirm_quit_and_save(CtkWindow *ctk_window) { - CtkWindow *ctk_window = CTK_WINDOW(object); - save_settings_and_exit(ctk_window); -} /* ctk_window_destroyed() */ + CtkConfig *ctk_config = ctk_window->ctk_config; + + if (ctk_config->conf->booleans & CONFIG_PROPERTIES_SHOW_QUIT_DIALOG) { + /* ask for confirmation */ + gtk_widget_show_all(ctk_window->quit_dialog); + } else { + /* doesn't return */ + save_settings_and_exit(ctk_window); + } +} @@ -223,16 +249,24 @@ static void ctk_window_destroyed(GtkObject *object, gpointer arg1, static void close_button_clicked(GtkButton *button, gpointer user_data) { CtkWindow *ctk_window = CTK_WINDOW(user_data); - CtkConfig *ctk_config = ctk_window->ctk_config; - if (ctk_config->conf->booleans & CONFIG_PROPERTIES_SHOW_QUIT_DIALOG) { - /* ask for confirmation */ - gtk_widget_show_all(ctk_window->quit_dialog); - } else { - /* doesn't return */ - save_settings_and_exit(ctk_window); - } -} /* close_button_clicked() */ + confirm_quit_and_save(ctk_window); +} + + + +static gboolean ctk_window_delete_event(GObject *object) +{ + CtkWindow *ctk_window = CTK_WINDOW(object); + + confirm_quit_and_save(ctk_window); + + /* gtk_main_quit() will be called above if the user really wants to quit, + * so halt the progress of the delete-event here so we don't exit + * prematurely. + */ + return TRUE; +} @@ -259,7 +293,7 @@ static void help_button_toggled(GtkToggleButton *button, gpointer user_data) } gtk_widget_show_all(ctk_window->ctk_help); } else { - gtk_widget_hide_all(ctk_window->ctk_help); + gtk_widget_hide(ctk_window->ctk_help); } } /* help_button_toggled() */ @@ -529,7 +563,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, /* Added row activated event to the tree view */ g_signal_connect(ctk_window->treeview, "row_activated", - G_CALLBACK(row_activated_event), GTK_OBJECT(ctk_window)); + G_CALLBACK(row_activated_event), GTK_WIDGET(ctk_window)); selection = gtk_tree_view_get_selection(ctk_window->treeview); @@ -637,7 +671,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, screen_name = NvCtrlGetDisplayName(screen_handle); child = ctk_screen_new(screen_handle, ctk_event); - g_object_ref(GTK_OBJECT(child)); + g_object_ref(G_OBJECT(child)); gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_WIDGET_COLUMN, child, -1); gtk_tree_store_set(ctk_window->tree_store, &iter, @@ -793,7 +827,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, child = ctk_gpu_new(gpu_handle, h->targets[X_SCREEN_TARGET].t, ctk_event, ctk_config); - g_object_ref(GTK_OBJECT(child)); + g_object_ref(G_OBJECT(child)); gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_WIDGET_COLUMN, child, -1); gtk_tree_store_set(ctk_window->tree_store, &iter, @@ -902,7 +936,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_LABEL_COLUMN, vcs_name, -1); child = ctk_vcs_new(vcs_handle, ctk_config); - g_object_ref(GTK_OBJECT(child)); + g_object_ref(G_OBJECT(child)); gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_WIDGET_COLUMN, child, -1); gtk_tree_store_set(ctk_window->tree_store, &iter, @@ -951,7 +985,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_LABEL_COLUMN, gvi_name, -1); child = ctk_gvi_new(gvi_handle, ctk_config, ctk_event); - g_object_ref(GTK_OBJECT(child)); + g_object_ref(G_OBJECT(child)); gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_WIDGET_COLUMN, child, -1); gtk_tree_store_set(ctk_window->tree_store, &iter, @@ -1057,7 +1091,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, */ g_signal_connect(selection, "changed", G_CALLBACK(tree_selection_changed), - GTK_OBJECT(ctk_window)); + GTK_WIDGET(ctk_window)); gtk_widget_show_all(GTK_WIDGET(ctk_window->treeview)); gtk_tree_view_expand_all(ctk_window->treeview); @@ -1083,17 +1117,18 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, */ label = gtk_label_new("XXXXXX Server Display ConfigurationXXXX"); - gtk_widget_size_request(label, &req); + gtk_widget_show(label); + ctk_widget_get_preferred_size(label, &req); width = req.width; gtk_widget_destroy(label); /* Get the width of the tree view scroll window */ - gtk_widget_size_request(sw, &req); + ctk_widget_get_preferred_size(sw, &req); /* If the scroll window is too wide, make it slimmer and * allow users to scroll horizontally (also allow resizing). */ - if ( width < req.width ) { + if (width < req.width && width > 0) { gtk_widget_set_size_request(sw, width, -1); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, @@ -1102,8 +1137,8 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, /* Add callback when window destroyed */ - g_signal_connect(G_OBJECT(ctk_window), "destroy", - G_CALLBACK(ctk_window_destroyed), (gpointer) ctk_window); + g_signal_connect(G_OBJECT(ctk_window), "delete-event", + G_CALLBACK(ctk_window_delete_event), (gpointer) ctk_window); return GTK_WIDGET(object); @@ -1220,7 +1255,7 @@ static void add_page(GtkWidget *widget, GtkTextBuffer *help, */ g_object_ref(G_OBJECT(widget)); - gtk_object_sink(GTK_OBJECT(widget)); + ctk_g_object_ref_sink(G_OBJECT(widget)); gtk_tree_store_append(ctk_window->tree_store, child_iter, iter); @@ -1260,24 +1295,23 @@ static GtkWidget *create_quit_dialog(CtkWindow *ctk_window) dialog = gtk_dialog_new_with_buttons("Really quit?", GTK_WINDOW(ctk_window), GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_QUIT, GTK_RESPONSE_OK, NULL); - g_signal_connect(GTK_OBJECT(dialog), "response", + g_signal_connect(GTK_WIDGET(dialog), "response", G_CALLBACK(quit_response), - GTK_OBJECT(ctk_window)); + GTK_WIDGET(ctk_window)); gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); hbox = gtk_hbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); + gtk_container_add(GTK_CONTAINER(ctk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox); pixbuf = gtk_widget_render_icon(dialog, GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG, NULL); @@ -1330,7 +1364,7 @@ static void quit_response(GtkWidget *button, gint response, gpointer user_data) save_settings_and_exit(ctk_window); } - gtk_widget_hide_all(ctk_window->quit_dialog); + gtk_widget_hide(ctk_window->quit_dialog); } /* quit_response() */ @@ -1538,7 +1572,7 @@ static void select_display_page(UpdateDisplaysData *data, gchar *name) * */ -static void update_display_devices(GtkObject *object, gpointer arg1, +static void update_display_devices(GtkWidget *object, gpointer arg1, gpointer user_data) { UpdateDisplaysData *data = (UpdateDisplaysData *) user_data; @@ -1587,7 +1621,7 @@ static void update_display_devices(GtkObject *object, gpointer arg1, gtk_tree_store_remove(ctk_window->tree_store, iter); /* unref the page so we don't leak memory */ - g_object_unref(GTK_OBJECT(widget)); + g_object_unref(G_OBJECT(widget)); data->num_displays--; } diff --git a/src/gtk+-2.x/ctkxvideo.c b/src/gtk+-2.x/ctkxvideo.c index 8d33c5c..878a550 100644 --- a/src/gtk+-2.x/ctkxvideo.c +++ b/src/gtk+-2.x/ctkxvideo.c @@ -303,7 +303,7 @@ static void xv_sync_to_display_rebuild_buttons(CtkXVideo *ctk_xvideo, * Handles NV_CTRL_ENABLED_DISPLAYS events and updates * the list of displays in the UI. */ -static void enabled_displays_handler(GtkObject *object, gpointer arg1, +static void enabled_displays_handler(GObject *object, gpointer arg1, gpointer user_data) { CtkXVideo *ctk_xvideo = CTK_XVIDEO(user_data); @@ -316,7 +316,7 @@ static void enabled_displays_handler(GtkObject *object, gpointer arg1, /* * Handler for NV_CTRL_XV_SYNC_TO_DISPLAY_ID events. */ -static void xv_sync_to_display_id_handler(GtkObject *object, +static void xv_sync_to_display_id_handler(GObject *object, gpointer arg1, gpointer user_data) { diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h index 2565d50..25bcff2 100644 --- a/src/libXNVCtrl/NVCtrl.h +++ b/src/libXNVCtrl/NVCtrl.h @@ -3361,9 +3361,15 @@ * This attribute is available on GeForce GTX 400 series and later * Geforce GPUs. */ -#define NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET 410 /* RW-G */ +#define NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET 410 /* RW-G */ -#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET +/* + * NV_CTRL_VIDEO_DECODER_UTILIZATION - Returns the video decoder engine + * utilization as a percentage. + */ +#define NV_CTRL_VIDEO_DECODER_UTILIZATION 411 /* R--G */ + +#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_VIDEO_DECODER_UTILIZATION /**************************************************************************/ diff --git a/src/libXNVCtrl/version.mk b/src/libXNVCtrl/version.mk index a7b8a27..043e890 100644 --- a/src/libXNVCtrl/version.mk +++ b/src/libXNVCtrl/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 340.24 +NVIDIA_VERSION = 343.13 diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributes.c b/src/libXNVCtrlAttributes/NvCtrlAttributes.c index d8033d2..b893a05 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributes.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributes.c @@ -1010,15 +1010,21 @@ ReturnStatus NvCtrlSetColorAttributes(NvCtrlAttributeHandle *handle, status = NvCtrlGetAttribute(h, NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE, &val); - if ((status != NvCtrlSuccess || !val) && - h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) { + if (status == NvCtrlSuccess && val) { + switch (h->target_type) { + case NV_CTRL_TARGET_TYPE_X_SCREEN: + return NvCtrlVidModeSetColorAttributes(h, c, b, g, bitmask); + case NV_CTRL_TARGET_TYPE_DISPLAY: + return NvCtrlXrandrSetColorAttributes(h, c, b, g, bitmask); + default: + return NvCtrlBadHandle; + } + } else if ((status != NvCtrlSuccess || !val) && + h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) { return NvCtrlVidModeSetColorAttributes(h, c, b, g, bitmask); - } else if (status == NvCtrlSuccess && val && - h->target_type == NV_CTRL_TARGET_TYPE_DISPLAY) { - return NvCtrlXrandrSetColorAttributes(h, c, b, g, bitmask); } - return NvCtrlBadHandle; + return NvCtrlError; } diff --git a/src/parse.c b/src/parse.c index 5dec1f5..30aab3c 100644 --- a/src/parse.c +++ b/src/parse.c @@ -190,6 +190,7 @@ const AttributeTableEntry attributeTable[] = { { "BaseMosaic", NV_CTRL_BASE_MOSAIC, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the current Base Mosaic configuration." }, { "MultiGpuMasterPossible", NV_CTRL_MULTIGPU_MASTER_POSSIBLE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns whether or not the GPU can be configured as the master GPU for a Multi GPU configuration (SLI, SLI Mosaic, Base Mosaic, ...)." }, { "VideoEncoderUtilization", NV_CTRL_VIDEO_ENCODER_UTILIZATION, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the video encoder engine utilization as a percentage." }, + { "VideoDecoderUtilization", NV_CTRL_VIDEO_DECODER_UTILIZATION, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the video decoder engine utilization as a percentage." }, { "GPUCurrentClockFreqsString", NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS, STR_ATTR, {0,0,0,0,1,0}, {}, "Returns the current GPU, memory and Processor clocks of the graphics device driving the X screen." }, { "GPUPerfModes", NV_CTRL_STRING_PERFORMANCE_MODES, STR_ATTR, {0,0,0,0,1,0}, {}, "Returns a string with all the performance modes defined for this GPU along with their associated NV Clock and Memory Clock values." }, { "GpuUUID", NV_CTRL_STRING_GPU_UUID, STR_ATTR, {0,0,0,0,1,0}, {}, "Returns the global unique identifier of the GPU." }, @@ -372,7 +373,7 @@ const int attributeTableLen = ARRAY_LEN(attributeTable); * the last attribute that the table knows about. */ -#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET +#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_VIDEO_DECODER_UTILIZATION #warning "Have you forgotten to add a new integer attribute to attributeTable?" #endif diff --git a/src/query-assign.c b/src/query-assign.c index 0a0a57c..cfe4c50 100644 --- a/src/query-assign.c +++ b/src/query-assign.c @@ -332,14 +332,28 @@ NvCtrlAttributeHandle *nv_get_target_handle(const CtrlHandles *handles, * \param[in/out] head The first node in the CtrlHandleTarget list, to which * target should be inserted. * \param[in] target The CtrlHandleTarget to add to the list. + * \param[in] enabled_display_check Whether or not to check that, if the + * target is a display target, it is also + * enabled. */ static void nv_target_list_add(CtrlHandleTargetNode **head, - CtrlHandleTarget *target) + CtrlHandleTarget *target, + Bool enabled_display_check) { CtrlHandleTargetNode *new_t; CtrlHandleTargetNode *t; + /* Do not add disabled displays to the list */ + if (enabled_display_check) { + int target_type = NvCtrlGetTargetType(target->h); + + if (target_type == NV_CTRL_TARGET_TYPE_DISPLAY && + !target->display.enabled) { + return; + } + } + new_t = nvalloc(sizeof(CtrlHandleTargetNode)); new_t->t = target; @@ -433,7 +447,7 @@ static void add_target_relationships(const CtrlHandles *h, CtrlHandleTarget *t, r = nv_get_target(h, targetType, targetId); if (r) { - nv_target_list_add(&(t->relations), r); + nv_target_list_add(&(t->relations), r, FALSE); /* Track connection state of display devices */ if (attr == NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU) { @@ -441,7 +455,7 @@ static void add_target_relationships(const CtrlHandles *h, CtrlHandleTarget *t, } if (implicit_reciprocal == NV_TRUE) { - nv_target_list_add(&(r->relations), t); + nv_target_list_add(&(r->relations), t, FALSE); } } } @@ -895,8 +909,7 @@ static int nv_infer_targets_from_specification(ParsedAttribute *p, } /* Target matches, add it to the list */ - - nv_target_list_add(&(p->targets), t); + nv_target_list_add(&(p->targets), t, TRUE); p->parser_flags.has_target = NV_TRUE; } } @@ -1374,7 +1387,7 @@ static void include_target_idx_targets(ParsedAttribute *p, const CtrlHandles *h, for (i = 0; i < targets->n; i++) { CtrlHandleTarget *target = &(targets->t[i]); - nv_target_list_add(&(p->targets), target); + nv_target_list_add(&(p->targets), target, TRUE); p->parser_flags.has_target = NV_TRUE; } } @@ -1509,7 +1522,7 @@ static void resolve_display_mask_string(ParsedAttribute *p, const char *whence) /* Include display targets that were previously resolved */ if (target_type == NV_CTRL_TARGET_TYPE_DISPLAY) { - nv_target_list_add(&head, t); + nv_target_list_add(&head, t, TRUE); continue; } @@ -1527,13 +1540,13 @@ static void resolve_display_mask_string(ParsedAttribute *p, const char *whence) /* Include all displays if no specification was given */ if (!p->parser_flags.has_display_device) { - nv_target_list_add(&head, t_other); + nv_target_list_add(&head, t_other, TRUE); continue; } for (i = 0; i < num_names; i++) { if (nv_target_has_name(t_other, name_toks[i])) { - nv_target_list_add(&head, t_other); + nv_target_list_add(&head, t_other, TRUE); break; } } @@ -1615,7 +1628,7 @@ static int resolve_attribute_targets(ParsedAttribute *p, CtrlHandles *h, return NV_PARSER_STATUS_TARGET_SPEC_NO_TARGETS; } - nv_target_list_add(&(p->targets), target); + nv_target_list_add(&(p->targets), target, TRUE); p->parser_flags.has_target = NV_TRUE; goto done; } @@ -3144,6 +3157,13 @@ int nv_process_parsed_attribute(const Options *op, goto done; } + if (!p->targets) { + nv_warning_msg("Failed to match any targets for target specification " + "'%s', specified %s.", + p->target_specification ? p->target_specification : "", + whence); + } + /* loop over the requested targets */ for (n = p->targets; n; n = n->next) { @@ -3183,10 +3203,10 @@ int nv_process_parsed_attribute(const Options *op, if (a->type == NV_PARSER_ATTRIBUTE_TYPE_COLOR) { float v[3]; if (!assign) { - nv_error_msg("Cannot query attribute '%s'", a->name); + nv_msg(NULL, "Attribute '%s' cannot be queried.", a->name); goto done; } - + /* * assign p->val.f to all values in the array; a->attr will * tell NvCtrlSetColorAttributes() which indices in the diff --git a/src/version.mk b/src/version.mk index a7b8a27..043e890 100644 --- a/src/version.mk +++ b/src/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 340.24 +NVIDIA_VERSION = 343.13 diff --git a/version.mk b/version.mk index a7b8a27..043e890 100644 --- a/version.mk +++ b/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 340.24 +NVIDIA_VERSION = 343.13 -- cgit v1.2.3