lqg 2 years ago
parent
commit
18217832c2

+ 5 - 21
README.md

@@ -1,22 +1,8 @@
 # ChatGPT-Gnome-Desktop-Extension
 
-
 ChatGPT Gnome Desktop Extension | Talk with ChatGPT from your menubar!
 
-![Screenshot from 2023-01-13 16-53-54](https://user-images.githubusercontent.com/21268783/212362417-1e06b82e-8abd-400a-9659-ba25611cd3ae.png)
-![Screenshot from 2023-01-13 16-57-31](https://user-images.githubusercontent.com/21268783/212363907-ce25b9d3-dda9-4586-ae66-29fc2a118831.png)
-
-- EARLY VERSION WORK IN PROGRESS
-
-This Gnome Desktop Extension adds ChatGPT to your desktop experience. Clickable icon in the menu bar to hide and show ChatGPT!
-
-![Screenshot from 2023-01-13 15-10-33](https://user-images.githubusercontent.com/21268783/212339570-3b56fd40-da79-4ef0-8373-fe6eb7a91d44.png)
-
-To-do & Info:
-
-- Enable mouse-wheel scrolling (currently only keyboard-arow-scrolling is supported)
-- Clicking within the extension window is buggy (Using keyboard navigation is recommended). This will be fixed.
-- Add Gnome 43 support.
+原项目直接内嵌openai网站,国内无法访问,所以我fork了一份,把openai网站换成了国内的解决方案,可以直接在gnome桌面上使用了。由于使用付费api,所以每天只能使用100次,如果你有自己的openai api key,可以自己修改代码。
 
 How to install:
 - Make sure you have the `gnome-shell-extensions` package installed. It allows you to turn on the Extension.
@@ -25,10 +11,11 @@ How to install:
 - Enable the extension inside the Gnome Extensions application.
 - Restart Gnome with `Alt`+`F2` then type `r` or Log out & Log back in to Gnome.
 
+To-do & Info:
 
-
-
-
+- Enable mouse-wheel scrolling (currently only keyboard-arow-scrolling is supported)
+- Clicking within the extension window is buggy (Using keyboard navigation is recommended). This will be fixed.
+- Add Gnome 43 support.
 
 KNOWN ISSUES AND POSSIBLE FIX:
 
@@ -58,6 +45,3 @@ You may also need to set the GDK_BACKEND environment variable.
 You will need to restart your terminal or run the command source ~/.bashrc for the changes to take effect.
 
 On other distributions, you may need to use a different package manager or set the environment variables in a different way.
-
-
-

+ 76 - 0
chatgpt-gnome-china/extension.js

@@ -0,0 +1,76 @@
+const St = imports.gi.St;
+const Main = imports.ui.main;
+const ExtensionUtils = imports.misc.extensionUtils;
+const Me = imports.misc.extensionUtils.getCurrentExtension();
+const Webkit = imports.gi.WebKit2;
+const Gtk = imports.gi.Gtk;
+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 });
+    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;
+
+        //enable scrolling inside the window
+        scrolled_window = new Gtk.ScrolledWindow();
+        //open the website
+        webView = new Webkit.WebView();
+        scrolled_window.add(webView);
+        //load the URL and add it to WebView
+        webView.load_uri('https://chat.openai.com/chat');
+        window.add(scrolled_window);
+        //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();
+}

BIN
chatgpt-gnome-china/icons/chatgpt_icon.png


+ 1 - 0
chatgpt-gnome-china/icons/info.txt

@@ -0,0 +1 @@
+icons go in this folder

+ 16 - 0
chatgpt-gnome-china/login.js

@@ -0,0 +1,16 @@
+// login
+function login(token:str) {
+    
+}
+
+function logout() {
+    
+}
+
+function setToken(token:str) {
+    
+}
+function getToken() {
+    // redicet to login page
+    
+}

+ 13 - 0
chatgpt-gnome-china/metadata.json

@@ -0,0 +1,13 @@
+{
+    "name": "ChatGPT for Gnome Desktop",
+    "description": "Access ChatGPT From Your Gnome-Desktop!",
+    "version": "1.0.2",
+    "uuid": "chatgpt-gnome-desktop@chatgpt-gnome-desktop",
+    "shell-version": [
+        "42",
+        "43"
+    ],
+    "url": "https://git.yoqi.me/openai/chatgpt-gnome",
+    "author": "jianoby",
+    "icon": "web-browser-symbolic"
+}