Why libvte copy/paste function not working on [gtk4]?
Can anyone suggest an alternative function to copy & paste text on libvte[gtk4]? As i check
vte_terminal_copy_clipboard
and vte_terminal_copy_clipboard_format
not working on gtk4.
Also vte_terminal_paste_clipboard
& vte_terminal_paste_primary()
expired!
do you know?
how many words do you know
See also questions close to this topic
-
How do I manipulate the contents of a stat() struct?
I have a stat struct, and I'm looking for a way to get data out of it to be manipulated. The program will successfully run and print the desired st_mtime value, but including either of the "seg-fault" lines below causes a segmentation fault in runtime.
struct stat buf; time_t time_m; time_t sys_time = time(0); if(stat(sub_dirp->d_name,&buf)==0) { //time_m = buf.st_mtime; //seg-fault //double since_last = (difftime(sys_time, buf.st_mtime)/60); //seg-fault printf("%d ", (int)buf.st_mtime); //This works. }
Both lines are attempting to manipulate the
buf.st_mtime
value in some way.I've had a hard time finding any examples of the usage of stat() that do anything other than print its contents, which makes me wonder if it's even possible.
So my question is, if it is possible, what am I missing?
P.S. I do wish to keep
st_mtime
in the Unix timestamp format to make it easier to manipulate.Edit: After realizing that
st_mtime
is itself its own struct (timespec), how can I access thest_mtime.tv_sec
member?The compiler doesn't like
buf.st_mtime.tv_sec
one bit. -
What's purpose of __linecapp in getline, when it'll auto resize?
It's all about second parameter of getline in stdio.h,
I'll name it 'n' or '__linecapp' below.
According to the document:
If the buffer is not large enough to hold the line, getline() resizes it with realloc(3), updating *lineptr and *n as necessary.
It'll automatically update line capacity, then why should we input __linecapp?
P.S Someone ask before, but discussion didn't explain when we need it, or how to make it useful.
-
Linked List Deletion function causing program to crash *wrong pointers?*
In my program when a username is following another one and also has posted a "tweet" which is a string in an attempt to delete the followed username it breaks the program. I believe this is the code snippet in question. If anyone could help me identify the issue I would be thankful as I am learning the usage of linked lists for scale able projects. Thanks
void deleteAccount(accountNodePtr *startPtr, accountNodePtr *curAcPtr, tweetsNodePtr *startTwtPtr){ accountNodePtr acLoopPtr; accountNodePtr tempCur = *curAcPtr; followNodePtr followingPtr = tempCur->followingPtr; followNodePtr tempPtr; followNodePtr tempPtr2; tweetsNodePtr iterTwtPtr; iterTwtPtr = *startTwtPtr; *below here in question* tempCur = *curAcPtr; while (tempCur->followersPtr!=NULL){ acLoopPtr = *startPtr; while (strcmp(acLoopPtr->username, tempCur->followersPtr->username)!=0){ acLoopPtr=acLoopPtr->nextPtr; } if (strcmp(acLoopPtr->followingPtr->username, tempCur->username)==0){ tempPtr=acLoopPtr->followingPtr->nextPtr; free(acLoopPtr->followingPtr); acLoopPtr->followingPtr=tempPtr; }else{ tempPtr=acLoopPtr->followingPtr; while(strcmp(tempPtr->nextPtr->username, tempCur->username)!=0){ tempPtr=tempPtr->nextPtr; } tempPtr2=tempPtr->nextPtr->nextPtr; free(tempPtr->nextPtr); tempPtr->nextPtr=tempPtr2; } tempPtr = tempCur->followersPtr->nextPtr; free(tempCur->followersPtr); tempCur->followersPtr=tempPtr; }
This is the structure
typedef struct followsNode { char username[MAX_USERNAME]; struct followsNode *nextPtr; } followNode; typedef struct accountsNode { char username[MAX_USERNAME]; struct followsNode *followersPtr; struct followsNode *followingPtr; struct accountsNode *nextPtr; } accountNode; typedef followNode *followNodePtr; typedef accountNode *accountNodePtr;
-
Why GTK4 seems to use only 48x48 icons for displaying minimized application in all context?
In GTK4 the icon system for displaying the apps have changed.
In GTK3/GTK2 we could use simple commands like gtk_window_set_icon() or gtk_window_set_default_icon_from_file() or gtk_window_set_icon_list().
In GTK4 these commands are gone and we have to use the system of theming defined by the Freedesktop Icon Theme Specification (which could be also used in GTK3). I have dug into what it means in practical in this previous question : GTK 4 and applications icons : how to include an application icon in a portable way?
And finally the resulting code is quite simple :
icon_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ()); gtk_icon_theme_add_search_path(icon_theme,path_to_my_ressource_directory); if(gtk_icon_theme_has_icon(icon_theme,"my-icon")!=1) { // manage error } gtk_window_set_default_icon_name("my-icon"); // default icon for all windows if nothing is set explicitly if I understand well. window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Your app"); gtk_window_set_icon_name(GTK_WINDOW (window),"my-icon"); // set explicitly the icon for the min window
Assuming that the ressource_directory is defined like that :
/ressources$ ls hicolor icon-theme.cache cd hicolor/ /ressources/hicolor$ ls 128x128 150x150 192x192 256x256 310x310 48x48 512x512 64x64 72x72 96x96 scalable /ressources/hicolor$ cd 128x128 /ressources/hicolor/128x128$ ls apps /ressources/hicolor/128x128$ cd apps /ressources/hicolor/128x128/apps$ ls my-icon.png
And it now works, i have my wonderfull icon when i launch the application.
Buuuuuttttt ... the reality is that the icon is fuzzy, whereas in the GTK2 version of my application, it is not.
The first icon from the bottom is my application in GTK2, the second icon (the fuzzy one) is the same appli in GTK4.
The result is a fuzzy icon. I have made some tests on the icons and it seems that under the hood GTK use only the 48x48 icon in this context in GTK4, which give a fuzzy icon when it is used in other context.
Is it a bug of GTK ? Is it a bad interaction with my desktop environment (KDE here) ? Or is it an error from my side ?
And more importantly : how to correct this dissatisfying result ?
-
GTK4 Window Created From XML Immediately Closes
I create a GTK4 Window from an XML file via Python. When I run the code, the window actually pops up very briefly (and all controls are there as expected), but then closes immediately. I assume there is something missing in my code, but I can't figure out what it is from the documentation.
import sys import gi gi.require_version('Gtk', '4.0') gi.require_version('Adw', '1') from gi.repository import Gtk, Adw class MyApp(Adw.Application): def __init__(self, **kwargs): super().__init__(**kwargs) self.connect('activate', self.on_activate) def on_activate(self, app): builder = Gtk.Builder() builder.add_from_file("main.glade") self.win = builder.get_object("window") self.win.present() app = MyApp(application_id="com.example.GtkApplication") app.run(sys.argv)
-
Can we use libvte terminal widget on gtk4 window?
I want to use libvte on this gtk4 window. But facing issue during compile, demo script given below. Can anyone tell me whether libvte-2.91 is supported with gtk4? I'm on Ubuntu 22.04LTS
$ gcc -Wall $(pkg-config --cflags gtk4 vte-2.91) gtk4App.c -o term $(pkg-config --libs gtk4 vte-2.91) ERROR SHOW-------------- In file included from /usr/include/vte-2.91/vte/vte.h:33, from gtk4App.c:2: /usr/include/vte-2.91/vte/vtetypebuiltins.h:27:10: fatal error: vtetypebuiltins-gtk4.h: No such file or directory 27 | #include "vtetypebuiltins-gtk4.h" | ^~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
This is the gtk4 script-----
#include <gtk/gtk.h> #include <vte/vte.h> //sudo apt install libgtk-4-dev libvte-2.91-dev //gcc -Wall $(pkg-config --cflags gtk4 vte-2.91) gtk4App.c -o term $(pkg-config --libs gtk4 vte-2.91) static void activate (GtkApplication *app, gpointer user_data) { GtkWidget *window; GtkWidget *terminal; window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Window"); gtk_window_set_default_size (GTK_WINDOW (window), 200, 200); GtkWidget *grid = gtk_grid_new (); gtk_window_set_child ((GtkWindow *)window, grid); gtk_widget_set_vexpand(grid, TRUE); gtk_widget_set_hexpand(grid, TRUE); GtkWidget *scrollview1; scrollview1 = gtk_scrolled_window_new(); gtk_grid_attach(GTK_GRID(grid), scrollview1, 0, 0, 1, 1); terminal = vte_terminal_new(); gtk_window_set_child ((GtkWindow *)scrollview1, terminal); gtk_widget_show (window); } int main (int argc, char **argv) { GtkApplication *app; int status; app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); return status; }
I know libvte working fine with gtk+3.0,,but i want to use it on gtk4.
-
Velocity split() and array display, concatenate syntax
I am trying to work with Velocity, which is like programming with your feet. I'm fluent in JavaScript and PHP but not Java. So I need a little help figuring out the correct syntax for this. I've done some research but since I'm not familiar with Java and Velocity is cringy, I can't figure out the right syntax.
I have a string, $string that is a url. I need to split it at the anchor # and reorganize it so that it will be in proper form for parameters and an anchor tag.
WHAT I HAVE:
URL ($string): http://url.com#anchorlink
PARAMETERS (plain text): ?utm_campaign=abc&utm_medium=def
WHAT I'M TRYING TO DO:
Split the string at # and reconsitute the url to:
http://url.com?utm_campaign=abc&utm_medium=def#anchorlink
HERE'S WHAT I HAVE IN CODE that I need help putting into proper syntax (it's wrong here):
<div> #set ($myArray = $string.split("#")); <a href = "${myArray[0]}?utm_campaign=abc&utm_medium=def${myArray[1]}"> Link Text </a> </div>
Thanks!