plug-ins: Reimplement date picker in metadata-editor without GtkBuilder

Also changes the dialog title to not have a ':' and make the title
express what the expected action is.
This commit is contained in:
Jacob Boerema 2023-05-01 12:12:54 -04:00
parent c48ce3675b
commit 58e02b4f4e
4 changed files with 11 additions and 63 deletions

View file

@ -906,39 +906,14 @@ on_date_button_clicked (GtkButton *widget,
GtkWidget *entry_widget,
gchar *tag)
{
GtkBuilder *builder;
GtkWidget *calendar_dialog;
GtkWidget *calendar_content_area;
GtkWidget *calendar_vbox;
GtkWidget *calendar;
const gchar *date_text;
gchar *ui_file;
GError *error = NULL;
GDateTime *current_datetime;
guint year, month, day;
builder = gtk_builder_new ();
ui_file = g_build_filename (gimp_data_directory (),
"ui", "plug-ins",
"plug-in-metadata-editor-calendar.ui", NULL);
if (! gtk_builder_add_from_file (builder, ui_file, &error))
{
g_log ("", G_LOG_LEVEL_MESSAGE,
_("Error loading calendar. %s"),
error ? error->message : "");
g_clear_error (&error);
if (ui_file)
g_free (ui_file);
g_object_unref (builder);
return;
}
if (ui_file)
g_free (ui_file);
date_text = gtk_entry_get_text (GTK_ENTRY (entry_widget));
if (date_text && date_text[0] != '\0')
{
@ -954,7 +929,7 @@ on_date_button_clicked (GtkButton *widget,
}
calendar_dialog =
gtk_dialog_new_with_buttons (_("Calendar Date:"),
gtk_dialog_new_with_buttons (_("Choose Date"),
NULL,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
_("_Cancel"), GTK_RESPONSE_CANCEL,
@ -970,20 +945,20 @@ on_date_button_clicked (GtkButton *widget,
gimp_window_set_transient (GTK_WINDOW (calendar_dialog));
calendar_content_area = gtk_dialog_get_content_area (GTK_DIALOG (
calendar_dialog));
calendar_content_area = gtk_dialog_get_content_area (GTK_DIALOG (calendar_dialog));
calendar_vbox = builder_get_widget (builder, "calendar-vbox");
gtk_container_set_border_width (GTK_CONTAINER (calendar_vbox), 12);
gtk_box_pack_start (GTK_BOX (calendar_content_area), calendar_vbox, TRUE, TRUE,
0);
calendar = builder_get_widget (builder, "calendar");
calendar_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_set_border_width (GTK_CONTAINER (calendar_vbox), 6);
gtk_box_pack_start (GTK_BOX (calendar_content_area), calendar_vbox, TRUE, TRUE, 0);
calendar = gtk_calendar_new ();
gtk_calendar_select_month (GTK_CALENDAR (calendar), month, year);
gtk_calendar_select_day (GTK_CALENDAR (calendar), day);
gtk_calendar_mark_day (GTK_CALENDAR (calendar), day);
gtk_widget_show (calendar);
gtk_container_add (GTK_CONTAINER (calendar_vbox), calendar);
gtk_widget_show (calendar_vbox);
if (gtk_dialog_run (GTK_DIALOG (calendar_dialog)) == GTK_RESPONSE_OK)
{

View file

@ -1,7 +1,6 @@
uidatadir = $(gimpdatadir)/ui/plug-ins
uidata_DATA = \
plug-in-metadata-editor.ui \
plug-in-metadata-editor-calendar.ui
plug-in-metadata-editor.ui
EXTRA_DIST = $(uidata_DATA)

View file

@ -1,5 +1,4 @@
plugin_ui = [
'plug-in-metadata-editor-calendar.ui',
'plug-in-metadata-editor.ui',
]

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkVBox" id="calendar-vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="spacing">6</property>
<child>
<object class="GtkCalendar" id="calendar">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="year">2016</property>
<property name="month">1</property>
<property name="day">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</interface>