Window of requesters doesn't show full title text

Linux specific forum
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Window of requesters doesn't show full title text

Post by marcoagpinto »

Hello!

If I open a requester, the size of its window depends on the width of the text inside and doesn't respect the title text size.

If the title text is big and the inside text small, we get a bad looking requester too small.
Fred
Administrator
Administrator
Posts: 16623
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB5.70] Window of requesters doesn't show full title te

Post by Fred »

Please always post a small snippet, thank you.
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: [PB5.70] Window of requesters doesn't show full title te

Post by marcoagpinto »

@fred

Sorry...

Code: Select all

MessageRequester("Version build data on website is outdated","Current Version:"+#LF$+"V"+current_version$+t$+#LF$+"Build: "+current_build$+#LF$+"Released: "+current_release_date$+#LF$+#LF$+"Site Version:"+#LF$+"V"+new_current_version$+" "+new_current_beta_final$+#LF$+"Build: "+new_current_build$+#LF$+"Released: "+new_current_release_date$+#LF$,#PB_MessageRequester_Warning)
Fred
Administrator
Administrator
Posts: 16623
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB5.70] Window of requesters doesn't show full title te

Post by Fred »

Seems like an OS limitation, we use standard requesters here
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: [PB5.70] Window of requesters doesn't show full title te

Post by Justin »

A simple 'hello' 'world' message fails to display correctly here.

But it can be done better:

Code: Select all

EnableExplicit

#GTK_MESSAGE_OTHER = 4

Enumeration
  #GTK_ALIGN_FILL
  #GTK_ALIGN_START
  #GTK_ALIGN_END
  #GTK_ALIGN_CENTER
EndEnumeration

ImportC ""
	gtk_dialog_get_content_area_(dlg.i) As "gtk_dialog_get_content_area"
	gtk_header_bar_new_() As "gtk_header_bar_new"
	gtk_header_bar_set_has_subtitle_(header.i, sett.l) As "gtk_header_bar_set_has_subtitle"

	gtk_window_set_titlebar_(dialog.i, header.i) As "gtk_window_set_titlebar"
	gtk_header_bar_set_title_(header.i, title.p-utf8) As "gtk_header_bar_set_title"
	gtk_header_bar_set_decoration_layout_(header.i, layout.p-utf8) As "gtk_header_bar_set_decoration_layout"
	gtk_header_bar_set_show_close_button_(header.i, sett.l) As "gtk_header_bar_set_show_close_button"
	gtk_widget_set_halign_(wg.i, align.l) As "gtk_widget_set_halign"
	gtk_widget_set_valign_(wg.i, align.l) As "gtk_widget_set_valign"

	gtk_box_new_(ort.l, sp.l) As "gtk_box_new"
	gtk_image_set_from_icon_name_(img.i, name.p-utf8, size.l) As "gtk_image_set_from_icon_name"
	gtk_image_new_from_icon_name_(name.p-utf8, size.l) As "gtk_image_new_from_icon_name"
	gtk_image_set_pixel_size_(img.i, sz.l) As "gtk_image_set_pixel_size"
	gtk_message_dialog_get_message_area_(dialog.i) As "gtk_message_dialog_get_message_area"
	gtk_message_dialog_set_image_(dialog.i, img.i) As "gtk_message_dialog_set_image"
	
	gtk_widget_override_font_(wg.i, fd.i) As "gtk_widget_override_font"
	pango_font_description_set_weight_(font.i, weight.l) As "pango_font_description_set_weight"
EndImport

