Adding Simple GTK 3.0+ GUI to Livewall

in #utopian-io6 years ago

Livewall is an Open Source Program that allows users to set a GIF or Video as a background for their desktop. Livewall is written completely in C.

New Features

  • Adding Simple GUI

I worked on adding a simple GTK based User Interface for the Command Line tool. The GTK based User Interface allows the user to select a GIF or a Video to be set as Live Background for your Desktop background.

User Interface

  • Implementation

I used GTK 3.0 with C Language to implement the User Interface. It consists of a simple Button which triggers the GTKFileChooser selector for selecting the GIF or Video.

  gtk_window_set_title (GTK_WINDOW (window), "Livewall Yogdaan");

  button = gtk_button_new_with_label("Choose a GIF");

  g_signal_connect(window,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
  g_signal_connect(button,"clicked",G_CALLBACK(open_dialog),NULL);
  
  gtk_container_set_border_width(GTK_CONTAINER(window),100);
  gtk_container_add(GTK_CONTAINER(window),button);

  gtk_widget_set_size_request(GTK_WINDOW(window),300,300);
  gtk_window_set_resizable (GTK_WINDOW(window),0);
  gtk_widget_show_all(window);

The main function starts the GTKWindow that contains the GTKWidget Button. Clicking on the button fires up the open_dialog callback for GTK.
The code for open dialog is given below

char *command = "livewall -ov -ni -fs -- mpv -wid WID --keepaspect=no --loop ";
  GtkWidget *dialog;
  dialog = gtk_file_chooser_dialog_new("Choose a GIF",
    GTK_WINDOW(window),
    GTK_FILE_CHOOSER_ACTION_OPEN,
    GTK_STOCK_OK,
    GTK_RESPONSE_OK,
    GTK_STOCK_CANCEL,
    GTK_RESPONSE_CANCEL,
    NULL);

This creates a new GTKFileChooser Dialog Box for selecting the GIF or Video.
Further, the selected GIF/Video is stored in a variable and is then used to trigger the command line application.

if(resp==GTK_RESPONSE_OK){
    g_print("%s\n",gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
    char *gif = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
    char gif_command[strlen(command) + strlen(gif)];
    strcpy(gif_command,command);
    strcat(gif_command,gif);
    printf("%s\n",gif_command);
    system(gif_command);
}

About Livewall

  • What is the project about?

Livewall is a program that allows user to set Live Wallpaper as their Desktop Background. The User can choose from a GIF to a Video. In simple terms, all that can be played as a video can be choosen as a live background for the desktop.

  • Technology Stack

Livewall runs on a C program with a simple GUI written in C - GTK.
We use Makefile to execute or build the program.

  • Roadmap

Currently the project is limited to mpv player. We would like to extend it to more players as well.
The GUI is very simple and needs to have verification and stuff.
We need to modify the livewall.c into an object file so that it can be accessed by the gui.c and the dependency on system command can be removed as well.

  • How to contribute?

Livewall is managed by Yogdaan. It is fairly simple to contribute. Just clone the project and send a PR for anything you consider can benefit the project.
You can reach out to us on Yogdaan Website which has all the links to get in touch with us.
We are looking forward for People who can contribute to Yogdaan.

  • Links

Link to my PR : Pull Request #4

Sort:  

Congratulations @gabrum! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Thanks for the contribution. It has been approved.


Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Thank you so much :)

Hey @gabrum

We're already looking forward to your next contribution!

Contributing on Utopian

Learn how to contribute on our website or by watching this tutorial on Youtube.

Utopian Witness!

Vote for Utopian Witness! We are made of developers, system administrators, entrepreneurs, artists, content creators, thinkers. We embrace every nationality, mindset and belief.

Want to chat? Join us on Discord https://discord.gg/h52nFrV

Sure! I will contribute more now <3