GeanyVC: Replace some deprecated GTK 3 code#1415
GeanyVC: Replace some deprecated GTK 3 code#1415cjmayo wants to merge 3 commits intogeany:masterfrom
Conversation
b4n
left a comment
There was a problem hiding this comment.
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
| 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.
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.
As we're making further changes let's revert so that it can be consistent across the board.
geanyvc/src/geanyvc.c
Outdated
|
|
||
| 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.
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); |
geanyvc/src/geanyvc.c
Outdated
| 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.
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); |
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.