Gtk4: Example of gtk_popover_menu_bar_add_child - gtk4

I am looking for an example of the utilization of the function:
gtk_popover_menu_bar_add_child
In particular how to setup what the documentation is calling the ‘id’
So far I could not find anything on the web.
I understand that I need to use the ‘custom’ attribute, so I set it up using:
g_menu_item_set_attribute (item, “custom”, “s”, “target”, NULL);
Then I try to insert the new widget using:
gtk_popover_menu_bar_add_child (the_menu_bar, widget, “target”);
But the widget never shows in my menu, and I got no error message ... In short I do not know what to do …
Thanks in advance for your help.

I did not come across any specific program examples, but within the GTK source code I did find a usage of the "g_menu_set_attribute" function. The thing I noticed is that it did not include your final parameter of NULL. You might want to revise your program and call the function as follows:
g_menu_set_attribute (item, "custom", "s", "target");
That function command allows for a variable number of parameters based upon the format parameter (e.g. "s"), but for what you are doing, the NULL probably is providing some confusing information to the function.
If that still does not address your issue, you may continue reading what I did to experiment with the addition of a child widget to a popover menu item.
This may not be an ultimate solution, but I tried out various methods of adding a child widget to the popover menu, and only one method worked for me that appeared to produce the results you are after.
I could not seem to get the "g_menu_item_set_attribute (item, “custom”, “s”, “target”, NULL);" statement to work. So, instead what I did was utilize an existing menu model "ui" build file and inserted the "custom" property manually as noted in the following snippet (I named the ID as "widgets").
<item>
<attribute name="label">Cut</attribute>
<attribute name="action">app.cut</attribute>
<attribute name="icon">edit-cut-symbolic</attribute>
<attribute name="custom">widgets</attribute>
</item>
Then in a sample program, after the popover menu object was built using the menu model defined in the "ui" file (I called it "popmenu"), I added a GTK check button to the menu item with the "Cut" label as noted in the following code snippet.
GtkWidget *colorbutton;
. . . /* Other code here */
colorbutton = gtk_colorbutton_button_new();
. . . /* Other code here */
gtk_popover_menu_add_child (GTK_POPOVER_MENU(popmenu), colorbutton, "widgets");
. . . /* Other code here */
When I ran the program and clicked on the widget to which I attached the popover menu, I got the color button to appear. Actually, the color button replaced the menu item's label, so I don't know if that is what you ultimately want. To get both text and the color button to appear, I placed a label and the color button within a GTK box and then added the box as a child. The following sample illustration was the result.
Anyway, you might try using a "ui" file that contains the menu model and build your popover menu that way.
Regards.

Related

how to find the Xpath for below given check box

enter image description here
Please tell me how to get the xpath for check box.
If you are using Chrome browser - one easy way you can use:
Open the Inspect (or just click the F12 key)
Mark the element you need and right click on it (or just right click on the object (the check box) you are looking for)
Choose Copy ---> Copy Xpath
I think the tshirt option is not public yet, did not get it in your site.I tried with shirts, looks like same dev pattern to me, let me know if the solution does not work.
<input id="Classic" class="facetChkBox" type="checkbox" value="brickstyletype:Classic" name=""/>
<label for="Classic"/>
This is the background html code.
As you already know, this is not the classic checkbox html code, so we need to create a xpath for this as shown below
driver.findElement(By.xpath(".//label[#for='Classic']"))
from the point of code reusablity I would suggest a method like this:
public void clickOnCheckbox(String checkbox){
driver.findElement(By.xpath(".//label[#for='"+checkbox+"']")).click();
}
and call it using
clickOnCheckbox("Blousons");
In this way you can use the same code to click on different check boxes, and create a clean code.
to relate more to what I am saying you can go the url
https://www.ajio.com/women-shirts/c/830316016

ngClass object syntax where class name is evaluated

I have some text coming in from a JSON file that looks like this:
[
{'text':'First text here', 'transition':'FadeIn', 'delay':1},
{'text':'Second text here', 'transition':'FadeIn', 'delay':2}
]
These text blocks should animate in, with a delay that is specified by the delay property and a transition specified with the transition property. I am using an ngRepeat. Originally I just used the enter/leave etc. on ngRepeat, but this text is bottom-aligned. When the second block comes in it shoves the first block up, which is not ideal.
What I want is something like:
<li ng-repeat="block in currentPage.textBlocks" ng-class="{block.transition:true, active:eventIndex>=$index}">block.text</li>
Note that I already have the model working to make this happen, and if I replace block.transition with 'FadeIn', it works. I'd really like to keep the ability to specify the transition through code, though, while solving the visual issue of the jumpy text.
OK, I can see the Internet is clamoring to answer this one, but imma stop you right there.
What worked for me is class="{{block.transition}}" ng-class="{active:eventIndex>=$index}"

