Skip to content

Commit

Permalink
fix calculator issues, fix icon theme issues, fix search issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzSelenux authored and ItzSelenux committed Sep 11, 2024
1 parent 6a5ae06 commit 9be848f
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 154 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v2
with:
body: Release ci-${{ env.DATE }}
name: ${{ github.event.head_commit.message }}
name: Release ci-${{ env.DATE }}
body: ${{ github.event.head_commit.message }}
tag_name: ${{ env.DATE }}
files: |
${{ env.GH_RELEASE_FILE }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test:
install:
install -Dm755 $(EXE) $(BIN_DIR)/$(EXE)
install -Dm644 $(EXE).desktop $(APP_DIR)/$(EXE).desktop
install -Dm644 icons/menulibre.svg $(PREFIX)/share/icons/hicolor/64x64/apps/menulibre.png
install -Dm644 icons/sglauncher.svg $(PREFIX)/share/icons/hicolor/48x48/apps/sglauncher.svg
uninstall:
rm $(BIN_DIR)/$(EXE)
rm $(APP_DIR)/$(EXE).desktop
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Standalone Simple GTK Launcher with some features

## Configuration:

You can use the Settings (sglauncher-cfg) program to easily edit the values with a GUI
You can use the Settings (sglauncher --cfg) program to easily edit the values with a GUI

| Item | Description | Possible values| Values explanation| example
| --- | --- | --- | --- | --- |
Expand Down
110 changes: 52 additions & 58 deletions calc.h
Original file line number Diff line number Diff line change
@@ -1,75 +1,69 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

double evaluate(const char* expression)
{
char* endptr;
double result = strtod(expression, &endptr), operand;
char op;

double result = strtod(expression, &endptr);
if (errno == ERANGE) return NAN;
while (*endptr != '\0')
{
while (isspace(*endptr)) endptr++;
op = *endptr++;
if (*endptr == '\0') break;
operand = strtod(endptr, &endptr);

char op = *endptr++;

switch (op)
{
case '+': result += operand; break;
case '-': result -= operand; break;
case '*': result *= operand; break;
case '/':
if (operand != 0)
result /= operand;
else
return NAN;
break;
case '^': result = pow(result, operand); break;
case '%': result = operand / 100.0 * result; break;
case 'r': result = sqrt(result); break;
case 'c':
if (*endptr == 'h')
{
endptr++;
result = cosh(result);
}
else
{
result = cos(result);
}
case 'l': result = log(result); break;
case 'S': result = asin(result); break;
case 'C': result = acos(result); break;
case 'T': result = atan(result); break;

case 'c':
if (*endptr == 'h') { endptr++; result = cosh(result); }
else result = cos(result);
break;
case 't':
if (*endptr == 'h')
{
endptr++;
result = tanh(result);
}
else
{
result = tan(result);
}

case 't':
if (*endptr == 'h') { endptr++; result = tanh(result); }
else result = tan(result);
break;
case 's':
if (*endptr == 'h')
{
endptr++;
result = sinh(result);
}
else

case 's':
if (*endptr == 'h') { endptr++; result = sinh(result); }
else result = sin(result);
break;

case '+': case '-': case '*': case '/': case '^': case '%': case 'b': case 'n':
{
result = sin(result);
double operand = strtod(endptr, &endptr);
if (errno == ERANGE) return NAN;

switch (op)
{
case '+': result += operand; break;
case '-': result -= operand; break;
case '*': result *= operand; break;
case '/':
if (operand != 0) result /= operand;
else return NAN;
break;
case '^': result = pow(result, operand); break;
case '%': result = operand / 100.0 * result; break;
case 'b':
if (operand != 0) result = log(result) / log(operand);
else return NAN;
break;
case 'n': result = pow(result, 1.0 / operand); break;
default: return NAN;
}
}
break;
case 'l': result = log(result); break;
case 'b':
if (operand != 0)
result = log(result) / log(operand);
else
return NAN;
break;
case 'n': result = pow(result, 1.0 / operand); break;
case 'S': result = asin(result); break;
case 'C': result = acos(result); break;
case 'T': result = atan(result); break;
default: return NAN;

default:
return NAN;
}
}
return result;
Expand Down
82 changes: 0 additions & 82 deletions icons/menulibre.svg

This file was deleted.

82 changes: 82 additions & 0 deletions icons/sglauncher.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion keyhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ gboolean on_key_release(GtkWidget *widget, GdkEventKey *event, gpointer user_dat
if (gtk_tree_model_get_iter_first(model, &iter))
{
gtk_tree_model_get(model, &iter, 0, &app_name, -1);
gchar *entry_text_lower = g_ascii_strdown(entry_text, -1);
gchar *app_name_lower = g_ascii_strdown(app_name, -1);

if (gtk_tree_model_iter_has_child(model, &iter))
{
if (g_strcmp0(entry_text, app_name) != 0)
if (g_strstr_len(app_name_lower, -1, entry_text_lower) == NULL)
{
GtkTreeIter child_iter;
if (gtk_tree_model_iter_children(model, &child_iter, &iter))
Expand All @@ -173,6 +176,13 @@ gboolean on_key_release(GtkWidget *widget, GdkEventKey *event, gpointer user_dat
return 0;
}
}
else
{
path = gtk_tree_model_get_path(model, &iter);
gtk_tree_view_set_cursor(GTK_TREE_VIEW(treeview), path, NULL, FALSE);
gtk_tree_view_row_activated(GTK_TREE_VIEW(treeview), path, NULL);
gtk_tree_path_free(path);
}
}
else
{
Expand Down
Loading

0 comments on commit 9be848f

Please sign in to comment.