Git Product home page Git Product logo

img's Issues

images path needs to be relative

To ensure the program can work after being installed in /usr/local/bin/ on Linux and is able to look at the directory the user is in, you can modify the program to take an optional command line argument specifying the directory to load images from. If no argument is provided, the program will load images from the current working directory.

User's now need to specify the path after img command is used, like this:
img /path/to/images

new main code:

int main(int argc, char** argv) {
  char* dir_path = ".";
  if (argc > 2) {
    g_print("Usage: %s [directory]\n", argv[0]);
    return EXIT_FAILURE;
  } else if (argc == 2) {
    dir_path = argv[1];
  }

  load_images(dir_path);

  gtk_init(&argc, &argv);

  GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "Image Viewer");
  gtk_window_set_default_size(GTK_WINDOW(window), 300, 300);
  gtk_container_set_border_width(GTK_CONTAINER(window), 10);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

  image = gtk_image_new_from_pixbuf(pixbuf[current_image]);
  gtk_container_add(GTK_CONTAINER(window), image);

  g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL);

  gtk_widget_show_all(window);

  gtk_main();

  for (int i = 0; i < total_images; i++) {
    g_object_unref(pixbuf[i]);
  }

  return EXIT_SUCCESS;
}

quality of life golang branch

walk through the files
oh no use flag package and NOT os.args

use mime type package instead of playing weird games with ext names

use fyne and FORGET GTK

@npmaile thx nate

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.