Browse Source

Extension

HorrorPills 2 years ago
parent
commit
84e9625c6e

+ 80 - 0
chatgpt-gnome-desktop@chatgpt-gnome-desktop/extension.js

@@ -0,0 +1,80 @@
+const St = imports.gi.St;
+const Main = imports.ui.main;
+const ExtensionUtils = imports.misc.extensionUtils;
+const Me = imports.misc.extensionUtils.getCurrentExtension();
+//const Me = ExtensionUtils.getCurrentExtension();
+const Webkit = imports.gi.WebKit2;
+const Gtk = imports.gi.Gtk;
+//new const
+const Gio = imports.gi.Gio;
+
+
+let button;
+
+function init() {
+    button = new St.Bin({ style_class: 'panel-button',
+                         reactive: true,
+                         can_focus: true,
+                         x_expand: true,
+                         y_expand: false,
+                         track_hover: true });
+                         //set menubar icon
+                         let gicon = Gio.icon_new_for_string(Me.path + "/icons/chatgpt_icon.png");
+                         icon = new St.Icon({ gicon });
+    //let icon = new St.Icon({ icon_name: 'system-run-symbolic',
+                             //style_class: 'system-status-icon' });
+
+    button.set_child(icon);
+    button.connect('button-press-event', _handleClick);
+}
+
+// Open GTK Window when the menubar button is clicked.
+let window, webView;
+
+function _handleClick() {
+    if (!window) {
+        //set window style- in this case TOPLEVEL
+        window = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL });
+        //remove window interaction buttons
+        window.decorated = false;
+        //set the size of the window
+        window.set_default_size(350, 550);
+        //set the border radius of the window
+        
+        //make the window non resizeable
+        window.resizable = false;
+
+        //open the website
+        webView = new Webkit.WebView();
+        //enable scrolling inside the window
+             // !!! NOT YET IMPLEMENTED !!!
+        //load the URL and add it to WebView
+        webView.load_uri('https://chat.openai.com');
+        window.add(webView);
+        //window positioning
+        window.set_position(Gtk.WindowPosition.MOUSE);
+        //skip showing in the taskbar
+        window.set_skip_taskbar_hint(true);
+        //open the window
+        window.show_all();
+        //check if the window is open, if yes, close it after clicking the menubar button
+    } else if (window.get_visible()) {
+        window.hide();
+    } else {
+        window.show_all();
+    }
+}
+
+
+function enable() {
+    Main.panel._rightBox.insert_child_at_index(button, 0);
+}
+
+function disable() {
+    Main.panel._rightBox.remove_child(button);
+}
+
+function main() {
+    init();
+    enable();
+}

+ 12 - 0
chatgpt-gnome-desktop@chatgpt-gnome-desktop/metadata.json

@@ -0,0 +1,12 @@
+{
+    "name": "ChatGPT for Gnome Desktop",
+    "description": "Access ChatGPT From Your Gnome-Desktop!",
+    "version": "1.0",
+    "uuid": "chatgpt-gnome-desktop@chatgpt-gnome-desktop",
+    "shell-version": [       
+		"42"
+    ],
+    "url": "https://www.example.com",
+    "author": "Rafal Mioduszewski",
+    "icon": "web-browser-symbolic"
+}