Drupal 7 alter node display

I have a content type with two image fields, banner and logo.
I am trying to implement logic which will allow one of the two to display depending on whether an editor elected to display just the banner or just the logo from radio button options.
I setup a small custom module implementing hook_node_view and tried to unset the image field from the node object but no joy. Code fragment below:
function mymodule_node_view($node, $view_mode, $langcode){
unset($node->field_main_picture[$node->language][0]);
unset($node->field_main_picture);
$node->field_main_picture = null;
}
None of those attempts worked.
I found the answer to my question.
The node object contains an array called content which is the renderable data Drupal will print to screen.
It's in that array that my unsets need to take place. I.E:
unset($node->content['field_main_picture']);
And the main picture image disappears.
I hardly suggest you to work with Devel module when you are programming like that. It allows you to display variables in your page and visualize the tree. For example, you can call dpm($node) function in your hook_node_view() to see what's in $node and how to access it.

KDevelop: transform selected text?

I was wondering whether there was a function in KDevelop similar to the one that we used to have in Quanta (miss you, Quanta, btw).
I would like to set a keyboard shortcut, and apply a text transformation upon hitting it. Example:
I select my text to be translated, and I get back: <?=_('my text to be translated'?>
As you can see, this saves me a lot of awkward keystrokes...
I only found this feature in PHPStorm (where it is called "Live Templates"). I defined it like this: <?=t('$SELECTION$')?> and I can call it by hitting CTRL+ALT+J, and select it from the dropdown that appears.
You should be able to do that using a snippet with the following text: <?=_('%{selection}'?>
And you can bind a Shortcut to a snippet.
However my tests showed that this doesn't work correctly - there seems to be a bug somewhere.
As alternative you can write a script that does insert the text. See the documentation.

Dynamic Hyperlink in Livecycle Form

I am trying to figure out how to make a hyperlink in a Livecycle Form which points to a URL which will change on different days that the form is rendered. For example on one day I might want the hyperlink to point to:
mywebsite/mypage?option=XXX
and on another day I want it to point to:
mywebsite/mypage?option=YYY
The XXX and YYY can be passed into the form's data pretty easily as XML, but I just don't know how to make it so that the hyperlink is changed to correspond to this.
Any suggestions?
This can be accomplished with JavaScript in LiveCycle Designer. The following script, placed on the Form's docReady event will let you dynamically change the URL of a text object.
form1::docReady - (JavaScript, client)
// If this code is running on the server, you don't want it to run any code
// that might force a relayout, or you could get stuck in an infinite loop
if (xfa.host.name != "XFAPresentationAgent") {
// You would load the URL that you want into this variable, based on
// whatever XML data is being passed into your form
var sURL = "www.stackoverflow.com"; // mywebsite/mypage?option=xxx
// URLs are encoded in XHTML. In order to change the URL, you need
// to create the right XHTML string and push it into the Text object's
// <value> node. This is a super simple XHTML shell for this purpose.
// You could add all sorts of markup to make your hyperlink look pretty
var sRichText = "<body><p>Foo</p></body>";
// Assuming you have a text object called "Text1" on the form, this
// call will push the rich text into the node. Note that this call
// will force a re-layout of the form
this.resolveNode("Text1").value.exData.loadXML(sRichText, false, true);
}
There are a couple of caveats: URLs in Acrobat are only supported in Acrobat 9.0 and later. So if someone using an older version of Acrobat opens your form, the URLs won't work.
Also, as you can see from the "if (xfa.host.name !=...)" line, this code won't run properly if the form is being generated on the server, because forcing a re-layout of a form during docReady can cause problems on certain older versions of the LiveCycle server. If you do need to run this script on the server, you should probably pick a different event then form::docReady.
I a number of complaints from users in WorkSpace that clicking links opened them in the same tab so they lost their WorkSpace form, and there's no option to change that in Designer 11. I think the solution I came up with for that would work for you too.
I made buttons with no border and no background, and in their click event have this line (in Javascript, run at client)
app.launchURL("http:/stackoverflow.com/", true);
It would be easy to add some logic to choose the right URL based on the day and it doesn't cause any form re-rendering.
In some spots where the hyperlink is in line with other text, I leave the text of the link blue and underlined but with no hyperlink, and just place the button (no background, no border, no caption) over it. Does require positioned and not flowed subforms for that to work, so depending on your layout it could get a little clunky.
Wow, just realized I am super late to the party. Well, for anyone using ES4 facing a similar problem . . .
Ended up using a 3rd party component to manipulate the PDF's hyperlinks...wish there was a better solution as this one costs about $1000.

Resources