Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear USE_GTK_3 macro #972

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yetist
Copy link
Contributor

@yetist yetist commented Dec 8, 2019

Please review and test.

@alerque
Copy link
Contributor

alerque commented Dec 9, 2019

What is the advantage of checking for this repeatedly at compile time instead of once at configure time?

@yetist
Copy link
Contributor Author

yetist commented Dec 10, 2019

There is no need to define USE_GTK3 in the build system.

  1. One reason is that the build may be failed.
    For example, when gtk-3.8 is installed in the system, the build system detects gtk+-3.0.pc, and then defines USE_GTK_3.
    But in the code, if USE_GTK3, we call the newly api that added after gtk-3.14.

  2. Another reason is that we can clean up the code.

For example, after gtk-2.18, we can use gtk_widget_set_can_default, so we can delete other lines:

-#if GTK_CHECK_VERSION(2, 18, 0)
 	gtk_widget_set_can_default(button, TRUE);
-#elif defined(USE_GTK_3)
-	gtk_widget_set_can_default(button, 1);
-#else
-	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
-#endif
  1. Enhance strong maintainability

If you use USE_GTK_3, can you quickly know that the following changes are safe?

-#ifdef USE_GTK_3
 			gtk_combo_box_text_append_text((GtkComboBoxText *)ss.entryUpper, book);
 			gtk_combo_box_text_append_text((GtkComboBoxText *)ss.entryLower, book);
-#else
-			gtk_combo_box_append_text(GTK_COMBO_BOX(ss.entryUpper), book);
-			gtk_combo_box_append_text(GTK_COMBO_BOX(ss.entryLower), book);
-#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants