VsCode extension development. Add gutter icon with action - icons

I'm working on VSCode extension and need to add actions to gutter icons. Right now I'm adding gutter icon
const documentDecorationType = vscode.window.createTextEditorDecorationType({
gutterIconPath: context.asAbsolutePath('media/link.svg')
});
editor.setDecorations(documentDecorationType, [
{
range: new vscode.Range(new vscode.Position(document.start_line, 0), new vscode.Position(document.end_line, 0)),
}
]);
How can I add action to icon?
Thanks for any help!
Regards,
Alex

It doesn't look like you can add a command directly to a gutter icon. See OnClick event on Gutter and Allow clicking gutter icon: both issues are still open.
You may be able to add it as a command in a hover though (still trying to get it to work...)

Related

GTK# button drawn incorrectly?

My GTK# (v2.12.44) app has a single Window with a single button on it. The button appears to be centered on the Window, because that's where the text appears, but the border/background for the button is shifted up and to the left for no reason I can see. Has anyone seen this before? I saw similar behavior from an Image widget. Note this only happens in Windows, not on (for example) Raspberry Pi/Jesse.
Here's the code:
Application.Init();
var window = new Window("test") {new Button("testing 1, 2, 3")};
window.Maximize();
window.ShowAll();
Application.Run();
Your code works well. Try to add a container before adding a button and set some parametrs you want to. Fill and Expand when adding Button.

Stacking Angular Material 2 Dialogs like toasts

I am using the #angular/material library and am trying to create a sort of bootstrap toast like effect. Where I want potentially multiple dialogs to appear in the top right hand corner and stack up below the most recent one.
By disabling the backdrop and closing features, I have this code:
let dialogRef = this.dialog.open(NotificationInputComponent, {disableClose: true, hasBackdrop: false});
dialogRef.afterClosed().subscribe(result => {
this.selectedOption = result;
});
Which works quite well, so when triggered, I get this in the middle of my screen:
If I manually change the elements css to position: absolute; right: 10px then it goes to the right hand side of the screen and looks correct. The issue is, now if I trigger another dialogue, I have to do the same again, but set the top property to stop it overlaying the existing dialog. I could presumably keep track of all the triggered dialogs in my component and manually update the top margin. But I was wondering if there is a neater way of doing it, either getting them to stack in css, or possibly is there a way to inject the triggered dialog into an #angular/flexbox layout?

Center buttons in dialog created with "gtk_dialog_new_with_buttons"

I am writing a Gtk application and I am having troubles centering some buttons.
I created a popup window in this way:
dialog = gtk_dialog_new_with_buttons ("Add element",
GTK_WINDOW(gElems->window),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
"OK",
GTK_RESPONSE_ACCEPT,
"Cancel",
GTK_RESPONSE_REJECT,
NULL);
Everything is ok, except for the OK and Cancel buttons, which are aligned to the right end of the popup window, while I would like them to be centered (as you can see from the picture).
Is there a way to do so without using additional containers to store the buttons?
You can align the buttons in the middle
buttons_container = gtk_dialog_get_action_area (dialog)
g_object_set_property (G_OBJECT (buttons_container), "halign", GTK_ALIGN_CENTER)
and voila.....
If you want to change the container, you also can, but that's not what you want, really
Regarding luciomrx answer: It is needed to pass a gvalue, otherwise you will get a compile warning and a runtime crash:
GValue val = G_VALUE_INIT;
g_value_init (&val, G_TYPE_ENUM);
g_value_set_enum (&val, GTK_ALIGN_CENTER);
buttons_container = gtk_dialog_get_action_area (dialog);
g_object_set_property (G_OBJECT (gtk_dialog_get_action_area (dialog)), "halign", &val);
Even Simpler, you can just use gtk_widget_set_halign, which accepts an enum:
gtk_widget_set_halign (gtk_dialog_get_action_area (dialog), GTK_ALIGN_CENTER);
Edit: I just realized that gtk_dialog_get_action_area anyhow is deprecated in gtk3 .. so a different sulution should be found.

Add Button in TabNavigator Header

i want to add minmun/maximum button on tabnavigator header.......how i could be possible
put the tab navigator and a button in a canvas
set the X and Y of button Y=0 and X=tabnavigator.width - button-width-10
on click of button use Resize function set HeightTo=0 and heightFrom= tabnavigator.width
then play() the resize
to restore heightFrom=0 and heightTo=previous size of navigator
then you got the illusion of minimizing ang maxizing the tab navigator.. please do add some more effects of your desire..
Hope this gives you a idea on it..
Forget how it looks at first. Create a button that simply hides the TabNavigator. I'm sure there are plenty of tutorials out there on how to animate show/hide. Once you have that, move the button where you want it and style it as you wish.
Ive never heard of a tabNavigator header, but if you mean adding buttons to the tabs themselves, then theres an example and source code you could work from with FlexLib SuperTabNavigator

In Qt, for a context menu item, how to hide the space of the icon

I am adding a context menu using QAction for a widget.
Now, there is some white space beside the text of the action. I assume this is the space where the QIcon association with the QAction should have been there. Now how do I hide this space. I tried doing:
action->setIcon(QIcon());
but still does not seem to work.
Kindly let me know if you have the way to remove that space before the text.
You don't say which platform. But on Mac you can turn off menu items altogether with:
qt_mac_set_menubar_icons( false );
I don't know if there is a way specific to the action or the menu, but you could probably remove it using a style.
You didn't mention the version of Qt you are using but version 4.4.3's QAction allows you to hide the icon:
http://doc.trolltech.com/4.4/qaction.html#iconVisibleInMenu-prop
You can also try using the QAction::QAction ( const QString & text, QObject * parent ) constructor:
http://doc.trolltech.com/4.4/qaction.html#QAction-2 (4.4.3)
http://doc.trolltech.com/4.0/qaction.html#QAction-2 (4.0)
http://doc.trolltech.com/3.3/qaction.html#QAction-2 (3.3)

Resources