Skip to content

Commit

Permalink
Fixed many warnings
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.code.sf.net/p/parcellite/code/trunk@532 b25b1718-469e-46af-be73-919d414b4ebe
  • Loading branch information
RickyRockRat committed Aug 6, 2014
1 parent 0ddd828 commit 599d6f5
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 40 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -7,6 +7,7 @@ V1.1.9 Saturday, July 5, 2014
+Updated Chinese translation by wenjie.
+Fixed Bug 123, right-click edit broken.
+Fixed unsolicited error message on startup (related to bug 125).
+Cleaned up many warnings. Note to self: use env CFLAGS=-Wall ./configure --prefix=/usr/local

V1.1.8 Thursday, July 3, 2014
+Fixed bug 107, segfault when action key missing in parcelliterc.
Expand Down
1 change: 1 addition & 0 deletions TODO
Expand Up @@ -3,3 +3,4 @@
+ Add auto-update of Wordpress:
scp user@shell.sourceforge.net:/home/project-web/parcellite/htdocs/wp-content/uploads/js_cache/tinymce_1a60aaf59360855aa0d7d0c5a41c8ef5.gz
+ Add visual feedback when using the history search function.
+ Have Alt-e edit the highlighted text, not currently selected.
3 changes: 2 additions & 1 deletion src/history.c
Expand Up @@ -213,7 +213,7 @@ void read_history ()
/* Read item and add ending character */
if ((x =fread(&c->text,end,1,history_file)) != 1){
c->text[end] = 0;
g_fprintf(stderr,"history_read: Invalid text, code %d!\n'%s'\n",x,c->text);
g_fprintf(stderr,"history_read: Invalid text, code %ld!\n'%s'\n",(unsigned long)x,c->text);
} else {
c->text[end] = 0;
c->len=validate_utf8_text(c->text,c->len);
Expand Down Expand Up @@ -531,6 +531,7 @@ int save_history_as_text(gchar *path)
}

g_printf("histpath='%s'\n",path);
return 0;
}
/***************************************************************************/
/** Dialog to save the history file.
Expand Down
1 change: 1 addition & 0 deletions src/history.h
Expand Up @@ -62,6 +62,7 @@ void append_item(gchar* item, int checkdup, gint iflags, gint itype);
void truncate_history();

gpointer get_last_item();
void clear_history( void );

void delete_duplicate(gchar* item);

Expand Down
59 changes: 30 additions & 29 deletions src/main.c
Expand Up @@ -64,6 +64,8 @@ g_signal_connect(clipboard, "owner-change", G_CALLBACK(handle_owner_change), NU

#include "parcellite.h"

#include <ctype.h>
#include <pthread.h>

/**ACT are actions, and MODE is the mode of the action */
/** #define ACT_STOP 0
Expand Down Expand Up @@ -101,9 +103,9 @@ static gboolean actions_lock = FALSE;
static int show_icon=0;
static int have_appindicator=0; /**if set, we have a running indicator-appmenu */
static int ignore_clipboard=0; /**if set, don't process clip entries */

#ifdef HAVE_APPINDICATOR
static gchar *appindicator_process="indicator-messages-service"; /**process name */

#endif

static int cmd_mode=CMODE_ALL; /**both clipboards */
/** static int cmd_state=ACT_RUN; running */
Expand Down Expand Up @@ -634,7 +636,7 @@ gboolean check_clipboards_tic(gpointer data)
#endif
return TRUE;
}

#if 0
/* Thread function called for each action performed */
static void *execute_action(void *command)
{
Expand All @@ -654,8 +656,9 @@ static void *execute_action(void *command)
g_free((gchar*)command);
/* Exit this thread */
pthread_exit(NULL);
return NULL;
}

