Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/l3ib/nitrogen
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWrigley committed Oct 23, 2015
2 parents fb39d2b + 1a796c4 commit eb8d95e
Show file tree
Hide file tree
Showing 23 changed files with 754 additions and 309 deletions.
6 changes: 6 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Dave Foster <daf@minuslab.net> Dave Foster <dave.foster@gmail.com>
Dave Foster <daf@minuslab.net> Dave Foster <dfoster@asascience.com>
Dave Foster <daf@minuslab.net> daf <daf>
Javeed Shaikh <syscrash2k@gmail.com> syscrash <syscrash>


2 changes: 2 additions & 0 deletions data/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
SUBDIRS = icons

appdatadir = /usr/share/appdata
desktopdir = $(datadir)/applications
desktop_DATA = nitrogen.desktop
appdata_DATA = nitrogen.appdata.xml

UPDATE_DESKTOP = update-desktop-database $(datadir)/applications || :

Expand Down
32 changes: 32 additions & 0 deletions data/nitrogen.appdata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2014 l3ib <daf@minuslab.net> -->
<application>
<id type="desktop">nitrogen.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+ and Zlib and CC-BY-SA-3.0</project_license>

<name>Nitrogen</name>
<summary>Background browser and setter for X windows</summary>

<description>
<p>
Nitrogen is a program that allows you to set the desktop background. Its
browser mode allows you to choose and apply a desktop background, and the
recall mode lets you apply the saved configuration from the command line.
</p>
<p>
It features Multihead and Xinerama awareness, inotify monitoring of browse
directory, lazy loading of thumbnails to conserve memory, and an
'automatic' set mode which determines the best mode to set an image based
on its size.
</p>
</description>

<screenshots>
<screenshot type="default" width="352" height="524">http://projects.l3ib.org/nitrogen/images/nitrogen-shot1.png</screenshot>
<screenshot width="475" height="560">http://projects.l3ib.org/nitrogen/images/nitrogen-ss-2.png</screenshot>
</screenshots>

<url type="homepage">http://projects.l3ib.org/nitrogen/</url>
<updatecontact>jwrigley7@gmail.com</updatecontact>
</application>
18 changes: 9 additions & 9 deletions src/ArgParser.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is from Nitrogen, an X11 background setter.
This file is from Nitrogen, an X11 background setter.
Copyright (C) 2006 Dave Foster & Javeed Shaikh
This program is free software; you can redistribute it and/or
Expand All @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ArgParser.h"
#include "gcs-i18n.h"

bool ArgParser::parse
bool ArgParser::parse
(int argc, char ** argv) {
int count = 1;
bool retval = true;
Expand All @@ -36,7 +36,7 @@ bool ArgParser::parse
received_args["help"];
continue;
}

std::string::size_type minuspos;
if ((minuspos = key.find ("--")) == std::string::npos) {
// this is not an arg, append it
Expand All @@ -48,9 +48,9 @@ bool ArgParser::parse
extra_arg_str += key;
continue;
}

key = std::string (key, minuspos + 2);

std::string::size_type pos = key.find ('=');
if (pos != std::string::npos) {
key.erase (pos);
Expand All @@ -59,7 +59,7 @@ bool ArgParser::parse

std::map<std::string, Arg>::const_iterator iter;
Arg current;

if ((iter = expected_args.find (key)) == expected_args.end ()) {
// ignore this argument and set the error string
retval = false;
Expand All @@ -68,7 +68,7 @@ bool ArgParser::parse
} else {
current = iter->second;
}

if (current.get_has_arg () && !value.length ()) {
// this expects an arg, but has received none.
retval = false;
Expand All @@ -84,7 +84,7 @@ bool ArgParser::parse
error_str += key + _(" conflicts with another argument.") + "\n";
continue;
}

// save it.
received_args[key] = value;
}
Expand All @@ -109,7 +109,7 @@ std::string ArgParser::help_text (void) const {

bool ArgParser::conflicts (std::string key) {
std::vector< std::vector<std::string> >::const_iterator iter;

// Look through the exclusive iter. Cramped together to fit
// into 80 columns.
for (iter=exclusive.begin();iter!=exclusive.end();iter++) {
Expand Down
28 changes: 14 additions & 14 deletions src/ArgParser.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is from Nitrogen, an X11 background setter.
This file is from Nitrogen, an X11 background setter.
Copyright (C) 2006 Dave Foster & Javeed Shaikh
This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

class Arg {
public:
Arg ( std::string desc = "",
Arg ( std::string desc = "",
bool has_arg = false) {
set_desc (desc);
set_has_arg (has_arg);
Expand All @@ -39,21 +39,21 @@ class Arg {
std::string get_desc (void) const {
return desc;
}

bool get_has_arg (void) const {
return has_arg;
}

void set_desc (std::string desc) {
this->desc = desc;
}

void set_has_arg (bool has_arg) {
this->has_arg = has_arg;
}

~Arg () {};

protected:
std::string desc;
bool has_arg;
Expand All @@ -70,12 +70,12 @@ class ArgParser {
inline void register_option (std::string name, std::string desc = "", bool has_arg = false) {
expected_args[name] = Arg(desc, has_arg);
}

// makes two or more options mutually exclusive (only one or the other.)
inline void make_exclusive (std::vector<std::string> exclusive_opts) {
exclusive.push_back (exclusive_opts);
}

// returns the parsed map.
inline std::map<std::string, std::string> get_map (void) const {
return received_args;
Expand All @@ -85,18 +85,18 @@ class ArgParser {
inline std::string get_error (void) const {
return error_str;
}

inline std::string get_extra_args (void) const {
return extra_arg_str;
}

inline bool has_argument (std::string option) {
if (received_args.find (option) != received_args.end ()) {
return true;
}
return false;
}

inline std::string get_value (std::string key) {
std::map<std::string, std::string>::const_iterator iter = received_args.find (key);
if (iter != received_args.end ()) {
Expand All @@ -117,7 +117,7 @@ class ArgParser {
stream >> tmp_int;
return tmp_int;
}

// parses away.
bool parse (int argc, char ** argv);

Expand All @@ -127,8 +127,8 @@ class ArgParser {
protected:
// checks if the supplied key conflicts with an existing key.
bool conflicts (std::string key);
std::string error_str, extra_arg_str;

std::string error_str, extra_arg_str;
std::map<std::string, std::string> received_args;
std::map<std::string, Arg> expected_args;
std::vector< std::vector<std::string> > exclusive;
Expand Down
Loading

0 comments on commit eb8d95e

Please sign in to comment.