Skip to content

Commit

Permalink
Small Update
Browse files Browse the repository at this point in the history
  • Loading branch information
marekpistorius committed Jan 22, 2025
1 parent 3e978bb commit 554298f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
7 changes: 4 additions & 3 deletions panel-plugin/nameday-plugin-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ GList* create_list_namedays(const gchar* _file)

file = g_fopen(_file, "r");

if( file == NULL)
if( NULL == file )
return list;

while (fgets(sData,256,file) != NULL)
Expand All @@ -60,7 +60,7 @@ gchar *findNamedaysInFile(gchar *_file, gchar *name)
char sData[256];
file = g_fopen(_file, "r");

if( file == NULL)
if(NULL == file)
return NULL;

while (fgets(sData,256,file) != NULL)
Expand Down Expand Up @@ -89,8 +89,9 @@ gchar *NamedayInFebruaryLeapYear(gchar *file)
gchar name[366];
f = g_fopen(file, "r");

if(f == NULL)
if(NULL == f)
return NULL;

if (fgets(name,366,f)!= NULL)
{
fclose(f);
Expand Down
11 changes: 6 additions & 5 deletions panel-plugin/nameday-plugin-dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void apply_options (xfcenameday_dialog *dialog)

tmp = load_nm(date,dialog->nmdplg);

if(G_LIKELY(tmp!= NULL))
if(G_LIKELY(tmp != NULL))
{
gtk_label_set_text(GTK_LABEL(dialog->nmdplg->label), tmp);
}
Expand All @@ -67,7 +67,6 @@ nameday_configure_response (GtkWidget *dialog,
if (response == GTK_RESPONSE_HELP)
{
/* show help */
//todo: change?
result = g_spawn_command_line_async ("exo-open --launch WebBrowser " PLUGIN_WEBSITE, NULL);

if (G_UNLIKELY (result == FALSE))
Expand Down Expand Up @@ -108,7 +107,7 @@ xfcenameday_dialog * create_config_dialog(NamedaysPlugin *data, GtkWidget *vbox)
label2 = gtk_label_new (_("Set Count of Tooltips Namedays"));
hbox = gtk_box_new (GTK_ORIENTATION_VERTICAL,BORDER);
dialog->nmdplg->combo = gtk_combo_box_text_new();
//TODO: not path directly?
//TODO: not path directly?
list = getdirlist(NAMEDAY_PATH_GLOBAL "/data/");

for(stmp = list; stmp ;stmp = g_list_next(stmp),i++)
Expand All @@ -118,7 +117,7 @@ xfcenameday_dialog * create_config_dialog(NamedaysPlugin *data, GtkWidget *vbox)
if(strcmp(((gchar *)stmp->data),data->setting1) == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->nmdplg->combo),i--);

g_free(stmp->data);
g_free(stmp->data);
}

gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
Expand All @@ -135,9 +134,12 @@ xfcenameday_dialog * create_config_dialog(NamedaysPlugin *data, GtkWidget *vbox)
static void update_config(NamedaysPlugin *data)
{
gchar *text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(data->combo));

if(G_UNLIKELY(text!= NULL))
data->setting1 = g_strdup(text);

gint count = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(data->spin));

if(G_UNLIKELY(count < 0))
data->setcount = count;
}
Expand Down Expand Up @@ -166,7 +168,6 @@ void nameday_configure(XfcePanelPlugin *plugin,
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))),vbox,TRUE,TRUE,0 );

/* set dialog icon */
//todo probaly?
gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings");

dialog = create_config_dialog (nmd, vbox);
Expand Down
35 changes: 18 additions & 17 deletions panel-plugin/nameday-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

/* default settings */
#define DEFAULT_LANG NAMEDAY_PATH_GLOBAL "data/czech.dat"

#define DEFAULT_COUNT 5
#define UPDATE_TIME 1800

Expand Down Expand Up @@ -406,7 +405,7 @@ static gint nmd_compare(GtkTreeModel *model, GtkTreeIter *a , GtkTreeIter *b, gp
gint ret = 0;

gtk_tree_model_get(model, a, 0, &name1, -1);
gtk_tree_model_get(model, b, 0, &name2, -1);
gtk_tree_model_get(model, b, 0, &name2, -1);

if (name1 == NULL || name2 == NULL)
{
Expand Down Expand Up @@ -551,23 +550,25 @@ static gboolean on_tooltip_cb (GtkWidget *widget,

if(G_UNLIKELY(!date))
{
gtk_tooltip_set_text (tooltip, _("Cannot update date"));
gtk_tooltip_set_text (tooltip, _("Cannot update date"));
}
else {
gchar *markup_text = NULL;
strcpy(mar_text,"");
for(int i = 0;i < count;i++)
{
g_date_add_days(date,i);
gchar *text = load_nm(date,nmday);
if(text) {
strcat(mar_text, text);
strcat(mar_text, "\n");
}
}
markup_text = g_markup_escape_text(mar_text,-1);
else
{
gchar *markup_text = NULL;
strcpy(mar_text,"");
for(int i = 0; i < count; i++)
{
g_date_add_days(date,i);
gchar *text = load_nm(date,nmday);
if(text) {
strcat(mar_text, text);
strcat(mar_text, "\n");
}
}

markup_text = g_markup_escape_text(mar_text,-1);

gtk_tooltip_set_markup (tooltip, markup_text);
gtk_tooltip_set_markup (tooltip, markup_text);
}
return TRUE;
}
Expand Down

0 comments on commit 554298f

Please sign in to comment.