#endif
/* Called when execution action exits */
static void action_exit(GPid pid, gint status, gpointer data)
{
Expand Down Expand Up @@ -819,7 +822,6 @@ static void edit_selected(GtkMenuItem *menu_item, gpointer user_data)
update_clipboards(ntext, H_MODE_LIST);
}else {/**Text is not blank */
g_fprintf(stderr,"Try to add '%s'\n",new_clipboard_text);
gint16 type;
if(!p_strcmp(new_clipboard_text,current_clipboard_text)) /**same text, nothing to do */
goto finish;
if( NULL != c){
Expand Down Expand Up @@ -873,6 +875,7 @@ gboolean history_item_right_click_on_edit(GtkWidget *menuitem, gpointer data)
struct history_info *h=(struct history_info*)data;
h->wi.tmp1|=EDIT_MODE_USE_RIGHT_CLICK;
edit_selected((GtkMenuItem *)menuitem, data);
return TRUE;
}

/***************************************************************************/
Expand Down Expand Up @@ -1298,8 +1301,8 @@ static gboolean selection_done(GtkMenuShell *menushell, gpointer user_data)
void set_widget_bg(gchar *color, GtkWidget *w)
{
GdkColor c, *cp;
GtkRcStyle *st;
/** c.red = 65535;
/**GtkRcStyle *st;
c.red = 65535;
c.green = 0;
c.blue = 0;*/
/*g_print("set_widget_bg\n"); */
Expand Down Expand Up @@ -1648,7 +1651,7 @@ static gboolean my_item_event (GtkWidget *w,GdkEventKey *e, gpointer user)
handle_marking(h,w,GPOINTER_TO_INT(user),OPERATE_DELETE);
}
if(GDK_KEY_PRESS == e->type){
GdkEventKey *k= (GdkEventKey *)e;
/*GdkEventKey *k= (GdkEventKey *)e; */
printf("key press %d (0x%x)\n",e->keyval,e->keyval);
fflush(NULL);
}
Expand All @@ -1657,7 +1660,6 @@ static gboolean my_item_event (GtkWidget *w,GdkEventKey *e, gpointer user)
GList* element = g_list_nth(history_list, GPOINTER_TO_INT(user));
/*printf("type %x State 0x%x val %x %p '%s'\n",e->type, b->state,b->button,w,(gchar *)((struct history_item *(element->data))->text)); */
if(3 == b->button){ /**right-click */
gboolean rtn;
if(GDK_CONTROL_MASK&b->state){
handle_marking(h,w,GPOINTER_TO_INT(user),OPERATE_DELETE);
}else{ /**shift-right click release */
Expand Down Expand Up @@ -1732,7 +1734,6 @@ GString* convert_string(GString* s)
gchar pharagraph[4]={0xe2,0x81,0x8b,0x00}; /**utf-8 pharagraph symbol \2192 */
gchar square_u[4]={0xe2,0x90,0xA3,0}; /**square-u \\2423 */
gchar *p, *r;
gint idx;

for (p=s->str; p!= NULL; p=g_utf8_find_next_char(p,s->str+s->len)){
switch(*p){
Expand Down Expand Up @@ -1775,7 +1776,6 @@ static gboolean show_history_menu(gpointer data)
GtkWidget *menu, *menu_item,
*menu_image, *item_label;
static struct history_info h;
gint nok,pok;
h.histno=GPOINTER_TO_INT(data);/**persistent or normal history */
h.change_flag=0;
h.element_text=NULL;
Expand Down Expand Up @@ -2008,6 +2008,24 @@ static gboolean show_history_menu(gpointer data)
return FALSE;
}

/***************************************************************************/
/** .
\n\b Arguments:
\n\b Returns:
****************************************************************************/
gint figure_histories(void)
{
gint i;
if(get_pref_int32("persistent_history")){
if(get_pref_int32("persistent_separate"))
i=HIST_DISPLAY_NORMAL;
else
i=HIST_DISPLAY_PERSISTENT|HIST_DISPLAY_NORMAL;
}else
i=HIST_DISPLAY_NORMAL;
/*g_printf("Using history 0x%X\n",i); */
return i;
}

/***************************************************************************/
/** .
Expand Down Expand Up @@ -2072,24 +2090,7 @@ static void show_parcellite_menu(GtkStatusIcon *status_icon, guint button, guin
create_parcellite_menu(button, activate_time);
}

/***************************************************************************/
/** .
\n\b Arguments:
\n\b Returns:
****************************************************************************/
gint figure_histories(void)
{
gint i;
if(get_pref_int32("persistent_history")){
if(get_pref_int32("persistent_separate"))
i=HIST_DISPLAY_NORMAL;
else
i=HIST_DISPLAY_PERSISTENT|HIST_DISPLAY_NORMAL;
}else
i=HIST_DISPLAY_NORMAL;
/*g_printf("Using history 0x%X\n",i); */
return i;
}

/* Called when status icon is left-clicked */
static void status_icon_clicked(GtkStatusIcon *status_icon, gpointer user_data)
{
Expand Down
2 changes: 2 additions & 0 deletions src/parcellite.h
Expand Up @@ -18,12 +18,14 @@
#ifndef _PARCELLITE_H_
#define _PARCELLITE_H_ 1
#include <glib.h>
#include <glib/gprintf.h>
#include <gtk/gtk.h>
#include <string.h>
#include <unistd.h>
#ifdef HAVE_APPINDICATOR
#include <libappindicator/app-indicator.h>
#endif
#include <stdlib.h>
#define PARCELLITE_PROG_NAME "parcellite"
#define PARCELLITE_ICON PARCELLITE_PROG_NAME
/*uncomment the next line to debug the clipboard updates
Expand Down
11 changes: 7 additions & 4 deletions src/preferences.c
Expand Up @@ -18,6 +18,9 @@

#include "parcellite.h"
#include <sys/wait.h>

void setup_icon( void ); /**in main.c */

#define MAX_HISTORY 1000

#define INIT_HISTORY_KEY NULL
Expand Down Expand Up @@ -311,6 +314,7 @@ int init_pref( void )
dummy[1].sec=PREF_SEC_NONE;
align_hist_y.upper=sy-100;
align_hist_x.upper=sx-100;
return 0;
}
/***************************************************************************/
/** set the wideget of item.
Expand All @@ -323,6 +327,7 @@ int set_pref_widget (char *name, GtkWidget *w)
if(NULL == p)
return -1;
p->w=w;
return 0;
}
/***************************************************************************/
/** get the char * value of string.
Expand Down Expand Up @@ -402,6 +407,7 @@ int set_pref_string (char *name, char *string)
if(p->cval != NULL)
g_free(p->cval);
p->cval=g_strdup(string);
return 0;
}

/***************************************************************************/
Expand Down Expand Up @@ -480,7 +486,6 @@ void set_key_entry(gchar *name, gchar *val)
void set_keys_from_prefs( void )
{
int i,l;
gchar *cval;
for (i=0;NULL != keylist[i].name; ++i){
/**NOTE: do not set up default keys here! User may WANT them null */
/** call egg_accelerator_parse_virtual to validate? */
Expand Down Expand Up @@ -988,7 +993,7 @@ int add_section(int sec, GtkWidget *parent)
{
int i,rtn=0;
int single_st, single_is;
gint x,y,connect;
gint connect;
GtkWidget *hbox, *label, *child, *vbox, *alignment;
GtkWidget* packit;
vbox=parent;
Expand Down Expand Up @@ -1103,8 +1108,6 @@ void show_preferences(gint tab)
/* Declare some variables */
GtkWidget *frame,*label,*alignment,*hbox, *vbox;
struct pref_item *p;
GtkObject *adjustment;
gint x,y;
GtkTreeViewColumn *tree_column;
init_pref();

Expand Down
10 changes: 4 additions & 6 deletions src/utils.c
Expand Up @@ -42,7 +42,6 @@ try to allocate using other methods.
gchar *p_strdup( const gchar *str )
{
gchar *n=NULL;
gint u8;
size_t l,x;
if(NULL == str)
return NULL;
Expand Down Expand Up @@ -306,15 +305,15 @@ int get_value_from_env(pid_t pid, gchar *key, char **value)
g_fprintf(stderr,"Unable to allocate for environ file name.\n");
return rtn;
}
g_sprintf(envf,"/proc/%ld/environ",pid);
g_sprintf(envf,"/proc/%ld/environ",(long int)pid);
if(0 != access(envf, R_OK)){/**doesn't exist, or not our process */
g_fprintf(stderr,"Unable to open '%s' for PID %ld\n",envf,pid);
g_fprintf(stderr,"Unable to open '%s' for PID %ld\n",envf,(long int)pid);
goto error;
}
fp=g_file_new_for_path(envf);
/**this dumps a zero at end of file. */
if(FALSE == g_file_load_contents(fp,NULL,&env,&elen,NULL,NULL) ){
g_fprintf(stderr,"Error finding '%s' for PID %ld\n",envf,pid);
g_fprintf(stderr,"Error finding '%s' for PID %ld\n",envf,(long int)pid);
goto error;
}
if(NULL == env){
Expand All @@ -329,7 +328,6 @@ int get_value_from_env(pid_t pid, gchar *key, char **value)

if(NULL != f){
if(i==0 || f[-1] == 0){/**beginning terminators */
gsize k;
i+=f-&env[i]; /**beginning of string */
while(i<elen && 0!=env[i] && '=' !=env[i]) ++i;
if('=' == env[i] ){/**found, return key */
Expand Down Expand Up @@ -455,7 +453,7 @@ int is_current_xsession_var (pid_t pid, gchar *env_var)
****************************************************************************/
int is_current_xsession (pid_t pid)
{
int i,x,rtn=1;
int i,x;
gchar *names[]={"XDG_SESSION_COOKIE","XDG_SEAT","DISPLAY",NULL};

for (i=0;NULL != names[i]; ++i){
Expand Down

0 comments on commit 599d6f5

Please sign in to comment.