Procedure.l MsgBox(title.s, msg.s, flags.l = 0)
	CompilerIf #PB_Compiler_OS = #PB_OS_Linux
		Define.i dialog,header, win, hwin, childs, msgArea, label, hdrFont
		Define.l msgType, btnType, ret, dres
	
		;icon
		If flags & #PB_MessageRequester_Info = #PB_MessageRequester_Info
			msgType = #GTK_MESSAGE_INFO
	
		ElseIf flags & #PB_MessageRequester_Warning = #PB_MessageRequester_Warning
			msgType = #GTK_MESSAGE_WARNING
	
		ElseIf flags & #PB_MessageRequester_Error = #PB_MessageRequester_Error
			msgType = #GTK_MESSAGE_ERROR
			
		Else
			msgType = #GTK_MESSAGE_OTHER
		EndIf 
		
		;button
		If flags & #PB_MessageRequester_YesNo = #PB_MessageRequester_YesNo
			btnType = #GTK_BUTTONS_YES_NO
	
		ElseIf flags & #PB_MessageRequester_YesNoCancel = #PB_MessageRequester_YesNoCancel
			btnType = #GTK_BUTTONS_YES_NO | #GTK_BUTTONS_CANCEL
			
		ElseIf flags & #PB_MessageRequester_Ok = #PB_MessageRequester_Ok
			btnType = #GTK_BUTTONS_OK
	
		Else
			btnType = #GTK_BUTTONS_OK
		EndIf 
	
		win = GetActiveWindow()
		If win <> -1 
			hwin = WindowID(win)
		EndIf 
		dialog = gtk_message_dialog_new_(hwin,
		                                 #GTK_DIALOG_MODAL | #GTK_DIALOG_DESTROY_WITH_PARENT,
		                                 msgType,
		                                 btnType,
		                                 msg,
		                                 0,
		                                 0)
		         
		;Justify label text to the left           
		msgArea = gtk_message_dialog_get_message_area_(dialog)
		childs = gtk_container_get_children_(msgArea)
		label = g_list_nth_data_(childs, 0)
		gtk_widget_set_halign_(label, #GTK_ALIGN_START)
		
		If msgType = #GTK_MESSAGE_OTHER                         
			gtk_message_dialog_set_image_(dialog, 0)
		EndIf
		
		header = gtk_header_bar_new_()
		hdrFont = GetGadgetFont(#PB_Default)
		pango_font_description_set_weight_(hdrFont, 700) ;PANGO_WEIGHT_BOLD
		gtk_widget_override_font_(header, hdrFont)
		gtk_header_bar_set_has_subtitle_(header, 0)
		gtk_header_bar_set_show_close_button_(header, #True)
		gtk_header_bar_set_title_(header, title)
		gtk_window_set_titlebar_(dialog, header)
	
		gtk_widget_show_all_(dialog)
		
		dres = gtk_dialog_run_(dialog)
		Select dres
			Case #GTK_RESPONSE_OK, #GTK_RESPONSE_YES : ret = #PB_MessageRequester_Yes
			
			Case #GTK_RESPONSE_NO : ret = #PB_MessageRequester_No
			
			Case #GTK_RESPONSE_CANCEL : ret = #PB_MessageRequester_Cancel 
	
			Default : ret = 0
		EndSelect
		
		gtk_widget_destroy_(dialog)
		
		ProcedureReturn ret
	
	CompilerElse
		ProcedureReturn MessageRequester(title, msg, flags)
	CompilerEndIf 
EndProcedure

Define.s title, msg
Define.l ev

gtk_init_(0, 0)

title = "Version build data on website is outdated"
msg = "Version:" + #LF$ + "V" + "1.0" + #LF$ + "Build: "+ "123" + #LF$+ "Released: " + "2019" + #LF$ + #LF$ + "Site Version:" + #LF$ + "V" + "1.0" + " " + "1.0" + #LF$ + "Build: "+ "1.0" + #LF$ + "Released: " + "2019" + #LF$

; MessageRequester(title, msg, #PB_MessageRequester_Warning)
MsgBox(title, msg, #PB_MessageRequester_Warning)
Last edited by Justin on Sun Apr 14, 2019 7:25 pm, edited 1 time in total.
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: [PB5.70] Window of requesters doesn't show full title te

Post by Justin »

Fixed to left align the message text.
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: [PB5.70] Window of requesters doesn't show full title te

Post by Justin »

Fixed bold font for message title.
Post Reply