-
Notifications
You must be signed in to change notification settings - Fork 274
GeanyVC: Replace some deprecated GTK 3 code #1415
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good start!
I'd suggest dealing with the remaining like this:
diff --git a/geanyvc/src/geanyvc.c b/geanyvc/src/geanyvc.c
index 31fe2047..28874f3f 100644
--- a/geanyvc/src/geanyvc.c
+++ b/geanyvc/src/geanyvc.c
@@ -1542,11 +1542,9 @@ create_commitDialog(void)
GtkWidget *scrolledwindow2;
GtkWidget *textDiff;
GtkWidget *frame1;
- GtkWidget *alignment1;
GtkWidget *scrolledwindow3;
GtkWidget *textCommitMessage;
GtkWidget *label1;
- GtkWidget *dialog_action_area1;
GtkWidget *btnCancel;
GtkWidget *btnCommit;
GtkWidget *select_cbox;
@@ -1556,16 +1554,6 @@ create_commitDialog(void)
GtkWidget *commitMessageHistoryComboBox;
GtkTreeSelection *sel;
- gchar *rcstyle = g_strdup_printf("style \"geanyvc-diff-font\"\n"
- "{\n"
- " font_name=\"%s\"\n"
- "}\n"
- "widget \"*.GeanyVCCommitDialogDiff\" style \"geanyvc-diff-font\"",
- geany_data->interface_prefs->editor_font);
-
- gtk_rc_parse_string(rcstyle);
- g_free(rcstyle);
-
commitDialog = gtk_dialog_new();
gtk_container_set_border_width(GTK_CONTAINER(commitDialog), 5);
gtk_widget_set_events(commitDialog,
@@ -1620,7 +1608,7 @@ create_commitDialog(void)
treeSelect);
textDiff = gtk_text_view_new();
- gtk_widget_set_name(textDiff, "GeanyVCCommitDialogDiff");
+ ui_widget_modify_font_from_string(textDiff, geany_data->interface_prefs->editor_font);
gtk_widget_show(textDiff);
gtk_container_add(GTK_CONTAINER(scrolledwindow2), textDiff);
gtk_widget_set_events(textDiff,
@@ -1633,14 +1621,10 @@ create_commitDialog(void)
gtk_box_pack_start(GTK_BOX(bottom_vbox), frame1, TRUE, TRUE, 2);
gtk_frame_set_shadow_type(GTK_FRAME(frame1), GTK_SHADOW_NONE);
- alignment1 = gtk_alignment_new(0.5, 0.5, 1, 1);
- gtk_widget_show(alignment1);
- gtk_container_add(GTK_CONTAINER(frame1), alignment1);
- gtk_alignment_set_padding(GTK_ALIGNMENT(alignment1), 0, 0, 12, 0);
-
commit_text_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_margin_start(commit_text_vbox, 12);
gtk_widget_show(commit_text_vbox);
- gtk_container_add(GTK_CONTAINER(alignment1), commit_text_vbox);
+ gtk_container_add(GTK_CONTAINER(frame1), commit_text_vbox);
scrolledwindow3 = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_show(scrolledwindow3);
@@ -1673,10 +1657,6 @@ create_commitDialog(void)
gtk_box_pack_end(GTK_BOX(commit_text_vbox), commitMessageHistoryComboBox, FALSE, TRUE, 0);
gtk_widget_show(commitMessageHistoryComboBox);
- dialog_action_area1 = gtk_dialog_get_action_area(GTK_DIALOG(commitDialog));
- gtk_widget_show(dialog_action_area1);
- gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END);
-
btnCancel = gtk_button_new_with_mnemonic(_("_Cancel"));
gtk_widget_show(btnCancel);
gtk_dialog_add_action_widget(GTK_DIALOG(commitDialog), btnCancel, GTK_RESPONSE_CANCEL);
@@ -1710,11 +1690,9 @@ create_commitDialog(void)
GLADE_HOOKUP_OBJECT(commitDialog, scrolledwindow2, "scrolledwindow2");
GLADE_HOOKUP_OBJECT(commitDialog, textDiff, "textDiff");
GLADE_HOOKUP_OBJECT(commitDialog, frame1, "frame1");
- GLADE_HOOKUP_OBJECT(commitDialog, alignment1, "alignment1");
GLADE_HOOKUP_OBJECT(commitDialog, scrolledwindow3, "scrolledwindow3");
GLADE_HOOKUP_OBJECT(commitDialog, textCommitMessage, "textCommitMessage");
GLADE_HOOKUP_OBJECT(commitDialog, label1, "label1");
- GLADE_HOOKUP_OBJECT_NO_REF(commitDialog, dialog_action_area1, "dialog_action_area1");
GLADE_HOOKUP_OBJECT(commitDialog, btnCancel, "btnCancel");
GLADE_HOOKUP_OBJECT(commitDialog, btnCommit, "btnCommit");
GLADE_HOOKUP_OBJECT(commitDialog, select_cbox, "select_cbox");
The explicit layout on the dialog's action area is removed, but it looks useless and probably only stems from the originally generated source code.
Another solution would be re-writing the UI code to use generated UI from XML definitions, similar to how it once was -- but nowadays the RAD tool can't generate code, you need to load the XML itself at runtime, be it from a file, embedded data or resource.
geanyvc/src/geanyvc.c
Outdated
@@ -1676,7 +1677,7 @@ create_commitDialog(void) | |||
gtk_widget_show(dialog_action_area1); | |||
gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END); | |||
|
|||
btnCancel = gtk_button_new_from_stock("gtk-cancel"); | |||
btnCancel = gtk_button_new_with_mnemonic(_("_Cancel")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is gonna lose the potential icon on the button. Not the end of the world though, but Geany itself has them if enabled at the system level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we're making further changes let's revert so that it can be consistent across the board.
geanyvc/src/geanyvc.c
Outdated
@@ -2293,7 +2294,8 @@ plugin_configure(GtkDialog * dialog) | |||
if (lang != NULL) | |||
gtk_entry_set_text(GTK_ENTRY(widgets.spellcheck_lang_textbox), lang); | |||
|
|||
gtk_misc_set_alignment(GTK_MISC(label_spellcheck_lang), 0, 0.5); | |||
gtk_widget_set_halign(GTK_WIDGET(label_spellcheck_lang), GTK_ALIGN_START); | |||
gtk_widget_set_valign(GTK_WIDGET(label_spellcheck_lang), GTK_ALIGN_CENTER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave the default valign
of FILL
(i.e. not explicitly set it: what this was after is left-align the label)
gtk_widget_set_valign(GTK_WIDGET(label_spellcheck_lang), GTK_ALIGN_CENTER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geanyvc/src/geanyvc.c
Outdated
@@ -1663,7 +1663,8 @@ create_commitDialog(void) | |||
|
|||
/* line/column status label */ | |||
lineColumnLabel = gtk_label_new(""); | |||
gtk_misc_set_alignment(GTK_MISC(lineColumnLabel), 0, 0.5); | |||
gtk_widget_set_halign(GTK_WIDGET(lineColumnLabel), GTK_ALIGN_START); | |||
gtk_widget_set_valign(GTK_WIDGET(lineColumnLabel), GTK_ALIGN_CENTER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave the default valign
of FILL
(i.e. not explicitly set it: what this was after is left-align the label)
gtk_widget_set_valign(GTK_WIDGET(lineColumnLabel), GTK_ALIGN_CENTER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Left this out - the font family and size were not the same for me after this. |
I think it is actually that |
There are is still some left - but probably would benefit from a common approach, others even just wait until it has to happen. This removes quite a bit of the noise anyway.