Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rizalmart authored May 11, 2024
1 parent ffe9696 commit 3a91850
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/add_change_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,14 @@ void add_change_user(struct w *widgets)
comment = gtk_entry_get_text(GTK_ENTRY(widgets->user_set_entry[3]));
homedir = gtk_entry_get_text(GTK_ENTRY(widgets->user_set_entry[4]));
/* Its a gtk combo box entry new text */
shell = gtk_entry_get_text(GTK_ENTRY(gtk_container_get_children(GTK_BIN(widgets->user_set_combo[0]))));
GtkTreeIter iter;
GtkListStore *store;

store = GTK_LIST_STORE(gtk_combo_box_get_model(widgets->user_set_combo[0]));
gtk_combo_box_get_active_iter(widgets->user_set_combo[0], &iter);
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &shell, -1);

//shell = gtk_entry_get_text(GTK_ENTRY(gtk_container_get_children(GTK_BIN(widgets->user_set_combo[0]))));


/* Puts the pdbedit userlist as:
Expand Down
3 changes: 2 additions & 1 deletion src/make_settings_combos.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ GtkWidget * make_label_textcombo_label(GtkTable * table,

hbox = gtk_hbox_new(FALSE, 2);
label = gtk_label_new(label_text);
combo = gtk_combo_box_new_with_entry();
//combo = gtk_combo_box_new_with_entry();
combo = gtk_combo_box_text_new();
pad_label = gtk_label_new("");

gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
Expand Down
25 changes: 24 additions & 1 deletion src/populate_shell_combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@
#include "show_info.h"
#include "populate_shell_combo.h"

gboolean item_shell_exists(GtkComboBox *combo_box, const gchar *text) {
GtkTreeIter iter;
GtkListStore *store;

store = GTK_LIST_STORE(gtk_combo_box_get_model(combo_box));

if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) {
do {
gchar *entry_text;
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &entry_text, -1);
if (g_strcmp0(entry_text, text) == 0) {
g_free(entry_text);
return TRUE; // Item exists
}
g_free(entry_text);
} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
}

return FALSE; // Item does not exist
}


void populate_shell_combo(GtkWidget * shell_combo)
Expand Down Expand Up @@ -73,9 +93,12 @@ void populate_shell_combo(GtkWidget * shell_combo)
shell_found = 1;
strcpy(new_buf, line);
utf8 = g_locale_to_utf8(new_buf, strlen(new_buf) - 1, NULL, NULL, NULL);
gtk_combo_box_text_append_text(GTK_COMBO_BOX(shell_combo), utf8);
if(item_shell_exists(shell_combo,utf8)==FALSE){
gtk_combo_box_text_append_text(GTK_COMBO_BOX(shell_combo), utf8);
}
}
}

fclose(fp);
free(line);
free(new_buf);
Expand Down

0 comments on commit 3a91850

Please sign in to comment.